node-forge 0.6.47 → 0.7.1

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +106 -0
  2. package/LICENSE +3 -3
  3. package/README.md +254 -175
  4. package/dist/forge.all.min.js +11 -0
  5. package/dist/forge.all.min.js.map +1 -0
  6. package/dist/forge.min.js +10 -0
  7. package/dist/forge.min.js.map +1 -0
  8. package/dist/prime.worker.min.js +2 -0
  9. package/dist/prime.worker.min.js.map +1 -0
  10. package/flash/README.md +48 -0
  11. package/flash/package.json +28 -0
  12. package/flash/swf/SocketPool.swf +0 -0
  13. package/{js → lib}/aes.js +5 -61
  14. package/{js → lib}/aesCipherSuites.js +4 -58
  15. package/{js → lib}/asn1.js +371 -132
  16. package/{js → lib}/cipher.js +3 -59
  17. package/{js → lib}/cipherModes.js +3 -65
  18. package/{js → lib}/debug.js +2 -58
  19. package/{js → lib}/des.js +6 -63
  20. package/lib/forge.js +13 -0
  21. package/{js → lib}/form.js +5 -13
  22. package/{js → lib}/hmac.js +4 -58
  23. package/{js → lib}/http.js +15 -20
  24. package/lib/index.all.js +16 -0
  25. package/lib/index.js +34 -0
  26. package/{js → lib}/jsbn.js +3 -60
  27. package/{js → lib}/kem.js +5 -58
  28. package/{js → lib}/log.js +3 -58
  29. package/lib/md.all.js +13 -0
  30. package/lib/md.js +11 -0
  31. package/{js → lib}/md5.js +4 -60
  32. package/lib/mgf.js +12 -0
  33. package/lib/mgf1.js +57 -0
  34. package/lib/oids.js +159 -0
  35. package/{js → lib}/pbe.js +29 -79
  36. package/{js → lib}/pbkdf2.js +10 -64
  37. package/{js → lib}/pem.js +3 -58
  38. package/{js → lib}/pkcs1.js +6 -59
  39. package/{js → lib}/pkcs12.js +15 -74
  40. package/{js → lib}/pkcs7.js +12 -72
  41. package/{js → lib}/pkcs7asn1.js +4 -58
  42. package/{js → lib}/pki.js +12 -71
  43. package/{js → lib}/prime.js +18 -58
  44. package/{js → lib}/prime.worker.js +4 -1
  45. package/{js → lib}/prng.js +5 -62
  46. package/{js → lib}/pss.js +7 -61
  47. package/{js → lib}/random.js +11 -57
  48. package/{js → lib}/rc2.js +13 -73
  49. package/{js → lib}/rsa.js +13 -71
  50. package/{js → lib}/sha1.js +4 -60
  51. package/{js → lib}/sha256.js +4 -60
  52. package/{js → lib}/sha512.js +19 -61
  53. package/{js → lib}/socket.js +8 -63
  54. package/{js → lib}/ssh.js +7 -66
  55. package/{js → lib}/task.js +5 -58
  56. package/{js → lib}/tls.js +10 -67
  57. package/{js → lib}/tlssocket.js +6 -61
  58. package/{js → lib}/util.js +39 -68
  59. package/{js → lib}/x509.js +25 -102
  60. package/{js → lib}/xhr.js +12 -15
  61. package/package.json +58 -21
  62. package/js/forge.js +0 -94
  63. package/js/md.js +0 -75
  64. package/js/mgf.js +0 -67
  65. package/js/mgf1.js +0 -112
  66. package/js/oids.js +0 -288
  67. package/swf/SocketPool.swf +0 -0
@@ -5,17 +5,21 @@
5
5
  *
6
6
  * Copyright (c) 2014 Digital Bazaar, Inc.
7
7
  */
