11CipherBlockChain::CipherBlockChain(BlockCipher *cipher) : _cipher(cipher)
16 _reader = _writer = 0L;
18 _blksz = cipher->blockSize();
22CipherBlockChain::~CipherBlockChain()
24 delete[](
char *)_register;
26 delete[](
char *)_next;
30bool CipherBlockChain::setKey(
void *key,
int bitlength)
33 return _cipher->setKey(key, bitlength);
38int CipherBlockChain::keyLen()
const
41 return _cipher->keyLen();
46bool CipherBlockChain::variableKeyLen()
const
49 return _cipher->variableKeyLen();
54bool CipherBlockChain::readyToGo()
const
57 return _cipher->readyToGo();
62int CipherBlockChain::encrypt(
void *block,
int len)
64 if (_cipher && !_reader) {
70 _register =
new unsigned char[len];
72 memset(_register, 0, len);
73 }
else if (len > _len) {
78 char *tb = (
char *)block;
79 for (
int i = 0; i < len; i++) {
80 tb[i] ^= ((
char *)_register)[i];
83 rc = _cipher->encrypt(block, len);
86 memcpy(_register, block, len);
94int CipherBlockChain::decrypt(
void *block,
int len)
96 if (_cipher && !_writer) {
102 _register =
new unsigned char[len];
104 memset(_register, 0, len);
105 }
else if (len > _len) {
110 _next =
new unsigned char[_len];
112 memcpy(_next, block, _len);
114 rc = _cipher->decrypt(block, len);
118 char *tb = (
char *)block;
119 for (
int i = 0; i < len; i++) {
120 tb[i] ^= ((
char *)_register)[i];
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:06 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.