Skip to content
This repository has been archived by the owner on Jul 10, 2019. It is now read-only.

Commit

Permalink
add key to signature
Browse files Browse the repository at this point in the history
  • Loading branch information
Tankred Hase committed Sep 16, 2013
1 parent 4d58e37 commit bf67dad
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/crypto-batch.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
throw new Error('Arguments missing!');
}

// encrypt a list of items
self.encryptList(list);

// set sender private key
self._rsa.init(null, senderPrivkey.privateKey);

// encrypt a list of items
self.encryptList(list);

list.forEach(function(i) {
// fetch correct public key for encryption
receiverPk = null;
Expand Down Expand Up @@ -71,7 +71,7 @@
// set sender's keypair id for later verification
i.senderPk = senderKeyId;
// 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 i.key;
Expand Down Expand Up @@ -155,12 +155,13 @@
// set rsa public key used to verify
self._rsa.init(senderPubkey);

// decrypt symmetric item key for user
i.key = self._rsa.decrypt(i.encryptedKey);

// verify signature
if (!self._rsa.verify([i.iv, i.ciphertext], i.signature)) {
if (!self._rsa.verify([i.iv, i.key, i.ciphertext], i.signature)) {
throw new Error('Verifying RSA signature failed!');
}
// decrypt symmetric item key for user
i.key = self._rsa.decrypt(i.encryptedKey);

// delete ciphertext values
delete i.signature;
Expand Down

0 comments on commit bf67dad

Please sign in to comment.