1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-23 09:22:23 -05:00

integrate crypto lib update

This commit is contained in:
Tankred Hase 2013-09-16 14:53:48 +02:00
parent d02f61b4a8
commit ac7329fcfa

View File

@ -30,12 +30,12 @@
throw new Error('Arguments missing!'); throw new Error('Arguments missing!');
} }
// encrypt a list of items
self.encryptList(list);
// set sender private key // set sender private key
self._rsa.init(null, senderPrivkey.privateKey); self._rsa.init(null, senderPrivkey.privateKey);
// encrypt a list of items
self.encryptList(list);
list.forEach(function(i) { list.forEach(function(i) {
// fetch correct public key for encryption // fetch correct public key for encryption
receiverPk = null; receiverPk = null;
@ -71,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, i.ciphertext]); i.signature = self._rsa.sign([i.iv, i.key, i.ciphertext]);
// delete plaintext values // delete plaintext values
delete i.key; delete i.key;
@ -155,13 +155,14 @@
// set rsa public key used to verify // set rsa public key used to verify
self._rsa.init(senderPubkey); self._rsa.init(senderPubkey);
// verify signature
if (!self._rsa.verify([i.iv, i.ciphertext], i.signature)) {
throw new Error('Verifying RSA signature failed!');
}
// decrypt symmetric item key for user // decrypt symmetric item key for user
i.key = self._rsa.decrypt(i.encryptedKey); i.key = self._rsa.decrypt(i.encryptedKey);
// verify signature
if (!self._rsa.verify([i.iv, i.key, i.ciphertext], i.signature)) {
throw new Error('Verifying RSA signature failed!');
}
// delete ciphertext values // delete ciphertext values
delete i.signature; delete i.signature;
delete i.encryptedKey; delete i.encryptedKey;