You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by za...@apache.org on 2015/04/01 16:22:31 UTC
[04/52] [abbrv] [partial] cordova-firefoxos git commit: CB-4548
Install new node-firefox-* dependencies in node_modules
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/aes.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/aes.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/aes.js
new file mode 100644
index 0000000..ddd91a4
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/aes.js
@@ -0,0 +1,1213 @@
+(function() {
+
+function Tests(ASSERT, CIPHER, AES, UTIL) {
+ describe('aes', function() {
+ it('should encrypt a single block with a 128-bit key', function() {
+ var key = [0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f];
+ var block = [0x00112233, 0x44556677, 0x8899aabb, 0xccddeeff];
+
+ var output = [];
+ var w = AES._expandKey(key, false);
+ AES._updateBlock(w, block, output, false);
+
+ var out = UTIL.createBuffer();
+ out.putInt32(output[0]);
+ out.putInt32(output[1]);
+ out.putInt32(output[2]);
+ out.putInt32(output[3]);
+
+ ASSERT.equal(out.toHex(), '69c4e0d86a7b0430d8cdb78070b4c55a');
+ });
+
+ it('should decrypt a single block with a 128-bit key', function() {
+ var key = [0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f];
+ var block = [0x69c4e0d8, 0x6a7b0430, 0xd8cdb780, 0x70b4c55a];
+
+ var output = [];
+ var w = AES._expandKey(key, true);
+ AES._updateBlock(w, block, output, true);
+
+ var out = UTIL.createBuffer();
+ out.putInt32(output[0]);
+ out.putInt32(output[1]);
+ out.putInt32(output[2]);
+ out.putInt32(output[3]);
+
+ ASSERT.equal(out.toHex(), '00112233445566778899aabbccddeeff');
+ });
+
+ it('should encrypt a single block with a 192-bit key', function() {
+ var key = [
+ 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f,
+ 0x10111213, 0x14151617];
+ var block = [0x00112233, 0x44556677, 0x8899aabb, 0xccddeeff];
+
+ var output = [];
+ var w = AES._expandKey(key, false);
+ AES._updateBlock(w, block, output, false);
+
+ var out = UTIL.createBuffer();
+ out.putInt32(output[0]);
+ out.putInt32(output[1]);
+ out.putInt32(output[2]);
+ out.putInt32(output[3]);
+
+ ASSERT.equal(out.toHex(), 'dda97ca4864cdfe06eaf70a0ec0d7191');
+ });
+
+ it('should decrypt a single block with a 192-bit key', function() {
+ var key = [
+ 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f,
+ 0x10111213, 0x14151617];
+ var block = [0xdda97ca4, 0x864cdfe0, 0x6eaf70a0, 0xec0d7191];
+
+ var output = [];
+ var w = AES._expandKey(key, true);
+ AES._updateBlock(w, block, output, true);
+
+ var out = UTIL.createBuffer();
+ out.putInt32(output[0]);
+ out.putInt32(output[1]);
+ out.putInt32(output[2]);
+ out.putInt32(output[3]);
+
+ ASSERT.equal(out.toHex(), '00112233445566778899aabbccddeeff');
+ });
+
+ it('should encrypt a single block with a 256-bit key', function() {
+ var key = [
+ 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f,
+ 0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f];
+ var block = [0x00112233, 0x44556677, 0x8899aabb, 0xccddeeff];
+
+ var output = [];
+ var w = AES._expandKey(key, false);
+ AES._updateBlock(w, block, output, false);
+
+ var out = UTIL.createBuffer();
+ out.putInt32(output[0]);
+ out.putInt32(output[1]);
+ out.putInt32(output[2]);
+ out.putInt32(output[3]);
+
+ ASSERT.equal(out.toHex(), '8ea2b7ca516745bfeafc49904b496089');
+ });
+
+ it('should decrypt a single block with a 256-bit key', function() {
+ var key = [
+ 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f,
+ 0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f];
+ var block = [0x8ea2b7ca, 0x516745bf, 0xeafc4990, 0x4b496089];
+
+ var output = [];
+ var w = AES._expandKey(key, true);
+ AES._updateBlock(w, block, output, true);
+
+ var out = UTIL.createBuffer();
+ out.putInt32(output[0]);
+ out.putInt32(output[1]);
+ out.putInt32(output[2]);
+ out.putInt32(output[3]);
+
+ ASSERT.equal(out.toHex(), '00112233445566778899aabbccddeeff');
+ });
+
+ // AES-128-CBC
+ (function() {
+ var keys = [
+ '06a9214036b8a15b512e03d534120006',
+ 'c286696d887c9aa0611bbb3e2025a45a',
+ '6c3ea0477630ce21a2ce334aa746c2cd',
+ '56e47a38c5598974bc46903dba290349'
+ ];
+
+ var ivs = [
+ '3dafba429d9eb430b422da802c9fac41',
+ '562e17996d093d28ddb3ba695a2e6f58',
+ 'c782dc4c098c66cbd9cd27d825682c81',
+ '8ce82eefbea0da3c44699ed7db51b7d9'
+ ];
+
+ var inputs = [
+ 'Single block msg',
+ '000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f',
+ 'This is a 48-byte message (exactly 3 AES blocks)',
+ 'a0a1a2a3a4a5a6a7a8a9aaabacadaeaf' +
+ 'b0b1b2b3b4b5b6b7b8b9babbbcbdbebf' +
+ 'c0c1c2c3c4c5c6c7c8c9cacbcccdcecf' +
+ 'd0d1d2d3d4d5d6d7d8d9dadbdcdddedf'
+ ];
+
+ var outputs = [
+ 'e353779c1079aeb82708942dbe77181a',
+ 'd296cd94c2cccf8a3a863028b5e1dc0a7586602d253cfff91b8266bea6d61ab1',
+ 'd0a02b3836451753d493665d33f0e886' +
+ '2dea54cdb293abc7506939276772f8d5' +
+ '021c19216bad525c8579695d83ba2684',
+ 'c30e32ffedc0774e6aff6af0869f71aa' +
+ '0f3af07a9a31a9c684db207eb0ef8e4e' +
+ '35907aa632c3ffdf868bb7b29d3d46ad' +
+ '83ce9f9a102ee99d49a53e87f4c3da55'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = (i & 1) ? UTIL.hexToBytes(inputs[i]) : inputs[i];
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-128-cbc encrypt: ' + inputs[i], function() {
+ // encrypt w/no padding
+ var cipher = CIPHER.createCipher('AES-CBC', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish(function(){return true;});
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-128-cbc decrypt: ' + outputs[i], function() {
+ // decrypt w/no padding
+ var cipher = CIPHER.createDecipher('AES-CBC', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish(function(){return true;});
+ var out = (i & 1) ? cipher.output.toHex() : cipher.output.bytes();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-192-CBC
+ (function() {
+ var keys = [
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b',
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b',
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b',
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b'
+ ];
+
+ var ivs = [
+ '000102030405060708090A0B0C0D0E0F',
+ '4F021DB243BC633D7178183A9FA071E8',
+ 'B4D9ADA9AD7DEDF4E5E738763F69145A',
+ '571B242012FB7AE07FA9BAAC3DF102E0'
+ ];
+
+ var inputs = [
+ '6bc1bee22e409f96e93d7e117393172a',
+ 'ae2d8a571e03ac9c9eb76fac45af8e51',
+ '30c81c46a35ce411e5fbc1191a0a52ef',
+ 'f69f2445df4f9b17ad2b417be66c3710'
+ ];
+
+ var outputs = [
+ '4f021db243bc633d7178183a9fa071e8',
+ 'b4d9ada9ad7dedf4e5e738763f69145a',
+ '571b242012fb7ae07fa9baac3df102e0',
+ '08b0e27988598881d920a9e64f5615cd'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = UTIL.hexToBytes(inputs[i]);
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-192-cbc encrypt: ' + inputs[i], function() {
+ // encrypt w/no padding
+ var cipher = CIPHER.createCipher('AES-CBC', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish(function(){return true;});
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-192-cbc decrypt: ' + outputs[i], function() {
+ // decrypt w/no padding
+ var cipher = CIPHER.createDecipher('AES-CBC', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish(function(){return true;});
+ var out = cipher.output.toHex();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-256-CBC
+ (function() {
+ var keys = [
+ '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4',
+ '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4',
+ '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4',
+ '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4'
+ ];
+
+ var ivs = [
+ '000102030405060708090A0B0C0D0E0F',
+ 'F58C4C04D6E5F1BA779EABFB5F7BFBD6',
+ '9CFC4E967EDB808D679F777BC6702C7D',
+ '39F23369A9D9BACFA530E26304231461'
+ ];
+
+ var inputs = [
+ '6bc1bee22e409f96e93d7e117393172a',
+ 'ae2d8a571e03ac9c9eb76fac45af8e51',
+ '30c81c46a35ce411e5fbc1191a0a52ef',
+ 'f69f2445df4f9b17ad2b417be66c3710'
+ ];
+
+ var outputs = [
+ 'f58c4c04d6e5f1ba779eabfb5f7bfbd6',
+ '9cfc4e967edb808d679f777bc6702c7d',
+ '39f23369a9d9bacfa530e26304231461',
+ 'b2eb05e2c39be9fcda6c19078c6a9d1b'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = UTIL.hexToBytes(inputs[i]);
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-256-cbc encrypt: ' + inputs[i], function() {
+ // encrypt w/no padding
+ var cipher = CIPHER.createCipher('AES-CBC', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish(function(){return true;});
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-256-cbc decrypt: ' + outputs[i], function() {
+ // decrypt w/no padding
+ var cipher = CIPHER.createDecipher('AES-CBC', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish(function(){return true;});
+ var out = cipher.output.toHex();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-128-CFB
+ (function() {
+ var keys = [
+ '00000000000000000000000000000000',
+ '2b7e151628aed2a6abf7158809cf4f3c',
+ '2b7e151628aed2a6abf7158809cf4f3c',
+ '2b7e151628aed2a6abf7158809cf4f3c',
+ '2b7e151628aed2a6abf7158809cf4f3c',
+ '00000000000000000000000000000000'
+ ];
+
+ var ivs = [
+ '80000000000000000000000000000000',
+ '000102030405060708090a0b0c0d0e0f',
+ '3B3FD92EB72DAD20333449F8E83CFB4A',
+ 'C8A64537A0B3A93FCDE3CDAD9F1CE58B',
+ '26751F67A3CBB140B1808CF187A4F4DF',
+ '60f9ff04fac1a25657bf5b36b5efaf75'
+ ];
+
+ var inputs = [
+ '00000000000000000000000000000000',
+ '6bc1bee22e409f96e93d7e117393172a',
+ 'ae2d8a571e03ac9c9eb76fac45af8e51',
+ '30c81c46a35ce411e5fbc1191a0a52ef',
+ 'f69f2445df4f9b17ad2b417be66c3710',
+ 'This is a 48-byte message (exactly 3 AES blocks)'
+ ];
+
+ var outputs = [
+ '3ad78e726c1ec02b7ebfe92b23d9ec34',
+ '3b3fd92eb72dad20333449f8e83cfb4a',
+ 'c8a64537a0b3a93fcde3cdad9f1ce58b',
+ '26751f67a3cbb140b1808cf187a4f4df',
+ 'c04b05357c5d1c0eeac4c66f9ff7f2e6',
+ '52396a2ba1ba420c5e5b699a814944d8' +
+ 'f4e7fbf984a038319fbc0b4ee45cfa6f' +
+ '07b2564beab5b5e92dbd44cb345f49b4'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = (i !== 5) ? UTIL.hexToBytes(inputs[i]) : inputs[i];
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-128-cfb encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-CFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-128-cfb decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-CFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish();
+ var out = (i !== 5) ?
+ cipher.output.toHex() : cipher.output.getBytes();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-192-CFB
+ (function() {
+ var keys = [
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b',
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b',
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b',
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b'
+ ];
+
+ var ivs = [
+ '000102030405060708090A0B0C0D0E0F',
+ 'CDC80D6FDDF18CAB34C25909C99A4174',
+ '67CE7F7F81173621961A2B70171D3D7A',
+ '2E1E8A1DD59B88B1C8E60FED1EFAC4C9'
+ ];
+
+ var inputs = [
+ '6bc1bee22e409f96e93d7e117393172a',
+ 'ae2d8a571e03ac9c9eb76fac45af8e51',
+ '30c81c46a35ce411e5fbc1191a0a52ef',
+ 'f69f2445df4f9b17ad2b417be66c3710'
+ ];
+
+ var outputs = [
+ 'cdc80d6fddf18cab34c25909c99a4174',
+ '67ce7f7f81173621961a2b70171d3d7a',
+ '2e1e8a1dd59b88b1c8e60fed1efac4c9',
+ 'c05f9f9ca9834fa042ae8fba584b09ff'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = UTIL.hexToBytes(inputs[i]);
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-192-cfb encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-CFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-192-cfb decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-CFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish();
+ var out = cipher.output.toHex();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-256-CFB
+ (function() {
+ var keys = [
+ '861009ec4d599fab1f40abc76e6f89880cff5833c79c548c99f9045f191cd90b'
+ ];
+
+ var ivs = [
+ 'd927ad81199aa7dcadfdb4e47b6dc694'
+ ];
+
+ var inputs = [
+ 'MY-DATA-AND-HERE-IS-MORE-DATA'
+ ];
+
+ var outputs = [
+ '80eb666a9fc9e263faf71e87ffc94451d7d8df7cfcf2606470351dd5ac'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = inputs[i];
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-256-cfb encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-CFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-256-cfb decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-CFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish();
+ var out = cipher.output.getBytes();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-128-OFB
+ (function() {
+ var keys = [
+ '00000000000000000000000000000000',
+ '00000000000000000000000000000000'
+ ];
+
+ var ivs = [
+ '80000000000000000000000000000000',
+ 'c8ca0d6a35dbeac776e911ee16bea7d3'
+ ];
+
+ var inputs = [
+ '00000000000000000000000000000000',
+ 'This is a 48-byte message (exactly 3 AES blocks)'
+ ];
+
+ var outputs = [
+ '3ad78e726c1ec02b7ebfe92b23d9ec34',
+ '39c0190727a76b2a90963426f63689cf' +
+ 'cdb8a2be8e20c5e877a81a724e3611f6' +
+ '2ecc386f2e941b2441c838906002be19'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = (i !== 1) ? UTIL.hexToBytes(inputs[i]) : inputs[i];
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-128-ofb encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-OFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-128-ofb decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-OFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish();
+ var out = (i !== 1) ?
+ cipher.output.toHex() : cipher.output.getBytes();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-192-OFB
+ (function() {
+ var keys = [
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b',
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b',
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b',
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b'
+ ];
+
+ var ivs = [
+ '000102030405060708090A0B0C0D0E0F',
+ 'A609B38DF3B1133DDDFF2718BA09565E',
+ '52EF01DA52602FE0975F78AC84BF8A50',
+ 'BD5286AC63AABD7EB067AC54B553F71D'
+ ];
+
+ var inputs = [
+ '6bc1bee22e409f96e93d7e117393172a',
+ 'ae2d8a571e03ac9c9eb76fac45af8e51',
+ '30c81c46a35ce411e5fbc1191a0a52ef',
+ 'f69f2445df4f9b17ad2b417be66c3710'
+ ];
+
+ var outputs = [
+ 'cdc80d6fddf18cab34c25909c99a4174',
+ 'fcc28b8d4c63837c09e81700c1100401',
+ '8d9a9aeac0f6596f559c6d4daf59a5f2',
+ '6d9f200857ca6c3e9cac524bd9acc92a'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = UTIL.hexToBytes(inputs[i]);
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-192-ofb encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-OFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-192-ofb decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-OFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish();
+ var out = cipher.output.toHex();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-256-OFB
+ (function() {
+ var keys = [
+ '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4',
+ '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4',
+ '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4',
+ '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4'
+ ];
+
+ var ivs = [
+ '000102030405060708090A0B0C0D0E0F',
+ 'B7BF3A5DF43989DD97F0FA97EBCE2F4A',
+ 'E1C656305ED1A7A6563805746FE03EDC',
+ '41635BE625B48AFC1666DD42A09D96E7'
+ ];
+
+ var inputs = [
+ '6bc1bee22e409f96e93d7e117393172a',
+ 'ae2d8a571e03ac9c9eb76fac45af8e51',
+ '30c81c46a35ce411e5fbc1191a0a52ef',
+ 'f69f2445df4f9b17ad2b417be66c3710'
+ ];
+
+ var outputs = [
+ 'dc7e84bfda79164b7ecd8486985d3860',
+ '4febdc6740d20b3ac88f6ad82a4fb08d',
+ '71ab47a086e86eedf39d1c5bba97c408',
+ '0126141d67f37be8538f5a8be740e484'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = UTIL.hexToBytes(inputs[i]);
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-256-ofb encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-OFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-256-ofb decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-OFB', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish();
+ var out = cipher.output.toHex();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-128-CTR
+ (function() {
+ var keys = [
+ '2b7e151628aed2a6abf7158809cf4f3c',
+ '00000000000000000000000000000000'
+ ];
+
+ var ivs = [
+ 'f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff',
+ '650cdb80ff9fc758342d2bd99ee2abcf'
+ ];
+
+ var inputs = [
+ '6bc1bee22e409f96e93d7e117393172a',
+ 'This is a 48-byte message (exactly 3 AES blocks)'
+ ];
+
+ var outputs = [
+ '874d6191b620e3261bef6864990db6ce',
+ '5ede11d00e9a76ec1d5e7e811ea3dd1c' +
+ 'e09ee941210f825d35718d3282796f1c' +
+ '07c3f1cb424f2b365766ab5229f5b5a4'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = (i !== 1) ? UTIL.hexToBytes(inputs[i]) : inputs[i];
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-128-ctr encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-CTR', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-128-ctr decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-CTR', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish();
+ var out = (i !== 1) ?
+ cipher.output.toHex() : cipher.output.getBytes();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-192-CTR
+ (function() {
+ var keys = [
+ '8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b'
+ ];
+
+ var ivs = [
+ 'f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff'
+ ];
+
+ var inputs = [
+ '6bc1bee22e409f96e93d7e117393172a' +
+ 'ae2d8a571e03ac9c9eb76fac45af8e51' +
+ '30c81c46a35ce411e5fbc1191a0a52ef' +
+ 'f69f2445df4f9b17ad2b417be66c3710'
+ ];
+
+ var outputs = [
+ '1abc932417521ca24f2b0459fe7e6e0b' +
+ '090339ec0aa6faefd5ccc2c6f4ce8e94' +
+ '1e36b26bd1ebc670d1bd1d665620abf7' +
+ '4f78a7f6d29809585a97daec58c6b050'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = UTIL.hexToBytes(inputs[i]);
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-192-ctr encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-CTR', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-192-ctr decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-CTR', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish();
+ var out = cipher.output.toHex();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-256-CTR
+ (function() {
+ var keys = [
+ '603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4'
+ ];
+
+ var ivs = [
+ 'f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff'
+ ];
+
+ var inputs = [
+ '6bc1bee22e409f96e93d7e117393172a' +
+ 'ae2d8a571e03ac9c9eb76fac45af8e51' +
+ '30c81c46a35ce411e5fbc1191a0a52ef' +
+ 'f69f2445df4f9b17ad2b417be66c3710'
+ ];
+
+ var outputs = [
+ '601ec313775789a5b7a7f504bbf3d228' +
+ 'f443e3ca4d62b59aca84e990cacaf5c5' +
+ '2b0930daa23de94ce87017ba2d84988d' +
+ 'dfc9c58db67aada613c2dd08457941a6'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var input = UTIL.hexToBytes(inputs[i]);
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-256-ctr encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-CTR', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ });
+
+ it('should aes-256-ctr decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-CTR', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer(output));
+ cipher.finish();
+ var out = cipher.output.toHex();
+ ASSERT.equal(out, inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-128-GCM
+ (function() {
+ var keys = [
+ '00000000000000000000000000000000',
+ '00000000000000000000000000000000',
+ 'feffe9928665731c6d6a8f9467308308',
+ 'feffe9928665731c6d6a8f9467308308',
+ 'feffe9928665731c6d6a8f9467308308',
+ 'feffe9928665731c6d6a8f9467308308'
+ ];
+
+ var ivs = [
+ '000000000000000000000000',
+ '000000000000000000000000',
+ 'cafebabefacedbaddecaf888',
+ 'cafebabefacedbaddecaf888',
+ 'cafebabefacedbad',
+ '9313225df88406e555909c5aff5269aa' +
+ '6a7a9538534f7da1e4c303d2a318a728' +
+ 'c3c0c95156809539fcf0e2429a6b5254' +
+ '16aedbf5a0de6a57a637b39b'
+ ];
+
+ var adatas = [
+ '',
+ '',
+ '',
+ 'feedfacedeadbeeffeedfacedeadbeef' +
+ 'abaddad2',
+ 'feedfacedeadbeeffeedfacedeadbeef' +
+ 'abaddad2',
+ 'feedfacedeadbeeffeedfacedeadbeef' +
+ 'abaddad2'
+ ];
+
+ var inputs = [
+ '',
+ '00000000000000000000000000000000',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b391aafd255',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b39',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b39',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b39'
+ ];
+
+ var outputs = [
+ '',
+ '0388dace60b6a392f328c2b971b2fe78',
+ '42831ec2217774244b7221b784d0d49c' +
+ 'e3aa212f2c02a4e035c17e2329aca12e' +
+ '21d514b25466931c7d8f6a5aac84aa05' +
+ '1ba30b396a0aac973d58e091473f5985',
+ '42831ec2217774244b7221b784d0d49c' +
+ 'e3aa212f2c02a4e035c17e2329aca12e' +
+ '21d514b25466931c7d8f6a5aac84aa05' +
+ '1ba30b396a0aac973d58e091',
+ '61353b4c2806934a777ff51fa22a4755' +
+ '699b2a714fcdc6f83766e5f97b6c7423' +
+ '73806900e49f24b22b097544d4896b42' +
+ '4989b5e1ebac0f07c23f4598',
+ '8ce24998625615b603a033aca13fb894' +
+ 'be9112a5c3a211a8ba262a3cca7e2ca7' +
+ '01e4a9a4fba43c90ccdcb281d48c7c6f' +
+ 'd62875d2aca417034c34aee5'
+ ];
+
+ var tags = [
+ '58e2fccefa7e3061367f1d57a4e7455a',
+ 'ab6e47d42cec13bdf53a67b21257bddf',
+ '4d5c2af327cd64a62cf35abd2ba6fab4',
+ '5bc94fbc3221a5db94fae95ae7121a47',
+ '3612d2e79e3b0785561be14aaca2fccb',
+ '619cc5aefffe0bfa462af43c1699d050'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var adata = UTIL.hexToBytes(adatas[i]);
+ var input = UTIL.hexToBytes(inputs[i]);
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-128-gcm encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-GCM', key);
+ cipher.start({iv: iv, additionalData: adata});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ ASSERT.equal(cipher.mode.tag.toHex(), tags[i]);
+ });
+
+ it('should aes-128-gcm decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-GCM', key);
+ cipher.start({
+ iv: iv,
+ additionalData: adata,
+ tag: UTIL.hexToBytes(tags[i])
+ });
+ cipher.update(UTIL.createBuffer(output));
+ var pass = cipher.finish();
+ ASSERT.equal(cipher.mode.tag.toHex(), tags[i]);
+ ASSERT.equal(pass, true);
+ ASSERT.equal(cipher.output.toHex(), inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-192-GCM
+ (function() {
+ var keys = [
+ '00000000000000000000000000000000' +
+ '0000000000000000',
+ '00000000000000000000000000000000' +
+ '0000000000000000',
+ 'feffe9928665731c6d6a8f9467308308' +
+ 'feffe9928665731c',
+ 'feffe9928665731c6d6a8f9467308308' +
+ 'feffe9928665731c',
+ 'feffe9928665731c6d6a8f9467308308' +
+ 'feffe9928665731c',
+ 'feffe9928665731c6d6a8f9467308308' +
+ 'feffe9928665731c'
+ ];
+
+ var ivs = [
+ '000000000000000000000000',
+ '000000000000000000000000',
+ 'cafebabefacedbaddecaf888',
+ 'cafebabefacedbaddecaf888',
+ 'cafebabefacedbad',
+ '9313225df88406e555909c5aff5269aa' +
+ '6a7a9538534f7da1e4c303d2a318a728' +
+ 'c3c0c95156809539fcf0e2429a6b5254' +
+ '16aedbf5a0de6a57a637b39b'
+ ];
+
+ var adatas = [
+ '',
+ '',
+ '',
+ 'feedfacedeadbeeffeedfacedeadbeef' +
+ 'abaddad2',
+ 'feedfacedeadbeeffeedfacedeadbeef' +
+ 'abaddad2',
+ 'feedfacedeadbeeffeedfacedeadbeef' +
+ 'abaddad2'
+ ];
+
+ var inputs = [
+ '',
+ '00000000000000000000000000000000',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b391aafd255',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b39',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b39',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b39'
+ ];
+
+ var outputs = [
+ '',
+ '98e7247c07f0fe411c267e4384b0f600',
+ '3980ca0b3c00e841eb06fac4872a2757' +
+ '859e1ceaa6efd984628593b40ca1e19c' +
+ '7d773d00c144c525ac619d18c84a3f47' +
+ '18e2448b2fe324d9ccda2710acade256',
+ '3980ca0b3c00e841eb06fac4872a2757' +
+ '859e1ceaa6efd984628593b40ca1e19c' +
+ '7d773d00c144c525ac619d18c84a3f47' +
+ '18e2448b2fe324d9ccda2710',
+ '0f10f599ae14a154ed24b36e25324db8' +
+ 'c566632ef2bbb34f8347280fc4507057' +
+ 'fddc29df9a471f75c66541d4d4dad1c9' +
+ 'e93a19a58e8b473fa0f062f7',
+ 'd27e88681ce3243c4830165a8fdcf9ff' +
+ '1de9a1d8e6b447ef6ef7b79828666e45' +
+ '81e79012af34ddd9e2f037589b292db3' +
+ 'e67c036745fa22e7e9b7373b'
+ ];
+
+ var tags = [
+ 'cd33b28ac773f74ba00ed1f312572435',
+ '2ff58d80033927ab8ef4d4587514f0fb',
+ '9924a7c8587336bfb118024db8674a14',
+ '2519498e80f1478f37ba55bd6d27618c',
+ '65dcc57fcf623a24094fcca40d3533f8',
+ 'dcf566ff291c25bbb8568fc3d376a6d9'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var adata = UTIL.hexToBytes(adatas[i]);
+ var input = UTIL.hexToBytes(inputs[i]);
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-128-gcm encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-GCM', key);
+ cipher.start({iv: iv, additionalData: adata});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ ASSERT.equal(cipher.mode.tag.toHex(), tags[i]);
+ });
+
+ it('should aes-128-gcm decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-GCM', key);
+ cipher.start({
+ iv: iv,
+ additionalData: adata,
+ tag: UTIL.hexToBytes(tags[i])
+ });
+ cipher.update(UTIL.createBuffer(output));
+ var pass = cipher.finish();
+ ASSERT.equal(cipher.mode.tag.toHex(), tags[i]);
+ ASSERT.equal(pass, true);
+ ASSERT.equal(cipher.output.toHex(), inputs[i]);
+ });
+ })(i);
+ }
+ })();
+
+ // AES-256-GCM
+ (function() {
+ var keys = [
+ '00000000000000000000000000000000' +
+ '00000000000000000000000000000000',
+ '00000000000000000000000000000000' +
+ '00000000000000000000000000000000',
+ 'feffe9928665731c6d6a8f9467308308' +
+ 'feffe9928665731c6d6a8f9467308308',
+ 'feffe9928665731c6d6a8f9467308308' +
+ 'feffe9928665731c6d6a8f9467308308',
+ 'feffe9928665731c6d6a8f9467308308' +
+ 'feffe9928665731c6d6a8f9467308308',
+ 'feffe9928665731c6d6a8f9467308308' +
+ 'feffe9928665731c6d6a8f9467308308'
+ ];
+
+ var ivs = [
+ '000000000000000000000000',
+ '000000000000000000000000',
+ 'cafebabefacedbaddecaf888',
+ 'cafebabefacedbaddecaf888',
+ 'cafebabefacedbad',
+ '9313225df88406e555909c5aff5269aa' +
+ '6a7a9538534f7da1e4c303d2a318a728' +
+ 'c3c0c95156809539fcf0e2429a6b5254' +
+ '16aedbf5a0de6a57a637b39b'
+ ];
+
+ var adatas = [
+ '',
+ '',
+ '',
+ 'feedfacedeadbeeffeedfacedeadbeef' +
+ 'abaddad2',
+ 'feedfacedeadbeeffeedfacedeadbeef' +
+ 'abaddad2',
+ 'feedfacedeadbeeffeedfacedeadbeef' +
+ 'abaddad2'
+ ];
+
+ var inputs = [
+ '',
+ '00000000000000000000000000000000',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b391aafd255',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b39',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b39',
+ 'd9313225f88406e5a55909c5aff5269a' +
+ '86a7a9531534f7da2e4c303d8a318a72' +
+ '1c3c0c95956809532fcf0e2449a6b525' +
+ 'b16aedf5aa0de657ba637b39'
+ ];
+
+ var outputs = [
+ '',
+ 'cea7403d4d606b6e074ec5d3baf39d18',
+ '522dc1f099567d07f47f37a32a84427d' +
+ '643a8cdcbfe5c0c97598a2bd2555d1aa' +
+ '8cb08e48590dbb3da7b08b1056828838' +
+ 'c5f61e6393ba7a0abcc9f662898015ad',
+ '522dc1f099567d07f47f37a32a84427d' +
+ '643a8cdcbfe5c0c97598a2bd2555d1aa' +
+ '8cb08e48590dbb3da7b08b1056828838' +
+ 'c5f61e6393ba7a0abcc9f662',
+ 'c3762df1ca787d32ae47c13bf19844cb' +
+ 'af1ae14d0b976afac52ff7d79bba9de0' +
+ 'feb582d33934a4f0954cc2363bc73f78' +
+ '62ac430e64abe499f47c9b1f',
+ '5a8def2f0c9e53f1f75d7853659e2a20' +
+ 'eeb2b22aafde6419a058ab4f6f746bf4' +
+ '0fc0c3b780f244452da3ebf1c5d82cde' +
+ 'a2418997200ef82e44ae7e3f'
+ ];
+
+ var tags = [
+ '530f8afbc74536b9a963b4f1c4cb738b',
+ 'd0d1c8a799996bf0265b98b5d48ab919',
+ 'b094dac5d93471bdec1a502270e3cc6c',
+ '76fc6ece0f4e1768cddf8853bb2d551b',
+ '3a337dbf46a792c45e454913fe2ea8f2',
+ 'a44a8266ee1c8eb0c8b5d4cf5ae9f19a'
+ ];
+
+ for(var i = 0; i < keys.length; ++i) {
+ (function(i) {
+ var key = UTIL.hexToBytes(keys[i]);
+ var iv = UTIL.hexToBytes(ivs[i]);
+ var adata = UTIL.hexToBytes(adatas[i]);
+ var input = UTIL.hexToBytes(inputs[i]);
+ var output = UTIL.hexToBytes(outputs[i]);
+
+ it('should aes-128-gcm encrypt: ' + inputs[i], function() {
+ // encrypt
+ var cipher = CIPHER.createCipher('AES-GCM', key);
+ cipher.start({iv: iv, additionalData: adata});
+ cipher.update(UTIL.createBuffer(input));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), outputs[i]);
+ ASSERT.equal(cipher.mode.tag.toHex(), tags[i]);
+ });
+
+ it('should aes-128-gcm decrypt: ' + outputs[i], function() {
+ // decrypt
+ var cipher = CIPHER.createDecipher('AES-GCM', key);
+ cipher.start({
+ iv: iv,
+ additionalData: adata,
+ tag: UTIL.hexToBytes(tags[i])
+ });
+ cipher.update(UTIL.createBuffer(output));
+ var pass = cipher.finish();
+ ASSERT.equal(cipher.mode.tag.toHex(), tags[i]);
+ ASSERT.equal(pass, true);
+ ASSERT.equal(cipher.output.toHex(), inputs[i]);
+ });
+ })(i);
+ }
+ })();
+ });
+}
+
+// check for AMD
+var forge = {};
+if(typeof define === 'function') {
+ define([
+ 'forge/cipher',
+ 'forge/aes',
+ 'forge/util'
+ ], function(CIPHER, AES, UTIL) {
+ Tests(
+ // Global provided by test harness
+ ASSERT,
+ CIPHER(forge),
+ AES(forge),
+ UTIL(forge)
+ );
+ });
+} else if(typeof module === 'object' && module.exports) {
+ // assume NodeJS
+ Tests(
+ require('assert'),
+ require('../../js/cipher')(forge),
+ require('../../js/aes')(forge),
+ require('../../js/util')(forge));
+}
+
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/asn1.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/asn1.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/asn1.js
new file mode 100644
index 0000000..7d0880e
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/asn1.js
@@ -0,0 +1,262 @@
+(function() {
+
+function Tests(ASSERT, ASN1, UTIL) {
+ describe('asn1', function() {
+ // TODO: add more ASN.1 coverage
+
+ it('should convert an OID to DER', function() {
+ ASSERT.equal(ASN1.oidToDer('1.2.840.113549').toHex(), '2a864886f70d');
+ });
+
+ it('should convert an OID from DER', function() {
+ var der = UTIL.hexToBytes('2a864886f70d');
+ ASSERT.equal(ASN1.derToOid(der), '1.2.840.113549');
+ });
+
+ it('should convert INTEGER 0 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(0).toHex(), '00');
+ });
+
+ it('should convert INTEGER 1 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(1).toHex(), '01');
+ });
+
+ it('should convert INTEGER 127 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(127).toHex(), '7f');
+ });
+
+ it('should convert INTEGER 128 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(128).toHex(), '0080');
+ });
+
+ it('should convert INTEGER 256 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(256).toHex(), '0100');
+ });
+
+ it('should convert INTEGER -128 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(-128).toHex(), '80');
+ });
+
+ it('should convert INTEGER -129 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(-129).toHex(), 'ff7f');
+ });
+
+ it('should convert INTEGER 32768 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(32768).toHex(), '008000');
+ });
+
+ it('should convert INTEGER -32768 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(-32768).toHex(), '8000');
+ });
+
+ it('should convert INTEGER -32769 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(-32769).toHex(), 'ff7fff');
+ });
+
+ it('should convert INTEGER 8388608 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(8388608).toHex(), '00800000');
+ });
+
+ it('should convert INTEGER -8388608 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(-8388608).toHex(), '800000');
+ });
+
+ it('should convert INTEGER -8388609 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(-8388609).toHex(), 'ff7fffff');
+ });
+
+ it('should convert INTEGER 2147483647 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(2147483647).toHex(), '7fffffff');
+ });
+
+ it('should convert INTEGER -2147483648 to DER', function() {
+ ASSERT.equal(ASN1.integerToDer(-2147483648).toHex(), '80000000');
+ });
+
+ it('should convert INTEGER 0 from DER', function() {
+ var der = UTIL.hexToBytes('00');
+ ASSERT.equal(ASN1.derToInteger(der), 0);
+ });
+
+ it('should convert INTEGER 1 from DER', function() {
+ var der = UTIL.hexToBytes('01');
+ ASSERT.equal(ASN1.derToInteger(der), 1);
+ });
+
+ it('should convert INTEGER 127 from DER', function() {
+ var der = UTIL.hexToBytes('7f');
+ ASSERT.equal(ASN1.derToInteger(der), 127);
+ });
+
+ it('should convert INTEGER 128 from DER', function() {
+ var der = UTIL.hexToBytes('0080');
+ ASSERT.equal(ASN1.derToInteger(der), 128);
+ });
+
+ it('should convert INTEGER 256 from DER', function() {
+ var der = UTIL.hexToBytes('0100');
+ ASSERT.equal(ASN1.derToInteger(der), 256);
+ });
+
+ it('should convert INTEGER -128 from DER', function() {
+ var der = UTIL.hexToBytes('80');
+ ASSERT.equal(ASN1.derToInteger(der), -128);
+ });
+
+ it('should convert INTEGER -129 from DER', function() {
+ var der = UTIL.hexToBytes('ff7f');
+ ASSERT.equal(ASN1.derToInteger(der), -129);
+ });
+
+ it('should convert INTEGER 32768 from DER', function() {
+ var der = UTIL.hexToBytes('008000');
+ ASSERT.equal(ASN1.derToInteger(der), 32768);
+ });
+
+ it('should convert INTEGER -32768 from DER', function() {
+ var der = UTIL.hexToBytes('8000');
+ ASSERT.equal(ASN1.derToInteger(der), -32768);
+ });
+
+ it('should convert INTEGER -32769 from DER', function() {
+ var der = UTIL.hexToBytes('ff7fff');
+ ASSERT.equal(ASN1.derToInteger(der), -32769);
+ });
+
+ it('should convert INTEGER 8388608 from DER', function() {
+ var der = UTIL.hexToBytes('00800000');
+ ASSERT.equal(ASN1.derToInteger(der), 8388608);
+ });
+
+ it('should convert INTEGER -8388608 from DER', function() {
+ var der = UTIL.hexToBytes('800000');
+ ASSERT.equal(ASN1.derToInteger(der), -8388608);
+ });
+
+ it('should convert INTEGER -8388609 from DER', function() {
+ var der = UTIL.hexToBytes('ff7fffff');
+ ASSERT.equal(ASN1.derToInteger(der), -8388609);
+ });
+
+ it('should convert INTEGER 2147483647 from DER', function() {
+ var der = UTIL.hexToBytes('7fffffff');
+ ASSERT.equal(ASN1.derToInteger(der), 2147483647);
+ });
+
+ it('should convert INTEGER -2147483648 from DER', function() {
+ var der = UTIL.hexToBytes('80000000');
+ ASSERT.equal(ASN1.derToInteger(der), -2147483648);
+ });
+
+ (function() {
+ var tests = [{
+ in: '20110223123400',
+ out: 1298464440000
+ }, {
+ in: '20110223123400.1',
+ out: 1298464440100
+ }, {
+ in: '20110223123400.123',
+ out: 1298464440123
+ }];
+ for(var i = 0; i < tests.length; ++i) {
+ var test = tests[i];
+ it('should convert local generalized time "' + test.in + '" to a Date', function() {
+ var d = ASN1.generalizedTimeToDate(test.in);
+ var localOffset = d.getTimezoneOffset() * 60000;
+ ASSERT.equal(d.getTime(), test.out + localOffset);
+ });
+ }
+ })();
+
+ (function() {
+ var tests = [{
+ in: '20110223123400Z', // Wed Feb 23 12:34:00.000 UTC 2011
+ out: 1298464440000
+ }, {
+ in: '20110223123400.1Z', // Wed Feb 23 12:34:00.100 UTC 2011
+ out: 1298464440100
+ }, {
+ in: '20110223123400.123Z', // Wed Feb 23 12:34:00.123 UTC 2011
+ out: 1298464440123
+ }, {
+ in: '20110223123400+0200', // Wed Feb 23 10:34:00.000 UTC 2011
+ out: 1298457240000
+ }, {
+ in: '20110223123400.1+0200', // Wed Feb 23 10:34:00.100 UTC 2011
+ out: 1298457240100
+ }, {
+ in: '20110223123400.123+0200', // Wed Feb 23 10:34:00.123 UTC 2011
+ out: 1298457240123
+ }, {
+ in: '20110223123400-0200', // Wed Feb 23 14:34:00.000 UTC 2011
+ out: 1298471640000
+ }, {
+ in: '20110223123400.1-0200', // Wed Feb 23 14:34:00.100 UTC 2011
+ out: 1298471640100
+ }, {
+ in: '20110223123400.123-0200', // Wed Feb 23 14:34:00.123 UTC 2011
+ out: 1298471640123
+ }];
+ for(var i = 0; i < tests.length; ++i) {
+ var test = tests[i];
+ it('should convert utc generalized time "' + test.in + '" to a Date', function() {
+ var d = ASN1.generalizedTimeToDate(test.in);
+ ASSERT.equal(d.getTime(), test.out);
+ });
+ }
+ })();
+
+ (function() {
+ var tests = [{
+ in: '1102231234Z', // Wed Feb 23 12:34:00 UTC 2011
+ out: 1298464440000
+ }, {
+ in: '1102231234+0200', // Wed Feb 23 10:34:00 UTC 2011
+ out: 1298457240000
+ }, {
+ in: '1102231234-0200', // Wed Feb 23 14:34:00 UTC 2011
+ out: 1298471640000
+ }, {
+ in: '110223123456Z', // Wed Feb 23 12:34:56 UTC 2011
+ out: 1298464496000
+ }, {
+ in: '110223123456+0200', // Wed Feb 23 10:34:56 UTC 2011
+ out: 1298457296000
+ }, {
+ in: '110223123456-0200', // Wed Feb 23 14:34:56 UTC 2011
+ out: 1298471696000
+ }];
+ for(var i = 0; i < tests.length; ++i) {
+ var test = tests[i];
+ it('should convert utc time "' + test.in + '" to a Date', function() {
+ var d = ASN1.utcTimeToDate(test.in);
+ ASSERT.equal(d.getTime(), test.out);
+ });
+ }
+ })();
+ });
+}
+
+// check for AMD
+if(typeof define === 'function') {
+ define([
+ 'forge/asn1',
+ 'forge/util'
+ ], function(ASN1, UTIL) {
+ Tests(
+ // Global provided by test harness
+ ASSERT,
+ ASN1(),
+ UTIL()
+ );
+ });
+} else if(typeof module === 'object' && module.exports) {
+ // assume NodeJS
+ Tests(
+ require('assert'),
+ require('../../js/asn1')(),
+ require('../../js/util')());
+}
+
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/browser.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/browser.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/browser.js
new file mode 100644
index 0000000..a96b2d6
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/browser.js
@@ -0,0 +1,41 @@
+var server = require('../server');
+var grunt = require('grunt');
+
+describe('browser', function() {
+ it('should run tests', function(done) {
+ this.timeout(60 * 1000 * 5);
+
+ return server.main(function(err, info) {
+ if(err) {
+ return done(err);
+ }
+
+ grunt.initConfig({
+ mocha: {
+ all: {
+ options: {
+ reporter: 'List',
+ urls: ['http://localhost:' + info.port + '/index.html']
+ }
+ }
+ }
+ });
+
+ grunt.loadNpmTasks('grunt-mocha');
+
+ grunt.registerInitTask('default', function() {
+ grunt.task.run(['mocha']);
+ });
+ grunt.tasks(['default'], {
+ //debug: true
+ }, function() {
+ if(err) {
+ return done(err);
+ }
+ // finish immediately
+ done(null);
+ return info.server.close();
+ });
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/csr.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/csr.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/csr.js
new file mode 100644
index 0000000..340c09f
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/csr.js
@@ -0,0 +1,148 @@
+(function() {
+
+function Tests(ASSERT, PKI) {
+ var _pem = {
+ privateKey: '-----BEGIN RSA PRIVATE KEY-----\r\n' +
+ 'MIICXQIBAAKBgQDL0EugUiNGMWscLAVM0VoMdhDZEJOqdsUMpx9U0YZI7szokJqQ\r\n' +
+ 'NIwokiQ6EonNnWSMlIvy46AhnlRYn+ezeTeU7eMGTkP3VF29vXBo+dLq5e+8VyAy\r\n' +
+ 'Q3FzM1wI4ts4hRACF8w6mqygXQ7i/SDu8/rXqRGtvnM+z0MYDdKo80efzwIDAQAB\r\n' +
+ 'AoGAIzkGONi5G+JifmXlLJdplom486p3upf4Ce2/7mqfaG9MnkyPSairKD/JXvfh\r\n' +
+ 'NNWkkN8DKKDKBcVVElPgORYT0qwrWc7ueLBMUCbRXb1ZyfEulimG0R3kjUh7NYau\r\n' +
+ 'DaIkVgfykXGSQMZx8FoaT6L080zd+0emKDDYRrb+/kgJNJECQQDoUZoiC2K/DWNY\r\n' +
+ 'h3/ppZ0ane2y4SBmJUHJVMPQ2CEgxsrJTxet668ckNCKaOP/3VFPoWC41f17DvKq\r\n' +
+ 'noYINNntAkEA4JbZBZBVUrQFhHlrpXT4jzqtO2RlKZzEq8qmFZfEErxOT1WMyyCi\r\n' +
+ 'lAQ5gUKardo1Kf0omC8Xq/uO9ZYdED55KwJBALs6cJ65UFaq4oLJiQPzLd7yokuE\r\n' +
+ 'dcj8g71PLBTW6jPxIiMFNA89nz3FU9wIVp+xbMNhSoMMKqIPVPC+m0Rn260CQQDA\r\n' +
+ 'I83fWK/mZWUjBM33a68KumRiH238v8XyQxj7+C8i6D8G2GXvkigFAehAkb7LZZd+\r\n' +
+ 'KLuGFyPlWv3fVWHf99KpAkBQFKk3MRMl6IGJZUEFQe4l5whm8LkGU4acSqv9B3xt\r\n' +
+ 'qROkCrsFrMPqjuuzEmyHoQZ64r2PLJg7FOuyhBnQUOt4\r\n' +
+ '-----END RSA PRIVATE KEY-----\r\n',
+ publicKey: '-----BEGIN PUBLIC KEY-----\r\n' +
+ 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDL0EugUiNGMWscLAVM0VoMdhDZ\r\n' +
+ 'EJOqdsUMpx9U0YZI7szokJqQNIwokiQ6EonNnWSMlIvy46AhnlRYn+ezeTeU7eMG\r\n' +
+ 'TkP3VF29vXBo+dLq5e+8VyAyQ3FzM1wI4ts4hRACF8w6mqygXQ7i/SDu8/rXqRGt\r\n' +
+ 'vnM+z0MYDdKo80efzwIDAQAB\r\n' +
+ '-----END PUBLIC KEY-----\r\n'
+ };
+
+ describe('csr', function() {
+ it('should generate a certification request', function() {
+ var keys = {
+ privateKey: PKI.privateKeyFromPem(_pem.privateKey),
+ publicKey: PKI.publicKeyFromPem(_pem.publicKey)
+ };
+ var csr = PKI.createCertificationRequest();
+ csr.publicKey = keys.publicKey;
+ csr.setSubject([{
+ name: 'commonName',
+ value: 'example.org'
+ }, {
+ name: 'countryName',
+ value: 'US'
+ }, {
+ shortName: 'ST',
+ value: 'Virginia'
+ }, {
+ name: 'localityName',
+ value: 'Blacksburg'
+ }, {
+ name: 'organizationName',
+ value: 'Test'
+ }, {
+ shortName: 'OU',
+ value: 'Test'
+ }]);
+ // add optional attributes
+ csr.setAttributes([{
+ name: 'challengePassword',
+ value: 'password'
+ }, {
+ name: 'unstructuredName',
+ value: 'My company'
+ }, {
+ name: 'extensionRequest',
+ extensions: [{
+ name: 'subjectAltName',
+ altNames: [{
+ // type 2 is DNS
+ type: 2,
+ value: 'test.domain.com'
+ }, {
+ type: 2,
+ value: 'other.domain.com'
+ }, {
+ type: 2,
+ value: 'www.domain.net'
+ }]
+ }]
+ }]);
+
+ // sign certification request
+ csr.sign(keys.privateKey);
+
+ var pem = PKI.certificationRequestToPem(csr);
+ csr = PKI.certificationRequestFromPem(pem);
+ ASSERT.ok(csr.getAttribute({name: 'extensionRequest'}));
+ ASSERT.equal(csr.getAttribute({name: 'extensionRequest'}).extensions[0].name, 'subjectAltName');
+ ASSERT.deepEqual(csr.getAttribute({name: 'extensionRequest'}).extensions[0].altNames, [{
+ // type 2 is DNS
+ type: 2,
+ value: 'test.domain.com'
+ }, {
+ type: 2,
+ value: 'other.domain.com'
+ }, {
+ type: 2,
+ value: 'www.domain.net'
+ }]);
+ ASSERT.ok(csr.verify());
+ });
+
+ it('should load an OpenSSL-generated certification request', function() {
+ var pem = '-----BEGIN CERTIFICATE REQUEST-----\r\n' +
+ 'MIICdTCCAV0CAQAwMDEVMBMGA1UEAwwMTXlDb21tb25OYW1lMRcwFQYDVQQKDA5N\r\n' +
+ 'eU9yZ2FuaXphdGlvbjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKRU\r\n' +
+ 'zrAMbiiSjAYYl3PWsOrNwY0VtemgRZc0t7+3FlWp1e8uIA3KxZFZY875wo0QOvD+\r\n' +
+ 'AdNv5+YnokgzOi83F3T4yewBSR0TiO3Pa4tL4C7CzWnhYliC/owk5bHCV0HLkYUW\r\n' +
+ 'F6z7Lx3HyhoxlKmrHySSPPZRLKp7KcwxbjFc2EfhQV21I73Z1mCG6MEp7cN2qBbQ\r\n' +
+ 'PyOMNjAUibOWs4JJEdUjWhm86EZm9+qfgpL5tlpZCe+kXySrKTp56mMsfSOQvlol\r\n' +
+ 'pRO8pP9AUjaEqRikCZ745I/9W7dHNPUoyxkWV5jRDwcT7s652+L6oxtoqVOXpg28\r\n' +
+ 'uAL0kUZQMa8wkYUKZiMCAwEAAaAAMA0GCSqGSIb3DQEBBQUAA4IBAQCXQH+ut6tr\r\n' +
+ 'Z/FdIDOljrc7uh8XpFRKS3GqC/PJsEwrV7d3CX5HuWPTuPc9FU5FQ88w6evXEA0o\r\n' +
+ 'ijxHuydeXmdjpy433vXWo1TaRSXh1WaBMG5pW/SlGZK9/Hr1P0v7KN/KCY5nXxoQ\r\n' +
+ 'k3Ndg9HzGrYnRoJVXzvdQeBGwCoJFk4FH+Rxa/F03VTUU5nwx66TsL9JUp9pnbI7\r\n' +
+ 'MR6DIA97LnTmut8Xp0Uurw+zsS5rif9iv0BKHd7eGpNNGl0RXu8E5dbT0zD90TSa\r\n' +
+ 'P5WjxjvY+Udg8XZU+UwT3kcyTEFpiQdkzTIKXg0dFurfUE9XG/9aic9oMZ/IBZz9\r\n' +
+ 'a535a7e9RkbJ\r\n' +
+ '-----END CERTIFICATE REQUEST-----\r\n';
+
+ var csr = PKI.certificationRequestFromPem(pem);
+ ASSERT.equal(csr.subject.getField('CN').value, 'MyCommonName');
+ ASSERT.equal(csr.subject.getField('O').value, 'MyOrganization');
+ ASSERT.equal(csr.signatureOid, PKI.oids.sha1WithRSAEncryption);
+ ASSERT.equal(csr.publicKey.e.toString(16), '10001');
+ ASSERT.equal(csr.publicKey.n.toString(16).toUpperCase(), 'A454CEB00C6E28928C06189773D6B0EACDC18D15B5E9A0459734B7BFB71655A9D5EF2E200DCAC5915963CEF9C28D103AF0FE01D36FE7E627A248333A2F371774F8C9EC01491D1388EDCF6B8B4BE02EC2CD69E1625882FE8C24E5B1C25741CB91851617ACFB2F1DC7CA1A3194A9AB1F24923CF6512CAA7B29CC316E315CD847E1415DB523BDD9D66086E8C129EDC376A816D03F238C36301489B396B3824911D5235A19BCE84666F7EA9F8292F9B65A5909EFA45F24AB293A79EA632C7D2390BE5A25A513BCA4FF40523684A918A4099EF8E48FFD5BB74734F528CB19165798D10F0713EECEB9DBE2FAA31B68A95397A60DBCB802F491465031AF3091850A6623');
+ ASSERT.ok(csr.verify());
+ });
+ });
+}
+
+// check for AMD
+if(typeof define === 'function') {
+ define([
+ 'forge/pki'
+ ], function(PKI) {
+ Tests(
+ // Global provided by test harness
+ ASSERT,
+ PKI()
+ );
+ });
+} else if(typeof module === 'object' && module.exports) {
+ // assume NodeJS
+ Tests(
+ require('assert'),
+ require('../../js/pki')());
+}
+
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/des.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/des.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/des.js
new file mode 100644
index 0000000..8be2c68
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/des.js
@@ -0,0 +1,155 @@
+(function() {
+
+function Tests(ASSERT, CIPHER, DES, UTIL) {
+ describe('des', function() {
+ // OpenSSL equivalent:
+ // openssl enc -des-ecb -K a1c06b381adf3651 -nosalt
+ it('should des-ecb encrypt: foobar', function() {
+ var key = new UTIL.createBuffer(
+ UTIL.hexToBytes('a1c06b381adf3651'));
+
+ var cipher = CIPHER.createCipher('DES-ECB', key);
+ cipher.start();
+ cipher.update(UTIL.createBuffer('foobar'));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), 'b705ffcf3dff06b3');
+ });
+
+ // OpenSSL equivalent:
+ // openssl enc -d -des-ecb -K a1c06b381adf3651 -nosalt
+ it('should des-ecb decrypt: b705ffcf3dff06b3', function() {
+ var key = new UTIL.createBuffer(
+ UTIL.hexToBytes('a1c06b381adf3651'));
+
+ var decipher = CIPHER.createDecipher('DES-ECB', key);
+ decipher.start();
+ decipher.update(UTIL.createBuffer(UTIL.hexToBytes('b705ffcf3dff06b3')));
+ decipher.finish();
+ ASSERT.equal(decipher.output.getBytes(), 'foobar');
+ });
+
+ // OpenSSL equivalent:
+ // openssl enc -des -K a1c06b381adf3651 -iv 818bcf76efc59662 -nosalt
+ it('should des-cbc encrypt: foobar', function() {
+ var key = new UTIL.createBuffer(
+ UTIL.hexToBytes('a1c06b381adf3651'));
+ var iv = new UTIL.createBuffer(
+ UTIL.hexToBytes('818bcf76efc59662'));
+
+ var cipher = CIPHER.createCipher('DES-CBC', key);
+ cipher.start({iv: iv});
+ cipher.update(UTIL.createBuffer('foobar'));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), '3261e5839a990454');
+ });
+
+ // OpenSSL equivalent:
+ // openssl enc -d -des -K a1c06b381adf3651 -iv 818bcf76efc59662 -nosalt
+ it('should des-cbc decrypt: 3261e5839a990454', function() {
+ var key = new UTIL.createBuffer(
+ UTIL.hexToBytes('a1c06b381adf3651'));
+ var iv = new UTIL.createBuffer(
+ UTIL.hexToBytes('818bcf76efc59662'));
+
+ var decipher = CIPHER.createDecipher('DES-CBC', key);
+ decipher.start({iv: iv});
+ decipher.update(UTIL.createBuffer(UTIL.hexToBytes('3261e5839a990454')));
+ decipher.finish();
+ ASSERT.equal(decipher.output.getBytes(), 'foobar');
+ });
+
+ // OpenSSL equivalent:
+ // openssl enc -des-ede3 -K a1c06b381adf36517e84575552777779da5e3d9f994b05b5 -nosalt
+ it('should 3des-ecb encrypt: foobar', function() {
+ var key = new UTIL.createBuffer(
+ UTIL.hexToBytes('a1c06b381adf36517e84575552777779da5e3d9f994b05b5'));
+
+ var cipher = CIPHER.createCipher('3DES-ECB', key);
+ cipher.start();
+ cipher.update(UTIL.createBuffer('foobar'));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), 'fce8b1ee8c6440d1');
+ });
+
+ // OpenSSL equivalent:
+ // openssl enc -d -des-ede3 -K a1c06b381adf36517e84575552777779da5e3d9f994b05b5 -nosalt
+ it('should 3des-ecb decrypt: fce8b1ee8c6440d1', function() {
+ var key = new UTIL.createBuffer(
+ UTIL.hexToBytes('a1c06b381adf36517e84575552777779da5e3d9f994b05b5'));
+
+ var decipher = CIPHER.createDecipher('3DES-ECB', key);
+ decipher.start();
+ decipher.update(UTIL.createBuffer(UTIL.hexToBytes('fce8b1ee8c6440d1')));
+ decipher.finish();
+ ASSERT.equal(decipher.output.getBytes(), 'foobar');
+ });
+
+ // OpenSSL equivalent:
+ // openssl enc -des3 -K a1c06b381adf36517e84575552777779da5e3d9f994b05b5 -iv 818bcf76efc59662 -nosalt
+ it('should 3des-cbc encrypt "foobar", restart, and encrypt "foobar,,"', function() {
+ var key = new UTIL.createBuffer(
+ UTIL.hexToBytes('a1c06b381adf36517e84575552777779da5e3d9f994b05b5'));
+ var iv = new UTIL.createBuffer(
+ UTIL.hexToBytes('818bcf76efc59662'));
+
+ var cipher = CIPHER.createCipher('3DES-CBC', key);
+ cipher.start({iv: iv.copy()});
+ cipher.update(UTIL.createBuffer('foobar'));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), '209225f7687ca0b2');
+
+ cipher.start({iv: iv.copy()});
+ cipher.update(UTIL.createBuffer('foobar,,'));
+ cipher.finish();
+ ASSERT.equal(cipher.output.toHex(), '57156174c48dfc37293831bf192a6742');
+ });
+
+ // OpenSSL equivalent:
+ // openssl enc -d -des3 -K a1c06b381adf36517e84575552777779da5e3d9f994b05b5 -iv 818bcf76efc59662 -nosalt
+ it('should 3des-cbc decrypt "209225f7687ca0b2", restart, and decrypt "57156174c48dfc37293831bf192a6742,,"', function() {
+ var key = new UTIL.createBuffer(
+ UTIL.hexToBytes('a1c06b381adf36517e84575552777779da5e3d9f994b05b5'));
+ var iv = new UTIL.createBuffer(
+ UTIL.hexToBytes('818bcf76efc59662'));
+
+ var decipher = CIPHER.createDecipher('3DES-CBC', key);
+ decipher.start({iv: iv.copy()});
+ decipher.update(UTIL.createBuffer(UTIL.hexToBytes('209225f7687ca0b2')));
+ decipher.finish();
+ ASSERT.equal(decipher.output.getBytes(), 'foobar');
+
+ decipher.start({iv: iv.copy()});
+ decipher.update(
+ UTIL.createBuffer(UTIL.hexToBytes('57156174c48dfc37293831bf192a6742')));
+ decipher.finish();
+ ASSERT.equal(decipher.output.getBytes(), 'foobar,,');
+ });
+ });
+}
+
+// check for AMD
+var forge = {};
+if(typeof define === 'function') {
+ define([
+ 'forge/cipher',
+ 'forge/des',
+ 'forge/util'
+ ], function(CIPHER, DES, UTIL) {
+ Tests(
+ // Global provided by test harness
+ ASSERT,
+ CIPHER(forge),
+ DES(forge),
+ UTIL(forge)
+ );
+ });
+} else if(typeof module === 'object' && module.exports) {
+ // assume NodeJS
+ Tests(
+ require('assert'),
+ require('../../js/cipher')(forge),
+ require('../../js/des')(forge),
+ require('../../js/util')(forge));
+}
+
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/hmac.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/hmac.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/hmac.js
new file mode 100644
index 0000000..404b36b
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/hmac.js
@@ -0,0 +1,85 @@
+(function() {
+
+function Tests(ASSERT, HMAC, UTIL) {
+ describe('hmac', function() {
+ it('should md5 hash "Hi There", 16-byte key', function() {
+ var key = UTIL.hexToBytes('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b');
+ var hmac = HMAC.create();
+ hmac.start('MD5', key);
+ hmac.update('Hi There');
+ ASSERT.equal(hmac.digest().toHex(), '9294727a3638bb1c13f48ef8158bfc9d');
+ });
+
+ it('should md5 hash "what do ya want for nothing?", "Jefe" key', function() {
+ var hmac = HMAC.create();
+ hmac.start('MD5', 'Jefe');
+ hmac.update('what do ya want for nothing?');
+ ASSERT.equal(hmac.digest().toHex(), '750c783e6ab0b503eaa86e310a5db738');
+ });
+
+ it('should md5 hash "Test Using Larger Than Block-Size Key - Hash Key First", 80-byte key', function() {
+ var key = UTIL.hexToBytes(
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
+ var hmac = HMAC.create();
+ hmac.start('MD5', key);
+ hmac.update('Test Using Larger Than Block-Size Key - Hash Key First');
+ ASSERT.equal(hmac.digest().toHex(), '6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd');
+ });
+
+ it('should sha1 hash "Hi There", 20-byte key', function() {
+ var key = UTIL.hexToBytes('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b');
+ var hmac = HMAC.create();
+ hmac.start('SHA1', key);
+ hmac.update('Hi There');
+ ASSERT.equal(
+ hmac.digest().toHex(), 'b617318655057264e28bc0b6fb378c8ef146be00');
+ });
+
+ it('should sha1 hash "what do ya want for nothing?", "Jefe" key', function() {
+ var hmac = HMAC.create();
+ hmac.start('SHA1', 'Jefe');
+ hmac.update('what do ya want for nothing?');
+ ASSERT.equal(
+ hmac.digest().toHex(), 'effcdf6ae5eb2fa2d27416d5f184df9c259a7c79');
+ });
+
+ it('should sha1 hash "Test Using Larger Than Block-Size Key - Hash Key First", 80-byte key', function() {
+ var key = UTIL.hexToBytes(
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +
+ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
+ var hmac = HMAC.create();
+ hmac.start('SHA1', key);
+ hmac.update('Test Using Larger Than Block-Size Key - Hash Key First');
+ ASSERT.equal(
+ hmac.digest().toHex(), 'aa4ae5e15272d00e95705637ce8a3b55ed402112');
+ });
+ });
+}
+
+// check for AMD
+if(typeof define === 'function') {
+ define([
+ 'forge/hmac',
+ 'forge/util'
+ ], function(HMAC, UTIL) {
+ Tests(
+ // Global provided by test harness
+ ASSERT,
+ HMAC(),
+ UTIL()
+ );
+ });
+} else if(typeof module === 'object' && module.exports) {
+ // assume NodeJS
+ Tests(
+ require('assert'),
+ require('../../js/hmac')(),
+ require('../../js/util')());
+}
+
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/kem.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/kem.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/kem.js
new file mode 100644
index 0000000..0415abe
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/kem.js
@@ -0,0 +1,198 @@
+(function() {
+
+function Tests(ASSERT, KEM, MD, RSA, UTIL, JSBN, RANDOM) {
+
+ function FixedSecureRandom(str) {
+ var bytes = UTIL.hexToBytes(str);
+ this.getBytesSync = function(count) {
+ // prepend zeros
+ return UTIL.fillString(String.fromCharCode(0), bytes.length - count) +
+ bytes;
+ };
+ }
+
+ describe('kem', function() {
+ it('should generate and encrypt a symmetric key and decrypt it 10x', function() {
+ for(var i = 0; i < 10; ++i) {
+ var kdf = new KEM.kdf1(MD.sha256.create());
+ var kem = KEM.rsa.create(kdf);
+
+ var pair = RSA.generateKeyPair(512);
+
+ var result = kem.encrypt(pair.publicKey, 256);
+ var key1 = result.key;
+ var key2 = kem.decrypt(pair.privateKey, result.encapsulation, 256);
+
+ ASSERT.equal(UTIL.bytesToHex(key1), UTIL.bytesToHex(key2));
+ }
+ });
+ });
+
+ /**
+ * According to section "C.6 Test vectors for RSA-KEM" from ISO-18033-2 final
+ * draft.
+ */
+ describe('C.6 Test vectors for RSA-KEM from ISO-18033-2 final', function() {
+ it('should pass test vector C.6.1', function() {
+ var n = '5888113332502691251761936431009284884966640757179802337490546478326238537107326596800820237597139824869184990638749556269785797065508097452399642780486933';
+ var e = '65537';
+ var d = '3202313555859948186315374524474173995679783580392140237044349728046479396037520308981353808895461806395564474639124525446044708705259675840210989546479265';
+
+ var C0 = '4603e5324cab9cef8365c817052d954d44447b1667099edc69942d32cd594e4ffcf268ae3836e2c35744aaa53ae201fe499806b67dedaa26bf72ecbd117a6fc0';
+ var K = '5f8de105b5e96b2e490ddecbd147dd1def7e3b8e0e6a26eb7b956ccb8b3bdc1ca975bc57c3989e8fbad31a224655d800c46954840ff32052cdf0d640562bdfadfa263cfccf3c52b29f2af4a1869959bc77f854cf15bd7a25192985a842dbff8e13efee5b7e7e55bbe4d389647c686a9a9ab3fb889b2d7767d3837eea4e0a2f04';
+
+ var kdf = new KEM.kdf1(MD.sha1.create());
+ var rnd = new FixedSecureRandom('032e45326fa859a72ec235acff929b15d1372e30b207255f0611b8f785d764374152e0ac009e509e7ba30cd2f1778e113b64e135cf4e2292c75efe5288edfda4');
+ var kem = KEM.rsa.create(kdf, {prng: rnd});
+
+ var rsaPublicKey = RSA.setPublicKey(
+ new JSBN.BigInteger(n), new JSBN.BigInteger(e));
+ var rsaPrivateKey = RSA.setPrivateKey(
+ new JSBN.BigInteger(n), null, new JSBN.BigInteger(d));
+
+ var result = kem.encrypt(rsaPublicKey, 128);
+ ASSERT.equal(UTIL.bytesToHex(result.encapsulation), C0);
+ ASSERT.equal(UTIL.bytesToHex(result.key), K);
+
+ var decryptedKey = kem.decrypt(rsaPrivateKey, result.encapsulation, 128);
+ ASSERT.equal(UTIL.bytesToHex(decryptedKey), K);
+ });
+
+ it('should pass test vector C.6.2', function() {
+ var n = '5888113332502691251761936431009284884966640757179802337490546478326238537107326596800820237597139824869184990638749556269785797065508097452399642780486933';
+ var e = '65537';
+ var d = '3202313555859948186315374524474173995679783580392140237044349728046479396037520308981353808895461806395564474639124525446044708705259675840210989546479265';
+
+ var C0 = '4603e5324cab9cef8365c817052d954d44447b1667099edc69942d32cd594e4ffcf268ae3836e2c35744aaa53ae201fe499806b67dedaa26bf72ecbd117a6fc0';
+ var K = '0e6a26eb7b956ccb8b3bdc1ca975bc57c3989e8fbad31a224655d800c46954840ff32052cdf0d640562bdfadfa263cfccf3c52b29f2af4a1869959bc77f854cf15bd7a25192985a842dbff8e13efee5b7e7e55bbe4d389647c686a9a9ab3fb889b2d7767d3837eea4e0a2f04b53ca8f50fb31225c1be2d0126c8c7a4753b0807';
+
+ var kdf = new KEM.kdf2(MD.sha1.create());
+ var rnd = new FixedSecureRandom('032e45326fa859a72ec235acff929b15d1372e30b207255f0611b8f785d764374152e0ac009e509e7ba30cd2f1778e113b64e135cf4e2292c75efe5288edfda4');
+ var kem = KEM.rsa.create(kdf, {prng: rnd});
+
+ var rsaPublicKey = RSA.setPublicKey(
+ new JSBN.BigInteger(n), new JSBN.BigInteger(e));
+ var rsaPrivateKey = RSA.setPrivateKey(
+ new JSBN.BigInteger(n), null, new JSBN.BigInteger(d));
+
+ var result = kem.encrypt(rsaPublicKey, 128);
+ ASSERT.equal(UTIL.bytesToHex(result.encapsulation), C0);
+ ASSERT.equal(UTIL.bytesToHex(result.key), K);
+
+ var decryptedKey = kem.decrypt(rsaPrivateKey, result.encapsulation, 128);
+ ASSERT.equal(UTIL.bytesToHex(decryptedKey), K);
+ });
+
+ it('should pass test vector C.6.3', function() {
+ var n = '5888113332502691251761936431009284884966640757179802337490546478326238537107326596800820237597139824869184990638749556269785797065508097452399642780486933';
+ var e = '65537';
+ var d = '3202313555859948186315374524474173995679783580392140237044349728046479396037520308981353808895461806395564474639124525446044708705259675840210989546479265';
+
+ var C0 = '4603e5324cab9cef8365c817052d954d44447b1667099edc69942d32cd594e4ffcf268ae3836e2c35744aaa53ae201fe499806b67dedaa26bf72ecbd117a6fc0';
+ var K = '09e2decf2a6e1666c2f6071ff4298305e2643fd510a2403db42a8743cb989de86e668d168cbe604611ac179f819a3d18412e9eb45668f2923c087c12fee0c5a0d2a8aa70185401fbbd99379ec76c663e875a60b4aacb1319fa11c3365a8b79a44669f26fb555c80391847b05eca1cb5cf8c2d531448d33fbaca19f6410ee1fcb';
+
+ var kdf = new KEM.kdf1(MD.sha256.create(), 20);
+ var rnd = new FixedSecureRandom('032e45326fa859a72ec235acff929b15d1372e30b207255f0611b8f785d764374152e0ac009e509e7ba30cd2f1778e113b64e135cf4e2292c75efe5288edfda4');
+ var kem = KEM.rsa.create(kdf, {prng: rnd});
+
+ var rsaPublicKey = RSA.setPublicKey(
+ new JSBN.BigInteger(n), new JSBN.BigInteger(e));
+ var rsaPrivateKey = RSA.setPrivateKey(
+ new JSBN.BigInteger(n), null, new JSBN.BigInteger(d));
+
+ var result = kem.encrypt(rsaPublicKey, 128);
+ ASSERT.equal(UTIL.bytesToHex(result.encapsulation), C0);
+ ASSERT.equal(UTIL.bytesToHex(result.key), K);
+
+ var decryptedKey = kem.decrypt(rsaPrivateKey, result.encapsulation, 128);
+ ASSERT.equal(UTIL.bytesToHex(decryptedKey), K);
+ });
+
+ it('should pass test vector C.6.4', function() {
+ var n = '5888113332502691251761936431009284884966640757179802337490546478326238537107326596800820237597139824869184990638749556269785797065508097452399642780486933';
+ var e = '65537';
+ var d = '3202313555859948186315374524474173995679783580392140237044349728046479396037520308981353808895461806395564474639124525446044708705259675840210989546479265';
+
+ var C0 = '4603e5324cab9cef8365c817052d954d44447b1667099edc69942d32cd594e4ffcf268ae3836e2c35744aaa53ae201fe499806b67dedaa26bf72ecbd117a6fc0';
+ var K = '10a2403db42a8743cb989de86e668d168cbe604611ac179f819a3d18412e9eb45668f2923c087c12fee0c5a0d2a8aa70185401fbbd99379ec76c663e875a60b4aacb1319fa11c3365a8b79a44669f26fb555c80391847b05eca1cb5cf8c2d531448d33fbaca19f6410ee1fcb260892670e0814c348664f6a7248aaf998a3acc6';
+
+ var kdf = new KEM.kdf2(MD.sha256.create(), 20);
+ var rnd = new FixedSecureRandom('00032e45326fa859a72ec235acff929b15d1372e30b207255f0611b8f785d764374152e0ac009e509e7ba30cd2f1778e113b64e135cf4e2292c75efe5288edfda4');
+ var kem = KEM.rsa.create(kdf, {prng: rnd});
+
+ var rsaPublicKey = RSA.setPublicKey(
+ new JSBN.BigInteger(n), new JSBN.BigInteger(e));
+ var rsaPrivateKey = RSA.setPrivateKey(
+ new JSBN.BigInteger(n), null, new JSBN.BigInteger(d));
+
+ var result = kem.encrypt(rsaPublicKey, 128);
+ ASSERT.equal(UTIL.bytesToHex(result.encapsulation), C0);
+ ASSERT.equal(UTIL.bytesToHex(result.key), K);
+
+ var decryptedKey = kem.decrypt(rsaPrivateKey, result.encapsulation, 128);
+ ASSERT.equal(UTIL.bytesToHex(decryptedKey), K);
+ });
+ });
+
+ describe('prepended zeros test', function() {
+ it('should pass when random has leading zeros', function() {
+ var n = '5888113332502691251761936431009284884966640757179802337490546478326238537107326596800820237597139824869184990638749556269785797065508097452399642780486933';
+ var e = '65537';
+ var d = '3202313555859948186315374524474173995679783580392140237044349728046479396037520308981353808895461806395564474639124525446044708705259675840210989546479265';
+
+ var C0 = '5f268a76c1aed04bc195a143d7ee768bee0aad308d16196274a02d9c1a72bbe10cbf718de323fc0135c5f8129f96ac8f504d9623960dc54cd87bddee94f5a0b2';
+ var K = '8bf41e59dc1b83142ee32569a347a94539e48c98347c685a29e3aa8b7a3ea714d68c1a43c4a760c9d4a45149b0ce8b681e98076bdd4393394c7832a7fa71848257772ac38a4e7fbe96e8bb383becbb7242841946e82e35d9ef1667245fc82601e7edf53b897f5ce2b6bce8e1e3212abd5a8a99a0c9b99472e22a313dac396383';
+
+ var kdf = new KEM.kdf1(MD.sha1.create());
+ var rnd = new FixedSecureRandom('000e45326fa859a72ec235acff929b15d1372e30b207255f0611b8f785d764374152e0ac009e509e7ba30cd2f1778e113b64e135cf4e2292c75efe5288edfda4');
+ var kem = KEM.rsa.create(kdf, {prng: rnd});
+
+ var rsaPublicKey = RSA.setPublicKey(
+ new JSBN.BigInteger(n), new JSBN.BigInteger(e));
+ var rsaPrivateKey = RSA.setPrivateKey(
+ new JSBN.BigInteger(n), null, new JSBN.BigInteger(d));
+
+ var result = kem.encrypt(rsaPublicKey, 128);
+ ASSERT.equal(UTIL.bytesToHex(result.encapsulation), C0);
+ ASSERT.equal(UTIL.bytesToHex(result.key), K);
+
+ var decryptedKey = kem.decrypt(rsaPrivateKey, result.encapsulation, 128);
+ ASSERT.equal(UTIL.bytesToHex(decryptedKey), K);
+ });
+ });
+}
+
+// check for AMD
+if(typeof define === 'function') {
+ define([
+ 'forge/kem',
+ 'forge/md',
+ 'forge/rsa',
+ 'forge/util',
+ 'forge/jsbn',
+ 'forge/random'
+ ], function(KEM, MD, RSA, UTIL, JSBN, RANDOM) {
+ Tests(
+ // Global provided by test harness
+ ASSERT,
+ KEM(),
+ MD(),
+ RSA(),
+ UTIL(),
+ JSBN(),
+ RANDOM()
+ );
+ });
+} else if(typeof module === 'object' && module.exports) {
+ // assume NodeJS
+ Tests(
+ require('assert'),
+ require('../../js/kem')(),
+ require('../../js/md')(),
+ require('../../js/rsa')(),
+ require('../../js/util')(),
+ require('../../js/jsbn')(),
+ require('../../js/random')());
+}
+
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/md5.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/md5.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/md5.js
new file mode 100644
index 0000000..5ab3d58
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/md5.js
@@ -0,0 +1,117 @@
+(function() {
+
+function Tests(ASSERT, MD5, UTIL) {
+ describe('md5', function() {
+ it('should digest the empty string', function() {
+ var md = MD5.create();
+ ASSERT.equal(md.digest().toHex(), 'd41d8cd98f00b204e9800998ecf8427e');
+ });
+
+ it('should digest "abc"', function() {
+ var md = MD5.create();
+ md.update('abc');
+ ASSERT.equal(md.digest().toHex(), '900150983cd24fb0d6963f7d28e17f72');
+ });
+
+ it('should digest "The quick brown fox jumps over the lazy dog"', function() {
+ var md = MD5.create();
+ md.update('The quick brown fox jumps over the lazy dog');
+ ASSERT.equal(md.digest().toHex(), '9e107d9d372bb6826bd81d3542a419d6');
+ });
+
+ it('should digest "c\'\u00e8"', function() {
+ var md = MD5.create();
+ md.update("c\'\u00e8", 'utf8');
+ ASSERT.equal(md.digest().toHex(), '8ef7c2941d78fe89f31e614437c9db59');
+ });
+
+ it('should digest "THIS IS A MESSAGE"', function() {
+ var md = MD5.create();
+ md.start();
+ md.update('THIS IS ');
+ md.update('A MESSAGE');
+ // do twice to check continuing digest
+ ASSERT.equal(md.digest().toHex(), '78eebfd9d42958e3f31244f116ab7bbe');
+ ASSERT.equal(md.digest().toHex(), '78eebfd9d42958e3f31244f116ab7bbe');
+ });
+
+ it('should digest a long message', function() {
+ var input = UTIL.hexToBytes(
+ '0100002903018d32e9c6dc423774c4c39a5a1b78f44cc2cab5f676d39' +
+ 'f703d29bfa27dfeb870000002002f01000200004603014c2c1e835d39' +
+ 'da71bc0857eb04c2b50fe90dbb2a8477fe7364598d6f0575999c20a6c' +
+ '7248c5174da6d03ac711888f762fc4ed54f7254b32273690de849c843' +
+ '073d002f000b0003d20003cf0003cc308203c8308202b0a0030201020' +
+ '20100300d06092a864886f70d0101050500308186310b300906035504' +
+ '0613025553311d301b060355040a13144469676974616c2042617a616' +
+ '1722c20496e632e31443042060355040b133b4269746d756e6b206c6f' +
+ '63616c686f73742d6f6e6c7920436572746966696361746573202d204' +
+ '17574686f72697a6174696f6e20766961204254503112301006035504' +
+ '0313096c6f63616c686f7374301e170d3130303231343137303931395' +
+ 'a170d3230303231333137303931395a308186310b3009060355040613' +
+ '025553311d301b060355040a13144469676974616c2042617a6161722' +
+ 'c20496e632e31443042060355040b133b4269746d756e6b206c6f6361' +
+ '6c686f73742d6f6e6c7920436572746966696361746573202d2041757' +
+ '4686f72697a6174696f6e207669612042545031123010060355040313' +
+ '096c6f63616c686f737430820122300d06092a864886f70d010101050' +
+ '00382010f003082010a0282010100dc436f17d6909d8a9d6186ea218e' +
+ 'b5c86b848bae02219bd56a71203daf07e81bc19e7e98134136bcb0128' +
+ '81864bf03b3774652ad5eab85dba411a5114ffeac09babce75f313143' +
+ '45512cd87c91318b2e77433270a52185fc16f428c3ca412ad6e9484bc' +
+ '2fb87abb4e8fb71bf0f619e31a42340b35967f06c24a741a31c979c0b' +
+ 'b8921a90a47025fbeb8adca576979e70a56830c61170c9647c18c0794' +
+ 'd68c0df38f3aac5fc3b530e016ea5659715339f3f3c209cdee9dbe794' +
+ 'b5af92530c5754c1d874b78974bfad994e0dfc582275e79feb522f6e4' +
+ 'bcc2b2945baedfb0dbdaebb605f9483ff0bea29ecd5f4d6f2769965d1' +
+ 'b3e04f8422716042680011ff676f0203010001a33f303d300c0603551' +
+ 'd130101ff04023000300e0603551d0f0101ff0404030204f0301d0603' +
+ '551d250416301406082b0601050507030106082b06010505070302300' +
+ 'd06092a864886f70d010105050003820101009c4562be3f2d8d8e3880' +
+ '85a697f2f106eaeff4992a43f198fe3dcf15c8229cf1043f061a38204' +
+ 'f73d86f4fb6348048cc5279ed719873aa10e3773d92b629c2c3fcce04' +
+ '012c81ba3b4ec451e9644ec5191078402d845e05d02c7b4d974b45882' +
+ '76e5037aba7ef26a8bddeb21e10698c82f425e767dc401adf722fa73a' +
+ 'b78cfa069bd69052d7ca6a75cc9225550e315d71c5f8764362ea4dbc6' +
+ 'ecb837a8471043c5a7f826a71af145a053090bd4bccca6a2c552841cd' +
+ 'b1908a8352f49283d2e641acdef667c7543af441a16f8294251e2ac37' +
+ '6fa507b53ae418dd038cd20cef1e7bfbf5ae03a7c88d93d843abaabbd' +
+ 'c5f3431132f3e559d2dd414c3eda38a210b80e0000001000010201002' +
+ '6a220b7be857402819b78d81080d01a682599bbd00902985cc64edf8e' +
+ '520e4111eb0e1729a14ffa3498ca259cc9ad6fc78fa130d968ebdb78d' +
+ 'c0b950c0aa44355f13ba678419185d7e4608fe178ca6b2cef33e41937' +
+ '78d1a70fe4d0dfcb110be4bbb4dbaa712177655728f914ab4c0f6c4ae' +
+ 'f79a46b3d996c82b2ebe9ed1748eb5cace7dc44fb67e73f452a047f2e' +
+ 'd199b3d50d5db960acf03244dc8efa4fc129faf8b65f9e52e62b55447' +
+ '22bd17d2358e817a777618a4265a3db277fc04851a82a91fe6cdcb812' +
+ '7f156e0b4a5d1f54ce2742eb70c895f5f8b85f5febe69bc73e891f928' +
+ '0826860a0c2ef94c7935e6215c3c4cd6b0e43e80cca396d913d36be');
+
+ var md = MD5.create();
+ md.update(input);
+ ASSERT.equal(md.digest().toHex(), 'd15a2da0e92c3da55dc573f885b6e653');
+ });
+ });
+}
+
+// check for AMD
+if(typeof define === 'function') {
+ define([
+ 'forge/md5',
+ 'forge/util'
+ ], function(MD5, UTIL) {
+ Tests(
+ // Global provided by test harness
+ ASSERT,
+ MD5(),
+ UTIL()
+ );
+ });
+} else if(typeof module === 'object' && module.exports) {
+ // assume NodeJS
+ Tests(
+ require('assert'),
+ require('../../js/md5')(),
+ require('../../js/util')());
+}
+
+})();
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/b2b43200/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/mgf1.js
----------------------------------------------------------------------
diff --git a/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/mgf1.js b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/mgf1.js
new file mode 100644
index 0000000..6c54ff1
--- /dev/null
+++ b/node_modules/node-firefox-find-devices/node_modules/adbkit/node_modules/node-forge/nodejs/test/mgf1.js
@@ -0,0 +1,39 @@
+(function() {
+
+function Tests(ASSERT, MGF, MD, UTIL) {
+ describe('mgf1', function() {
+ it('should digest the empty string', function() {
+ var seed = UTIL.hexToBytes('032e45326fa859a72ec235acff929b15d1372e30b207255f0611b8f785d764374152e0ac009e509e7ba30cd2f1778e113b64e135cf4e2292c75efe5288edfda4');
+ var expect = UTIL.hexToBytes('5f8de105b5e96b2e490ddecbd147dd1def7e3b8e0e6a26eb7b956ccb8b3bdc1ca975bc57c3989e8fbad31a224655d800c46954840ff32052cdf0d640562bdfadfa263cfccf3c52b29f2af4a1869959bc77f854cf15bd7a25192985a842dbff8e13efee5b7e7e55bbe4d389647c686a9a9ab3fb889b2d7767d3837eea4e0a2f04');
+ var mgf = MGF.mgf1.create(MD.sha1.create());
+ var result = mgf.generate(seed, expect.length);
+ ASSERT.equal(result, expect);
+ });
+ });
+}
+
+// check for AMD
+if(typeof define === 'function') {
+ define([
+ 'forge/mgf',
+ 'forge/md',
+ 'forge/util'
+ ], function(MGF, MD, UTIL) {
+ Tests(
+ // Global provided by test harness
+ ASSERT,
+ MGF(),
+ MD(),
+ UTIL()
+ );
+ });
+} else if(typeof module === 'object' && module.exports) {
+ // assume NodeJS
+ Tests(
+ require('assert'),
+ require('../../js/mgf')(),
+ require('../../js/md')(),
+ require('../../js/util')());
+}
+
+})();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org