You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
617 B
35 lines
617 B
/*!
|
|
* Crypto-JS v1.1.0
|
|
* http://code.google.com/p/crypto-js/
|
|
* Copyright (c) 2009, Jeff Mott. All rights reserved.
|
|
* http://code.google.com/p/crypto-js/wiki/License
|
|
*/
|
|
(function(){
|
|
|
|
// Public API
|
|
Crypto.mode.OFB = {
|
|
encrypt: OFB,
|
|
decrypt: OFB
|
|
};
|
|
|
|
// The mode function
|
|
function OFB(cipher, m, iv) {
|
|
|
|
var blockSizeInBytes = cipher._blocksize * 4,
|
|
keystream = iv.slice(0);
|
|
|
|
// Encrypt each byte
|
|
for (var i = 0; i < m.length; i++) {
|
|
|
|
// Generate keystream
|
|
if (i % blockSizeInBytes == 0)
|
|
cipher._encryptblock(keystream, 0);
|
|
|
|
// Encrypt byte
|
|
m[i] ^= keystream[i % blockSizeInBytes];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})();
|
|
|