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

Abstract base class for the SHAKE Extendable-Output Functions (XOFs). More...

#include <SHAKE.h>

Inheritance diagram for SHAKE:
XOF SHAKE128 SHAKE256

Public Member Functions

virtual ~SHAKE ()
 Destroys this SHAKE object after clearing all sensitive information.
 
size_t blockSize () const
 Size of the internal block used by the XOF algorithm, in bytes. More...
 
void reset ()
 Resets the XOF ready for a new session. More...
 
void update (const void *data, size_t len)
 Updates the XOF with more data. More...
 
void extend (uint8_t *data, size_t len)
 Generates extendable output from this XOF. More...
 
void encrypt (uint8_t *output, const uint8_t *input, size_t len)
 Encrypts an input buffer with extendable output from this XOF. More...
 
void clear ()
 Clears the hash state, removing all sensitive data, and then resets the XOF ready for a new session. More...
 
- Public Member Functions inherited from XOF
 XOF ()
 Constructs a new XOF object.
 
virtual ~XOF ()
 Destroys this XOF object. More...
 
void decrypt (uint8_t *output, const uint8_t *input, size_t len)
 Decrypts an input buffer with extendable output from this XOF. More...
 

Protected Member Functions

 SHAKE (size_t capacity)
 Constructs a SHAKE object. More...
 

Detailed Description

Abstract base class for the SHAKE Extendable-Output Functions (XOFs).

Reference: http://en.wikipedia.org/wiki/SHA-3

See also
SHAKE256, SHAKE128, SHA3_256

Definition at line 29 of file SHAKE.h.

Constructor & Destructor Documentation

◆ SHAKE()

SHAKE::SHAKE ( size_t  capacity)
protected

Constructs a SHAKE object.

Parameters
capacityThe capacity of the Keccak sponge function in bits which should be a multiple of 64 and between 64 and 1536.

Definition at line 40 of file SHAKE.cpp.

Member Function Documentation

◆ blockSize()

size_t SHAKE::blockSize ( ) const
virtual

Size of the internal block used by the XOF algorithm, in bytes.

See also
update()

Implements XOF.

Definition at line 53 of file SHAKE.cpp.

◆ clear()

void SHAKE::clear ( )
virtual

Clears the hash state, removing all sensitive data, and then resets the XOF ready for a new session.

See also
reset()

Implements XOF.

Definition at line 89 of file SHAKE.cpp.

◆ encrypt()

void SHAKE::encrypt ( uint8_t *  output,
const uint8_t *  input,
size_t  len 
)
virtual

Encrypts an input buffer with extendable output from this XOF.

Parameters
outputThe output buffer to write to, which may be the same buffer as input. The output buffer must have at least as many bytes as the input buffer.
inputThe input buffer to read from.
lenThe number of bytes to encrypt.

This function is a convenience that generates data with extend() and then XOR's it with the contents of input to generate the output. This function can also be used to decrypt.

The encrypt() function can be called multiple times with different regions of the plaintext data.

See also
reset(), update(), extend(), decrypt()

Implements XOF.

Definition at line 80 of file SHAKE.cpp.

◆ extend()

void SHAKE::extend ( uint8_t *  data,
size_t  len 
)
virtual

Generates extendable output from this XOF.

Parameters
dataThe data buffer to be filled.
lenThe number of bytes to write to data.
See also
reset(), update(), encrypt()

Implements XOF.

Definition at line 71 of file SHAKE.cpp.

◆ reset()

void SHAKE::reset ( )
virtual

Resets the XOF ready for a new session.

See also
update(), extend(), encrypt()

Implements XOF.

Definition at line 58 of file SHAKE.cpp.

◆ update()

void SHAKE::update ( const void *  data,
size_t  len 
)
virtual

Updates the XOF with more data.

Parameters
dataData to be hashed.
lenNumber of bytes of data to be added to the XOF.

If extend() or encrypt() has already been called, then the behavior of update() will be undefined. Call reset() first to start a new session.

See also
reset(), extend(), encrypt()

Implements XOF.

Definition at line 64 of file SHAKE.cpp.


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