node-forge 0.8.1 → 0.8.2

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.
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "node-forge-flash",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "description": "Flash build support for Forge.",
6
+ "homepage": "https://github.com/digitalbazaar/forge",
7
+ "author": {
8
+ "name": "Digital Bazaar, Inc.",
9
+ "email": "support@digitalbazaar.com",
10
+ "url": "http://digitalbazaar.com/"
11
+ },
12
+ "devDependencies": {
13
+ "flex-sdk": ""
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/digitalbazaar/forge"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/digitalbazaar/forge/issues",
21
+ "email": "support@digitalbazaar.com"
22
+ },
23
+ "license": "(BSD-3-Clause OR GPL-2.0)",
24
+ "scripts": {
25
+ "build": "mxmlc -debug=false -define=CONFIG::debugging,false -define=CONFIG::release,true -compiler.source-path=. -static-link-runtime-shared-libraries -output=swf/SocketPool.swf SocketPool.as",
26
+ "build-debug": "mxmlc -debug=true -define=CONFIG::debugging,true -define=CONFIG::release,false -compiler.source-path=. -static-link-runtime-shared-libraries -output=swf/SocketPool.swf SocketPool.as"
27
+ }
28
+ }
@@ -16,7 +16,7 @@ var tls = module.exports = forge.tls;
16
16
  * Supported cipher suites.
17
17
  */
18
18
  tls.CipherSuites['TLS_RSA_WITH_AES_128_CBC_SHA'] = {
19
- id: [0x00,0x2f],
19
+ id: [0x00, 0x2f],
20
20
  name: 'TLS_RSA_WITH_AES_128_CBC_SHA',
21
21
  initSecurityParameters: function(sp) {
22
22
  sp.bulk_cipher_algorithm = tls.BulkCipherAlgorithm.aes;
@@ -32,7 +32,7 @@ tls.CipherSuites['TLS_RSA_WITH_AES_128_CBC_SHA'] = {
32
32
  initConnectionState: initConnectionState
33
33
  };
34
34
  tls.CipherSuites['TLS_RSA_WITH_AES_256_CBC_SHA'] = {
35
- id: [0x00,0x35],
35
+ id: [0x00, 0x35],
36
36
  name: 'TLS_RSA_WITH_AES_256_CBC_SHA',
37
37
  initSecurityParameters: function(sp) {
38
38
  sp.bulk_cipher_algorithm = tls.BulkCipherAlgorithm.aes;
@@ -199,10 +199,8 @@ function decrypt_aes_cbc_sha1_padding(blockSize, output, decrypt) {
199
199
  *
200
200
  * @return true on success, false on failure.
201
201
  */
202
- var count = 0;
203
202
  function decrypt_aes_cbc_sha1(record, s) {
204
203
  var rval = false;
205
- ++count;
206
204
 
207
205
  var iv;
208
206
  if(record.version.minor === tls.Versions.TLS_1_0.minor) {
@@ -652,7 +652,7 @@ modes.gcm.prototype.encrypt = function(input, output, finish) {
652
652
  this._partialOutput.putInt32(input.getInt32() ^ this._outBlock[i]);
653
653
  }
654
654
 
655
- if(partialBytes === 0 || finish) {
655
+ if(partialBytes <= 0 || finish) {
656
656
  // handle overflow prior to hashing
657
657
  if(finish) {
658
658
  // get block overflow
package/lib/des.js CHANGED
@@ -7,7 +7,8 @@
7
7
  * Paul Tero, July 2001
8
8
  * http://www.tero.co.uk/des/
9
9
  *
10
- * Optimised for performance with large blocks by Michael Hayworth, November 2001
10
+ * Optimised for performance with large blocks by
11
+ * Michael Hayworth, November 2001
11
12
  * http://www.netdealing.com
12
13
  *
13
14
  * THIS SOFTWARE IS PROVIDED "AS IS" AND
package/lib/pkcs1.js CHANGED
@@ -119,7 +119,7 @@ pkcs1.encode_rsa_oaep = function(key, message, options) {
119
119
 
120
120
  var PS = '';
121
121
  var PS_length = maxLength - message.length;
122
- for (var i = 0; i < PS_length; i++) {
122
+ for(var i = 0; i < PS_length; i++) {
123
123
  PS += '\x00';
124
124
  }
125
125
 
package/lib/rsa.js CHANGED
@@ -89,7 +89,6 @@ forge.pki = forge.pki || {};
89
89
  module.exports = forge.pki.rsa = forge.rsa = forge.rsa || {};
90
90
  var pki = forge.pki;
91
91
 
92
-
93
92
  // for finding primes, which are 30k+i for i = 1, 7, 11, 13, 17, 19, 23, 29
94
93
  var GCD_30_DELTA = [6, 4, 2, 4, 2, 4, 6, 2];
95
94
 
@@ -688,7 +687,7 @@ pki.rsa.stepKeyPairGenerationState = function(state, n) {
688
687
  var THIRTY = new BigInteger(null);
689
688
  THIRTY.fromInt(30);
690
689
  var deltaIdx = 0;
691
- var op_or = function(x, y) { return x|y; };
690
+ var op_or = function(x, y) {return x | y;};
692
691
 
693
692
  // keep stepping until time limit is reached or done
694
693
  var t1 = +new Date();
@@ -737,7 +736,7 @@ pki.rsa.stepKeyPairGenerationState = function(state, n) {
737
736
  // ensure number is coprime with e
738
737
  state.pqState =
739
738
  (state.num.subtract(BigInteger.ONE).gcd(state.e)
740
- .compareTo(BigInteger.ONE) === 0) ? 3 : 0;
739
+ .compareTo(BigInteger.ONE) === 0) ? 3 : 0;
741
740
  } else if(state.pqState === 3) {
742
741
  // store p or q
743
742
  state.pqState = 0;
@@ -907,7 +906,7 @@ pki.rsa.generateKeyPair = function(bits, e, options, callback) {
907
906
  format: 'pem'
908
907
  }
909
908
  }, function(err, pub, priv) {
910
- if (err) {
909
+ if(err) {
911
910
  return callback(err);
912
911
  }
913
912
  callback(null, {
@@ -916,7 +915,8 @@ pki.rsa.generateKeyPair = function(bits, e, options, callback) {
916
915
  });
917
916
  });
918
917
  }
919
- if(_detectSubtleCrypto('generateKey') && _detectSubtleCrypto('exportKey')) {
918
+ if(_detectSubtleCrypto('generateKey') &&
919
+ _detectSubtleCrypto('exportKey')) {
920
920
  // use standard native generateKey
921
921
  return util.globalScope.crypto.subtle.generateKey({
922
922
  name: 'RSASSA-PKCS1-v1_5',
@@ -1054,7 +1054,7 @@ pki.setRsaPublicKey = pki.rsa.setPublicKey = function(n, e) {
1054
1054
  }
1055
1055
  };
1056
1056
  } else if(['RAW', 'NONE', 'NULL', null].indexOf(scheme) !== -1) {
1057
- scheme = { encode: function(e) { return e; } };
1057
+ scheme = {encode: function(e) {return e;}};
1058
1058
  } else if(typeof scheme === 'string') {
1059
1059
  throw new Error('Unsupported encryption scheme: "' + scheme + '".');
1060
1060
  }
@@ -1095,37 +1095,37 @@ pki.setRsaPublicKey = pki.rsa.setPublicKey = function(n, e) {
1095
1095
  *
1096
1096
  * @return true if the signature was verified, false if not.
1097
1097
  */
1098
- key.verify = function(digest, signature, scheme) {
1099
- if(typeof scheme === 'string') {
1100
- scheme = scheme.toUpperCase();
1101
- } else if(scheme === undefined) {
1102
- scheme = 'RSASSA-PKCS1-V1_5';
1103
- }
1104
-
1105
- if(scheme === 'RSASSA-PKCS1-V1_5') {
1106
- scheme = {
1107
- verify: function(digest, d) {
1108
- // remove padding
1109
- d = _decodePkcs1_v1_5(d, key, true);
1110
- // d is ASN.1 BER-encoded DigestInfo
1111
- var obj = asn1.fromDer(d);
1112
- // compare the given digest to the decrypted one
1113
- return digest === obj.value[1].value;
1114
- }
1115
- };
1116
- } else if(scheme === 'NONE' || scheme === 'NULL' || scheme === null) {
1117
- scheme = {
1118
- verify: function(digest, d) {
1119
- // remove padding
1120
- d = _decodePkcs1_v1_5(d, key, true);
1121
- return digest === d;
1122
- }
1123
- };
1124
- }
1125
-
1126
- // do rsa decryption w/o any decoding, then verify -- which does decoding
1127
- var d = pki.rsa.decrypt(signature, key, true, false);
1128
- return scheme.verify(digest, d, key.n.bitLength());
1098
+ key.verify = function(digest, signature, scheme) {
1099
+ if(typeof scheme === 'string') {
1100
+ scheme = scheme.toUpperCase();
1101
+ } else if(scheme === undefined) {
1102
+ scheme = 'RSASSA-PKCS1-V1_5';
1103
+ }
1104
+
1105
+ if(scheme === 'RSASSA-PKCS1-V1_5') {
1106
+ scheme = {
1107
+ verify: function(digest, d) {
1108
+ // remove padding
1109
+ d = _decodePkcs1_v1_5(d, key, true);
1110
+ // d is ASN.1 BER-encoded DigestInfo
1111
+ var obj = asn1.fromDer(d);
1112
+ // compare the given digest to the decrypted one
1113
+ return digest === obj.value[1].value;
1114
+ }
1115
+ };
1116
+ } else if(scheme === 'NONE' || scheme === 'NULL' || scheme === null) {
1117
+ scheme = {
1118
+ verify: function(digest, d) {
1119
+ // remove padding
1120
+ d = _decodePkcs1_v1_5(d, key, true);
1121
+ return digest === d;
1122
+ }
1123
+ };
1124
+ }
1125
+
1126
+ // do rsa decryption w/o any decoding, then verify -- which does decoding
1127
+ var d = pki.rsa.decrypt(signature, key, true, false);
1128
+ return scheme.verify(digest, d, key.n.bitLength());
1129
1129
  };
1130
1130
 
1131
1131
  return key;
@@ -1183,7 +1183,7 @@ pki.setRsaPrivateKey = pki.rsa.setPrivateKey = function(
1183
1183
  var d = pki.rsa.decrypt(data, key, false, false);
1184
1184
 
1185
1185
  if(scheme === 'RSAES-PKCS1-V1_5') {
1186
- scheme = { decode: _decodePkcs1_v1_5 };
1186
+ scheme = {decode: _decodePkcs1_v1_5};
1187
1187
  } else if(scheme === 'RSA-OAEP' || scheme === 'RSAES-OAEP') {
1188
1188
  scheme = {
1189
1189
  decode: function(d, key) {
@@ -1191,7 +1191,7 @@ pki.setRsaPrivateKey = pki.rsa.setPrivateKey = function(
1191
1191
  }
1192
1192
  };
1193
1193
  } else if(['RAW', 'NONE', 'NULL', null].indexOf(scheme) !== -1) {
1194
- scheme = { decode: function(d) { return d; } };
1194
+ scheme = {decode: function(d) {return d;}};
1195
1195
  } else {
1196
1196
  throw new Error('Unsupported encryption scheme: "' + scheme + '".');
1197
1197
  }
@@ -1233,10 +1233,10 @@ pki.setRsaPrivateKey = pki.rsa.setPrivateKey = function(
1233
1233
  }
1234
1234
 
1235
1235
  if(scheme === undefined || scheme === 'RSASSA-PKCS1-V1_5') {
1236
- scheme = { encode: emsaPkcs1v15encode };
1236
+ scheme = {encode: emsaPkcs1v15encode};
1237
1237
  bt = 0x01;
1238
1238
  } else if(scheme === 'NONE' || scheme === 'NULL' || scheme === null) {
1239
- scheme = { encode: function() { return md; } };
1239
+ scheme = {encode: function() {return md;}};
1240
1240
  bt = 0x01;
1241
1241
  }
1242
1242
 
@@ -1271,7 +1271,7 @@ pki.wrapRsaPrivateKey = function(rsaKey) {
1271
1271
  // PrivateKey
1272
1272
  asn1.create(asn1.Class.UNIVERSAL, asn1.Type.OCTETSTRING, false,
1273
1273
  asn1.toDer(rsaKey).getBytes())
1274
- ]);
1274
+ ]);
1275
1275
  };
1276
1276
 
1277
1277
  /**
package/lib/sha1.js CHANGED
@@ -113,12 +113,12 @@ sha1.create = function() {
113
113
  return md;
114
114
  };
115
115
 
116
- /**
117
- * Produces the digest.
118
- *
119
- * @return a byte buffer containing the digest value.
120
- */
121
- md.digest = function() {
116
+ /**
117
+ * Produces the digest.
118
+ *
119
+ * @return a byte buffer containing the digest value.
120
+ */
121
+ md.digest = function() {
122
122
  /* Note: Here we copy the remaining bytes in the input buffer and
123
123
  add the appropriate SHA-1 padding. Then we do the final update
124
124
  on a copy of the state so that if the user wants to get
package/lib/sha512.js CHANGED
@@ -81,7 +81,7 @@ sha512.create = function(algorithm) {
81
81
 
82
82
  // determine digest length by algorithm name (default)
83
83
  var digestLength = 64;
84
- switch (algorithm) {
84
+ switch(algorithm) {
85
85
  case 'SHA-384':
86
86
  digestLength = 48;
87
87
  break;