Arduino Cryptography Library
|
Poly1305 message authenticator. More...
#include <Poly1305.h>
Public Member Functions | |
Poly1305 () | |
Constructs a new Poly1305 message authenticator. | |
~Poly1305 () | |
Destroys this Poly1305 message authenticator after clearing all sensitive information. | |
void | reset (const void *key) |
Resets the Poly1305 message authenticator for a new session. More... | |
void | update (const void *data, size_t len) |
Updates the message authenticator with more data. More... | |
void | finalize (const void *nonce, void *token, size_t len) |
Finalizes the authentication process and returns the token. More... | |
void | pad () |
Pads the input stream with zero bytes to a multiple of 16. More... | |
void | clear () |
Clears the authenticator's state, removing all sensitive data. | |
Poly1305 message authenticator.
Poly1305 is a message authenticator designed by Daniel J. Bernstein. An arbitrary-length message is broken up into 16-byte chunks and fed into a polynomial mod 2130 - 5 based on the 16-byte authentication key. The final polynomial value is then combined with a 16-byte nonce to create the authentication token.
The following example demonstrates how to compute an authentication token for a message made up of several blocks under a specific key and nonce:
In the original Poly1305 specification, the nonce was encrypted with AES and a second 16-byte key. Since then, common practice has been for the caller to encrypt the nonce which gives the caller more flexibility as to how to derive and/or encrypt the nonce.
References: http://en.wikipedia.org/wiki/Poly1305-AES, http://cr.yp.to/mac.html
Definition at line 29 of file Poly1305.h.
void Poly1305::finalize | ( | const void * | nonce, |
void * | token, | ||
size_t | len | ||
) |
Finalizes the authentication process and returns the token.
nonce | Points to the 16-byte nonce to combine with the token. |
token | The buffer to return the token value in. |
len | The length of the token buffer between 0 and 16. |
If len is less than 16, then the token value will be truncated to the first len bytes. If len is greater than 16, then the remaining bytes will left unchanged.
If finalize() is called again, then the returned token value is undefined. Call reset() first to start a new authentication process.
Definition at line 182 of file Poly1305.cpp.
void Poly1305::pad | ( | ) |
Pads the input stream with zero bytes to a multiple of 16.
Definition at line 254 of file Poly1305.cpp.
void Poly1305::reset | ( | const void * | key | ) |
Resets the Poly1305 message authenticator for a new session.
key | Points to the 16 byte authentication key. |
Definition at line 113 of file Poly1305.cpp.
void Poly1305::update | ( | const void * | data, |
size_t | len | ||
) |
Updates the message authenticator with more data.
data | Data to be hashed. |
len | Number of bytes of data to be hashed. |
If finalize() has already been called, then the behavior of update() will be undefined. Call reset() first to start a new authentication process.
Definition at line 145 of file Poly1305.cpp.