MCCI TweetNaCl
TweetNaCl library adapted for embedded use
One-time authentication
+ Collaboration diagram for One-time authentication:

Data Structures

struct  mcci_tweetnacl_onetimeauth_authenticator_t
 abstract type for crypto authenticators More...
 
struct  mcci_tweetnacl_onetimeauth_key_t
 abstract type for crypto keys More...
 
struct  mcci_tweetnacl_stream_key_t
 abstract type for crypto keys More...
 
struct  mcci_tweetnacl_stream_nonce_t
 abstract type for crypto nonces More...
 

Functions

static void mcci_tweetnacl_core_hsalsa20 (unsigned char *out, const unsigned char *in, const mcci_tweetnacl_stream_key_t *key, const unsigned char *expansion)
 perform a core hash round of Salsa20 encryption. More...
 
static void mcci_tweetnacl_core_salsa20 (unsigned char *out, const unsigned char *in, const mcci_tweetnacl_stream_key_t *key, const unsigned char *expansion)
 perform a core hash round of Salsa20 encryption. More...
 
static void mcci_tweetnacl_onetimeauth (mcci_tweetnacl_onetimeauth_authenticator_t *pAuth, const unsigned char *pMessage, size_t nMessage, const mcci_tweetnacl_onetimeauth_key_t *pKey)
 Generate one-time authenticator for a given message and secret key. More...
 
static mcci_tweetnacl_result_t mcci_tweetnacl_onetimeauth_verify (const mcci_tweetnacl_onetimeauth_authenticator_t *pAuth, const unsigned char *pMessage, size_t nMessage, const mcci_tweetnacl_onetimeauth_key_t *pKey)
 Verify message given one-time authenticator and secret key. More...
 
static void mcci_tweetnacl_stream (unsigned char *pOutText, size_t sizeText, const mcci_tweetnacl_stream_nonce_t *pNonce, const mcci_tweetnacl_stream_key_t *pKey)
 Generate stream of crypto bytes. More...
 
static void mcci_tweetnacl_stream_salsa20 (unsigned char *pOutText, size_t sizeText, const mcci_tweetnacl_stream_nonce_t *pNonce, const mcci_tweetnacl_stream_key_t *pKey)
 Generate stream of Salsa20 bytes. More...
 
static void mcci_tweetnacl_stream_salsa20_xor (unsigned char *pOutText, const unsigned char *pInText, size_t sizeText, const mcci_tweetnacl_stream_nonce_t *pNonce, const mcci_tweetnacl_stream_key_t *pKey)
 encrypt or decrypt text using Salsa20 More...
 
static void mcci_tweetnacl_stream_xor (unsigned char *pOutText, const unsigned char *pInText, size_t sizeText, const mcci_tweetnacl_stream_nonce_t *pNonce, const mcci_tweetnacl_stream_key_t *pKey)
 Encrypt or decrypt text (using xsalsa20) More...
 

Detailed Description

Function Documentation

◆ mcci_tweetnacl_core_hsalsa20()

static void mcci_tweetnacl_core_hsalsa20 ( unsigned char *  out,
const unsigned char *  in,
const mcci_tweetnacl_stream_key_t key,
const unsigned char *  expansion 
)
inlinestatic

perform a core hash round of Salsa20 encryption.

Parameters
[out]outpointer to a 64-byte buffer
[in]inpointer to a 16-byte input value
[in]keypointer to the 32-byte key
[in]expansionpointer to a 16-byte expansion vector, normally "expand 32-byte k"
Note
Rarely used directly, but exported for convenience.
See also
http://www.crypto-it.net/eng/symmetric/salsa20.html

Definition at line 103 of file mcci_tweetnacl_stream.h.

References mcci_tweetnacl_stream_key_t::bytes.

◆ mcci_tweetnacl_core_salsa20()

static void mcci_tweetnacl_core_salsa20 ( unsigned char *  out,
const unsigned char *  in,
const mcci_tweetnacl_stream_key_t key,
const unsigned char *  expansion 
)
inlinestatic

perform a core hash round of Salsa20 encryption.

Parameters
[out]outpointer to a 64-byte buffer
[in]inpointer to a 16-byte input value
[in]keypointer to the 32-byte key
[in]expansionpointer to a 16-byte expansion vector, normally either "expand 32-byte k" or "expand 16-byte k"
Note
Rarely used directly, but exported for convenience.
See also
http://www.crypto-it.net/eng/symmetric/salsa20.html

Definition at line 78 of file mcci_tweetnacl_stream.h.

References mcci_tweetnacl_stream_key_t::bytes.

◆ mcci_tweetnacl_onetimeauth()

static void mcci_tweetnacl_onetimeauth ( mcci_tweetnacl_onetimeauth_authenticator_t pAuth,
const unsigned char *  pMessage,
size_t  nMessage,
const mcci_tweetnacl_onetimeauth_key_t pKey 
)
inlinestatic

Generate one-time authenticator for a given message and secret key.

Parameters
[out]pAuthset to the authenticator code.
[in]pMessagethe message to be authenticated.
[in]nMessagenumber of bytes in the message.
[in]pKeythe secret key
See also
https://nacl.cr.yp.to/onetimeauth.html

