|
|
@ -14,24 +14,12 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
'use strict'; |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
var coreCrypto = require('../../core/crypto.js'); |
|
|
|
var _crypto = require('../../core/crypto'); |
|
|
|
var corePrimitives = require('../../core/primitives.js'); |
|
|
|
|
|
|
|
var sharedUtil = require('../../shared/util.js'); |
|
|
|
var _primitives = require('../../core/primitives'); |
|
|
|
var calculateMD5 = coreCrypto.calculateMD5; |
|
|
|
|
|
|
|
var ARCFourCipher = coreCrypto.ARCFourCipher; |
|
|
|
var _util = require('../../shared/util'); |
|
|
|
var calculateSHA256 = coreCrypto.calculateSHA256; |
|
|
|
|
|
|
|
var calculateSHA384 = coreCrypto.calculateSHA384; |
|
|
|
|
|
|
|
var calculateSHA512 = coreCrypto.calculateSHA512; |
|
|
|
|
|
|
|
var AES128Cipher = coreCrypto.AES128Cipher; |
|
|
|
|
|
|
|
var AES256Cipher = coreCrypto.AES256Cipher; |
|
|
|
|
|
|
|
var PDF17 = coreCrypto.PDF17; |
|
|
|
|
|
|
|
var PDF20 = coreCrypto.PDF20; |
|
|
|
|
|
|
|
var CipherTransformFactory = coreCrypto.CipherTransformFactory; |
|
|
|
|
|
|
|
var Name = corePrimitives.Name; |
|
|
|
|
|
|
|
var Dict = corePrimitives.Dict; |
|
|
|
|
|
|
|
var stringToBytes = sharedUtil.stringToBytes; |
|
|
|
|
|
|
|
var PasswordException = sharedUtil.PasswordException; |
|
|
|
|
|
|
|
var PasswordResponses = sharedUtil.PasswordResponses; |
|
|
|
|
|
|
|
describe('crypto', function () { |
|
|
|
describe('crypto', function () { |
|
|
|
function hex2binary(s) { |
|
|
|
function hex2binary(s) { |
|
|
|
var digits = '0123456789ABCDEF'; |
|
|
|
var digits = '0123456789ABCDEF'; |
|
|
@ -51,50 +39,50 @@ describe('crypto', function () { |
|
|
|
describe('calculateMD5', function () { |
|
|
|
describe('calculateMD5', function () { |
|
|
|
it('should pass RFC 1321 test #1', function () { |
|
|
|
it('should pass RFC 1321 test #1', function () { |
|
|
|
var input, result, expected; |
|
|
|
var input, result, expected; |
|
|
|
input = stringToBytes(''); |
|
|
|
input = (0, _util.stringToBytes)(''); |
|
|
|
result = calculateMD5(input, 0, input.length); |
|
|
|
result = (0, _crypto.calculateMD5)(input, 0, input.length); |
|
|
|
expected = hex2binary('d41d8cd98f00b204e9800998ecf8427e'); |
|
|
|
expected = hex2binary('d41d8cd98f00b204e9800998ecf8427e'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('should pass RFC 1321 test #2', function () { |
|
|
|
it('should pass RFC 1321 test #2', function () { |
|
|
|
var input, result, expected; |
|
|
|
var input, result, expected; |
|
|
|
input = stringToBytes('a'); |
|
|
|
input = (0, _util.stringToBytes)('a'); |
|
|
|
result = calculateMD5(input, 0, input.length); |
|
|
|
result = (0, _crypto.calculateMD5)(input, 0, input.length); |
|
|
|
expected = hex2binary('0cc175b9c0f1b6a831c399e269772661'); |
|
|
|
expected = hex2binary('0cc175b9c0f1b6a831c399e269772661'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('should pass RFC 1321 test #3', function () { |
|
|
|
it('should pass RFC 1321 test #3', function () { |
|
|
|
var input, result, expected; |
|
|
|
var input, result, expected; |
|
|
|
input = stringToBytes('abc'); |
|
|
|
input = (0, _util.stringToBytes)('abc'); |
|
|
|
result = calculateMD5(input, 0, input.length); |
|
|
|
result = (0, _crypto.calculateMD5)(input, 0, input.length); |
|
|
|
expected = hex2binary('900150983cd24fb0d6963f7d28e17f72'); |
|
|
|
expected = hex2binary('900150983cd24fb0d6963f7d28e17f72'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('should pass RFC 1321 test #4', function () { |
|
|
|
it('should pass RFC 1321 test #4', function () { |
|
|
|
var input, result, expected; |
|
|
|
var input, result, expected; |
|
|
|
input = stringToBytes('message digest'); |
|
|
|
input = (0, _util.stringToBytes)('message digest'); |
|
|
|
result = calculateMD5(input, 0, input.length); |
|
|
|
result = (0, _crypto.calculateMD5)(input, 0, input.length); |
|
|
|
expected = hex2binary('f96b697d7cb7938d525a2f31aaf161d0'); |
|
|
|
expected = hex2binary('f96b697d7cb7938d525a2f31aaf161d0'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('should pass RFC 1321 test #5', function () { |
|
|
|
it('should pass RFC 1321 test #5', function () { |
|
|
|
var input, result, expected; |
|
|
|
var input, result, expected; |
|
|
|
input = stringToBytes('abcdefghijklmnopqrstuvwxyz'); |
|
|
|
input = (0, _util.stringToBytes)('abcdefghijklmnopqrstuvwxyz'); |
|
|
|
result = calculateMD5(input, 0, input.length); |
|
|
|
result = (0, _crypto.calculateMD5)(input, 0, input.length); |
|
|
|
expected = hex2binary('c3fcd3d76192e4007dfb496cca67e13b'); |
|
|
|
expected = hex2binary('c3fcd3d76192e4007dfb496cca67e13b'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('should pass RFC 1321 test #6', function () { |
|
|
|
it('should pass RFC 1321 test #6', function () { |
|
|
|
var input, result, expected; |
|
|
|
var input, result, expected; |
|
|
|
input = stringToBytes('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv' + 'wxyz0123456789'); |
|
|
|
input = (0, _util.stringToBytes)('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv' + 'wxyz0123456789'); |
|
|
|
result = calculateMD5(input, 0, input.length); |
|
|
|
result = (0, _crypto.calculateMD5)(input, 0, input.length); |
|
|
|
expected = hex2binary('d174ab98d277d9f5a5611c2c9f419d9f'); |
|
|
|
expected = hex2binary('d174ab98d277d9f5a5611c2c9f419d9f'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('should pass RFC 1321 test #7', function () { |
|
|
|
it('should pass RFC 1321 test #7', function () { |
|
|
|
var input, result, expected; |
|
|
|
var input, result, expected; |
|
|
|
input = stringToBytes('123456789012345678901234567890123456789012345678' + '90123456789012345678901234567890'); |
|
|
|
input = (0, _util.stringToBytes)('123456789012345678901234567890123456789012345678' + '90123456789012345678901234567890'); |
|
|
|
result = calculateMD5(input, 0, input.length); |
|
|
|
result = (0, _crypto.calculateMD5)(input, 0, input.length); |
|
|
|
expected = hex2binary('57edf4a22be3c955ac49da2e2107b67a'); |
|
|
|
expected = hex2binary('57edf4a22be3c955ac49da2e2107b67a'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -104,7 +92,7 @@ describe('crypto', function () { |
|
|
|
var key, input, result, expected, cipher; |
|
|
|
var key, input, result, expected, cipher; |
|
|
|
key = hex2binary('0123456789abcdef'); |
|
|
|
key = hex2binary('0123456789abcdef'); |
|
|
|
input = hex2binary('0123456789abcdef'); |
|
|
|
input = hex2binary('0123456789abcdef'); |
|
|
|
cipher = new ARCFourCipher(key); |
|
|
|
cipher = new _crypto.ARCFourCipher(key); |
|
|
|
result = cipher.encryptBlock(input); |
|
|
|
result = cipher.encryptBlock(input); |
|
|
|
expected = hex2binary('75b7878099e0c596'); |
|
|
|
expected = hex2binary('75b7878099e0c596'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
@ -113,7 +101,7 @@ describe('crypto', function () { |
|
|
|
var key, input, result, expected, cipher; |
|
|
|
var key, input, result, expected, cipher; |
|
|
|
key = hex2binary('0123456789abcdef'); |
|
|
|
key = hex2binary('0123456789abcdef'); |
|
|
|
input = hex2binary('0000000000000000'); |
|
|
|
input = hex2binary('0000000000000000'); |
|
|
|
cipher = new ARCFourCipher(key); |
|
|
|
cipher = new _crypto.ARCFourCipher(key); |
|
|
|
result = cipher.encryptBlock(input); |
|
|
|
result = cipher.encryptBlock(input); |
|
|
|
expected = hex2binary('7494c2e7104b0879'); |
|
|
|
expected = hex2binary('7494c2e7104b0879'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
@ -122,7 +110,7 @@ describe('crypto', function () { |
|
|
|
var key, input, result, expected, cipher; |
|
|
|
var key, input, result, expected, cipher; |
|
|
|
key = hex2binary('0000000000000000'); |
|
|
|
key = hex2binary('0000000000000000'); |
|
|
|
input = hex2binary('0000000000000000'); |
|
|
|
input = hex2binary('0000000000000000'); |
|
|
|
cipher = new ARCFourCipher(key); |
|
|
|
cipher = new _crypto.ARCFourCipher(key); |
|
|
|
result = cipher.encryptBlock(input); |
|
|
|
result = cipher.encryptBlock(input); |
|
|
|
expected = hex2binary('de188941a3375d3a'); |
|
|
|
expected = hex2binary('de188941a3375d3a'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
@ -131,7 +119,7 @@ describe('crypto', function () { |
|
|
|
var key, input, result, expected, cipher; |
|
|
|
var key, input, result, expected, cipher; |
|
|
|
key = hex2binary('ef012345'); |
|
|
|
key = hex2binary('ef012345'); |
|
|
|
input = hex2binary('00000000000000000000'); |
|
|
|
input = hex2binary('00000000000000000000'); |
|
|
|
cipher = new ARCFourCipher(key); |
|
|
|
cipher = new _crypto.ARCFourCipher(key); |
|
|
|
result = cipher.encryptBlock(input); |
|
|
|
result = cipher.encryptBlock(input); |
|
|
|
expected = hex2binary('d6a141a7ec3c38dfbd61'); |
|
|
|
expected = hex2binary('d6a141a7ec3c38dfbd61'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
@ -140,7 +128,7 @@ describe('crypto', function () { |
|
|
|
var key, input, result, expected, cipher; |
|
|
|
var key, input, result, expected, cipher; |
|
|
|
key = hex2binary('0123456789abcdef'); |
|
|
|
key = hex2binary('0123456789abcdef'); |
|
|
|
input = hex2binary('010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '101010101010101010101'); |
|
|
|
input = hex2binary('010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '10101010101010101010101010101010101010101010101010101010101010101010' + '101010101010101010101'); |
|
|
|
cipher = new ARCFourCipher(key); |
|
|
|
cipher = new _crypto.ARCFourCipher(key); |
|
|
|
result = cipher.encryptBlock(input); |
|
|
|
result = cipher.encryptBlock(input); |
|
|
|
expected = hex2binary('7595c3e6114a09780c4ad452338e1ffd9a1be9498f813d76' + '533449b6778dcad8c78a8d2ba9ac66085d0e53d59c26c2d1c490c1ebbe0ce66d1b6b' + '1b13b6b919b847c25a91447a95e75e4ef16779cde8bf0a95850e32af9689444fd377' + '108f98fdcbd4e726567500990bcc7e0ca3c4aaa304a387d20f3b8fbbcd42a1bd311d' + '7a4303dda5ab078896ae80c18b0af66dff319616eb784e495ad2ce90d7f772a81747' + 'b65f62093b1e0db9e5ba532fafec47508323e671327df9444432cb7367cec82f5d44' + 'c0d00b67d650a075cd4b70dedd77eb9b10231b6b5b741347396d62897421d43df9b4' + '2e446e358e9c11a9b2184ecbef0cd8e7a877ef968f1390ec9b3d35a5585cb009290e' + '2fcde7b5ec66d9084be44055a619d9dd7fc3166f9487f7cb272912426445998514c1' + '5d53a18c864ce3a2b7555793988126520eacf2e3066e230c91bee4dd5304f5fd0405' + 'b35bd99c73135d3d9bc335ee049ef69b3867bf2d7bd1eaa595d8bfc0066ff8d31509' + 'eb0c6caa006c807a623ef84c3d33c195d23ee320c40de0558157c822d4b8c569d849' + 'aed59d4e0fd7f379586b4b7ff684ed6a189f7486d49b9c4bad9ba24b96abf924372c' + '8a8fffb10d55354900a77a3db5f205e1b99fcd8660863a159ad4abe40fa48934163d' + 'dde542a6585540fd683cbfd8c00f12129a284deacc4cdefe58be7137541c047126c8' + 'd49e2755ab181ab7e940b0c0'); |
|
|
|
expected = hex2binary('7595c3e6114a09780c4ad452338e1ffd9a1be9498f813d76' + '533449b6778dcad8c78a8d2ba9ac66085d0e53d59c26c2d1c490c1ebbe0ce66d1b6b' + '1b13b6b919b847c25a91447a95e75e4ef16779cde8bf0a95850e32af9689444fd377' + '108f98fdcbd4e726567500990bcc7e0ca3c4aaa304a387d20f3b8fbbcd42a1bd311d' + '7a4303dda5ab078896ae80c18b0af66dff319616eb784e495ad2ce90d7f772a81747' + 'b65f62093b1e0db9e5ba532fafec47508323e671327df9444432cb7367cec82f5d44' + 'c0d00b67d650a075cd4b70dedd77eb9b10231b6b5b741347396d62897421d43df9b4' + '2e446e358e9c11a9b2184ecbef0cd8e7a877ef968f1390ec9b3d35a5585cb009290e' + '2fcde7b5ec66d9084be44055a619d9dd7fc3166f9487f7cb272912426445998514c1' + '5d53a18c864ce3a2b7555793988126520eacf2e3066e230c91bee4dd5304f5fd0405' + 'b35bd99c73135d3d9bc335ee049ef69b3867bf2d7bd1eaa595d8bfc0066ff8d31509' + 'eb0c6caa006c807a623ef84c3d33c195d23ee320c40de0558157c822d4b8c569d849' + 'aed59d4e0fd7f379586b4b7ff684ed6a189f7486d49b9c4bad9ba24b96abf924372c' + '8a8fffb10d55354900a77a3db5f205e1b99fcd8660863a159ad4abe40fa48934163d' + 'dde542a6585540fd683cbfd8c00f12129a284deacc4cdefe58be7137541c047126c8' + 'd49e2755ab181ab7e940b0c0'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
@ -149,7 +137,7 @@ describe('crypto', function () { |
|
|
|
var key, input, result, expected, cipher; |
|
|
|
var key, input, result, expected, cipher; |
|
|
|
key = hex2binary('fb029e3031323334'); |
|
|
|
key = hex2binary('fb029e3031323334'); |
|
|
|
input = hex2binary('aaaa0300000008004500004e661a00008011be640a0001220af' + 'fffff00890089003a000080a601100001000000000000204543454a4548454346434' + '550464545494546464343414341434143414341414100002000011bd0b604'); |
|
|
|
input = hex2binary('aaaa0300000008004500004e661a00008011be640a0001220af' + 'fffff00890089003a000080a601100001000000000000204543454a4548454346434' + '550464545494546464343414341434143414341414100002000011bd0b604'); |
|
|
|
cipher = new ARCFourCipher(key); |
|
|
|
cipher = new _crypto.ARCFourCipher(key); |
|
|
|
result = cipher.encryptBlock(input); |
|
|
|
result = cipher.encryptBlock(input); |
|
|
|
expected = hex2binary('f69c5806bd6ce84626bcbefb9474650aad1f7909b0f64d5f' + '58a503a258b7ed22eb0ea64930d3a056a55742fcce141d485f8aa836dea18df42c53' + '80805ad0c61a5d6f58f41040b24b7d1a693856ed0d4398e7aee3bf0e2a2ca8f7'); |
|
|
|
expected = hex2binary('f69c5806bd6ce84626bcbefb9474650aad1f7909b0f64d5f' + '58a503a258b7ed22eb0ea64930d3a056a55742fcce141d485f8aa836dea18df42c53' + '80805ad0c61a5d6f58f41040b24b7d1a693856ed0d4398e7aee3bf0e2a2ca8f7'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
@ -158,7 +146,7 @@ describe('crypto', function () { |
|
|
|
var key, input, result, expected, cipher; |
|
|
|
var key, input, result, expected, cipher; |
|
|
|
key = hex2binary('0123456789abcdef'); |
|
|
|
key = hex2binary('0123456789abcdef'); |
|
|
|
input = hex2binary('123456789abcdef0123456789abcdef0123456789abcdef0123' + '45678'); |
|
|
|
input = hex2binary('123456789abcdef0123456789abcdef0123456789abcdef0123' + '45678'); |
|
|
|
cipher = new ARCFourCipher(key); |
|
|
|
cipher = new _crypto.ARCFourCipher(key); |
|
|
|
result = cipher.encryptBlock(input); |
|
|
|
result = cipher.encryptBlock(input); |
|
|
|
expected = hex2binary('66a0949f8af7d6891f7f832ba833c00c892ebe30143ce287' + '40011ecf'); |
|
|
|
expected = hex2binary('66a0949f8af7d6891f7f832ba833c00c892ebe30143ce287' + '40011ecf'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
@ -167,15 +155,15 @@ describe('crypto', function () { |
|
|
|
describe('calculateSHA256', function () { |
|
|
|
describe('calculateSHA256', function () { |
|
|
|
it('should properly hash abc', function () { |
|
|
|
it('should properly hash abc', function () { |
|
|
|
var input, result, expected; |
|
|
|
var input, result, expected; |
|
|
|
input = stringToBytes('abc'); |
|
|
|
input = (0, _util.stringToBytes)('abc'); |
|
|
|
result = calculateSHA256(input, 0, input.length); |
|
|
|
result = (0, _crypto.calculateSHA256)(input, 0, input.length); |
|
|
|
expected = hex2binary('BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9C' + 'B410FF61F20015AD'); |
|
|
|
expected = hex2binary('BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9C' + 'B410FF61F20015AD'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('should properly hash a multiblock input', function () { |
|
|
|
it('should properly hash a multiblock input', function () { |
|
|
|
var input, result, expected; |
|
|
|
var input, result, expected; |
|
|
|
input = stringToBytes('abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmno' + 'mnopnopq'); |
|
|
|
input = (0, _util.stringToBytes)('abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmno' + 'mnopnopq'); |
|
|
|
result = calculateSHA256(input, 0, input.length); |
|
|
|
result = (0, _crypto.calculateSHA256)(input, 0, input.length); |
|
|
|
expected = hex2binary('248D6A61D20638B8E5C026930C3E6039A33CE45964FF2167' + 'F6ECEDD419DB06C1'); |
|
|
|
expected = hex2binary('248D6A61D20638B8E5C026930C3E6039A33CE45964FF2167' + 'F6ECEDD419DB06C1'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -183,15 +171,15 @@ describe('crypto', function () { |
|
|
|
describe('calculateSHA384', function () { |
|
|
|
describe('calculateSHA384', function () { |
|
|
|
it('should properly hash abc', function () { |
|
|
|
it('should properly hash abc', function () { |
|
|
|
var input, result, expected; |
|
|
|
var input, result, expected; |
|
|
|
input = stringToBytes('abc'); |
|
|
|
input = (0, _util.stringToBytes)('abc'); |
|
|
|
result = calculateSHA384(input, 0, input.length); |
|
|
|
result = (0, _crypto.calculateSHA384)(input, 0, input.length); |
|
|
|
expected = hex2binary('CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED163' + '1A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7'); |
|
|
|
expected = hex2binary('CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED163' + '1A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('should properly hash a multiblock input', function () { |
|
|
|
it('should properly hash a multiblock input', function () { |
|
|
|
var input, result, expected; |
|
|
|
var input, result, expected; |
|
|
|
input = stringToBytes('abcdefghbcdefghicdefghijdefghijkefghijklfghijklm' + 'ghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrs' + 'mnopqrstnopqrstu'); |
|
|
|
input = (0, _util.stringToBytes)('abcdefghbcdefghicdefghijdefghijkefghijklfghijklm' + 'ghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrs' + 'mnopqrstnopqrstu'); |
|
|
|
result = calculateSHA384(input, 0, input.length); |
|
|
|
result = (0, _crypto.calculateSHA384)(input, 0, input.length); |
|
|
|
expected = hex2binary('09330C33F71147E83D192FC782CD1B4753111B173B3B05D2' + '2FA08086E3B0F712FCC7C71A557E2DB966C3E9FA91746039'); |
|
|
|
expected = hex2binary('09330C33F71147E83D192FC782CD1B4753111B173B3B05D2' + '2FA08086E3B0F712FCC7C71A557E2DB966C3E9FA91746039'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -199,15 +187,15 @@ describe('crypto', function () { |
|
|
|
describe('calculateSHA512', function () { |
|
|
|
describe('calculateSHA512', function () { |
|
|
|
it('should properly hash abc', function () { |
|
|
|
it('should properly hash abc', function () { |
|
|
|
var input, result, expected; |
|
|
|
var input, result, expected; |
|
|
|
input = stringToBytes('abc'); |
|
|
|
input = (0, _util.stringToBytes)('abc'); |
|
|
|
result = calculateSHA512(input, 0, input.length); |
|
|
|
result = (0, _crypto.calculateSHA512)(input, 0, input.length); |
|
|
|
expected = hex2binary('DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA2' + '0A9EEEE64B55D39A2192992A274FC1A836BA3C23A3FEEBBD' + '454D4423643CE80E2A9AC94FA54CA49F'); |
|
|
|
expected = hex2binary('DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA2' + '0A9EEEE64B55D39A2192992A274FC1A836BA3C23A3FEEBBD' + '454D4423643CE80E2A9AC94FA54CA49F'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('should properly hash a multiblock input', function () { |
|
|
|
it('should properly hash a multiblock input', function () { |
|
|
|
var input, result, expected; |
|
|
|
var input, result, expected; |
|
|
|
input = stringToBytes('abcdefghbcdefghicdefghijdefghijkefghijklfghijklm' + 'ghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrs' + 'mnopqrstnopqrstu'); |
|
|
|
input = (0, _util.stringToBytes)('abcdefghbcdefghicdefghijdefghijkefghijklfghijklm' + 'ghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrs' + 'mnopqrstnopqrstu'); |
|
|
|
result = calculateSHA512(input, 0, input.length); |
|
|
|
result = (0, _crypto.calculateSHA512)(input, 0, input.length); |
|
|
|
expected = hex2binary('8E959B75DAE313DA8CF4F72814FC143F8F7779C6EB9F7FA1' + '7299AEADB6889018501D289E4900F7E4331B99DEC4B5433A' + 'C7D329EEB6DD26545E96E55B874BE909'); |
|
|
|
expected = hex2binary('8E959B75DAE313DA8CF4F72814FC143F8F7779C6EB9F7FA1' + '7299AEADB6889018501D289E4900F7E4331B99DEC4B5433A' + 'C7D329EEB6DD26545E96E55B874BE909'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -219,7 +207,7 @@ describe('crypto', function () { |
|
|
|
input = hex2binary('00112233445566778899aabbccddeeff'); |
|
|
|
input = hex2binary('00112233445566778899aabbccddeeff'); |
|
|
|
key = hex2binary('000102030405060708090a0b0c0d0e0f'); |
|
|
|
key = hex2binary('000102030405060708090a0b0c0d0e0f'); |
|
|
|
iv = hex2binary('00000000000000000000000000000000'); |
|
|
|
iv = hex2binary('00000000000000000000000000000000'); |
|
|
|
cipher = new AES128Cipher(key); |
|
|
|
cipher = new _crypto.AES128Cipher(key); |
|
|
|
result = cipher.encrypt(input, iv); |
|
|
|
result = cipher.encrypt(input, iv); |
|
|
|
expected = hex2binary('69c4e0d86a7b0430d8cdb78070b4c55a'); |
|
|
|
expected = hex2binary('69c4e0d86a7b0430d8cdb78070b4c55a'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
@ -230,7 +218,7 @@ describe('crypto', function () { |
|
|
|
var input, key, result, expected, cipher; |
|
|
|
var input, key, result, expected, cipher; |
|
|
|
input = hex2binary('0000000000000000000000000000000069c4e0d86a7b0430d' + '8cdb78070b4c55a'); |
|
|
|
input = hex2binary('0000000000000000000000000000000069c4e0d86a7b0430d' + '8cdb78070b4c55a'); |
|
|
|
key = hex2binary('000102030405060708090a0b0c0d0e0f'); |
|
|
|
key = hex2binary('000102030405060708090a0b0c0d0e0f'); |
|
|
|
cipher = new AES128Cipher(key); |
|
|
|
cipher = new _crypto.AES128Cipher(key); |
|
|
|
result = cipher.decryptBlock(input); |
|
|
|
result = cipher.decryptBlock(input); |
|
|
|
expected = hex2binary('00112233445566778899aabbccddeeff'); |
|
|
|
expected = hex2binary('00112233445566778899aabbccddeeff'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
@ -244,7 +232,7 @@ describe('crypto', function () { |
|
|
|
input = hex2binary('00112233445566778899aabbccddeeff'); |
|
|
|
input = hex2binary('00112233445566778899aabbccddeeff'); |
|
|
|
key = hex2binary('000102030405060708090a0b0c0d0e0f101112131415161718' + '191a1b1c1d1e1f'); |
|
|
|
key = hex2binary('000102030405060708090a0b0c0d0e0f101112131415161718' + '191a1b1c1d1e1f'); |
|
|
|
iv = hex2binary('00000000000000000000000000000000'); |
|
|
|
iv = hex2binary('00000000000000000000000000000000'); |
|
|
|
cipher = new AES256Cipher(key); |
|
|
|
cipher = new _crypto.AES256Cipher(key); |
|
|
|
result = cipher.encrypt(input, iv); |
|
|
|
result = cipher.encrypt(input, iv); |
|
|
|
expected = hex2binary('8ea2b7ca516745bfeafc49904b496089'); |
|
|
|
expected = hex2binary('8ea2b7ca516745bfeafc49904b496089'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
@ -256,7 +244,7 @@ describe('crypto', function () { |
|
|
|
input = hex2binary('8ea2b7ca516745bfeafc49904b496089'); |
|
|
|
input = hex2binary('8ea2b7ca516745bfeafc49904b496089'); |
|
|
|
key = hex2binary('000102030405060708090a0b0c0d0e0f101112131415161718' + '191a1b1c1d1e1f'); |
|
|
|
key = hex2binary('000102030405060708090a0b0c0d0e0f101112131415161718' + '191a1b1c1d1e1f'); |
|
|
|
iv = hex2binary('00000000000000000000000000000000'); |
|
|
|
iv = hex2binary('00000000000000000000000000000000'); |
|
|
|
cipher = new AES256Cipher(key); |
|
|
|
cipher = new _crypto.AES256Cipher(key); |
|
|
|
result = cipher.decryptBlock(input, false, iv); |
|
|
|
result = cipher.decryptBlock(input, false, iv); |
|
|
|
expected = hex2binary('00112233445566778899aabbccddeeff'); |
|
|
|
expected = hex2binary('00112233445566778899aabbccddeeff'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
@ -265,7 +253,7 @@ describe('crypto', function () { |
|
|
|
var input, key, result, expected, cipher; |
|
|
|
var input, key, result, expected, cipher; |
|
|
|
input = hex2binary('000000000000000000000000000000008ea2b7ca516745bf' + 'eafc49904b496089'); |
|
|
|
input = hex2binary('000000000000000000000000000000008ea2b7ca516745bf' + 'eafc49904b496089'); |
|
|
|
key = hex2binary('000102030405060708090a0b0c0d0e0f101112131415161718' + '191a1b1c1d1e1f'); |
|
|
|
key = hex2binary('000102030405060708090a0b0c0d0e0f101112131415161718' + '191a1b1c1d1e1f'); |
|
|
|
cipher = new AES256Cipher(key); |
|
|
|
cipher = new _crypto.AES256Cipher(key); |
|
|
|
result = cipher.decryptBlock(input, false); |
|
|
|
result = cipher.decryptBlock(input, false); |
|
|
|
expected = hex2binary('00112233445566778899aabbccddeeff'); |
|
|
|
expected = hex2binary('00112233445566778899aabbccddeeff'); |
|
|
|
expect(result).toEqual(expected); |
|
|
|
expect(result).toEqual(expected); |
|
|
@ -275,7 +263,7 @@ describe('crypto', function () { |
|
|
|
describe('PDF17Algorithm', function () { |
|
|
|
describe('PDF17Algorithm', function () { |
|
|
|
it('should correctly check a user key', function () { |
|
|
|
it('should correctly check a user key', function () { |
|
|
|
var password, userValidation, userPassword, alg, result; |
|
|
|
var password, userValidation, userPassword, alg, result; |
|
|
|
alg = new PDF17(); |
|
|
|
alg = new _crypto.PDF17(); |
|
|
|
password = new Uint8Array([117, 115, 101, 114]); |
|
|
|
password = new Uint8Array([117, 115, 101, 114]); |
|
|
|
userValidation = new Uint8Array([117, 169, 4, 32, 159, 101, 22, 220]); |
|
|
|
userValidation = new Uint8Array([117, 169, 4, 32, 159, 101, 22, 220]); |
|
|
|
userPassword = new Uint8Array([131, 242, 143, 160, 87, 2, 138, 134, 79, 253, 189, 173, 224, 73, 144, 241, 190, 81, 197, 15, 249, 105, 145, 151, 15, 194, 65, 3, 1, 126, 187, 221]); |
|
|
|
userPassword = new Uint8Array([131, 242, 143, 160, 87, 2, 138, 134, 79, 253, 189, 173, 224, 73, 144, 241, 190, 81, 197, 15, 249, 105, 145, 151, 15, 194, 65, 3, 1, 126, 187, 221]); |
|
|
@ -284,7 +272,7 @@ describe('crypto', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('should correctly check an owner key', function () { |
|
|
|
it('should correctly check an owner key', function () { |
|
|
|
var password, ownerValidation, ownerPassword, alg, result, uBytes; |
|
|
|
var password, ownerValidation, ownerPassword, alg, result, uBytes; |
|
|
|
alg = new PDF17(); |
|
|
|
alg = new _crypto.PDF17(); |
|
|
|
password = new Uint8Array([111, 119, 110, 101, 114]); |
|
|
|
password = new Uint8Array([111, 119, 110, 101, 114]); |
|
|
|
ownerValidation = new Uint8Array([243, 118, 71, 153, 128, 17, 101, 62]); |
|
|
|
ownerValidation = new Uint8Array([243, 118, 71, 153, 128, 17, 101, 62]); |
|
|
|
ownerPassword = new Uint8Array([60, 98, 137, 35, 51, 101, 200, 152, 210, 178, 226, 228, 134, 205, 163, 24, 204, 126, 177, 36, 106, 50, 36, 125, 210, 172, 171, 120, 222, 108, 139, 115]); |
|
|
|
ownerPassword = new Uint8Array([60, 98, 137, 35, 51, 101, 200, 152, 210, 178, 226, 228, 134, 205, 163, 24, 204, 126, 177, 36, 106, 50, 36, 125, 210, 172, 171, 120, 222, 108, 139, 115]); |
|
|
@ -294,7 +282,7 @@ describe('crypto', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('should generate a file encryption key from the user key', function () { |
|
|
|
it('should generate a file encryption key from the user key', function () { |
|
|
|
var password, userKeySalt, expected, alg, result, userEncryption; |
|
|
|
var password, userKeySalt, expected, alg, result, userEncryption; |
|
|
|
alg = new PDF17(); |
|
|
|
alg = new _crypto.PDF17(); |
|
|
|
password = new Uint8Array([117, 115, 101, 114]); |
|
|
|
password = new Uint8Array([117, 115, 101, 114]); |
|
|
|
userKeySalt = new Uint8Array([168, 94, 215, 192, 100, 38, 188, 40]); |
|
|
|
userKeySalt = new Uint8Array([168, 94, 215, 192, 100, 38, 188, 40]); |
|
|
|
userEncryption = new Uint8Array([35, 150, 195, 169, 245, 51, 51, 255, 158, 158, 33, 242, 231, 75, 125, 190, 25, 126, 172, 114, 195, 244, 137, 245, 234, 165, 42, 74, 60, 38, 17, 17]); |
|
|
|
userEncryption = new Uint8Array([35, 150, 195, 169, 245, 51, 51, 255, 158, 158, 33, 242, 231, 75, 125, 190, 25, 126, 172, 114, 195, 244, 137, 245, 234, 165, 42, 74, 60, 38, 17, 17]); |
|
|
@ -305,7 +293,7 @@ describe('crypto', function () { |
|
|
|
it('should generate a file encryption key from the owner key', function () { |
|
|
|
it('should generate a file encryption key from the owner key', function () { |
|
|
|
var password, ownerKeySalt, expected, alg, result, ownerEncryption; |
|
|
|
var password, ownerKeySalt, expected, alg, result, ownerEncryption; |
|
|
|
var uBytes; |
|
|
|
var uBytes; |
|
|
|
alg = new PDF17(); |
|
|
|
alg = new _crypto.PDF17(); |
|
|
|
password = new Uint8Array([111, 119, 110, 101, 114]); |
|
|
|
password = new Uint8Array([111, 119, 110, 101, 114]); |
|
|
|
ownerKeySalt = new Uint8Array([200, 245, 242, 12, 218, 123, 24, 120]); |
|
|
|
ownerKeySalt = new Uint8Array([200, 245, 242, 12, 218, 123, 24, 120]); |
|
|
|
ownerEncryption = new Uint8Array([213, 202, 14, 189, 110, 76, 70, 191, 6, 195, 10, 190, 157, 100, 144, 85, 8, 62, 123, 178, 156, 229, 50, 40, 229, 216, 54, 222, 34, 38, 106, 223]); |
|
|
|
ownerEncryption = new Uint8Array([213, 202, 14, 189, 110, 76, 70, 191, 6, 195, 10, 190, 157, 100, 144, 85, 8, 62, 123, 178, 156, 229, 50, 40, 229, 216, 54, 222, 34, 38, 106, 223]); |
|
|
@ -318,7 +306,7 @@ describe('crypto', function () { |
|
|
|
describe('PDF20Algorithm', function () { |
|
|
|
describe('PDF20Algorithm', function () { |
|
|
|
it('should correctly check a user key', function () { |
|
|
|
it('should correctly check a user key', function () { |
|
|
|
var password, userValidation, userPassword, alg, result; |
|
|
|
var password, userValidation, userPassword, alg, result; |
|
|
|
alg = new PDF20(); |
|
|
|
alg = new _crypto.PDF20(); |
|
|
|
password = new Uint8Array([117, 115, 101, 114]); |
|
|
|
password = new Uint8Array([117, 115, 101, 114]); |
|
|
|
userValidation = new Uint8Array([83, 245, 146, 101, 198, 247, 34, 198]); |
|
|
|
userValidation = new Uint8Array([83, 245, 146, 101, 198, 247, 34, 198]); |
|
|
|
userPassword = new Uint8Array([94, 230, 205, 75, 166, 99, 250, 76, 219, 128, 17, 85, 57, 17, 33, 164, 150, 46, 103, 176, 160, 156, 187, 233, 166, 223, 163, 253, 147, 235, 95, 184]); |
|
|
|
userPassword = new Uint8Array([94, 230, 205, 75, 166, 99, 250, 76, 219, 128, 17, 85, 57, 17, 33, 164, 150, 46, 103, 176, 160, 156, 187, 233, 166, 223, 163, 253, 147, 235, 95, 184]); |
|
|
@ -327,7 +315,7 @@ describe('crypto', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('should correctly check an owner key', function () { |
|
|
|
it('should correctly check an owner key', function () { |
|
|
|
var password, ownerValidation, ownerPassword, alg, result, uBytes; |
|
|
|
var password, ownerValidation, ownerPassword, alg, result, uBytes; |
|
|
|
alg = new PDF20(); |
|
|
|
alg = new _crypto.PDF20(); |
|
|
|
password = new Uint8Array([111, 119, 110, 101, 114]); |
|
|
|
password = new Uint8Array([111, 119, 110, 101, 114]); |
|
|
|
ownerValidation = new Uint8Array([142, 232, 169, 208, 202, 214, 5, 185]); |
|
|
|
ownerValidation = new Uint8Array([142, 232, 169, 208, 202, 214, 5, 185]); |
|
|
|
ownerPassword = new Uint8Array([88, 232, 62, 54, 245, 26, 245, 209, 137, 123, 221, 72, 199, 49, 37, 217, 31, 74, 115, 167, 127, 158, 176, 77, 45, 163, 87, 47, 39, 90, 217, 141]); |
|
|
|
ownerPassword = new Uint8Array([88, 232, 62, 54, 245, 26, 245, 209, 137, 123, 221, 72, 199, 49, 37, 217, 31, 74, 115, 167, 127, 158, 176, 77, 45, 163, 87, 47, 39, 90, 217, 141]); |
|
|
@ -337,7 +325,7 @@ describe('crypto', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('should generate a file encryption key from the user key', function () { |
|
|
|
it('should generate a file encryption key from the user key', function () { |
|
|
|
var password, userKeySalt, expected, alg, result, userEncryption; |
|
|
|
var password, userKeySalt, expected, alg, result, userEncryption; |
|
|
|
alg = new PDF20(); |
|
|
|
alg = new _crypto.PDF20(); |
|
|
|
password = new Uint8Array([117, 115, 101, 114]); |
|
|
|
password = new Uint8Array([117, 115, 101, 114]); |
|
|
|
userKeySalt = new Uint8Array([191, 11, 16, 94, 237, 216, 20, 175]); |
|
|
|
userKeySalt = new Uint8Array([191, 11, 16, 94, 237, 216, 20, 175]); |
|
|
|
userEncryption = new Uint8Array([121, 208, 2, 181, 230, 89, 156, 60, 253, 143, 212, 28, 84, 180, 196, 177, 173, 128, 221, 107, 46, 20, 94, 186, 135, 51, 95, 24, 20, 223, 254, 36]); |
|
|
|
userEncryption = new Uint8Array([121, 208, 2, 181, 230, 89, 156, 60, 253, 143, 212, 28, 84, 180, 196, 177, 173, 128, 221, 107, 46, 20, 94, 186, 135, 51, 95, 24, 20, 223, 254, 36]); |
|
|
@ -348,7 +336,7 @@ describe('crypto', function () { |
|
|
|
it('should generate a file encryption key from the owner key', function () { |
|
|
|
it('should generate a file encryption key from the owner key', function () { |
|
|
|
var password, ownerKeySalt, expected, alg, result, ownerEncryption; |
|
|
|
var password, ownerKeySalt, expected, alg, result, ownerEncryption; |
|
|
|
var uBytes; |
|
|
|
var uBytes; |
|
|
|
alg = new PDF20(); |
|
|
|
alg = new _crypto.PDF20(); |
|
|
|
password = new Uint8Array([111, 119, 110, 101, 114]); |
|
|
|
password = new Uint8Array([111, 119, 110, 101, 114]); |
|
|
|
ownerKeySalt = new Uint8Array([29, 208, 185, 46, 11, 76, 135, 149]); |
|
|
|
ownerKeySalt = new Uint8Array([29, 208, 185, 46, 11, 76, 135, 149]); |
|
|
|
ownerEncryption = new Uint8Array([209, 73, 224, 77, 103, 155, 201, 181, 190, 68, 223, 20, 62, 90, 56, 210, 5, 240, 178, 128, 238, 124, 68, 254, 253, 244, 62, 108, 208, 135, 10, 251]); |
|
|
|
ownerEncryption = new Uint8Array([209, 73, 224, 77, 103, 155, 201, 181, 190, 68, 223, 20, 62, 90, 56, 210, 5, 240, 178, 128, 238, 124, 68, 254, 253, 244, 62, 108, 208, 135, 10, 251]); |
|
|
@ -361,7 +349,7 @@ describe('crypto', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
describe('CipherTransformFactory', function () { |
|
|
|
describe('CipherTransformFactory', function () { |
|
|
|
function buildDict(map) { |
|
|
|
function buildDict(map) { |
|
|
|
var dict = new Dict(); |
|
|
|
var dict = new _primitives.Dict(); |
|
|
|
for (var key in map) { |
|
|
|
for (var key in map) { |
|
|
|
dict.set(key, map[key]); |
|
|
|
dict.set(key, map[key]); |
|
|
|
} |
|
|
|
} |
|
|
@ -369,7 +357,7 @@ describe('CipherTransformFactory', function () { |
|
|
|
} |
|
|
|
} |
|
|
|
function ensurePasswordCorrect(done, dict, fileId, password) { |
|
|
|
function ensurePasswordCorrect(done, dict, fileId, password) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
var factory = new CipherTransformFactory(dict, fileId, password); |
|
|
|
var factory = new _crypto.CipherTransformFactory(dict, fileId, password); |
|
|
|
expect('createCipherTransform' in factory).toEqual(true); |
|
|
|
expect('createCipherTransform' in factory).toEqual(true); |
|
|
|
} catch (ex) { |
|
|
|
} catch (ex) { |
|
|
|
done.fail('Password should be accepted: ' + ex); |
|
|
|
done.fail('Password should be accepted: ' + ex); |
|
|
@ -379,10 +367,10 @@ describe('CipherTransformFactory', function () { |
|
|
|
} |
|
|
|
} |
|
|
|
function ensurePasswordNeeded(done, dict, fileId, password) { |
|
|
|
function ensurePasswordNeeded(done, dict, fileId, password) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
new CipherTransformFactory(dict, fileId, password); |
|
|
|
new _crypto.CipherTransformFactory(dict, fileId, password); |
|
|
|
} catch (ex) { |
|
|
|
} catch (ex) { |
|
|
|
expect(ex instanceof PasswordException).toEqual(true); |
|
|
|
expect(ex instanceof _util.PasswordException).toEqual(true); |
|
|
|
expect(ex.code).toEqual(PasswordResponses.NEED_PASSWORD); |
|
|
|
expect(ex.code).toEqual(_util.PasswordResponses.NEED_PASSWORD); |
|
|
|
done(); |
|
|
|
done(); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -390,10 +378,10 @@ describe('CipherTransformFactory', function () { |
|
|
|
} |
|
|
|
} |
|
|
|
function ensurePasswordIncorrect(done, dict, fileId, password) { |
|
|
|
function ensurePasswordIncorrect(done, dict, fileId, password) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
new CipherTransformFactory(dict, fileId, password); |
|
|
|
new _crypto.CipherTransformFactory(dict, fileId, password); |
|
|
|
} catch (ex) { |
|
|
|
} catch (ex) { |
|
|
|
expect(ex instanceof PasswordException).toEqual(true); |
|
|
|
expect(ex instanceof _util.PasswordException).toEqual(true); |
|
|
|
expect(ex.code).toEqual(PasswordResponses.INCORRECT_PASSWORD); |
|
|
|
expect(ex.code).toEqual(_util.PasswordResponses.INCORRECT_PASSWORD); |
|
|
|
done(); |
|
|
|
done(); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -405,7 +393,7 @@ describe('CipherTransformFactory', function () { |
|
|
|
fileId1 = unescape('%F6%C6%AF%17%F3rR%8DRM%9A%80%D1%EF%DF%18'); |
|
|
|
fileId1 = unescape('%F6%C6%AF%17%F3rR%8DRM%9A%80%D1%EF%DF%18'); |
|
|
|
fileId2 = unescape('%3CL_%3AD%96%AF@%9A%9D%B3%3Cx%1Cv%AC'); |
|
|
|
fileId2 = unescape('%3CL_%3AD%96%AF@%9A%9D%B3%3Cx%1Cv%AC'); |
|
|
|
dict1 = buildDict({ |
|
|
|
dict1 = buildDict({ |
|
|
|
Filter: Name.get('Standard'), |
|
|
|
Filter: _primitives.Name.get('Standard'), |
|
|
|
V: 2, |
|
|
|
V: 2, |
|
|
|
Length: 128, |
|
|
|
Length: 128, |
|
|
|
O: unescape('%80%C3%04%96%91o%20sl%3A%E6%1B%13T%91%F2%0DV%12%E3%FF%5E%B' + 'B%E9VO%D8k%9A%CA%7C%5D'), |
|
|
|
O: unescape('%80%C3%04%96%91o%20sl%3A%E6%1B%13T%91%F2%0DV%12%E3%FF%5E%B' + 'B%E9VO%D8k%9A%CA%7C%5D'), |
|
|
@ -414,7 +402,7 @@ describe('CipherTransformFactory', function () { |
|
|
|
R: 3 |
|
|
|
R: 3 |
|
|
|
}); |
|
|
|
}); |
|
|
|
dict2 = buildDict({ |
|
|
|
dict2 = buildDict({ |
|
|
|
Filter: Name.get('Standard'), |
|
|
|
Filter: _primitives.Name.get('Standard'), |
|
|
|
V: 4, |
|
|
|
V: 4, |
|
|
|
Length: 128, |
|
|
|
Length: 128, |
|
|
|
O: unescape('sF%14v.y5%27%DB%97%0A5%22%B3%E1%D4%AD%BD%9B%3C%B4%A5%89u%1' + '5%B2Y%F1h%D9%E9%F4'), |
|
|
|
O: unescape('sF%14v.y5%27%DB%97%0A5%22%B3%E1%D4%AD%BD%9B%3C%B4%A5%89u%1' + '5%B2Y%F1h%D9%E9%F4'), |
|
|
@ -423,7 +411,7 @@ describe('CipherTransformFactory', function () { |
|
|
|
R: 4 |
|
|
|
R: 4 |
|
|
|
}); |
|
|
|
}); |
|
|
|
aes256Dict = buildDict({ |
|
|
|
aes256Dict = buildDict({ |
|
|
|
Filter: Name.get('Standard'), |
|
|
|
Filter: _primitives.Name.get('Standard'), |
|
|
|
V: 5, |
|
|
|
V: 5, |
|
|
|
Length: 256, |
|
|
|
Length: 256, |
|
|
|
O: unescape('%3Cb%89%233e%C8%98%D2%B2%E2%E4%86%CD%A3%18%CC%7E%B1%24j2%2' + '4%7D%D2%AC%ABx%DEl%8Bs%F3vG%99%80%11e%3E%C8%F5%F2%0C%DA%7B' + '%18x'), |
|
|
|
O: unescape('%3Cb%89%233e%C8%98%D2%B2%E2%E4%86%CD%A3%18%CC%7E%B1%24j2%2' + '4%7D%D2%AC%ABx%DEl%8Bs%F3vG%99%80%11e%3E%C8%F5%F2%0C%DA%7B' + '%18x'), |
|
|
@ -435,7 +423,7 @@ describe('CipherTransformFactory', function () { |
|
|
|
R: 5 |
|
|
|
R: 5 |
|
|
|
}); |
|
|
|
}); |
|
|
|
aes256IsoDict = buildDict({ |
|
|
|
aes256IsoDict = buildDict({ |
|
|
|
Filter: Name.get('Standard'), |
|
|
|
Filter: _primitives.Name.get('Standard'), |
|
|
|
V: 5, |
|
|
|
V: 5, |
|
|
|
Length: 256, |
|
|
|
Length: 256, |
|
|
|
O: unescape('X%E8%3E6%F5%1A%F5%D1%89%7B%DDH%C71%25%D9%1FJs%A7%7F%9E%B0M' + '-%A3W/%27Z%D9%8D%8E%E8%A9%D0%CA%D6%05%B9%1D%D0%B9.%0BL%87%' + '95'), |
|
|
|
O: unescape('X%E8%3E6%F5%1A%F5%D1%89%7B%DDH%C71%25%D9%1FJs%A7%7F%9E%B0M' + '-%A3W/%27Z%D9%8D%8E%E8%A9%D0%CA%D6%05%B9%1D%D0%B9.%0BL%87%' + '95'), |
|
|
@ -447,7 +435,7 @@ describe('CipherTransformFactory', function () { |
|
|
|
R: 6 |
|
|
|
R: 6 |
|
|
|
}); |
|
|
|
}); |
|
|
|
aes256BlankDict = buildDict({ |
|
|
|
aes256BlankDict = buildDict({ |
|
|
|
Filter: Name.get('Standard'), |
|
|
|
Filter: _primitives.Name.get('Standard'), |
|
|
|
V: 5, |
|
|
|
V: 5, |
|
|
|
Length: 256, |
|
|
|
Length: 256, |
|
|
|
O: unescape('%B8p%04%C3g%26%FCW%CCN%D4%16%A1%E8%950YZ%C9%9E%B1-%97%F3%F' + 'E%03%13%19ffZn%8F%F5%EB%EC%CC5sV%10e%CEl%B5%E9G%C1'), |
|
|
|
O: unescape('%B8p%04%C3g%26%FCW%CCN%D4%16%A1%E8%950YZ%C9%9E%B1-%97%F3%F' + 'E%03%13%19ffZn%8F%F5%EB%EC%CC5sV%10e%CEl%B5%E9G%C1'), |
|
|
@ -459,7 +447,7 @@ describe('CipherTransformFactory', function () { |
|
|
|
R: 5 |
|
|
|
R: 5 |
|
|
|
}); |
|
|
|
}); |
|
|
|
aes256IsoBlankDict = buildDict({ |
|
|
|
aes256IsoBlankDict = buildDict({ |
|
|
|
Filter: Name.get('Standard'), |
|
|
|
Filter: _primitives.Name.get('Standard'), |
|
|
|
V: 5, |
|
|
|
V: 5, |
|
|
|
Length: 256, |
|
|
|
Length: 256, |
|
|
|
O: unescape('%F7%DB%99U%A6M%ACk%AF%CF%D7AFw%E9%C1%91%CBDgI%23R%CF%0C%15' + 'r%D74%0D%CE%E9%91@%E4%98QF%BF%88%7Ej%DE%AD%8F%F4@%C1'), |
|
|
|
O: unescape('%F7%DB%99U%A6M%ACk%AF%CF%D7AFw%E9%C1%91%CBDgI%23R%CF%0C%15' + 'r%D74%0D%CE%E9%91@%E4%98QF%BF%88%7Ej%DE%AD%8F%F4@%C1'), |
|
|
|