8
+ var forge = require('./forge');
9
+ require('./util');
10
+ require('./jsbn');
11
+ require('./random');
12
+
8
13
  (function() {
9
- /* ########## Begin module implementation ########## */
10
- function initModule(forge) {
11
14
 
12
15
  // forge.prime already defined
13
16
  if(forge.prime) {
17
+ module.exports = forge.prime;
14
18
  return;
15
19
  }
16
20
 
17
21
  /* PRIME API */
18
- var prime = forge.prime = forge.prime || {};
22
+ var prime = module.exports = forge.prime = forge.prime || {};
19
23
 
20
24
  var BigInteger = forge.jsbn.BigInteger;
21
25
 
@@ -118,6 +122,11 @@ function primeincFindPrimeWithoutWorkers(bits, rng, options, callback) {
118
122
  if('maxBlockTime' in options) {
119
123
  maxBlockTime = options.maxBlockTime;
120
124
  }
125
+
126
+ _primeinc(num, bits, rng, deltaIdx, mrTests, maxBlockTime, callback);
127
+ }
128
+
129
+ function _primeinc(num, bits, rng, deltaIdx, mrTests, maxBlockTime, callback) {
121
130
  var start = +new Date();
122
131
  do {
123
132
  // overflow, regenerate random number
@@ -132,12 +141,16 @@ function primeincFindPrimeWithoutWorkers(bits, rng, options, callback) {
132
141
  num.dAddOffset(GCD_30_DELTA[deltaIdx++ % 8], 0);
133
142
  } while(maxBlockTime < 0 || (+new Date() - start < maxBlockTime));
134
143
 
135
- // keep trying (setImmediate would be better here)
144
+ // keep trying later
136
145
  forge.util.setImmediate(function() {
137
- primeincFindPrimeWithoutWorkers(bits, rng, options, callback);
146
+ _primeinc(num, bits, rng, deltaIdx, mrTests, maxBlockTime, callback);
138
147
  });
139
148
  }
140
149
 
150
+ // NOTE: This algorithm is indeterminate in nature because workers
151
+ // run in parallel looking at different segments of numbers. Even if this
152
+ // algorithm is run twice with the same input from a predictable RNG, it
153
+ // may produce different outputs.
141
154
  function primeincFindPrimeWithWorkers(bits, rng, options, callback) {
142
155
  // web workers unavailable
143
156
  if(typeof Worker === 'undefined') {
@@ -281,57 +294,4 @@ function getMillerRabinTests(bits) {
281
294
  return 2;
282
295
  }
283
296
 
284
- } // end module implementation
285
-
286
- /* ########## Begin module wrapper ########## */
287
- var name = 'prime';
288
- if(typeof define !== 'function') {
289
- // NodeJS -> AMD
290
- if(typeof module === 'object' && module.exports) {
291
- var nodeJS = true;
292
- define = function(ids, factory) {
293
- factory(require, module);
294
- };
295
- } else {
296
- // <script>
297
- if(typeof forge === 'undefined') {
298
- forge = {};
299
- }
300
- return initModule(forge);
301
- }
302
- }
303
- // AMD
304
- var deps;
305
- var defineFunc = function(require, module) {
306
- module.exports = function(forge) {
307
- var mods = deps.map(function(dep) {
308
- return require(dep);
309
- }).concat(initModule);
310
- // handle circular dependencies
311
- forge = forge || {};
312
- forge.defined = forge.defined || {};
313
- if(forge.defined[name]) {
314
- return forge[name];
315
- }
316
- forge.defined[name] = true;
317
- for(var i = 0; i < mods.length; ++i) {
318
- mods[i](forge);
319
- }
320
- return forge[name];
321
- };
322
- };
323
- var tmpDefine = define;
324
- define = function(ids, factory) {
325
- deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
326
- if(nodeJS) {
327
- delete define;
328
- return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
329
- }
330
- define = tmpDefine;
331
- return define.apply(null, Array.prototype.slice.call(arguments, 0));
332
- };
333
- define(['require', 'module', './util', './jsbn', './random'], function() {
334
- defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
335
- });
336
-
337
297
  })();
@@ -5,7 +5,10 @@
5
5
  *
6
6
  * Copyright (c) 2013 Digital Bazaar, Inc.
7
7
  */
8
- importScripts('jsbn.js');
8
+ // worker is built using CommonJS syntax to include all code in one worker file
9
+ //importScripts('jsbn.js');
10
+ var forge = require('./forge');
11
+ require('./jsbn');
9
12
 
10
13
  // prime constants
11
14
  var LOW_PRIMES = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];
@@ -9,19 +9,17 @@
9
9
  *
10
10
  * Copyright (c) 2010-2014 Digital Bazaar, Inc.
11
11
  */
12
- (function() {
13
- /* ########## Begin module implementation ########## */
14
- function initModule(forge) {
12
+ var forge = require('./forge');
13
+ require('./util');
15
14
 
16
- var _nodejs = (
17
- typeof process !== 'undefined' && process.versions && process.versions.node);
18
15
  var _crypto = null;
19
- if(!forge.disableNativeCode && _nodejs && !process.versions['node-webkit']) {
16
+ if(forge.util.isNodejs && !forge.options.usePureJavaScript &&
17
+ !process.versions['node-webkit']) {
20
18
  _crypto = require('crypto');
21
19
  }
22
20
 
23
21
  /* PRNG API */
24
- var prng = forge.prng = forge.prng || {};
22
+ var prng = module.exports = forge.prng = forge.prng || {};
25
23
 
26
24
  /**
27
25
  * Creates a new PRNG context.
@@ -401,58 +399,3 @@ prng.create = function(plugin) {
401
399
 
402
400
  return ctx;
403
401
  };
404
-
405
- } // end module implementation
406
-
407
- /* ########## Begin module wrapper ########## */
408
- var name = 'prng';
409
- if(typeof define !== 'function') {
410
- // NodeJS -> AMD
411
- if(typeof module === 'object' && module.exports) {
412
- var nodeJS = true;
413
- define = function(ids, factory) {
414
- factory(require, module);
415
- };
416
- } else {
417
- // <script>
418
- if(typeof forge === 'undefined') {
419
- forge = {};
420
- }
421
- return initModule(forge);
422
- }
423
- }
424
- // AMD
425
- var deps;
426
- var defineFunc = function(require, module) {
427
- module.exports = function(forge) {
428
- var mods = deps.map(function(dep) {
429
- return require(dep);
430
- }).concat(initModule);
431
- // handle circular dependencies
432
- forge = forge || {};
433
- forge.defined = forge.defined || {};
434
- if(forge.defined[name]) {
435
- return forge[name];
436
- }
437
- forge.defined[name] = true;
438
- for(var i = 0; i < mods.length; ++i) {
439
- mods[i](forge);
440
- }
441
- return forge[name];
442
- };
443
- };
444
- var tmpDefine = define;
445
- define = function(ids, factory) {
446
- deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
447
- if(nodeJS) {
448
- delete define;
449
- return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
450
- }
451
- define = tmpDefine;
452
- return define.apply(null, Array.prototype.slice.call(arguments, 0));
453
- };
454
- define(['require', 'module', './md', './util'], function() {
455
- defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
456
- });
457
-
458
- })();
@@ -5,12 +5,12 @@
5
5
  *
6
6
  * Copyright (c) 2012 Stefan Siegl <stesie@brokenpipe.de>
7
7
  */
8
- (function() {
9
- /* ########## Begin module implementation ########## */
10
- function initModule(forge) {
8
+ var forge = require('./forge');
9
+ require('./random');
10
+ require('./util');
11
11
 
12
12
  // shortcut for PSS API
13
- var pss = forge.pss = forge.pss || {};
13
+ var pss = module.exports = forge.pss = forge.pss || {};
14
14
 
15
15
  /**
16
16
  * Creates a PSS signature scheme object.
@@ -129,7 +129,7 @@ pss.create = function(options) {
129
129
 
130
130
  /* 10. Let maskedDB = DB \xor dbMask. */
131
131
  var maskedDB = '';
132
- for(i = 0; i < maskLen; i ++) {
132
+ for(i = 0; i < maskLen; i++) {
133
133
  maskedDB += String.fromCharCode(db.charCodeAt(i) ^ dbMask.charCodeAt(i));
134
134
  }
135
135
 
@@ -196,7 +196,7 @@ pss.create = function(options) {
196
196
 
197
197
  /* 8. Let DB = maskedDB \xor dbMask. */
198
198
  var db = '';
199
- for(i = 0; i < maskLen; i ++) {
199
+ for(i = 0; i < maskLen; i++) {
200
200
  db += String.fromCharCode(maskedDB.charCodeAt(i) ^ dbMask.charCodeAt(i));
201
201
  }
202
202
 
@@ -209,7 +209,7 @@ pss.create = function(options) {
209
209
  * position is "position 1") does not have hexadecimal value 0x01,
210
210
  * output "inconsistent" and stop. */
211
211
  var checkLen = emLen - hLen - sLen - 2;
212
- for(i = 0; i < checkLen; i ++) {
212
+ for(i = 0; i < checkLen; i++) {
213
213
  if(db.charCodeAt(i) !== 0x00) {
214
214
  throw new Error('Leftmost octets not zero as expected');
215
215
  }
@@ -239,57 +239,3 @@ pss.create = function(options) {
239
239
 
240
240
  return pssobj;
241
241
  };
242
-
243
- } // end module implementation
244
-
245
- /* ########## Begin module wrapper ########## */
246
- var name = 'pss';
247
- if(typeof define !== 'function') {
248
- // NodeJS -> AMD
249
- if(typeof module === 'object' && module.exports) {
250
- var nodeJS = true;
251
- define = function(ids, factory) {
252
- factory(require, module);
253
- };
254
- } else {
255
- // <script>
256
- if(typeof forge === 'undefined') {
257
- forge = {};
258
- }
259
- return initModule(forge);
260
- }
261
- }
262
- // AMD
263
- var deps;
264
- var defineFunc = function(require, module) {
265
- module.exports = function(forge) {
266
- var mods = deps.map(function(dep) {
267
- return require(dep);
268
- }).concat(initModule);
269
- // handle circular dependencies
270
- forge = forge || {};
271
- forge.defined = forge.defined || {};
272
- if(forge.defined[name]) {
273
- return forge[name];
274
- }
275
- forge.defined[name] = true;
276
- for(var i = 0; i < mods.length; ++i) {
277
- mods[i](forge);
278
- }
279
- return forge[name];
280
- };
281
- };
282
- var tmpDefine = define;
283
- define = function(ids, factory) {
284
- deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
285
- if(nodeJS) {
286
- delete define;
287
- return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
288
- }
289
- define = tmpDefine;
290
- return define.apply(null, Array.prototype.slice.call(arguments, 0));
291
- };
292
- define(['require', 'module', './random', './util'], function() {
293
- defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
294
- });
295
- })();
@@ -13,12 +13,17 @@
13
13
  *
14
14
  * Copyright (c) 2009-2014 Digital Bazaar, Inc.
15
15
  */
16
+ var forge = require('./forge');
17
+ require('./aes');
18
+ require('./sha256');
19
+ require('./prng');
20
+ require('./util');
21
+
16
22
  (function() {
17
- /* ########## Begin module implementation ########## */
18
- function initModule(forge) {
19
23
 
20
24
  // forge.random already defined
21
25
  if(forge.random && forge.random.getBytes) {
26
+ module.exports = forge.random;
22
27
  return;
23
28
  }
24
29
 
@@ -109,8 +114,6 @@ var _ctx = spawnPrng();
109
114
 
110
115
  // add other sources of entropy only if window.crypto.getRandomValues is not
111
116
  // available -- otherwise this source will be automatically used by the prng
112
- var _nodejs = (
113
- typeof process !== 'undefined' && process.versions && process.versions.node);
114
117
  var getRandomValues = null;
115
118
  if(typeof window !== 'undefined') {
116
119
  var _crypto = window.crypto || window.msCrypto;
@@ -120,7 +123,8 @@ if(typeof window !== 'undefined') {
120
123
  };
121
124
  }
122
125
  }
123
- if(forge.disableNativeCode || (!_nodejs && !getRandomValues)) {
126
+ if(forge.options.usePureJavaScript ||
127
+ (!forge.util.isNodejs && !getRandomValues)) {
124
128
  // if this is a web worker, do not use weak entropy, instead register to
125
129
  // receive strong entropy asynchronously from the main thread
126
130
  if(typeof window === 'undefined' || window.document === undefined) {
@@ -180,58 +184,8 @@ if(!forge.random) {
180
184
  // expose spawn PRNG
181
185
  forge.random.createInstance = spawnPrng;
182
186
 
183
- })(typeof(jQuery) !== 'undefined' ? jQuery : null);
187
+ module.exports = forge.random;
184
188
 
185
- } // end module implementation
189
+ })(typeof(jQuery) !== 'undefined' ? jQuery : null);
186
190
 
187
- /* ########## Begin module wrapper ########## */
188
- var name = 'random';
189
- if(typeof define !== 'function') {
190
- // NodeJS -> AMD
191
- if(typeof module === 'object' && module.exports) {
192
- var nodeJS = true;
193
- define = function(ids, factory) {
194
- factory(require, module);
195
- };
196
- } else {
197
- // <script>
198
- if(typeof forge === 'undefined') {
199
- forge = {};
200
- }
201
- return initModule(forge);
202
- }
203
- }
204
- // AMD
205
- var deps;
206
- var defineFunc = function(require, module) {
207
- module.exports = function(forge) {
208
- var mods = deps.map(function(dep) {
209
- return require(dep);
210
- }).concat(initModule);
211
- // handle circular dependencies
212
- forge = forge || {};
213
- forge.defined = forge.defined || {};
214
- if(forge.defined[name]) {
215
- return forge[name];
216
- }
217
- forge.defined[name] = true;
218
- for(var i = 0; i < mods.length; ++i) {
219
- mods[i](forge);
220
- }
221
- return forge[name];
222
- };
223
- };
224
- var tmpDefine = define;
225
- define = function(ids, factory) {
226
- deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
227
- if(nodeJS) {
228
- delete define;
229
- return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
230
- }
231
- define = tmpDefine;
232
- return define.apply(null, Array.prototype.slice.call(arguments, 0));
233
- };
234
- define(['require', 'module', './aes', './md', './prng', './util'], function() {
235
- defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
236
- });
237
191
  })();
@@ -8,9 +8,8 @@
8
8
  * Information on the RC2 cipher is available from RFC #2268,
9
9
  * http://www.ietf.org/rfc/rfc2268.txt
10
10
  */
11
- (function() {
12
- /* ########## Begin module implementation ########## */
13
- function initModule(forge) {
11
+ var forge = require('./forge');
12
+ require('./util');
14
13
 
15
14
  var piTable = [
16
15
  0xd9, 0x78, 0xf9, 0xc4, 0x19, 0xdd, 0xb5, 0xed, 0x28, 0xe9, 0xfd, 0x79, 0x4a, 0xa0, 0xd8, 0x9d,
@@ -33,7 +32,6 @@ var piTable = [
33
32
 
34
33
  var s = [1, 2, 3, 5];
35
34
 
36
-
37
35
  /**
38
36
  * Rotate a word left by given number of bits.
39
37
  *
@@ -62,9 +60,8 @@ var ror = function(word, bits) {
62
60
  return ((word & 0xffff) >> bits) | ((word << (16 - bits)) & 0xffff);
63
61
  };
64
62
 
65
-
66
63
  /* RC2 API */
67
- forge.rc2 = forge.rc2 || {};
64
+ module.exports = forge.rc2 = forge.rc2 || {};
68
65
 
69
66
  /**
70
67
  * Perform RC2 key expansion as per RFC #2268, section 2.
@@ -87,20 +84,19 @@ forge.rc2.expandKey = function(key, effKeyBits) {
87
84
  var TM = 0xff >> (T1 & 0x07);
88
85
  var i;
89
86
 
90
- for(i = T; i < 128; i ++) {
87
+ for(i = T; i < 128; i++) {
91
88
  L.putByte(piTable[(L.at(i - 1) + L.at(i - T)) & 0xff]);
92
89
  }
93
90
 
94
91
  L.setAt(128 - T8, piTable[L.at(128 - T8) & TM]);
95
92
 
96
- for(i = 127 - T8; i >= 0; i --) {
93
+ for(i = 127 - T8; i >= 0; i--) {
97
94
  L.setAt(i, piTable[L.at(i + 1) ^ L.at(i + T8)]);
98
95
  }
99
96
 
100
97
  return L;
101
98
  };
102
99
 
103
-
104
100
  /**
105
101
  * Creates a RC2 cipher object.
106
102
  *
@@ -117,7 +113,7 @@ var createCipher = function(key, bits, encrypt) {
117
113
 
118
114
  /* Expand key and fill into K[] Array */
119
115
  key = forge.rc2.expandKey(key, bits);
120
- for(i = 0; i < 64; i ++) {
116
+ for(i = 0; i < 64; i++) {
121
117
  K.push(key.getInt16Le());
122
118
  }
123
119
 
@@ -132,7 +128,7 @@ var createCipher = function(key, bits, encrypt) {
132
128
  R[i] += K[j] + (R[(i + 3) % 4] & R[(i + 2) % 4]) +
133
129
  ((~R[(i + 3) % 4]) & R[(i + 1) % 4]);
134
130
  R[i] = rol(R[i], s[i]);
135
- j ++;
131
+ j++;
136
132
  }
137
133
  };
138
134
 
@@ -142,7 +138,7 @@ var createCipher = function(key, bits, encrypt) {
142
138
  * @param R Array of four words to perform mashing on.
143
139
  */
144
140
  mashRound = function(R) {
145
- for(i = 0; i < 4; i ++) {
141
+ for(i = 0; i < 4; i++) {
146
142
  R[i] += K[R[(i + 3) % 4] & 63];
147
143
  }
148
144
  };
@@ -157,7 +153,7 @@ var createCipher = function(key, bits, encrypt) {
157
153
  R[i] = ror(R[i], s[i]);
158
154
  R[i] -= K[j] + (R[(i + 3) % 4] & R[(i + 2) % 4]) +
159
155
  ((~R[(i + 3) % 4]) & R[(i + 1) % 4]);
160
- j --;
156
+ j--;
161
157
  }
162
158
  };
163
159
 
@@ -190,7 +186,7 @@ var createCipher = function(key, bits, encrypt) {
190
186
  var R = [];
191
187
 
192
188
  /* Get data from input buffer and fill the four words into R */
193
- for(i = 0; i < 4; i ++) {
189
+ for(i = 0; i < 4; i++) {
194
190
  var val = _input.getInt16Le();
195
191
 
196
192
  if(_iv !== null) {
@@ -210,14 +206,14 @@ var createCipher = function(key, bits, encrypt) {
210
206
  j = encrypt ? 0 : 63;
211
207
 
212
208
  /* Run execution plan. */
213
- for(var ptr = 0; ptr < plan.length; ptr ++) {
214
- for(var ctr = 0; ctr < plan[ptr][0]; ctr ++) {
209
+ for(var ptr = 0; ptr < plan.length; ptr++) {
210
+ for(var ctr = 0; ctr < plan[ptr][0]; ctr++) {
215
211
  plan[ptr][1](R);
216
212
  }
217
213
  }
218
214
 
219
215
  /* Write back result to output buffer. */
220
- for(i = 0; i < 4; i ++) {
216
+ for(i = 0; i < 4; i++) {
221
217
  if(_iv !== null) {
222
218
  if(encrypt) {
223
219
  /* We're encrypting in CBC-mode, feed back encrypted bytes into
@@ -232,7 +228,6 @@ var createCipher = function(key, bits, encrypt) {
232
228
  }
233
229
  };
234
230
 
235
-
236
231
  /* Create cipher object */
237
232
  var cipher = null;
238
233
  cipher = {
@@ -340,7 +335,6 @@ var createCipher = function(key, bits, encrypt) {
340
335
  return cipher;
341
336
  };
342
337
 
343
-
344
338
  /**
345
339
  * Creates an RC2 cipher object to encrypt data in ECB or CBC mode using the
346
340
  * given symmetric key. The output will be stored in the 'output' member
@@ -414,57 +408,3 @@ forge.rc2.startDecrypting = function(key, iv, output) {
414
408
  forge.rc2.createDecryptionCipher = function(key, bits) {
415
409
  return createCipher(key, bits, false);
416
410
  };
417
-
418
- } // end module implementation
419
-
420
- /* ########## Begin module wrapper ########## */
421
- var name = 'rc2';
422
- if(typeof define !== 'function') {
423
- // NodeJS -> AMD
424
- if(typeof module === 'object' && module.exports) {
425
- var nodeJS = true;
426
- define = function(ids, factory) {
427
- factory(require, module);
428
- };
429
- } else {
430
- // <script>
431
- if(typeof forge === 'undefined') {
432
- forge = {};
433
- }
434
- return initModule(forge);
435
- }
436
- }
437
- // AMD
438
- var deps;
439
- var defineFunc = function(require, module) {
440
- module.exports = function(forge) {
441
- var mods = deps.map(function(dep) {
442
- return require(dep);
443
- }).concat(initModule);
444
- // handle circular dependencies
445
- forge = forge || {};
446
- forge.defined = forge.defined || {};
447
- if(forge.defined[name]) {
448
- return forge[name];
449
- }
450
- forge.defined[name] = true;
451
- for(var i = 0; i < mods.length; ++i) {
452
- mods[i](forge);
453
- }
454
- return forge[name];
455
- };
456
- };
457
- var tmpDefine = define;
458
- define = function(ids, factory) {
459
- deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
460
- if(nodeJS) {
461
- delete define;
462
- return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
463
- }
464
- define = tmpDefine;
465
- return define.apply(null, Array.prototype.slice.call(arguments, 0));
466
- };
467
- define(['require', 'module', './util'], function() {
468
- defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
469
- });
470
- })();