64     return blockCipher1->
keySize() * 2;
 
  121     if (!blockCipher1->
setKey(key, len / 2))
 
  123     return blockCipher2->
setKey(key + len / 2, len - (len / 2));
 
  146     memcpy(twk, tweak, len);
 
  147     memset(((uint8_t *)twk) + len, 0, 16 - len);
 
  148     blockCipher2->
encryptBlock((uint8_t *)twk, (uint8_t *)twk);
 
  152 #define xorTweak(output, input, tweak) \ 
  154         for (uint8_t i = 0; i < 16; ++i) \ 
  155             (output)[i] = (input)[i] ^ ((const uint8_t *)(tweak))[i]; \ 
  172     size_t sectLast = sectSize & ~15;
 
  175     memcpy(t, twk, 
sizeof(t));
 
  176     while (posn < sectLast) {
 
  178         xorTweak(output, input, t);
 
  180         xorTweak(output, output, t);
 
  186     if (posn < sectSize) {
 
  188         uint8_t leftOver = sectSize - posn;
 
  190         while (leftOver > 0) {
 
  193             uint8_t temp = input[leftOver];
 
  194             output[leftOver + 16] = output[leftOver];
 
  195             output[leftOver] = temp;
 
  197         xorTweak(output, output, t);
 
  199         xorTweak(output, output, t);
 
  217     size_t sectLast = sectSize & ~15;
 
  220     memcpy(t, twk, 
sizeof(t));
 
  221     if (sectLast != sectSize)
 
  223     while (posn < sectLast) {
 
  225         xorTweak(output, input, t);
 
  227         xorTweak(output, output, t);
 
  233     if (posn < sectSize) {
 
  235         uint8_t leftOver = sectSize - 16 - posn;
 
  242         memcpy(u, t, 
sizeof(t));
 
  244         xorTweak(output, input, t);
 
  246         xorTweak(output, output, t);
 
  249         while (leftOver > 0) {
 
  251             uint8_t temp = input[leftOver + 16];
 
  252             output[leftOver + 16] = output[leftOver];
 
  253             output[leftOver] = temp;
 
  257         xorTweak(output, output, u);
 
  259         xorTweak(output, output, u);
 
  269     blockCipher1->
clear();
 
  270     blockCipher2->
clear();
 
  317     return blockCipher1->keySize();
 
  336     return blockCipher1->setKey(key, len);
 
virtual void clear()=0
Clears all security-sensitive state from this block cipher.
virtual bool setKey(const uint8_t *key, size_t len)=0
Sets the key to use for future encryption and decryption operations.
virtual void decryptBlock(uint8_t *output, const uint8_t *input)=0
Decrypts a single block using this cipher.
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.
static void dblXTS(uint32_t V[4])
Doubles a value in the GF(2^128) field using XTS conventions.
size_t tweakSize() const
Gets the maximum supported size for the tweak.
virtual size_t keySize() const
Gets the size of the key for XTS mode.
virtual bool setKey(const uint8_t *key, size_t len)
Sets the key to use for XTS mode.
bool setTweak(const uint8_t *tweak, size_t len)
Sets the tweak value for the current sector to encrypt or decrypt.
void decryptSector(uint8_t *output, const uint8_t *input)
Decrypts an entire sector of data.
bool setSectorSize(size_t size)
Sets the size of sectors encrypted or decrypted by this class.
void encryptSector(uint8_t *output, const uint8_t *input)
Encrypts an entire sector of data.
void clear()
Clears all security-sensitive state from this XTS object.
virtual ~XTSCommon()
Clears all sensitive information and destroys this object.
XTSCommon()
Constructs an XTS object with a default sector size of 512 bytes.
virtual ~XTSSingleKeyCommon()
Clears all sensitive information and destroys this object.
size_t keySize() const
Gets the size of the key for single-pkey XTS mode.
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for single-keyh XTS mode.