Initial browserify support. Symmetric encryption algorithms
and hashes are now working.
This commit is contained in:
parent
844ebcf254
commit
ccc0a4eb48
2
Makefile
2
Makefile
|
@ -30,6 +30,8 @@ lint:
|
|||
@echo See http://code.google.com/closure/utilities/
|
||||
@./scripts/lint.sh
|
||||
|
||||
bundle:
|
||||
@browserify -d -r ./src/openpgp.js:openpgp > ./resources/openpgp.js
|
||||
minify:
|
||||
@echo See http://code.google.com/closure/compiler/
|
||||
@./scripts/minimize.sh
|
||||
|
|
13215
resources/openpgp.js
13215
resources/openpgp.js
File diff suppressed because one or more lines are too long
|
@ -202,3 +202,5 @@ msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
|||
return (msw << 16) | (lsw & 0xFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = MD5
|
||||
|
|
|
@ -290,4 +290,6 @@ function RMDstring(message)
|
|||
}
|
||||
|
||||
return retString;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = RMDstring;
|
||||
|
|
|
@ -1193,29 +1193,26 @@ var jsSHA = (function () {
|
|||
return jsSHA;
|
||||
}());
|
||||
|
||||
function str_sha1(str) {
|
||||
var shaObj = new jsSHA(str, "ASCII");
|
||||
return shaObj.getHash("SHA-1", "ASCII");
|
||||
}
|
||||
|
||||
function str_sha224(str) {
|
||||
var shaObj = new jsSHA(str, "ASCII");
|
||||
return shaObj.getHash("SHA-224", "ASCII");
|
||||
}
|
||||
|
||||
function str_sha256(str) {
|
||||
var shaObj = new jsSHA(str, "ASCII");
|
||||
return shaObj.getHash("SHA-256", "ASCII");
|
||||
}
|
||||
|
||||
|
||||
function str_sha384(str) {
|
||||
var shaObj = new jsSHA(str, "ASCII");
|
||||
return shaObj.getHash("SHA-384", "ASCII");
|
||||
|
||||
}
|
||||
|
||||
function str_sha512(str) {
|
||||
var shaObj = new jsSHA(str, "ASCII");
|
||||
return shaObj.getHash("SHA-512", "ASCII");
|
||||
module.exports = {
|
||||
sha1: function(str) {
|
||||
var shaObj = new jsSHA(str, "ASCII");
|
||||
return shaObj.getHash("SHA-1", "ASCII");
|
||||
},
|
||||
sha224: function(str) {
|
||||
var shaObj = new jsSHA(str, "ASCII");
|
||||
return shaObj.getHash("SHA-224", "ASCII");
|
||||
},
|
||||
sha256: function(str) {
|
||||
var shaObj = new jsSHA(str, "ASCII");
|
||||
return shaObj.getHash("SHA-256", "ASCII");
|
||||
},
|
||||
sha384: function(str) {
|
||||
var shaObj = new jsSHA(str, "ASCII");
|
||||
return shaObj.getHash("SHA-384", "ASCII");
|
||||
|
||||
},
|
||||
sha512: function(str) {
|
||||
var shaObj = new jsSHA(str, "ASCII");
|
||||
return shaObj.getHash("SHA-512", "ASCII");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -482,3 +482,8 @@ function AESencrypt(block, ctx)
|
|||
|
||||
return unpackBytes(b);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
AESencrypt: AESencrypt,
|
||||
keyExpansion: keyExpansion
|
||||
}
|
||||
|
|
|
@ -391,3 +391,5 @@ function BFencrypt(block,key) {
|
|||
bf.init(util.str2bin(key));
|
||||
return bf.encrypt_block(block);
|
||||
}
|
||||
|
||||
module.exports = BFencrypt;
|
||||
|
|
|
@ -545,3 +545,5 @@ function openpgp_symenc_cast5() {
|
|||
|
||||
};
|
||||
|
||||
|
||||
module.exports = cast5_encrypt;
|
||||
|
|
|
@ -206,3 +206,4 @@ function des_createKeys (key) {
|
|||
} //end of des_createKeys
|
||||
|
||||
|
||||
module.exports = desede;
|
||||
|
|
|
@ -300,3 +300,4 @@ function createTwofish() {
|
|||
};
|
||||
}
|
||||
|
||||
module.exports = TFencrypt;
|
||||
|
|
|
@ -509,3 +509,20 @@ openpgp.hash = {
|
|||
sha512: 10,
|
||||
sha224: 11
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
cipher: {
|
||||
aes: require('./ciphers/symmetric/aes.js'),
|
||||
des: require('./ciphers/symmetric/dessrc.js'),
|
||||
cast5: require('./ciphers/symmetric/cast5.js'),
|
||||
twofish: require('./ciphers/symmetric/twofish.js'),
|
||||
blowfish: require('./ciphers/symmetric/blowfish.js')
|
||||
},
|
||||
hash: {
|
||||
md5: require('./ciphers/hash/md5.js'),
|
||||
sha: require('./ciphers/hash/sha.js'),
|
||||
ripemd: require('./ciphers/hash/ripe-md.js')
|
||||
},
|
||||
util: require('./util/util.js')
|
||||
}
|
||||
|
||||
|
|
|
@ -301,4 +301,4 @@ var Util = function() {
|
|||
/**
|
||||
* an instance that should be used.
|
||||
*/
|
||||
var util = new Util();
|
||||
module.exports = new Util();
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
|
||||
unittests.register("MD5 test with test vectors from RFC 1321", function() {
|
||||
var openpgp = require('openpgp'),
|
||||
util = openpgp.util,
|
||||
MD5 = openpgp.hash.md5;
|
||||
|
||||
var result = new Array();
|
||||
result[0] = new test_result("MD5 (\"\") = d41d8cd98f00b204e9800998ecf8427e",
|
||||
util.hexstrdump(MD5("")) == "d41d8cd98f00b204e9800998ecf8427e");
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
|
||||
unittests.register("RIPE-MD 160 bits test with test vectors from http://homes.esat.kuleuven.be/~bosselae/ripemd160.html", function() {
|
||||
|
||||
var openpgp = require('openpgp'),
|
||||
util = openpgp.util,
|
||||
RMDstring = openpgp.hash.ripemd;
|
||||
|
||||
var result = new Array();
|
||||
result[0] = new test_result("RMDstring (\"\") = 9c1185a5c5e9fc54612808977ee8f548b2258d31",
|
||||
util.hexstrdump(RMDstring("")) == "9c1185a5c5e9fc54612808977ee8f548b2258d31");
|
||||
|
|
|
@ -1,26 +1,31 @@
|
|||
|
||||
|
||||
unittests.register("SHA* test with test vectors from NIST FIPS 180-2", function() {
|
||||
var openpgp = require('openpgp'),
|
||||
util = openpgp.util,
|
||||
sha = openpgp.hash.sha;
|
||||
|
||||
var result = new Array();
|
||||
|
||||
result[0] = new test_result("SHA1 - a9993e364706816aba3e25717850c26c9cd0d89d = str_sha1(\"abc\") ",
|
||||
"a9993e364706816aba3e25717850c26c9cd0d89d" == util.hexstrdump(str_sha1("abc")));
|
||||
result[1] = new test_result("SHA1 - 84983e441c3bd26ebaae4aa1f95129e5e54670f1 = str_sha1(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\") ",
|
||||
"84983e441c3bd26ebaae4aa1f95129e5e54670f1" == util.hexstrdump(str_sha1("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")));
|
||||
result[2] = new test_result("SHA224 - 23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7 = str_sha224(\"abc\") ",
|
||||
"23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7" == util.hexstrdump(str_sha224("abc")));
|
||||
result[3] = new test_result("SHA224 - 75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525 = str_sha224(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\") ",
|
||||
"75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525" == util.hexstrdump(str_sha224("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")));
|
||||
result[4] = new test_result("SHA256 - ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad = str_sha256(\"abc\") ",
|
||||
"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" == util.hexstrdump(str_sha256("abc")));
|
||||
result[5] = new test_result("SHA256 - 248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1 = str_sha256(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\") ",
|
||||
"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1" == util.hexstrdump(str_sha256("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")));
|
||||
result[6] = new test_result("SHA384 - cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7 = str_sha384(\"abc\") ",
|
||||
"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7" == util.hexstrdump(str_sha384("abc")));
|
||||
result[0] = new test_result("SHA1 - a9993e364706816aba3e25717850c26c9cd0d89d = sha.sha1(\"abc\") ",
|
||||
"a9993e364706816aba3e25717850c26c9cd0d89d" == util.hexstrdump(sha.sha1("abc")));
|
||||
result[1] = new test_result("SHA1 - 84983e441c3bd26ebaae4aa1f95129e5e54670f1 = sha.sha1(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\") ",
|
||||
"84983e441c3bd26ebaae4aa1f95129e5e54670f1" == util.hexstrdump(sha.sha1("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")));
|
||||
result[2] = new test_result("SHA224 - 23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7 = sha.sha224(\"abc\") ",
|
||||
"23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7" == util.hexstrdump(sha.sha224("abc")));
|
||||
result[3] = new test_result("SHA224 - 75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525 = sha.sha224(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\") ",
|
||||
"75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525" == util.hexstrdump(sha.sha224("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")));
|
||||
result[4] = new test_result("SHA256 - ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad = sha.sha256(\"abc\") ",
|
||||
"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" == util.hexstrdump(sha.sha256("abc")));
|
||||
result[5] = new test_result("SHA256 - 248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1 = sha.sha256(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\") ",
|
||||
"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1" == util.hexstrdump(sha.sha256("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")));
|
||||
result[6] = new test_result("SHA384 - cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7 = sha.sha384(\"abc\") ",
|
||||
"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7" == util.hexstrdump(sha.sha384("abc")));
|
||||
result[7] = new test_result("SHA384 - 3391fdddfc8dc7393707a65b1b4709397cf8b1d162af05abfe8f450de5f36bc6b0455a8520bc4e6f5fe95b1fe3c8452b = str384(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\") ",
|
||||
"3391fdddfc8dc7393707a65b1b4709397cf8b1d162af05abfe8f450de5f36bc6b0455a8520bc4e6f5fe95b1fe3c8452b" == util.hexstrdump(str_sha384("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")));
|
||||
result[8] = new test_result("SHA512 - ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f = str_sha512(\"abc\") ",
|
||||
"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f" == util.hexstrdump(str_sha512("abc")));
|
||||
result[9] = new test_result("SHA512 - 204a8fc6dda82f0a0ced7beb8e08a41657c16ef468b228a8279be331a703c33596fd15c13b1b07f9aa1d3bea57789ca031ad85c7a71dd70354ec631238ca3445 = str_sha512(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\") ",
|
||||
"204a8fc6dda82f0a0ced7beb8e08a41657c16ef468b228a8279be331a703c33596fd15c13b1b07f9aa1d3bea57789ca031ad85c7a71dd70354ec631238ca3445" == util.hexstrdump(str_sha512("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")));
|
||||
"3391fdddfc8dc7393707a65b1b4709397cf8b1d162af05abfe8f450de5f36bc6b0455a8520bc4e6f5fe95b1fe3c8452b" == util.hexstrdump(sha.sha384("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")));
|
||||
result[8] = new test_result("SHA512 - ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f = sha.sha512(\"abc\") ",
|
||||
"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f" == util.hexstrdump(sha.sha512("abc")));
|
||||
result[9] = new test_result("SHA512 - 204a8fc6dda82f0a0ced7beb8e08a41657c16ef468b228a8279be331a703c33596fd15c13b1b07f9aa1d3bea57789ca031ad85c7a71dd70354ec631238ca3445 = sha.sha512(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\") ",
|
||||
"204a8fc6dda82f0a0ced7beb8e08a41657c16ef468b228a8279be331a703c33596fd15c13b1b07f9aa1d3bea57789ca031ad85c7a71dd70354ec631238ca3445" == util.hexstrdump(sha.sha512("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")));
|
||||
return result;
|
||||
});
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
var openpgp = require('openpgp')
|
||||
|
||||
var util = openpgp.util,
|
||||
keyExpansion = openpgp.cipher.aes.keyExpansion,
|
||||
AESencrypt = openpgp.cipher.aes.AESencrypt;
|
||||
|
||||
unittests.register("AES Rijndael cipher test with test vectors from ecb_tbl.txt", function() {
|
||||
var result = new Array();
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
|
||||
unittests.register("Blowfish cipher test with test vectors from http://www.schneier.com/code/vectors.txt", function() {
|
||||
var openpgp = require('openpgp'),
|
||||
util = openpgp.util,
|
||||
BFencrypt = openpgp.cipher.blowfish;
|
||||
|
||||
var result = new Array();
|
||||
function test_bf(input, key, output) {
|
||||
return (util.hexstrdump(util.bin2str(BFencrypt(input,util.bin2str(key)))) == util.hexstrdump(util.bin2str(output)));
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
|
||||
unittests.register("CAST-128 cipher test with test vectors from RFC2144", function() {
|
||||
var openpgp = require('openpgp'),
|
||||
util = openpgp.util,
|
||||
cast5_encrypt = openpgp.cipher.cast5;
|
||||
|
||||
var result = new Array();
|
||||
function test_cast(input, key, output) {
|
||||
return (util.hexstrdump(util.bin2str(cast5_encrypt(input,util.bin2str(key)))) == util.hexstrdump(util.bin2str(output)));
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
|
||||
unittests.register("TripleDES (EDE) cipher test with test vectors from http://csrc.nist.gov/publications/nistpubs/800-20/800-20.pdf", function() {
|
||||
var openpgp = require('openpgp'),
|
||||
util = openpgp.util,
|
||||
desede = openpgp.cipher.des
|
||||
|
||||
var result = new Array();
|
||||
var key = util.bin2str([1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]);
|
||||
var testvectors = [[[0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00],[0x95,0xF8,0xA5,0xE5,0xDD,0x31,0xD9,0x00]],
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
|
||||
unittests.register("Twofish test with test vectors from http://www.schneier.com/code/ecb_ival.txt", function() {
|
||||
var openpgp = require('openpgp'),
|
||||
util = openpgp.util,
|
||||
TFencrypt = openpgp.cipher.twofish;
|
||||
|
||||
var result = new Array();
|
||||
var start = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
|
||||
var start_short = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
|
||||
|
|
Loading…
Reference in New Issue
Block a user