Skinny-C
 All Data Structures Files Functions Variables Groups Pages
Public Member Functions
Mantis8 Class Reference

Mantis-8 tweakable block cipher. More...

#include <Mantis8.h>

Inheritance diagram for Mantis8:
BlockCipher

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...
 

Detailed Description

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/

See Also
Skinny64, Skinny128

Definition at line 28 of file Mantis8.h.

Member Function Documentation

size_t Mantis8::blockSize ( ) const
virtual

Size of a Mantis-8 block in bytes.

Returns
Always returns 8.

Implements BlockCipher.

Definition at line 117 of file Mantis8.cpp.

void Mantis8::clear ( )
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.

See Also
setKey(), encryptBlock(), decryptBlock()

Implements BlockCipher.

Definition at line 1209 of file Mantis8.cpp.

void Mantis8::decryptBlock ( uint8_t *  output,
const uint8_t *  input 
)
virtual

Decrypts a single block using this cipher.

Parameters
outputThe output buffer to put the plaintext into. Must be at least blockSize() bytes in length.
inputThe input buffer to read the ciphertext from which is allowed to overlap with output. Must be at least blockSize() bytes in length.
See Also
encryptBlock(), blockSize()

Implements BlockCipher.

Definition at line 1202 of file Mantis8.cpp.

void Mantis8::encryptBlock ( uint8_t *  output,
const uint8_t *  input 
)
virtual

Encrypts a single block using this cipher.

Parameters
outputThe output buffer to put the ciphertext into. Must be at least blockSize() bytes in length.
inputThe input buffer to read the plaintext from which is allowed to overlap with output. Must be at least blockSize() bytes in length.
See Also
decryptBlock(), blockSize()

Implements BlockCipher.

Definition at line 608 of file Mantis8.cpp.

size_t Mantis8::keySize ( ) const
virtual

Size of a Mantis-8 key in bytes.

Returns
Always returns 16.

Implements BlockCipher.

Definition at line 126 of file Mantis8.cpp.

bool Mantis8::setKey ( const uint8_t *  key,
size_t  len 
)
virtual

Sets the key to use for future encryption and decryption operations.

Parameters
keyThe key to use.
lenThe length of the key.
Returns
Returns false if the key length is not supported, or the key is somehow "weak" and unusable by this cipher.

Use clear() or the destructor to remove the key and any other sensitive data from the object once encryption or decryption is complete.

See Also
keySize(), clear()

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.

Parameters
tweakPoints to the tweak, and can be NULL if you want a tweak of all-zeroes (the default).
lenLength of tweak in bytes, which must be 8.
Returns
Returns true if the tweak was set or false if len is incorrect.

This function must be called after setKey() as the setKey() call will implicitly set the tweak back to all-zeroes.

See Also
setKey()

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.


The documentation for this class was generated from the following files: