node-forge 1.3.2 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/oids.js CHANGED
@@ -123,6 +123,7 @@ _IN('2.5.4.13', 'description');
123
123
  _IN('2.5.4.15', 'businessCategory');
124
124
  _IN('2.5.4.17', 'postalCode');
125
125
  _IN('2.5.4.42', 'givenName');
126
+ _IN('2.5.4.65', 'pseudonym');
126
127
  _IN('1.3.6.1.4.1.311.60.2.1.2', 'jurisdictionOfIncorporationStateOrProvinceName');
127
128
  _IN('1.3.6.1.4.1.311.60.2.1.3', 'jurisdictionOfIncorporationCountryName');
128
129
 
package/lib/pkcs12.js CHANGED
@@ -168,6 +168,7 @@ var pfxValidator = {
168
168
  capture: 'macAlgorithm'
169
169
  }, {
170
170
  name: 'PFX.macData.mac.digestAlgorithm.parameters',
171
+ optional: true,
171
172
  tagClass: asn1.Class.UNIVERSAL,
172
173
  captureAsn1: 'macAlgorithmParameters'
173
174
  }]
package/lib/rsa.js CHANGED
@@ -1133,6 +1133,9 @@ pki.setRsaPublicKey = pki.rsa.setPublicKey = function(n, e) {
1133
1133
  * _parseAllDigestBytes testing flag to control parsing of all
1134
1134
  * digest bytes. Unsupported and not for general usage.
1135
1135
  * (default: true)
1136
+ * _skipPaddingChecks testing flag to skip some padding checks to
1137
+ * test other checks. Unsupported and not for general usage.
1138
+ * (default: false)
1136
1139
  *
1137
1140
  * @return true if the signature was verified, false if not.
1138
1141
  */
@@ -1144,27 +1147,32 @@ pki.setRsaPublicKey = pki.rsa.setPublicKey = function(n, e) {
1144
1147
  }
1145
1148
  if(options === undefined) {
1146
1149
  options = {
1147
- _parseAllDigestBytes: true
1150
+ _parseAllDigestBytes: true,
1151
+ _skipPaddingChecks: false
1148
1152
  };
1149
1153
  }
1150
1154
  if(!('_parseAllDigestBytes' in options)) {
1151
1155
  options._parseAllDigestBytes = true;
1152
1156
  }
1157
+ if(!('_skipPaddingChecks' in options)) {
1158
+ options._skipPaddingChecks = false;
1159
+ }
1153
1160
 
1154
1161
  if(scheme === 'RSASSA-PKCS1-V1_5') {
1155
1162
  scheme = {
1156
1163
  verify: function(digest, d) {
1157
1164
  // remove padding
1158
- d = _decodePkcs1_v1_5(d, key, true);
1165
+ d = _decodePkcs1_v1_5(d, key, true, undefined, options);
1159
1166
  // d is ASN.1 BER-encoded DigestInfo
1160
1167
  var obj = asn1.fromDer(d, {
1161
1168
  parseAllBytes: options._parseAllDigestBytes
1162
1169
  });
1163
1170
 
1164
- // validate DigestInfo
1171
+ // validate DigestInfo structure and element count
1165
1172
  var capture = {};
1166
1173
  var errors = [];
1167
- if(!asn1.validate(obj, digestInfoValidator, capture, errors)) {
1174
+ if(!asn1.validate(obj, digestInfoValidator, capture, errors) ||
1175
+ obj.value.length !== 2) {
1168
1176
  var error = new Error(
1169
1177
  'ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 ' +
1170
1178
  'DigestInfo value.');
@@ -1208,7 +1216,7 @@ pki.setRsaPublicKey = pki.rsa.setPublicKey = function(n, e) {
1208
1216
  scheme = {
1209
1217
  verify: function(digest, d) {
1210
1218
  // remove padding
1211
- d = _decodePkcs1_v1_5(d, key, true);
1219
+ d = _decodePkcs1_v1_5(d, key, true, undefined, options);
1212
1220
  return digest === d;
1213
1221
  }
1214
1222
  };
@@ -1626,10 +1634,11 @@ function _encodePkcs1_v1_5(m, key, bt) {
1626
1634
  * @param key the RSA key to use.
1627
1635
  * @param pub true if the key is a public key, false if it is private.
1628
1636
  * @param ml the message length, if specified.
1637
+ * @param options testing options.
1629
1638
  *
1630
1639
  * @return the decoded bytes.
1631
1640
  */
1632
- function _decodePkcs1_v1_5(em, key, pub, ml) {
1641
+ function _decodePkcs1_v1_5(em, key, pub, ml, options) {
1633
1642
  // get the length of the modulus in bytes
1634
1643
  var k = Math.ceil(key.n.bitLength() / 8);
1635
1644
 
@@ -1649,7 +1658,7 @@ function _decodePkcs1_v1_5(em, key, pub, ml) {
1649
1658
  var bt = eb.getByte();
1650
1659
  if(first !== 0x00 ||
1651
1660
  (pub && bt !== 0x00 && bt !== 0x01) ||
1652
- (!pub && bt != 0x02) ||
1661
+ (!pub && bt !== 0x02) ||
1653
1662
  (pub && bt === 0x00 && typeof(ml) === 'undefined')) {
1654
1663
  throw new Error('Encryption block is invalid.');
1655
1664
  }
@@ -1673,6 +1682,11 @@ function _decodePkcs1_v1_5(em, key, pub, ml) {
1673
1682
  }
1674
1683
  ++padNum;
1675
1684
  }
1685
+
1686
+ // RFC 2313 8.1 note 6
1687
+ if(padNum < 8 && !(options ? options._skipPaddingChecks : false)) {
1688
+ throw new Error('Encryption block is invalid.');
1689
+ }
1676
1690
  } else if(bt === 0x02) {
1677
1691
  // look for 0x00 byte
1678
1692
  padNum = 0;
@@ -1683,6 +1697,11 @@ function _decodePkcs1_v1_5(em, key, pub, ml) {
1683
1697
  }
1684
1698
  ++padNum;
1685
1699
  }
1700
+
1701
+ // RFC 2313 8.1 note 6
1702
+ if(padNum < 8 && !(options ? options._skipPaddingChecks : false)) {
1703
+ throw new Error('Encryption block is invalid.');
1704
+ }
1686
1705
  }
1687
1706
 
1688
1707
  // zero must be 0x00 and padNum must be (k - 3 - message length)
package/lib/x509.js CHANGED
@@ -3167,6 +3167,15 @@ pki.verifyCertificateChain = function(caStore, chain, options) {
3167
3167
  };
3168
3168
  }
3169
3169
  }
3170
+ // check for absent basicConstraints on non-leaf certificates
3171
+ if(error === null && bcExt === null) {
3172
+ error = {
3173
+ message:
3174
+ 'Certificate is missing basicConstraints extension and cannot ' +
3175
+ 'be used as a CA.',
3176
+ error: pki.certificateError.bad_certificate
3177
+ };
3178
+ }
3170
3179
  // basic constraints cA flag must be set
3171
3180
  if(error === null && bcExt !== null && !bcExt.cA) {
3172
3181
  // bad certificate
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-forge",
3
- "version": "1.3.2",
3
+ "version": "1.4.0",
4
4
  "description": "JavaScript implementations of network transports, cryptography, ciphers, PKI, message digests, and various utilities.",
5
5
  "homepage": "https://github.com/digitalbazaar/forge",
6
6
  "author": {
package/flash/README.md DELETED
@@ -1,48 +0,0 @@
1
- Forge Flash Support
2
- ===================
3
-
4
- SocketPool.swf
5
- --------------
6
-
7
- Some special networking features can optionally use a Flash component.
8
- Building the output SWF file requires the [Flex SDK][]. A pre-built component
9
- is included: `swf/SocketPool.swf`.
10
-
11
- Building the output SWF requires the `mxmlc` tool from the [Flex SDK][]. If
12
- that tools is already installed then look in the `package.json` file for the
13
- commands to rebuild it. If you need the SDK installed, there is a npm module that installs it:
14
-
15
- npm install
16
-
17
- To build a regular component:
18
-
19
- npm run build
20
-
21
- Additional debug support can be built in with the following:
22
-
23
- npm run build-debug
24
-
25
- Policy Server
26
- -------------
27
-
28
- Flash support requires the use of a Policy Server.
29
-
30
- ### Apache Flash Socket Policy Module
31
-
32
- [mod_fsp](./mod_fsp) provides an [Apache][] module that can serve up a Flash
33
- Socket Policy. See `mod_fsp/README` for more details. This module makes it easy
34
- to modify an [Apache][] server to allow cross domain requests to be made to it.
35
-
36
- ### Simple Python Policy Server
37
-
38
- `policyserver.py` provides a very simple test policy server.
39
-
40
- ### Simple Node.js Policy Server
41
-
42
- `policyserver.js` provides a very simple test policy server. If a server is
43
- needed for production environments, please use another option such as perhaps
44
- [nodejs_socket_policy_server][].
45
-
46
- [Apache]: http://httpd.apache.org/
47
- [Flex SDK]: https://flex.apache.org/
48
- [nodejs_socket_policy_server]: https://github.com/bichinger/nodejs_socket_policy_server