corrade-nucleus-nucleons – Blame information for rev 2

Subversion Repositories:
Rev:
Rev Author Line No. Line
2 office 1 /*
2 CryptoJS v3.1.2
3 code.google.com/p/crypto-js
4 (c) 2009-2013 by Jeff Mott. All rights reserved.
5 code.google.com/p/crypto-js/wiki/License
6 */
7 /**
8 * Cipher Feedback block mode.
9 */
10 CryptoJS.mode.CFB = (function () {
11 var CFB = CryptoJS.lib.BlockCipherMode.extend();
12  
13 CFB.Encryptor = CFB.extend({
14 processBlock: function (words, offset) {
15 // Shortcuts
16 var cipher = this._cipher;
17 var blockSize = cipher.blockSize;
18  
19 generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
20  
21 // Remember this block to use with next block
22 this._prevBlock = words.slice(offset, offset + blockSize);
23 }
24 });
25  
26 CFB.Decryptor = CFB.extend({
27 processBlock: function (words, offset) {
28 // Shortcuts
29 var cipher = this._cipher;
30 var blockSize = cipher.blockSize;
31  
32 // Remember this block to use with next block
33 var thisBlock = words.slice(offset, offset + blockSize);
34  
35 generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
36  
37 // This block becomes the previous block
38 this._prevBlock = thisBlock;
39 }
40 });
41  
42 function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
43 // Shortcut
44 var iv = this._iv;
45  
46 // Generate keystream
47 if (iv) {
48 var keystream = iv.slice(0);
49  
50 // Remove IV for subsequent blocks
51 this._iv = undefined;
52 } else {
53 var keystream = this._prevBlock;
54 }
55 cipher.encryptBlock(keystream, 0);
56  
57 // Encrypt
58 for (var i = 0; i < blockSize; i++) {
59 words[offset + i] ^= keystream[i];
60 }
61 }
62  
63 return CFB;
64 }());