mirror of
https://github.com/moparisthebest/mail
synced 2025-02-07 10:30:18 -05:00
refactored crypto api to use forge cbc mode instead of sjcl
This commit is contained in:
parent
3e12c7eae6
commit
c89569fabd
@ -2,14 +2,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// import web worker dependencies
|
// import web worker dependencies
|
||||||
importScripts('../../lib/sjcl/sjcl.js');
|
importScripts('../../lib/forge/forge.rsa.bundle.js');
|
||||||
importScripts('../../lib/sjcl/bitArray.js');
|
|
||||||
importScripts('../../lib/sjcl/codecBase64.js');
|
|
||||||
importScripts('../../lib/sjcl/codecString.js');
|
|
||||||
importScripts('../../lib/sjcl/aes.js');
|
|
||||||
importScripts('../../lib/sjcl/ccm.js');
|
|
||||||
importScripts('../app-config.js');
|
importScripts('../app-config.js');
|
||||||
importScripts('./aes-ccm.js');
|
importScripts('./aes-cbc.js');
|
||||||
importScripts('./util.js');
|
importScripts('./util.js');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,7 +15,7 @@
|
|||||||
|
|
||||||
var args = e.data,
|
var args = e.data,
|
||||||
output = null,
|
output = null,
|
||||||
aes = new app.crypto.AesCCM(sjcl),
|
aes = new app.crypto.AesCBC(forge),
|
||||||
util = new app.crypto.Util(null, null);
|
util = new app.crypto.Util(null, null);
|
||||||
|
|
||||||
if (args.type === 'encrypt' && args.list) {
|
if (args.type === 'encrypt' && args.list) {
|
||||||
|
@ -2,14 +2,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// import web worker dependencies
|
// import web worker dependencies
|
||||||
importScripts('../../lib/sjcl/sjcl.js');
|
importScripts('../../lib/forge/forge.rsa.bundle.js');
|
||||||
importScripts('../../lib/sjcl/bitArray.js');
|
|
||||||
importScripts('../../lib/sjcl/codecBase64.js');
|
|
||||||
importScripts('../../lib/sjcl/codecString.js');
|
|
||||||
importScripts('../../lib/sjcl/aes.js');
|
|
||||||
importScripts('../../lib/sjcl/ccm.js');
|
|
||||||
importScripts('../app-config.js');
|
importScripts('../app-config.js');
|
||||||
importScripts('./aes-ccm.js');
|
importScripts('./aes-cbc.js');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In the web worker thread context, 'this' and 'self' can be used as a global
|
* In the web worker thread context, 'this' and 'self' can be used as a global
|
||||||
@ -19,7 +14,7 @@
|
|||||||
|
|
||||||
var args = e.data,
|
var args = e.data,
|
||||||
output = null,
|
output = null,
|
||||||
aes = new app.crypto.AesCCM(sjcl);
|
aes = new app.crypto.AesCBC(forge);
|
||||||
|
|
||||||
if (args.type === 'encrypt' && args.plaintext && args.key && args.iv) {
|
if (args.type === 'encrypt' && args.plaintext && args.key && args.iv) {
|
||||||
// start encryption
|
// start encryption
|
||||||
|
@ -7,7 +7,7 @@ app.crypto.Crypto = function(window, util) {
|
|||||||
|
|
||||||
var symmetricUserKey = null, // the user's secret key used to encrypt item-keys
|
var symmetricUserKey = null, // the user's secret key used to encrypt item-keys
|
||||||
keyId = null, // the key ID linking the user's key set
|
keyId = null, // the key ID linking the user's key set
|
||||||
aes = new app.crypto.AesCCM(sjcl); // use authenticated AES-CCM mode by default
|
aes = new app.crypto.AesCBC(forge); // use AES-CBC mode by default
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the crypto modules by fetching the user's
|
* Initializes the crypto modules by fetching the user's
|
||||||
|
@ -4,7 +4,7 @@ var crypto_test = {
|
|||||||
user: 'crypto_test@example.com',
|
user: 'crypto_test@example.com',
|
||||||
password: 'Password',
|
password: 'Password',
|
||||||
keySize: 128,
|
keySize: 128,
|
||||||
ivSize: 104
|
ivSize: 128
|
||||||
};
|
};
|
||||||
|
|
||||||
asyncTest("Init", 2, function() {
|
asyncTest("Init", 2, function() {
|
||||||
@ -54,7 +54,7 @@ asyncTest("En/Decrypt for User", 4, function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest("CCM mode (Async/Worker)", 2, function() {
|
asyncTest("AES (Async/Worker)", 2, function() {
|
||||||
var secret = 'Big secret';
|
var secret = 'Big secret';
|
||||||
|
|
||||||
var key = crypto_test.util.random(crypto_test.keySize);
|
var key = crypto_test.util.random(crypto_test.keySize);
|
||||||
@ -71,7 +71,7 @@ asyncTest("CCM mode (Async/Worker)", 2, function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest("CCM batch mode (Async/Worker)", 5, function() {
|
asyncTest("AES batch (Async/Worker)", 5, function() {
|
||||||
// generate test data
|
// generate test data
|
||||||
var collection, list, td = new TestData();
|
var collection, list, td = new TestData();
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ asyncTest("CCM batch mode (Async/Worker)", 5, function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest("CCM batch mode for User (Async/Worker)", 5, function() {
|
asyncTest("AES batch for User (Async/Worker)", 5, function() {
|
||||||
// generate test data
|
// generate test data
|
||||||
var collection, list, td = new TestData();
|
var collection, list, td = new TestData();
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ var emaildao_test = {
|
|||||||
user: 'test@atlasdev.onmicrosoft.com',
|
user: 'test@atlasdev.onmicrosoft.com',
|
||||||
password: 'Xoza76645',
|
password: 'Xoza76645',
|
||||||
keySize: 128,
|
keySize: 128,
|
||||||
ivSize: 104
|
ivSize: 128
|
||||||
};
|
};
|
||||||
|
|
||||||
asyncTest("Init", 2, function() {
|
asyncTest("Init", 2, function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user