49 CTRCommon::~CTRCommon()
88 if (size < 1 || size > 16)
90 counterStart = 16 - size;
101 return blockCipher->
setKey(key, len);
123 memcpy(counter, iv, len);
142 while (index > counterStart) {
144 temp += counter[index];
145 counter[index] = (uint8_t)temp;
149 uint8_t templen = 16 - posn;
153 while (templen > 0) {
154 *output++ = *input++ ^ state[posn++];
167 blockCipher->
clear();
virtual void clear()=0
Clears all security-sensitive state from this block cipher.
virtual size_t blockSize() const =0
Size of a single block processed by this cipher, in bytes.
virtual bool setKey(const uint8_t *key, size_t len)=0
Sets the key to use for future encryption and decryption operations.
virtual void encryptBlock(uint8_t *output, const uint8_t *input)=0
Encrypts a single block using this cipher.
virtual size_t keySize() const =0
Default size of the key for this block cipher, in bytes.
void decrypt(uint8_t *output, const uint8_t *input, size_t len)
Decrypts an input buffer and writes the plaintext to an output buffer.
void encrypt(uint8_t *output, const uint8_t *input, size_t len)
Encrypts an input buffer and writes the ciphertext to an output buffer.
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
bool setIV(const uint8_t *iv, size_t len)
Sets the initial counter value to use for future encryption and decryption operations.
CTRCommon()
Constructs a new cipher in CTR mode.
void clear()
Clears all security-sensitive state from this cipher.
bool setCounterSize(size_t size)
Sets the counter size for the IV.
size_t ivSize() const
Size of the initialization vector for this cipher, in bytes.
size_t keySize() const
Default size of the key for this cipher, in bytes.