Mantis-8 tweakable block cipher. More...
#include <Mantis8.h>
Public Member Functions | |
Mantis8 () | |
Constructs a new Mantis-8 tweakable block cipher instance. | |
virtual | ~Mantis8 () |
Destroys this Mantis-8 block cipher object after clearing sensitive information. | |
size_t | blockSize () const |
Size of a Mantis-8 block in bytes. More... | |
size_t | keySize () const |
Size of a Mantis-8 key in bytes. More... | |
bool | setKey (const uint8_t *key, size_t len) |
Sets the key to use for future encryption and decryption operations. More... | |
bool | setTweak (const uint8_t *tweak, size_t len) |
Sets the 64-bit tweak value for this Mantis-8 block cipher. More... | |
void | swapModes () |
Swaps the encryption/decryption mode for this Mantis block cipher. More... | |
void | encryptBlock (uint8_t *output, const uint8_t *input) |
Encrypts a single block using this cipher. More... | |
void | decryptBlock (uint8_t *output, const uint8_t *input) |
Decrypts a single block using this cipher. More... | |
void | clear () |
Clears all security-sensitive state from this block cipher. More... | |
Public Member Functions inherited from BlockCipher | |
BlockCipher () | |
Constructs a block cipher. | |
virtual | ~BlockCipher () |
Destroys this block cipher object. More... | |
Mantis-8 tweakable block cipher.
Mantis is a tweakable block cipher with 64-bit blocks, a 128-bit key, and a 64-bit tweak. It is a variant of SKINNY that is designed for memory encryption. Typically, memory is encrypted in 8-byte blocks in ECB mode with the memory address of each block supplied to the cipher as the tweak.
Mantis comes in variants with round counts between 5 and 8. The authors advise that there is a known efficient attack against Mantis-5. They recommend using at least Mantis-7. In this implementation we only support Mantis-8. For a larger security margin, use Skinny64 or Skinny128 instead.
In Mantis, ECB encryption and decryption are identical operations. The initial mode is set to encryption by setKey() and can then be switched to decryption by calling swapModes(). The application can continue to swap back and forth between encryption and decryption as needed.
Reference: https://sites.google.com/site/skinnycipher/
|
virtual |
Size of a Mantis-8 block in bytes.
Implements BlockCipher.
Definition at line 117 of file Mantis8.cpp.
|
virtual |
Clears all security-sensitive state from this block cipher.
Security-sensitive information includes key schedules and any temporary state that is used by encryptBlock() or decryptBlock() which is stored in the object itself.
Implements BlockCipher.
Definition at line 1209 of file Mantis8.cpp.
|
virtual |
Decrypts a single block using this cipher.
output | The output buffer to put the plaintext into. Must be at least blockSize() bytes in length. |
input | The input buffer to read the ciphertext from which is allowed to overlap with output. Must be at least blockSize() bytes in length. |
Implements BlockCipher.
Definition at line 1202 of file Mantis8.cpp.
|
virtual |
Encrypts a single block using this cipher.
output | The output buffer to put the ciphertext into. Must be at least blockSize() bytes in length. |
input | The input buffer to read the plaintext from which is allowed to overlap with output. Must be at least blockSize() bytes in length. |
Implements BlockCipher.
Definition at line 608 of file Mantis8.cpp.
|
virtual |
Size of a Mantis-8 key in bytes.
Implements BlockCipher.
Definition at line 126 of file Mantis8.cpp.
|
virtual |
Sets the key to use for future encryption and decryption operations.
key | The key to use. |
len | The length of the key. |
Use clear() or the destructor to remove the key and any other sensitive data from the object once encryption or decryption is complete.
Implements BlockCipher.
Definition at line 163 of file Mantis8.cpp.
bool Mantis8::setTweak | ( | const uint8_t * | tweak, |
size_t | len | ||
) |
Sets the 64-bit tweak value for this Mantis-8 block cipher.
tweak | Points to the tweak, and can be NULL if you want a tweak of all-zeroes (the default). |
len | Length of tweak in bytes, which must be 8. |
This function must be called after setKey() as the setKey() call will implicitly set the tweak back to all-zeroes.
Definition at line 266 of file Mantis8.cpp.
void Mantis8::swapModes | ( | ) |
Swaps the encryption/decryption mode for this Mantis block cipher.
When setKey() is called, the object is set up for encryption and calls on either encryptBlock() or decryptBlock() will encrypt. To decrypt it is necessary to call swapModes() after setKey().
Definition at line 322 of file Mantis8.cpp.