Arduino Cryptography Library
|
Concrete base class to assist with implementing XTS mode for 128-bit block ciphers. More...
#include <XTS.h>
Public Member Functions | |
virtual | ~XTSCommon () |
Clears all sensitive information and destroys this object. | |
virtual size_t | keySize () const |
Gets the size of the key for XTS mode. More... | |
size_t | tweakSize () const |
Gets the maximum supported size for the tweak. More... | |
size_t | sectorSize () const |
Gets the size of sectors encrypted or decrypted by this class. More... | |
bool | setSectorSize (size_t size) |
Sets the size of sectors encrypted or decrypted by this class. More... | |
virtual bool | setKey (const uint8_t *key, size_t len) |
Sets the key to use for XTS mode. More... | |
bool | setTweak (const uint8_t *tweak, size_t len) |
Sets the tweak value for the current sector to encrypt or decrypt. More... | |
void | encryptSector (uint8_t *output, const uint8_t *input) |
Encrypts an entire sector of data. More... | |
void | decryptSector (uint8_t *output, const uint8_t *input) |
Decrypts an entire sector of data. More... | |
void | clear () |
Clears all security-sensitive state from this XTS object. | |
Protected Member Functions | |
XTSCommon () | |
Constructs an XTS object with a default sector size of 512 bytes. | |
void | setBlockCiphers (BlockCipher *cipher1, BlockCipher *cipher2) |
Sets the two block ciphers to use for XTS mode. More... | |
Friends | |
class | XTSSingleKeyCommon |
Concrete base class to assist with implementing XTS mode for 128-bit block ciphers.
References: IEEE Std. 1619-2007, NIST SP 800-38E, a href="http://web.cs.ucdavis.edu/~rogaway/papers/offsets.pdf">XEX.
void XTSCommon::decryptSector | ( | uint8_t * | output, |
const uint8_t * | input | ||
) |
Decrypts an entire sector of data.
output | The output buffer to write the plaintext to, which can be the same as input. |
input | The input buffer to read the ciphertext from. |
The input and output buffers must be at least sectorSize() bytes in length.
void XTSCommon::encryptSector | ( | uint8_t * | output, |
const uint8_t * | input | ||
) |
Encrypts an entire sector of data.
output | The output buffer to write the ciphertext to, which can be the same as input. |
input | The input buffer to read the plaintext from. |
The input and output buffers must be at least sectorSize() bytes in length.
|
virtual |
Gets the size of the key for XTS mode.
The key size for XTS mode is twice the size of the underlying block cipher key size.
Reimplemented in XTSSingleKeyCommon.
|
inline |
Gets the size of sectors encrypted or decrypted by this class.
The default value is 512 bytes.
|
inlineprotected |
Sets the two block ciphers to use for XTS mode.
cipher1 | Points to the first block cipher object, which must be capable of both encryption and decryption. |
cipher2 | Points to the second block cipher object, which must be capable of both encryption but does not need to be capable of decryption. |
Both block ciphers must have a 128-bit block size.
|
virtual |
Sets the key to use for XTS mode.
key | Points to the key. |
len | The size of the key in bytes which must be twice the size of the underlying block cipher's key size. |
This function should be followed by a call to setTweak() to specify the sector-specific tweak.
Reimplemented in XTSSingleKeyCommon.
bool XTSCommon::setSectorSize | ( | size_t | size | ) |
Sets the size of sectors encrypted or decrypted by this class.
size | The sector size in bytes, which must be greater than or equal to 16. |
bool XTSCommon::setTweak | ( | const uint8_t * | tweak, |
size_t | len | ||
) |
Sets the tweak value for the current sector to encrypt or decrypt.
tweak | Points to the tweak. |
len | The length of the tweak which must be less than or equal to 16. |
If len is less than 16, then the tweak will be zero-padded to 16 bytes.
The tweak is encrypted with the second half of the XTS key to generate the actual tweak value for the sector.
size_t XTSCommon::tweakSize | ( | ) | const |
Gets the maximum supported size for the tweak.
This function returns 16, which indicates that any tweak up to 16 bytes in size can be specified via setTweak().