mirror of
https://github.com/moparisthebest/mail
synced 2024-12-24 00:08:48 -05:00
integrate crypto lub patches
This commit is contained in:
parent
7f128448cc
commit
4ad311929b
@ -31,7 +31,7 @@ define(function(require) {
|
|||||||
window.open(url, 'Compose Message', 'toolbar=no,width=800,height=700,left=500,top=200,status=no,scrollbars=no,resize=no');
|
window.open(url, 'Compose Message', 'toolbar=no,width=800,height=700,left=500,top=200,status=no,scrollbars=no,resize=no');
|
||||||
};
|
};
|
||||||
|
|
||||||
if (false) {
|
if (window.chrome && chrome.identity) {
|
||||||
fetchList(function(emails) {
|
fetchList(function(emails) {
|
||||||
$scope.emails = emails;
|
$scope.emails = emails;
|
||||||
$scope.select($scope.emails[0]);
|
$scope.select($scope.emails[0]);
|
||||||
|
@ -25,6 +25,11 @@
|
|||||||
var receiverPk,
|
var receiverPk,
|
||||||
self = this;
|
self = this;
|
||||||
|
|
||||||
|
// validate presence of args
|
||||||
|
if (!list || !receiverPubkeys || !senderPrivkey || !senderPrivkey._id || !senderPrivkey.privateKey) {
|
||||||
|
throw new Error('Arguments missing!');
|
||||||
|
}
|
||||||
|
|
||||||
// encrypt a list of items
|
// encrypt a list of items
|
||||||
self.encryptList(list);
|
self.encryptList(list);
|
||||||
|
|
||||||
@ -38,6 +43,11 @@
|
|||||||
_id: i.receiverPk
|
_id: i.receiverPk
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// validate presence of args
|
||||||
|
if (!receiverPk || !receiverPk.publicKey || !i.key || !i.iv || !i.ciphertext) {
|
||||||
|
throw new Error('Arguments missing!');
|
||||||
|
}
|
||||||
|
|
||||||
// encrypt item for user
|
// encrypt item for user
|
||||||
self.encryptItemKeyForUser(i, receiverPk.publicKey, senderPrivkey._id);
|
self.encryptItemKeyForUser(i, receiverPk.publicKey, senderPrivkey._id);
|
||||||
});
|
});
|
||||||
@ -61,7 +71,7 @@
|
|||||||
// set sender's keypair id for later verification
|
// set sender's keypair id for later verification
|
||||||
i.senderPk = senderKeyId;
|
i.senderPk = senderKeyId;
|
||||||
// sign the bundle
|
// sign the bundle
|
||||||
i.signature = self._rsa.sign([i.iv, self._util.str2Base64(i.senderPk), i.encryptedKey, i.ciphertext]);
|
i.signature = self._rsa.sign([i.iv, i.ciphertext]);
|
||||||
|
|
||||||
// delete plaintext values
|
// delete plaintext values
|
||||||
delete i.key;
|
delete i.key;
|
||||||
@ -83,6 +93,11 @@
|
|||||||
CryptoBatch.prototype.decryptListForUser = function(list, senderPubkeys, receiverPrivkey) {
|
CryptoBatch.prototype.decryptListForUser = function(list, senderPubkeys, receiverPrivkey) {
|
||||||
var j;
|
var j;
|
||||||
|
|
||||||
|
// validate presence of args
|
||||||
|
if (!list || !senderPubkeys || !receiverPrivkey || !receiverPrivkey._id || !receiverPrivkey.privateKey) {
|
||||||
|
throw new Error('Arguments missing!');
|
||||||
|
}
|
||||||
|
|
||||||
// verify and decrypt a list of items using RSA
|
// verify and decrypt a list of items using RSA
|
||||||
this.decryptListKeysForUser(list, senderPubkeys, receiverPrivkey);
|
this.decryptListKeysForUser(list, senderPubkeys, receiverPrivkey);
|
||||||
|
|
||||||
@ -117,6 +132,11 @@
|
|||||||
_id: i.senderPk
|
_id: i.senderPk
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// validate presence of args
|
||||||
|
if (!senderPk || !senderPk.publicKey || !i.encryptedKey || !i.iv || !i.ciphertext) {
|
||||||
|
throw new Error('Arguments missing!');
|
||||||
|
}
|
||||||
|
|
||||||
// decrypt item for user
|
// decrypt item for user
|
||||||
self.decryptItemKeyForUser(i, senderPk.publicKey);
|
self.decryptItemKeyForUser(i, senderPk.publicKey);
|
||||||
});
|
});
|
||||||
@ -136,7 +156,7 @@
|
|||||||
self._rsa.init(senderPubkey);
|
self._rsa.init(senderPubkey);
|
||||||
|
|
||||||
// verify signature
|
// verify signature
|
||||||
if (!self._rsa.verify([i.iv, self._util.str2Base64(i.senderPk), i.encryptedKey, i.ciphertext], i.signature)) {
|
if (!self._rsa.verify([i.iv, i.ciphertext], i.signature)) {
|
||||||
throw new Error('Verifying RSA signature failed!');
|
throw new Error('Verifying RSA signature failed!');
|
||||||
}
|
}
|
||||||
// decrypt symmetric item key for user
|
// decrypt symmetric item key for user
|
||||||
|
Loading…
Reference in New Issue
Block a user