Arduino Cryptography Library
Public Member Functions | List of all members
Speck Class Reference

Speck block cipher with a 128-bit block size. More...

#include <Speck.h>

Inheritance diagram for Speck:
BlockCipher

Public Member Functions

 Speck ()
 Constructs a Speck block cipher with no initial key. More...
 
size_t blockSize () const
 Size of a single block processed by this cipher, in bytes. More...
 
size_t keySize () const
 Default size of the key for this block cipher, in bytes. More...
 
bool setKey (const uint8_t *key, size_t len)
 Sets the key to use for future encryption and decryption operations. 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

Speck block cipher with a 128-bit block size.

Speck is a family of lightweight block ciphers designed by the National Security Agency (NSA). The ciphers are highly optimized for software implementation on microcontrollers.

This class implements the Speck family that uses 128-bit block sizes with 128-bit, 192-bit, or 256-bit key sizes. Other Speck families support smaller block sizes of 32, 48, 64, or 96 bits but such block sizes are too small for use in modern cryptosystems.

Note
Current crytoanalysis (up until 2015) has not revealed any obvious weaknesses in the full-round version of Speck. But if you are wary of ciphers designed by the NSA, then use ChaCha or AES instead.

The SpeckTiny and SpeckSmall classes provide alternative implementations that have reduced RAM and flash size requirements at the cost of some features and performance.

References: https://en.wikipedia.org/wiki/Speck_%28cipher%29, http://eprint.iacr.org/2013/404

See also
SpeckTiny, SpeckSmall

Definition at line 28 of file Speck.h.

Constructor & Destructor Documentation

◆ Speck()

Speck::Speck ( )

Constructs a Speck block cipher with no initial key.

This constructor must be followed by a call to setKey() before the block cipher can be used for encryption or decryption.

Definition at line 72 of file Speck.cpp.

Member Function Documentation

◆ blockSize()

size_t Speck::blockSize ( ) const
virtual

Size of a single block processed by this cipher, in bytes.

Returns
Returns the size of a block in bytes.
See also
keySize(), encryptBlock()

Implements BlockCipher.

Definition at line 82 of file Speck.cpp.

◆ clear()

void Speck::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 550 of file Speck.cpp.

◆ decryptBlock()

void Speck::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 425 of file Speck.cpp.

◆ encryptBlock()

void Speck::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 303 of file Speck.cpp.

◆ keySize()

size_t Speck::keySize ( ) const
virtual

Default size of the key for this block cipher, in bytes.

This value indicates the default, or recommended, size for the key.

See also
setKey(), blockSize()

Implements BlockCipher.

Definition at line 87 of file Speck.cpp.

◆ setKey()

bool Speck::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 105 of file Speck.cpp.


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