mirror of
https://github.com/moparisthebest/mail
synced 2024-12-22 07:18:49 -05:00
removed sjcl dependencies from code
This commit is contained in:
parent
c89569fabd
commit
d59077dedd
@ -20,19 +20,19 @@ var Util = function(window, uuid, crypt) {
|
|||||||
var keyBase64, keyBuf;
|
var keyBase64, keyBuf;
|
||||||
|
|
||||||
if (typeof module !== 'undefined' && module.exports) {
|
if (typeof module !== 'undefined' && module.exports) {
|
||||||
|
// node.js
|
||||||
keyBuf = crypt.randomBytes(keySize / 8);
|
keyBuf = crypt.randomBytes(keySize / 8);
|
||||||
keyBase64 = new Buffer(keyBuf).toString('base64');
|
keyBase64 = new Buffer(keyBuf).toString('base64');
|
||||||
|
|
||||||
} else if (window.crypto && window.crypto.getRandomValues) {
|
} else if (window.crypto && window.crypto.getRandomValues) {
|
||||||
|
// browser if secure rng exists
|
||||||
keyBuf = new Uint8Array(keySize / 8);
|
keyBuf = new Uint8Array(keySize / 8);
|
||||||
window.crypto.getRandomValues(keyBuf);
|
window.crypto.getRandomValues(keyBuf);
|
||||||
keyBase64 = window.btoa(this.uint8Arr2BinStr(keyBuf));
|
keyBase64 = window.btoa(this.uint8Arr2BinStr(keyBuf));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// add an additional peace of entropy to the pot and stir with the sjcl prng
|
// generate random bytes with fortuna algorithm from forge
|
||||||
sjcl.random.addEntropy((new Date()).valueOf(), 2, "calltime");
|
keyBase64 = window.btoa(forge.random.getBytesSync(keySize / 8));
|
||||||
keyBuf = sjcl.random.randomWords(keySize / 32, 0);
|
|
||||||
keyBase64 = sjcl.codec.base64.fromBits(keyBuf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return keyBase64;
|
return keyBase64;
|
||||||
|
@ -4,7 +4,7 @@ var cloudstoragedao_test = {
|
|||||||
user: 'email.dao.it.test@mail.whiteout.io',
|
user: 'email.dao.it.test@mail.whiteout.io',
|
||||||
password: 'hellosafe',
|
password: 'hellosafe',
|
||||||
keySize: 128,
|
keySize: 128,
|
||||||
ivSize: 104
|
ivSize: 128
|
||||||
};
|
};
|
||||||
|
|
||||||
asyncTest("Init", 1, function() {
|
asyncTest("Init", 1, function() {
|
||||||
|
@ -23,20 +23,10 @@
|
|||||||
<script src="../lib/lawnchair/lawnchair-git.min.js"></script>
|
<script src="../lib/lawnchair/lawnchair-git.min.js"></script>
|
||||||
<script src="../lib/lawnchair/lawnchair-adapter-indexed-db-git.js"></script>
|
<script src="../lib/lawnchair/lawnchair-adapter-indexed-db-git.js"></script>
|
||||||
<script src="../lib/lawnchair/lawnchair-adapter-webkit-sqlite-git.js"></script>
|
<script src="../lib/lawnchair/lawnchair-adapter-webkit-sqlite-git.js"></script>
|
||||||
|
|
||||||
<script src="../lib/sjcl/sjcl.js"></script>
|
|
||||||
<script src="../lib/sjcl/sha256.js"></script>
|
|
||||||
<script src="../lib/sjcl/random.js"></script>
|
|
||||||
<script src="../lib/sjcl/bitArray.js"></script>
|
|
||||||
<script src="../lib/sjcl/codecBase64.js"></script>
|
|
||||||
<script src="../lib/sjcl/codecString.js"></script>
|
|
||||||
<script src="../lib/sjcl/aes.js"></script>
|
|
||||||
<script src="../lib/sjcl/ccm.js"></script>
|
|
||||||
|
|
||||||
|
<script src="../lib/forge/forge.rsa.bundle.js"></script>
|
||||||
<script src="../lib/nacl.js"></script>
|
<script src="../lib/nacl.js"></script>
|
||||||
|
|
||||||
<script src="../lib/uuid.js"></script>
|
<script src="../lib/uuid.js"></script>
|
||||||
<script src="../lib/openpgp.min.js"></script>
|
|
||||||
|
|
||||||
<script src="../js/app-config.js"></script>
|
<script src="../js/app-config.js"></script>
|
||||||
<script>
|
<script>
|
||||||
@ -52,8 +42,6 @@
|
|||||||
<script src="../js/crypto/util.js"></script>
|
<script src="../js/crypto/util.js"></script>
|
||||||
<script src="../js/crypto/pbkdf2.js"></script>
|
<script src="../js/crypto/pbkdf2.js"></script>
|
||||||
<script src="../js/crypto/aes-cbc.js"></script>
|
<script src="../js/crypto/aes-cbc.js"></script>
|
||||||
<script src="../js/crypto/aes-ccm.js"></script>
|
|
||||||
<script src="../js/crypto/aes-gcm.js"></script>
|
|
||||||
<script src="../js/crypto/nacl-crypto.js"></script>
|
<script src="../js/crypto/nacl-crypto.js"></script>
|
||||||
<script src="../js/crypto/crypto.js"></script>
|
<script src="../js/crypto/crypto.js"></script>
|
||||||
|
|
||||||
|
@ -28,16 +28,16 @@ test("CBC mode", 4, function() {
|
|||||||
equal(decrypted, plaintext, 'Decryption correct' + decrypted);
|
equal(decrypted, plaintext, 'Decryption correct' + decrypted);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("CCM mode", 2, function() {
|
// test("CCM mode", 2, function() {
|
||||||
var aes = new app.crypto.AesCCM(sjcl);
|
// var aes = new app.crypto.AesCCM(sjcl);
|
||||||
|
|
||||||
var plaintext = aes_test.test_message;
|
// var plaintext = aes_test.test_message;
|
||||||
var key = aes_test.util.random(aes_test.keySize);
|
// var key = aes_test.util.random(aes_test.keySize);
|
||||||
var iv = aes_test.util.random(104);
|
// var iv = aes_test.util.random(104);
|
||||||
|
|
||||||
var ciphertext = aes.encrypt(plaintext, key, iv);
|
// var ciphertext = aes.encrypt(plaintext, key, iv);
|
||||||
ok(ciphertext, 'Ciphertext length: ' + ciphertext.length);
|
// ok(ciphertext, 'Ciphertext length: ' + ciphertext.length);
|
||||||
|
|
||||||
var decrypted = aes.decrypt(ciphertext, key, iv);
|
// var decrypted = aes.decrypt(ciphertext, key, iv);
|
||||||
equal(decrypted, plaintext, 'Decryption correct: ' + decrypted);
|
// equal(decrypted, plaintext, 'Decryption correct: ' + decrypted);
|
||||||
});
|
// });
|
@ -23,23 +23,9 @@
|
|||||||
<script src="../lib/lawnchair/lawnchair-git.min.js"></script>
|
<script src="../lib/lawnchair/lawnchair-git.min.js"></script>
|
||||||
<script src="../lib/lawnchair/lawnchair-adapter-indexed-db-git.js"></script>
|
<script src="../lib/lawnchair/lawnchair-adapter-indexed-db-git.js"></script>
|
||||||
<script src="../lib/lawnchair/lawnchair-adapter-webkit-sqlite-git.js"></script>
|
<script src="../lib/lawnchair/lawnchair-adapter-webkit-sqlite-git.js"></script>
|
||||||
|
|
||||||
<script src="../lib/sjcl/sjcl.js"></script>
|
|
||||||
<script src="../lib/sjcl/sha256.js"></script>
|
|
||||||
<script src="../lib/sjcl/random.js"></script>
|
|
||||||
<script src="../lib/sjcl/bitArray.js"></script>
|
|
||||||
<script src="../lib/sjcl/codecBase64.js"></script>
|
|
||||||
<script src="../lib/sjcl/codecString.js"></script>
|
|
||||||
<script src="../lib/sjcl/aes.js"></script>
|
|
||||||
<script src="../lib/sjcl/ccm.js"></script>
|
|
||||||
<script src="../lib/sjcl/bn.js"></script>
|
|
||||||
<script src="../lib/sjcl/ecc.js"></script>
|
|
||||||
<script src="../lib/sjcl/convenience.js"></script>
|
|
||||||
|
|
||||||
<script src="../lib/forge/forge.rsa.bundle.js"></script>
|
<script src="../lib/forge/forge.rsa.bundle.js"></script>
|
||||||
|
|
||||||
<script src="../lib/nacl.js"></script>
|
<script src="../lib/nacl.js"></script>
|
||||||
|
|
||||||
<script src="../lib/uuid.js"></script>
|
<script src="../lib/uuid.js"></script>
|
||||||
|
|
||||||
<script src="../js/app-config.js"></script>
|
<script src="../js/app-config.js"></script>
|
||||||
@ -56,8 +42,6 @@
|
|||||||
<script src="../js/crypto/util.js"></script>
|
<script src="../js/crypto/util.js"></script>
|
||||||
<script src="../js/crypto/pbkdf2.js"></script>
|
<script src="../js/crypto/pbkdf2.js"></script>
|
||||||
<script src="../js/crypto/aes-cbc.js"></script>
|
<script src="../js/crypto/aes-cbc.js"></script>
|
||||||
<script src="../js/crypto/aes-ccm.js"></script>
|
|
||||||
<script src="../js/crypto/aes-gcm.js"></script>
|
|
||||||
<script src="../js/crypto/nacl-crypto.js"></script>
|
<script src="../js/crypto/nacl-crypto.js"></script>
|
||||||
<script src="../js/crypto/crypto.js"></script>
|
<script src="../js/crypto/crypto.js"></script>
|
||||||
|
|
||||||
@ -73,7 +57,6 @@
|
|||||||
<script src="forge-test.js"></script>
|
<script src="forge-test.js"></script>
|
||||||
<script src="aes-test.js"></script>
|
<script src="aes-test.js"></script>
|
||||||
<script src="nacl-crypto-test.js"></script>
|
<script src="nacl-crypto-test.js"></script>
|
||||||
<script src="ecc-test.js"></script>
|
|
||||||
<script src="crypto-test.js"></script>
|
<script src="crypto-test.js"></script>
|
||||||
<script src="localstorage-dao-test.js"></script>
|
<script src="localstorage-dao-test.js"></script>
|
||||||
<script src="lawnchair-dao-test.js"></script>
|
<script src="lawnchair-dao-test.js"></script>
|
||||||
|
Loading…
Reference in New Issue
Block a user