first
This commit is contained in:
36
node_modules/crypto-es/lib/mode-ofb.js
generated
vendored
Normal file
36
node_modules/crypto-es/lib/mode-ofb.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
import {
|
||||
BlockCipherMode,
|
||||
} from './cipher-core.js';
|
||||
|
||||
/**
|
||||
* Output Feedback block mode.
|
||||
*/
|
||||
export class OFB extends BlockCipherMode {
|
||||
}
|
||||
OFB.Encryptor = class extends OFB {
|
||||
processBlock(words, offset) {
|
||||
const _words = words;
|
||||
|
||||
// Shortcuts
|
||||
const cipher = this._cipher;
|
||||
const { blockSize } = cipher;
|
||||
const iv = this._iv;
|
||||
let keystream = this._keystream;
|
||||
|
||||
// Generate keystream
|
||||
if (iv) {
|
||||
this._keystream = iv.slice(0);
|
||||
keystream = this._keystream;
|
||||
|
||||
// Remove IV for subsequent blocks
|
||||
this._iv = undefined;
|
||||
}
|
||||
cipher.encryptBlock(keystream, 0);
|
||||
|
||||
// Encrypt
|
||||
for (let i = 0; i < blockSize; i += 1) {
|
||||
_words[offset + i] ^= keystream[i];
|
||||
}
|
||||
}
|
||||
};
|
||||
OFB.Decryptor = OFB.Encryptor;
|
||||
Reference in New Issue
Block a user