libzpc 1.5
IBM Z Protected-key Crypto library
Loading...
Searching...
No Matches
hmac.h File Reference

HMAC API. More...

Go to the source code of this file.

Functions

int zpc_hmac_alloc (struct zpc_hmac **ctx)
int zpc_hmac_set_key (struct zpc_hmac *ctx, struct zpc_hmac_key *key)
int zpc_hmac_sign (struct zpc_hmac *ctx, unsigned char *mac, size_t maclen, const unsigned char *msg, size_t msglen)
int zpc_hmac_verify (struct zpc_hmac *ctx, const unsigned char *mac, size_t maclen, const unsigned char *msg, size_t msglen)
void zpc_hmac_free (struct zpc_hmac **ctx)

Detailed Description

HMAC API.

Message authentication API for the Hash-based Message Authentication Code (HMAC).

Definition in file hmac.h.

Function Documentation

◆ zpc_hmac_alloc()

int zpc_hmac_alloc ( struct zpc_hmac ** ctx)

Allocate a new context for an HMAC operation.

Parameters
[in,out]ctxHMAC context
Returns
0 on success. Otherwise, a non-zero error code is returned.

◆ zpc_hmac_set_key()

int zpc_hmac_set_key ( struct zpc_hmac * ctx,
struct zpc_hmac_key * key )

Set the key to be used in the context of an HMAC operation.

Parameters
[in,out]ctxHMAC context
[in]keyHMAC key
Returns
0 on success. Otherwise, a non-zero error code is returned.

◆ zpc_hmac_sign()

int zpc_hmac_sign ( struct zpc_hmac * ctx,
unsigned char * mac,
size_t maclen,
const unsigned char * msg,
size_t msglen )

Do an HMAC signing operation.

Parameters
[in,out]ctxHMAC context
[in,out]macmessage authentication code when set to NULL, this indicates that an internal intermediate MAC is calculated and further intermediate calls with additional msg data may follow. If the mac parm is not NULL and the maclen is a valid MAC length (dependent on the underlying hash function of the key) the final MAC is computed.
[in]maclenmessage authentication code length [bytes]
[in]msgmessage
[in]msglenmessage length [bytes]
Returns
0 on success. Otherwise, a non-zero error code is returned.

◆ zpc_hmac_verify()

int zpc_hmac_verify ( struct zpc_hmac * ctx,
const unsigned char * mac,
size_t maclen,
const unsigned char * msg,
size_t msglen )

Do an HMAC verify operation.

Parameters
[in,out]ctxHMAC context
[in,out]macmessage authentication code if the mac parm is NULL, then an intermediate verify op is performed. If the mac parm is not NULL and the maclen is a valid MAC length (dependent on the underlying hash function of the key), then the given MAC is checked for correctness.
[in]maclenmessage authentication code length [bytes]
[in]msgmessage
[in]msglenmessage length [bytes]
Returns
0 on success. Otherwise, a non-zero error code is returned.

◆ zpc_hmac_free()

void zpc_hmac_free ( struct zpc_hmac ** ctx)

Free an HMAC context.

Parameters
[in,out]ctxHMAC context