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.
- package/CHANGELOG.md +106 -0
- package/LICENSE +3 -3
- package/README.md +254 -175
- package/dist/forge.all.min.js +11 -0
- package/dist/forge.all.min.js.map +1 -0
- package/dist/forge.min.js +10 -0
- package/dist/forge.min.js.map +1 -0
- package/dist/prime.worker.min.js +2 -0
- package/dist/prime.worker.min.js.map +1 -0
- package/flash/README.md +48 -0
- package/flash/package.json +28 -0
- package/flash/swf/SocketPool.swf +0 -0
- package/{js → lib}/aes.js +5 -61
- package/{js → lib}/aesCipherSuites.js +4 -58
- package/{js → lib}/asn1.js +371 -132
- package/{js → lib}/cipher.js +3 -59
- package/{js → lib}/cipherModes.js +3 -65
- package/{js → lib}/debug.js +2 -58
- package/{js → lib}/des.js +6 -63
- package/lib/forge.js +13 -0
- package/{js → lib}/form.js +5 -13
- package/{js → lib}/hmac.js +4 -58
- package/{js → lib}/http.js +15 -20
- package/lib/index.all.js +16 -0
- package/lib/index.js +34 -0
- package/{js → lib}/jsbn.js +3 -60
- package/{js → lib}/kem.js +5 -58
- package/{js → lib}/log.js +3 -58
- package/lib/md.all.js +13 -0
- package/lib/md.js +11 -0
- package/{js → lib}/md5.js +4 -60
- package/lib/mgf.js +12 -0
- package/lib/mgf1.js +57 -0
- package/lib/oids.js +159 -0
- package/{js → lib}/pbe.js +29 -79
- package/{js → lib}/pbkdf2.js +10 -64
- package/{js → lib}/pem.js +3 -58
- package/{js → lib}/pkcs1.js +6 -59
- package/{js → lib}/pkcs12.js +15 -74
- package/{js → lib}/pkcs7.js +12 -72
- package/{js → lib}/pkcs7asn1.js +4 -58
- package/{js → lib}/pki.js +12 -71
- package/{js → lib}/prime.js +18 -58
- package/{js → lib}/prime.worker.js +4 -1
- package/{js → lib}/prng.js +5 -62
- package/{js → lib}/pss.js +7 -61
- package/{js → lib}/random.js +11 -57
- package/{js → lib}/rc2.js +13 -73
- package/{js → lib}/rsa.js +13 -71
- package/{js → lib}/sha1.js +4 -60
- package/{js → lib}/sha256.js +4 -60
- package/{js → lib}/sha512.js +19 -61
- package/{js → lib}/socket.js +8 -63
- package/{js → lib}/ssh.js +7 -66
- package/{js → lib}/task.js +5 -58
- package/{js → lib}/tls.js +10 -67
- package/{js → lib}/tlssocket.js +6 -61
- package/{js → lib}/util.js +39 -68
- package/{js → lib}/x509.js +25 -102
- package/{js → lib}/xhr.js +12 -15
- package/package.json +58 -21
- package/js/forge.js +0 -94
- package/js/md.js +0 -75
- package/js/mgf.js +0 -67
- package/js/mgf1.js +0 -112
- package/js/oids.js +0 -288
- package/swf/SocketPool.swf +0 -0
package/{js → lib}/cipher.js
RENAMED
|
@@ -5,11 +5,10 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) 2010-2014 Digital Bazaar, Inc.
|
|
7
7
|
*/
|
|
8
|
-
(
|
|
9
|
-
|
|
10
|
-
function initModule(forge) {
|
|
8
|
+
var forge = require('./forge');
|
|
9
|
+
require('./util');
|
|
11
10
|
|
|
12
|
-
forge.cipher = forge.cipher || {};
|
|
11
|
+
module.exports = forge.cipher = forge.cipher || {};
|
|
13
12
|
|
|
14
13
|
// registered algorithms
|
|
15
14
|
forge.cipher.algorithms = forge.cipher.algorithms || {};
|
|
@@ -229,58 +228,3 @@ BlockCipher.prototype.finish = function(pad) {
|
|
|
229
228
|
|
|
230
229
|
return true;
|
|
231
230
|
};
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
} // end module implementation
|
|
235
|
-
|
|
236
|
-
/* ########## Begin module wrapper ########## */
|
|
237
|
-
var name = 'cipher';
|
|
238
|
-
if(typeof define !== 'function') {
|
|
239
|
-
// NodeJS -> AMD
|
|
240
|
-
if(typeof module === 'object' && module.exports) {
|
|
241
|
-
var nodeJS = true;
|
|
242
|
-
define = function(ids, factory) {
|
|
243
|
-
factory(require, module);
|
|
244
|
-
};
|
|
245
|
-
} else {
|
|
246
|
-
// <script>
|
|
247
|
-
if(typeof forge === 'undefined') {
|
|
248
|
-
forge = {};
|
|
249
|
-
}
|
|
250
|
-
return initModule(forge);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
// AMD
|
|
254
|
-
var deps;
|
|
255
|
-
var defineFunc = function(require, module) {
|
|
256
|
-
module.exports = function(forge) {
|
|
257
|
-
var mods = deps.map(function(dep) {
|
|
258
|
-
return require(dep);
|
|
259
|
-
}).concat(initModule);
|
|
260
|
-
// handle circular dependencies
|
|
261
|
-
forge = forge || {};
|
|
262
|
-
forge.defined = forge.defined || {};
|
|
263
|
-
if(forge.defined[name]) {
|
|
264
|
-
return forge[name];
|
|
265
|
-
}
|
|
266
|
-
forge.defined[name] = true;
|
|
267
|
-
for(var i = 0; i < mods.length; ++i) {
|
|
268
|
-
mods[i](forge);
|
|
269
|
-
}
|
|
270
|
-
return forge[name];
|
|
271
|
-
};
|
|
272
|
-
};
|
|
273
|
-
var tmpDefine = define;
|
|
274
|
-
define = function(ids, factory) {
|
|
275
|
-
deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
|
|
276
|
-
if(nodeJS) {
|
|
277
|
-
delete define;
|
|
278
|
-
return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
|
|
279
|
-
}
|
|
280
|
-
define = tmpDefine;
|
|
281
|
-
return define.apply(null, Array.prototype.slice.call(arguments, 0));
|
|
282
|
-
};
|
|
283
|
-
define(['require', 'module', './util'], function() {
|
|
284
|
-
defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
|
|
285
|
-
});
|
|
286
|
-
})();
|
|
@@ -5,15 +5,13 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) 2010-2014 Digital Bazaar, Inc.
|
|
7
7
|
*/
|
|
8
|
-
(
|
|
9
|
-
|
|
10
|
-
function initModule(forge) {
|
|
8
|
+
var forge = require('./forge');
|
|
9
|
+
require('./util');
|
|
11
10
|
|
|
12
11
|
forge.cipher = forge.cipher || {};
|
|
13
12
|
|
|
14
13
|
// supported cipher modes
|
|
15
|
-
var modes = forge.cipher.modes = forge.cipher.modes || {};
|
|
16
|
-
|
|
14
|
+
var modes = module.exports = forge.cipher.modes = forge.cipher.modes || {};
|
|
17
15
|
|
|
18
16
|
/** Electronic codebook (ECB) (Don't use this; it's not secure) **/
|
|
19
17
|
|
|
@@ -96,7 +94,6 @@ modes.ecb.prototype.unpad = function(output, options) {
|
|
|
96
94
|
return true;
|
|
97
95
|
};
|
|
98
96
|
|
|
99
|
-
|
|
100
97
|
/** Cipher-block Chaining (CBC) **/
|
|
101
98
|
|
|
102
99
|
modes.cbc = function(options) {
|
|
@@ -198,7 +195,6 @@ modes.cbc.prototype.unpad = function(output, options) {
|
|
|
198
195
|
return true;
|
|
199
196
|
};
|
|
200
197
|
|
|
201
|
-
|
|
202
198
|
/** Cipher feedback (CFB) **/
|
|
203
199
|
|
|
204
200
|
modes.cfb = function(options) {
|
|
@@ -429,7 +425,6 @@ modes.ofb.prototype.encrypt = function(input, output, finish) {
|
|
|
429
425
|
|
|
430
426
|
modes.ofb.prototype.decrypt = modes.ofb.prototype.encrypt;
|
|
431
427
|
|
|
432
|
-
|
|
433
428
|
/** Counter (CTR) **/
|
|
434
429
|
|
|
435
430
|
modes.ctr = function(options) {
|
|
@@ -511,7 +506,6 @@ modes.ctr.prototype.encrypt = function(input, output, finish) {
|
|
|
511
506
|
|
|
512
507
|
modes.ctr.prototype.decrypt = modes.ctr.prototype.encrypt;
|
|
513
508
|
|
|
514
|
-
|
|
515
509
|
/** Galois/Counter Mode (GCM) **/
|
|
516
510
|
|
|
517
511
|
modes.gcm = function(options) {
|
|
@@ -958,7 +952,6 @@ modes.gcm.prototype.generateSubHashTable = function(mid, bits) {
|
|
|
958
952
|
return m;
|
|
959
953
|
};
|
|
960
954
|
|
|
961
|
-
|
|
962
955
|
/** Utility functions */
|
|
963
956
|
|
|
964
957
|
function transformIV(iv) {
|
|
@@ -992,58 +985,3 @@ function from64To32(num) {
|
|
|
992
985
|
// convert 64-bit number to two BE Int32s
|
|
993
986
|
return [(num / 0x100000000) | 0, num & 0xFFFFFFFF];
|
|
994
987
|
}
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
} // end module implementation
|
|
998
|
-
|
|
999
|
-
/* ########## Begin module wrapper ########## */
|
|
1000
|
-
var name = 'cipherModes';
|
|
1001
|
-
if(typeof define !== 'function') {
|
|
1002
|
-
// NodeJS -> AMD
|
|
1003
|
-
if(typeof module === 'object' && module.exports) {
|
|
1004
|
-
var nodeJS = true;
|
|
1005
|
-
define = function(ids, factory) {
|
|
1006
|
-
factory(require, module);
|
|
1007
|
-
};
|
|
1008
|
-
} else {
|
|
1009
|
-
// <script>
|
|
1010
|
-
if(typeof forge === 'undefined') {
|
|
1011
|
-
forge = {};
|
|
1012
|
-
}
|
|
1013
|
-
return initModule(forge);
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
// AMD
|
|
1017
|
-
var deps;
|
|
1018
|
-
var defineFunc = function(require, module) {
|
|
1019
|
-
module.exports = function(forge) {
|
|
1020
|
-
var mods = deps.map(function(dep) {
|
|
1021
|
-
return require(dep);
|
|
1022
|
-
}).concat(initModule);
|
|
1023
|
-
// handle circular dependencies
|
|
1024
|
-
forge = forge || {};
|
|
1025
|
-
forge.defined = forge.defined || {};
|
|
1026
|
-
if(forge.defined[name]) {
|
|
1027
|
-
return forge[name];
|
|
1028
|
-
}
|
|
1029
|
-
forge.defined[name] = true;
|
|
1030
|
-
for(var i = 0; i < mods.length; ++i) {
|
|
1031
|
-
mods[i](forge);
|
|
1032
|
-
}
|
|
1033
|
-
return forge[name];
|
|
1034
|
-
};
|
|
1035
|
-
};
|
|
1036
|
-
var tmpDefine = define;
|
|
1037
|
-
define = function(ids, factory) {
|
|
1038
|
-
deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
|
|
1039
|
-
if(nodeJS) {
|
|
1040
|
-
delete define;
|
|
1041
|
-
return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
|
|
1042
|
-
}
|
|
1043
|
-
define = tmpDefine;
|
|
1044
|
-
return define.apply(null, Array.prototype.slice.call(arguments, 0));
|
|
1045
|
-
};
|
|
1046
|
-
define(['require', 'module', './util'], function() {
|
|
1047
|
-
defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
|
|
1048
|
-
});
|
|
1049
|
-
})();
|
package/{js → lib}/debug.js
RENAMED
|
@@ -5,12 +5,10 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Copyright 2008-2013 Digital Bazaar, Inc.
|
|
7
7
|
*/
|
|
8
|
-
(
|
|
9
|
-
/* ########## Begin module implementation ########## */
|
|
10
|
-
function initModule(forge) {
|
|
8
|
+
var forge = require('./forge');
|
|
11
9
|
|
|
12
10
|
/* DEBUG API */
|
|
13
|
-
forge.debug = forge.debug || {};
|
|
11
|
+
module.exports = forge.debug = forge.debug || {};
|
|
14
12
|
|
|
15
13
|
// Private storage for debugging.
|
|
16
14
|
// Useful to expose data that is otherwise unviewable behind closures.
|
|
@@ -78,57 +76,3 @@ forge.debug.clear = function(cat, name) {
|
|
|
78
76
|
}
|
|
79
77
|
}
|
|
80
78
|
};
|
|
81
|
-
|
|
82
|
-
} // end module implementation
|
|
83
|
-
|
|
84
|
-
/* ########## Begin module wrapper ########## */
|
|
85
|
-
var name = 'debug';
|
|
86
|
-
if(typeof define !== 'function') {
|
|
87
|
-
// NodeJS -> AMD
|
|
88
|
-
if(typeof module === 'object' && module.exports) {
|
|
89
|
-
var nodeJS = true;
|
|
90
|
-
define = function(ids, factory) {
|
|
91
|
-
factory(require, module);
|
|
92
|
-
};
|
|
93
|
-
} else {
|
|
94
|
-
// <script>
|
|
95
|
-
if(typeof forge === 'undefined') {
|
|
96
|
-
forge = {};
|
|
97
|
-
}
|
|
98
|
-
return initModule(forge);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
// AMD
|
|
102
|
-
var deps;
|
|
103
|
-
var defineFunc = function(require, module) {
|
|
104
|
-
module.exports = function(forge) {
|
|
105
|
-
var mods = deps.map(function(dep) {
|
|
106
|
-
return require(dep);
|
|
107
|
-
}).concat(initModule);
|
|
108
|
-
// handle circular dependencies
|
|
109
|
-
forge = forge || {};
|
|
110
|
-
forge.defined = forge.defined || {};
|
|
111
|
-
if(forge.defined[name]) {
|
|
112
|
-
return forge[name];
|
|
113
|
-
}
|
|
114
|
-
forge.defined[name] = true;
|
|
115
|
-
for(var i = 0; i < mods.length; ++i) {
|
|
116
|
-
mods[i](forge);
|
|
117
|
-
}
|
|
118
|
-
return forge[name];
|
|
119
|
-
};
|
|
120
|
-
};
|
|
121
|
-
var tmpDefine = define;
|
|
122
|
-
define = function(ids, factory) {
|
|
123
|
-
deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
|
|
124
|
-
if(nodeJS) {
|
|
125
|
-
delete define;
|
|
126
|
-
return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
|
|
127
|
-
}
|
|
128
|
-
define = tmpDefine;
|
|
129
|
-
return define.apply(null, Array.prototype.slice.call(arguments, 0));
|
|
130
|
-
};
|
|
131
|
-
define(['require', 'module'], function() {
|
|
132
|
-
defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
|
|
133
|
-
});
|
|
134
|
-
})();
|
package/{js → lib}/des.js
RENAMED
|
@@ -28,12 +28,13 @@
|
|
|
28
28
|
* Copyright (c) 2012 Stefan Siegl <stesie@brokenpipe.de>
|
|
29
29
|
* Copyright (c) 2012-2014 Digital Bazaar, Inc.
|
|
30
30
|
*/
|
|
31
|
-
(
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
var forge = require('./forge');
|
|
32
|
+
require('./cipher');
|
|
33
|
+
require('./cipherModes');
|
|
34
|
+
require('./util');
|
|
34
35
|
|
|
35
36
|
/* DES API */
|
|
36
|
-
forge.des = forge.des || {};
|
|
37
|
+
module.exports = forge.des = forge.des || {};
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* Deprecated. Instead, use:
|
|
@@ -193,7 +194,6 @@ forge.des.Algorithm.prototype.initialize = function(options) {
|
|
|
193
194
|
this._init = true;
|
|
194
195
|
};
|
|
195
196
|
|
|
196
|
-
|
|
197
197
|
/** Register DES algorithms **/
|
|
198
198
|
|
|
199
199
|
registerAlgorithm('DES-ECB', forge.cipher.modes.ecb);
|
|
@@ -215,7 +215,6 @@ function registerAlgorithm(name, mode) {
|
|
|
215
215
|
forge.cipher.registerAlgorithm(name, factory);
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
|
|
219
218
|
/** DES implementation **/
|
|
220
219
|
|
|
221
220
|
var spfunction1 = [0x1010400,0,0x10000,0x1010404,0x1010004,0x10404,0x4,0x10000,0x400,0x1010400,0x1010404,0x400,0x1000404,0x1010004,0x1000000,0x4,0x404,0x1000400,0x1000400,0x10400,0x10400,0x1010000,0x1010000,0x1000404,0x10004,0x1000004,0x1000004,0x10004,0,0x404,0x10404,0x1000000,0x10000,0x1010404,0x4,0x1010000,0x1010400,0x1000000,0x1000000,0x400,0x1010004,0x10000,0x10400,0x1000004,0x400,0x4,0x1000404,0x10404,0x1010404,0x10004,0x1010000,0x1000404,0x1000004,0x404,0x10404,0x1010400,0x404,0x1000400,0x1000400,0,0x10004,0x10400,0,0x1010004];
|
|
@@ -261,7 +260,7 @@ function _createKeys(key) {
|
|
|
261
260
|
var shifts = [0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0];
|
|
262
261
|
|
|
263
262
|
var n = 0, tmp;
|
|
264
|
-
for(var j = 0; j < iterations; j
|
|
263
|
+
for(var j = 0; j < iterations; j++) {
|
|
265
264
|
var left = key.getInt32();
|
|
266
265
|
var right = key.getInt32();
|
|
267
266
|
|
|
@@ -494,59 +493,3 @@ function _createCipher(options) {
|
|
|
494
493
|
|
|
495
494
|
return cipher;
|
|
496
495
|
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
} // end module implementation
|
|
500
|
-
|
|
501
|
-
/* ########## Begin module wrapper ########## */
|
|
502
|
-
var name = 'des';
|
|
503
|
-
if(typeof define !== 'function') {
|
|
504
|
-
// NodeJS -> AMD
|
|
505
|
-
if(typeof module === 'object' && module.exports) {
|
|
506
|
-
var nodeJS = true;
|
|
507
|
-
define = function(ids, factory) {
|
|
508
|
-
factory(require, module);
|
|
509
|
-
};
|
|
510
|
-
} else {
|
|
511
|
-
// <script>
|
|
512
|
-
if(typeof forge === 'undefined') {
|
|
513
|
-
forge = {};
|
|
514
|
-
}
|
|
515
|
-
return initModule(forge);
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
// AMD
|
|
519
|
-
var deps;
|
|
520
|
-
var defineFunc = function(require, module) {
|
|
521
|
-
module.exports = function(forge) {
|
|
522
|
-
var mods = deps.map(function(dep) {
|
|
523
|
-
return require(dep);
|
|
524
|
-
}).concat(initModule);
|
|
525
|
-
// handle circular dependencies
|
|
526
|
-
forge = forge || {};
|
|
527
|
-
forge.defined = forge.defined || {};
|
|
528
|
-
if(forge.defined[name]) {
|
|
529
|
-
return forge[name];
|
|
530
|
-
}
|
|
531
|
-
forge.defined[name] = true;
|
|
532
|
-
for(var i = 0; i < mods.length; ++i) {
|
|
533
|
-
mods[i](forge);
|
|
534
|
-
}
|
|
535
|
-
return forge[name];
|
|
536
|
-
};
|
|
537
|
-
};
|
|
538
|
-
var tmpDefine = define;
|
|
539
|
-
define = function(ids, factory) {
|
|
540
|
-
deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
|
|
541
|
-
if(nodeJS) {
|
|
542
|
-
delete define;
|
|
543
|
-
return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
|
|
544
|
-
}
|
|
545
|
-
define = tmpDefine;
|
|
546
|
-
return define.apply(null, Array.prototype.slice.call(arguments, 0));
|
|
547
|
-
};
|
|
548
|
-
define(
|
|
549
|
-
['require', 'module', './cipher', './cipherModes', './util'], function() {
|
|
550
|
-
defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
|
|
551
|
-
});
|
|
552
|
-
})();
|
package/lib/forge.js
ADDED
package/{js → lib}/form.js
RENAMED
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Copyright (c) 2011-2014 Digital Bazaar, Inc. All rights reserved.
|
|
9
9
|
*/
|
|
10
|
-
(
|
|
10
|
+
var forge = require('./forge');
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
/* Form API */
|
|
13
|
+
var form = module.exports = forge.form = forge.form || {};
|
|
14
|
+
|
|
15
|
+
(function($) {
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Regex for parsing a single name property (handles array brackets).
|
|
@@ -146,12 +146,4 @@ form.serialize = function(input, sep, dict) {
|
|
|
146
146
|
return rval;
|
|
147
147
|
};
|
|
148
148
|
|
|
149
|
-
/**
|
|
150
|
-
* The forge namespace and form API.
|
|
151
|
-
*/
|
|
152
|
-
if(typeof forge === 'undefined') {
|
|
153
|
-
forge = {};
|
|
154
|
-
}
|
|
155
|
-
forge.form = form;
|
|
156
|
-
|
|
157
149
|
})(jQuery);
|
package/{js → lib}/hmac.js
RENAMED
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Copyright (c) 2010-2012 Digital Bazaar, Inc. All rights reserved.
|
|
9
9
|
*/
|
|
10
|
-
(
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
var forge = require('./forge');
|
|
11
|
+
require('./md');
|
|
12
|
+
require('./util');
|
|
13
13
|
|
|
14
14
|
/* HMAC API */
|
|
15
|
-
var hmac = forge.hmac = forge.hmac || {};
|
|
15
|
+
var hmac = module.exports = forge.hmac = forge.hmac || {};
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Creates an HMAC object that uses the given message digest object.
|
|
@@ -144,57 +144,3 @@ hmac.create = function() {
|
|
|
144
144
|
|
|
145
145
|
return ctx;
|
|
146
146
|
};
|
|
147
|
-
|
|
148
|
-
} // end module implementation
|
|
149
|
-
|
|
150
|
-
/* ########## Begin module wrapper ########## */
|
|
151
|
-
var name = 'hmac';
|
|
152
|
-
if(typeof define !== 'function') {
|
|
153
|
-
// NodeJS -> AMD
|
|
154
|
-
if(typeof module === 'object' && module.exports) {
|
|
155
|
-
var nodeJS = true;
|
|
156
|
-
define = function(ids, factory) {
|
|
157
|
-
factory(require, module);
|
|
158
|
-
};
|
|
159
|
-
} else {
|
|
160
|
-
// <script>
|
|
161
|
-
if(typeof forge === 'undefined') {
|
|
162
|
-
forge = {};
|
|
163
|
-
}
|
|
164
|
-
return initModule(forge);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
// AMD
|
|
168
|
-
var deps;
|
|
169
|
-
var defineFunc = function(require, module) {
|
|
170
|
-
module.exports = function(forge) {
|
|
171
|
-
var mods = deps.map(function(dep) {
|
|
172
|
-
return require(dep);
|
|
173
|
-
}).concat(initModule);
|
|
174
|
-
// handle circular dependencies
|
|
175
|
-
forge = forge || {};
|
|
176
|
-
forge.defined = forge.defined || {};
|
|
177
|
-
if(forge.defined[name]) {
|
|
178
|
-
return forge[name];
|
|
179
|
-
}
|
|
180
|
-
forge.defined[name] = true;
|
|
181
|
-
for(var i = 0; i < mods.length; ++i) {
|
|
182
|
-
mods[i](forge);
|
|
183
|
-
}
|
|
184
|
-
return forge[name];
|
|
185
|
-
};
|
|
186
|
-
};
|
|
187
|
-
var tmpDefine = define;
|
|
188
|
-
define = function(ids, factory) {
|
|
189
|
-
deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
|
|
190
|
-
if(nodeJS) {
|
|
191
|
-
delete define;
|
|
192
|
-
return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
|
|
193
|
-
}
|
|
194
|
-
define = tmpDefine;
|
|
195
|
-
return define.apply(null, Array.prototype.slice.call(arguments, 0));
|
|
196
|
-
};
|
|
197
|
-
define(['require', 'module', './md', './util'], function() {
|
|
198
|
-
defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
|
|
199
|
-
});
|
|
200
|
-
})();
|
package/{js → lib}/http.js
RENAMED
|
@@ -5,10 +5,13 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) 2010-2014 Digital Bazaar, Inc. All rights reserved.
|
|
7
7
|
*/
|
|
8
|
-
(
|
|
8
|
+
var forge = require('./forge');
|
|
9
|
+
require('./debug');
|
|
10
|
+
require('./tls');
|
|
11
|
+
require('./util');
|
|
9
12
|
|
|
10
13
|
// define http namespace
|
|
11
|
-
var http = {};
|
|
14
|
+
var http = module.exports = forge.http = forge.http || {};
|
|
12
15
|
|
|
13
16
|
// logging category
|
|
14
17
|
var cat = 'forge.http';
|
|
@@ -21,7 +24,7 @@ if(forge.debug) {
|
|
|
21
24
|
// normalizes an http header field name
|
|
22
25
|
var _normalize = function(name) {
|
|
23
26
|
return name.toLowerCase().replace(/(^.)|(-.)/g,
|
|
24
|
-
function(a){return a.toUpperCase();});
|
|
27
|
+
function(a) {return a.toUpperCase();});
|
|
25
28
|
};
|
|
26
29
|
|
|
27
30
|
/**
|
|
@@ -566,8 +569,8 @@ http.createClient = function(options) {
|
|
|
566
569
|
// set default dummy handlers
|
|
567
570
|
var opts = {};
|
|
568
571
|
opts.request = options.request;
|
|
569
|
-
opts.connected = options.connected || function(){};
|
|
570
|
-
opts.closed = options.close || function(){};
|
|
572
|
+
opts.connected = options.connected || function() {};
|
|
573
|
+
opts.closed = options.close || function() {};
|
|
571
574
|
opts.headerReady = function(e) {
|
|
572
575
|
// read cookies
|
|
573
576
|
_readCookies(client, e.response);
|
|
@@ -575,8 +578,8 @@ http.createClient = function(options) {
|
|
|
575
578
|
options.headerReady(e);
|
|
576
579
|
}
|
|
577
580
|
};
|
|
578
|
-
opts.bodyReady = options.bodyReady || function(){};
|
|
579
|
-
opts.error = options.error || function(){};
|
|
581
|
+
opts.bodyReady = options.bodyReady || function() {};
|
|
582
|
+
opts.error = options.error || function() {};
|
|
580
583
|
|
|
581
584
|
// create response
|
|
582
585
|
opts.response = http.createResponse();
|
|
@@ -588,11 +591,11 @@ http.createClient = function(options) {
|
|
|
588
591
|
opts.request.abort = function() {
|
|
589
592
|
// set aborted, clear handlers
|
|
590
593
|
opts.request.aborted = true;
|
|
591
|
-
opts.connected = function(){};
|
|
592
|
-
opts.closed = function(){};
|
|
593
|
-
opts.headerReady = function(){};
|
|
594
|
-
opts.bodyReady = function(){};
|
|
595
|
-
opts.error = function(){};
|
|
594
|
+
opts.connected = function() {};
|
|
595
|
+
opts.closed = function() {};
|
|
596
|
+
opts.headerReady = function() {};
|
|
597
|
+
opts.bodyReady = function() {};
|
|
598
|
+
opts.error = function() {};
|
|
596
599
|
};
|
|
597
600
|
|
|
598
601
|
// add cookies to request
|
|
@@ -1359,11 +1362,3 @@ http.withinCookieDomain = function(url, cookie) {
|
|
|
1359
1362
|
|
|
1360
1363
|
return rval;
|
|
1361
1364
|
};
|
|
1362
|
-
|
|
1363
|
-
// public access to http namespace
|
|
1364
|
-
if(typeof forge === 'undefined') {
|
|
1365
|
-
forge = {};
|
|
1366
|
-
}
|
|
1367
|
-
forge.http = http;
|
|
1368
|
-
|
|
1369
|
-
})();
|
package/lib/index.all.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node.js module for Forge with extra utils and networking.
|
|
3
|
+
*
|
|
4
|
+
* @author Dave Longley
|
|
5
|
+
*
|
|
6
|
+
* Copyright 2011-2016 Digital Bazaar, Inc.
|
|
7
|
+
*/
|
|
8
|
+
module.exports = require('./forge');
|
|
9
|
+
// require core forge
|
|
10
|
+
require('./index');
|
|
11
|
+
// additional utils and networking support
|
|
12
|
+
require('./form');
|
|
13
|
+
require('./socket');
|
|
14
|
+
require('./tlssocket');
|
|
15
|
+
require('./http');
|
|
16
|
+
require('./xhr');
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node.js module for Forge.
|
|
3
|
+
*
|
|
4
|
+
* @author Dave Longley
|
|
5
|
+
*
|
|
6
|
+
* Copyright 2011-2016 Digital Bazaar, Inc.
|
|
7
|
+
*/
|
|
8
|
+
module.exports = require('./forge');
|
|
9
|
+
require('./aes');
|
|
10
|
+
require('./aesCipherSuites');
|
|
11
|
+
require('./asn1');
|
|
12
|
+
require('./cipher');
|
|
13
|
+
require('./debug');
|
|
14
|
+
require('./des');
|
|
15
|
+
require('./hmac');
|
|
16
|
+
require('./kem');
|
|
17
|
+
require('./log');
|
|
18
|
+
require('./md.all');
|
|
19
|
+
require('./mgf1');
|
|
20
|
+
require('./pbkdf2');
|
|
21
|
+
require('./pem');
|
|
22
|
+
require('./pkcs1');
|
|
23
|
+
require('./pkcs12');
|
|
24
|
+
require('./pkcs7');
|
|
25
|
+
require('./pki');
|
|
26
|
+
require('./prime');
|
|
27
|
+
require('./prng');
|
|
28
|
+
require('./pss');
|
|
29
|
+
require('./random');
|
|
30
|
+
require('./rc2');
|
|
31
|
+
require('./ssh');
|
|
32
|
+
require('./task');
|
|
33
|
+
require('./tls');
|
|
34
|
+
require('./util');
|
package/{js → lib}/jsbn.js
RENAMED
|
@@ -46,10 +46,9 @@ Address all questions regarding this license to:
|
|
|
46
46
|
Tom Wu
|
|
47
47
|
tjw@cs.Stanford.EDU
|
|
48
48
|
*/
|
|
49
|
+
var forge = require('./forge');
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
/* ########## Begin module implementation ########## */
|
|
52
|
-
function initModule(forge) {
|
|
51
|
+
module.exports = forge.jsbn = forge.jsbn || {};
|
|
53
52
|
|
|
54
53
|
// Bits per digit
|
|
55
54
|
var dbits;
|
|
@@ -66,6 +65,7 @@ function BigInteger(a,b,c) {
|
|
|
66
65
|
else if(b == null && "string" != typeof a) this.fromString(a,256);
|
|
67
66
|
else this.fromString(a,b);
|
|
68
67
|
}
|
|
68
|
+
forge.jsbn.BigInteger = BigInteger;
|
|
69
69
|
|
|
70
70
|
// return new, unset BigInteger
|
|
71
71
|
function nbi() { return new BigInteger(null); }
|
|
@@ -1262,60 +1262,3 @@ BigInteger.prototype.isProbablePrime = bnIsProbablePrime;
|
|
|
1262
1262
|
//int hashCode()
|
|
1263
1263
|
//long longValue()
|
|
1264
1264
|
//static BigInteger valueOf(long val)
|
|
1265
|
-
|
|
1266
|
-
forge.jsbn = forge.jsbn || {};
|
|
1267
|
-
forge.jsbn.BigInteger = BigInteger;
|
|
1268
|
-
|
|
1269
|
-
} // end module implementation
|
|
1270
|
-
|
|
1271
|
-
/* ########## Begin module wrapper ########## */
|
|
1272
|
-
var name = 'jsbn';
|
|
1273
|
-
if(typeof define !== 'function') {
|
|
1274
|
-
// NodeJS -> AMD
|
|
1275
|
-
if(typeof module === 'object' && module.exports) {
|
|
1276
|
-
var nodeJS = true;
|
|
1277
|
-
define = function(ids, factory) {
|
|
1278
|
-
factory(require, module);
|
|
1279
|
-
};
|
|
1280
|
-
} else {
|
|
1281
|
-
// <script>
|
|
1282
|
-
if(typeof forge === 'undefined') {
|
|
1283
|
-
forge = {};
|
|
1284
|
-
}
|
|
1285
|
-
return initModule(forge);
|
|
1286
|
-
}
|
|
1287
|
-
}
|
|
1288
|
-
// AMD
|
|
1289
|
-
var deps;
|
|
1290
|
-
var defineFunc = function(require, module) {
|
|
1291
|
-
module.exports = function(forge) {
|
|
1292
|
-
var mods = deps.map(function(dep) {
|
|
1293
|
-
return require(dep);
|
|
1294
|
-
}).concat(initModule);
|
|
1295
|
-
// handle circular dependencies
|
|
1296
|
-
forge = forge || {};
|
|
1297
|
-
forge.defined = forge.defined || {};
|
|
1298
|
-
if(forge.defined[name]) {
|
|
1299
|
-
return forge[name];
|
|
1300
|
-
}
|
|
1301
|
-
forge.defined[name] = true;
|
|
1302
|
-
for(var i = 0; i < mods.length; ++i) {
|
|
1303
|
-
mods[i](forge);
|
|
1304
|
-
}
|
|
1305
|
-
return forge[name];
|
|
1306
|
-
};
|
|
1307
|
-
};
|
|
1308
|
-
var tmpDefine = define;
|
|
1309
|
-
define = function(ids, factory) {
|
|
1310
|
-
deps = (typeof ids === 'string') ? factory.slice(2) : ids.slice(2);
|
|
1311
|
-
if(nodeJS) {
|
|
1312
|
-
delete define;
|
|
1313
|
-
return tmpDefine.apply(null, Array.prototype.slice.call(arguments, 0));
|
|
1314
|
-
}
|
|
1315
|
-
define = tmpDefine;
|
|
1316
|
-
return define.apply(null, Array.prototype.slice.call(arguments, 0));
|
|
1317
|
-
};
|
|
1318
|
-
define(['require', 'module'], function() {
|
|
1319
|
-
defineFunc.apply(null, Array.prototype.slice.call(arguments, 0));
|
|
1320
|
-
});
|
|
1321
|
-
})();
|