Skip to content

Commit

Permalink
Add explanation of ECB simulation with CBC
Browse files Browse the repository at this point in the history
  • Loading branch information
Strikeskids committed Mar 19, 2016
1 parent ac739bf commit 4a5b1bc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/crypto/key-encryptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ var maxRoundsPreIteration = 10000;
var aesBlockSize = 16;
var credentialSize = 32;

/*
In order to simulate multiple rounds of ECB encryption, we do CBC encryption
across a zero buffer of large length with the IV being the desired plaintext.
The zero buffer does not contribute to the xor, so xoring the previous block
with the next one simulates running ECB multiple times. We limit the maximum
size of the zero buffer to prevent enormous memory usage.
*/

function encrypt(credentials, key, rounds, callback) {
if (!subtle) {
fallbackEncrypt(credentials, key, rounds, callback);
Expand Down

0 comments on commit 4a5b1bc

Please sign in to comment.