Definition at line 75 of file mcci_tweetnacl_onetimeauth.h.

References mcci_tweetnacl_onetimeauth_key_t::bytes, and mcci_tweetnacl_onetimeauth_authenticator_t::bytes.

◆ mcci_tweetnacl_onetimeauth_verify()

static mcci_tweetnacl_result_t mcci_tweetnacl_onetimeauth_verify ( const mcci_tweetnacl_onetimeauth_authenticator_t pAuth,
const unsigned char *  pMessage,
size_t  nMessage,
const mcci_tweetnacl_onetimeauth_key_t pKey 
)
inlinestatic

Verify message given one-time authenticator and secret key.

Parameters
[out]pAuthset to the authenticator code.
[in]pMessagethe message to be authenticated.
[in]nMessagenumber of bytes in the message.
[in]pKeythe secret key
Returns
zero if valid, non-zero otherwise.
See also
https://nacl.cr.yp.to/onetimeauth.html

Definition at line 104 of file mcci_tweetnacl_onetimeauth.h.

References mcci_tweetnacl_onetimeauth_key_t::bytes, and mcci_tweetnacl_onetimeauth_authenticator_t::bytes.

◆ mcci_tweetnacl_stream()

static void mcci_tweetnacl_stream ( unsigned char *  pOutText,
size_t  sizeText,
const mcci_tweetnacl_stream_nonce_t pNonce,
const mcci_tweetnacl_stream_key_t pKey 
)
inlinestatic

Generate stream of crypto bytes.

Parameters
[out]pOutTextpointer to buffer of size sizeText bytes.
[in]sizeTextsize of the output text buffer
[in]pNoncepointer to 8-byte nonce, followed by 8-byte index buffer
[in]pKeypointer to 32-byte key buffer.
See also
https://nacl.cr.yp.to/stream.html
https://www.xsalsa20.com/

Definition at line 188 of file mcci_tweetnacl_stream.h.

References mcci_tweetnacl_stream_key_t::bytes, and mcci_tweetnacl_stream_nonce_t::bytes.

◆ mcci_tweetnacl_stream_salsa20()

static void mcci_tweetnacl_stream_salsa20 ( unsigned char *  pOutText,
size_t  sizeText,
const mcci_tweetnacl_stream_nonce_t pNonce,
const mcci_tweetnacl_stream_key_t pKey 
)
inlinestatic

Generate stream of Salsa20 bytes.

Parameters
[out]pOutTextpointer to buffer of size sizeText bytes.
[in]sizeTextsize of the input and output text buffers
[in]pNoncepointer to 8-byte nonce buffer
[in]pKeypointer to 32-byte key buffer.
Note
generally not used directly; use mcci_tweetnacl_stream() instead.
See also
http://www.crypto-it.net/eng/symmetric/salsa20.html

Definition at line 165 of file mcci_tweetnacl_stream.h.

References mcci_tweetnacl_stream_key_t::bytes, and mcci_tweetnacl_stream_nonce_t::bytes.

◆ mcci_tweetnacl_stream_salsa20_xor()

static void mcci_tweetnacl_stream_salsa20_xor ( unsigned char *  pOutText,
const unsigned char *  pInText,
size_t  sizeText,
const mcci_tweetnacl_stream_nonce_t pNonce,
const mcci_tweetnacl_stream_key_t pKey 
)
inlinestatic

encrypt or decrypt text using Salsa20

Parameters
[out]pOutTextpointer to buffer of size sizeText bytes.
[in]pInTextpointer to buffer of size sizeText bytes. If NULL, a string of zero bytes will be substituted.
[in]sizeTextsize of the input and output text buffers
[in]pNoncepointer to 8-byte nonce buffer
[in]pKeypointer to 32-byte key buffer.
Note
generally not used directly; use mcci_tweetnacl_stream_xor() instead.
See also
http://www.crypto-it.net/eng/symmetric/salsa20.html

Definition at line 134 of file mcci_tweetnacl_stream.h.

References mcci_tweetnacl_stream_key_t::bytes, and mcci_tweetnacl_stream_nonce_t::bytes.

◆ mcci_tweetnacl_stream_xor()

static void mcci_tweetnacl_stream_xor ( unsigned char *  pOutText,
const unsigned char *  pInText,
size_t  sizeText,
const mcci_tweetnacl_stream_nonce_t pNonce,
const mcci_tweetnacl_stream_key_t pKey 
)
inlinestatic

Encrypt or decrypt text (using xsalsa20)

Parameters
[out]pOutTextpointer to buffer of size sizeText bytes.
[in]pInTextpointer to buffer of size sizeText bytes.
[in]sizeTextsize of the output text buffer
[in]pNoncepointer to 8-byte nonce, followed by 8-byte index buffer
[in]pKeypointer to 32-byte key buffer.
See also
https://nacl.cr.yp.to/stream.html
https://www.xsalsa20.com/
crypto_onetimeauth

Definition at line 219 of file mcci_tweetnacl_stream.h.

References mcci_tweetnacl_stream_key_t::bytes, and mcci_tweetnacl_stream_nonce_t::bytes.