My Project
Functions
Algorithm - SipHash

Functions

int wc_InitSipHash (SipHash *siphash, const unsigned char *key, unsigned char outSz)
 This function initializes SipHash with a key for a MAC size. More...
 
int wc_SipHashUpdate (SipHash *siphash, const unsigned char *in, word32 inSz)
 Can be called to continually hash the provided byte array of length len. More...
 
int wc_SipHashFinal (SipHash *siphash, unsigned char *out, unsigned char outSz)
 Finalizes MACing of data. Result is placed into out. More...
 
int wc_SipHash (const unsigned char *key, const unsigned char *in, word32 inSz, unsigned char *out, unsigned char outSz)
 This function one-shots the data using SipHash to calculate a MAC based on the key. More...
 

Detailed Description

Function Documentation

◆ wc_InitSipHash()

int wc_InitSipHash ( SipHash *  siphash,
const unsigned char *  key,
unsigned char  outSz 
)

This function initializes SipHash with a key for a MAC size.

Returns
0 Returned upon successfully initializing
BAD_FUNC_ARG Returned when siphash or key is NULL
BAD_FUNC_ARG Returned when outSz is neither 8 nor 16
Parameters
siphashpointer to the SipHash structure to use for MACing
keypointer to the 16-byte array
outSznumber of bytes to output as MAC

Example

SipHash siphash[1];
unsigned char key[16] = { ... };
byte macSz = 8; // 8 or 16
if ((ret = wc_InitSipHash(siphash, key, macSz)) != 0) {
WOLFSSL_MSG("wc_InitSipHash failed");
}
else if ((ret = wc_SipHashUpdate(siphash, data, len)) != 0) {
WOLFSSL_MSG("wc_SipHashUpdate failed");
}
else if ((ret = wc_SipHashFinal(siphash, mac, macSz)) != 0) {
WOLFSSL_MSG("wc_SipHashFinal failed");
}
See also
wc_SipHash
wc_SipHashUpdate
wc_SipHashFinal

◆ wc_SipHash()

int wc_SipHash ( const unsigned char *  key,
const unsigned char *  in,
word32  inSz,
unsigned char *  out,
unsigned char  outSz 
)

This function one-shots the data using SipHash to calculate a MAC based on the key.

Returns
0 Returned upon successfully MACing
BAD_FUNC_ARG Returned when key or out is NULL
BAD_FUNC_ARG Returned when in is NULL and inSz is not zero
BAD_FUNC_ARG Returned when outSz is neither 8 nor 16
Parameters
keypointer to the 16-byte array
inthe data to be MACed
inSzsize of data to be MACed
outByte array to hold MAC value
outSznumber of bytes to output as MAC

Example

unsigned char key[16] = { ... };
byte data[] = { Data to be MACed };
word32 len = sizeof(data);
byte mac[8] = { ... }; // 8 or 16 bytes
byte macSz = sizeof(mac);
if ((ret = wc_SipHash(key, data, len, mac, macSz)) != 0) {
WOLFSSL_MSG("wc_SipHash failed");
}
See also
wc_InitSipHash
wc_SipHashUpdate
wc_SipHashFinal

◆ wc_SipHashFinal()

int wc_SipHashFinal ( SipHash *  siphash,
unsigned char *  out,
unsigned char  outSz 
)

Finalizes MACing of data. Result is placed into out.

Returns
0 Returned upon successfully finalizing.
BAD_FUNC_ARG Returned when siphash of out is NULL
BAD_FUNC_ARG Returned when outSz is not the same as the initialized value
Parameters
siphashpointer to the SipHash structure to use for MACing
outByte array to hold MAC value
outSznumber of bytes to output as MAC

Example

SipHash siphash[1];
byte mac[8] = { ... }; // 8 or 16 bytes
byte macSz = sizeof(mac);
if ((ret = wc_InitSipHash(siphash, key, macSz)) != 0) {
WOLFSSL_MSG("wc_InitSipHash failed");
}
else if ((ret = wc_SipHashUpdate(siphash, data, len)) != 0) {
WOLFSSL_MSG("wc_SipHashUpdate failed");
}
else if ((ret = wc_SipHashFinal(siphash, mac, macSz)) != 0) {
WOLFSSL_MSG("wc_SipHashFinal failed");
}
See also
wc_SipHash
wc_InitSipHash
wc_SipHashUpdate

◆ wc_SipHashUpdate()

int wc_SipHashUpdate ( SipHash *  siphash,
const unsigned char *  in,
word32  inSz 
)

Can be called to continually hash the provided byte array of length len.

Returns
0 Returned upon successfully adding the data to the MAC
BAD_FUNC_ARG Returned when siphash is NULL
BAD_FUNC_ARG Returned when in is NULL and inSz is not zero
Parameters
siphashpointer to the SipHash structure to use for MACing
inthe data to be MACed
inSzsize of data to be MACed

Example

SipHash siphash[1];
byte data[] = { Data to be MACed };
word32 len = sizeof(data);
if ((ret = wc_InitSipHash(siphash, key, macSz)) != 0) {
WOLFSSL_MSG("wc_InitSipHash failed");
}
else if ((ret = wc_SipHashUpdate(siphash, data, len)) != 0) {
WOLFSSL_MSG("wc_SipHashUpdate failed");
}
else if ((ret = wc_SipHashFinal(siphash, mac, macSz)) != 0) {
WOLFSSL_MSG("wc_SipHashFinal failed");
}
See also
wc_SipHash
wc_InitSipHash
wc_SipHashFinal
wc_SipHashUpdate
int wc_SipHashUpdate(SipHash *siphash, const unsigned char *in, word32 inSz)
Can be called to continually hash the provided byte array of length len.
wc_InitSipHash
int wc_InitSipHash(SipHash *siphash, const unsigned char *key, unsigned char outSz)
This function initializes SipHash with a key for a MAC size.
wc_SipHashFinal
int wc_SipHashFinal(SipHash *siphash, unsigned char *out, unsigned char outSz)
Finalizes MACing of data. Result is placed into out.
wc_SipHash
int wc_SipHash(const unsigned char *key, const unsigned char *in, word32 inSz, unsigned char *out, unsigned char outSz)
This function one-shots the data using SipHash to calculate a MAC based on the key.