SharkSSL C/C++ Reference
TLS, cryptography, certificates, and PSA integration
SharkSslPSAConsumerCMAC.h File Reference
#include "SharkSSL.h"

Go to the source code of this file.

Functions

SHARKSSL_API int SharkSslPSACMAC_compute (psa_key_id_t key, const U8 *message, U32 messageLen, U8 *mac, U16 macSize, U16 *macLen)
 Compute AES-CMAC with a caller-owned PSA key authorized for SIGN_MESSAGE. More...
 
SHARKSSL_API int SharkSslPSACMAC_verify (psa_key_id_t key, const U8 *message, U32 messageLen, const U8 *mac, U16 macLen)
 Verify AES-CMAC with a caller-owned PSA key authorized for VERIFY_MESSAGE. More...
 

Detailed Description

See Choose a SharkSSL API for build scope and the owning API layer.

Function Documentation

◆ SharkSslPSACMAC_compute()

int SharkSslPSACMAC_compute ( psa_key_id_t  key,
const U8 *  message,
U32  messageLen,
U8 *  mac,
U16  macSize,
U16 *  macLen 
)

Compute AES-CMAC with a caller-owned PSA key authorized for SIGN_MESSAGE.

After output arguments pass validation, a subsequent failure clears macSize output bytes.

Returns zero on success; clears mac and returns -1 on failure.

The key remains owned by the caller.

Parameters
keypsa_key_id_t; borrowed non-null AES key handle permitting CMAC signing.
messageconst U8 *; message bytes; may be NULL only when messageLen=0.
messageLenU32; message length in bytes.
macU8 *; required caller-owned output buffer.
macSizeU16; output capacity in bytes, sufficient for the full CMAC (16 bytes for AES).
macLenU16 *; required result length in bytes, initialized to zero.
Returns
int: 0 on success; -1 for invalid arguments, unsupported algorithms/policies, or provider failure.

◆ SharkSslPSACMAC_verify()

int SharkSslPSACMAC_verify ( psa_key_id_t  key,
const U8 *  message,
U32  messageLen,
const U8 *  mac,
U16  macLen 
)

Verify AES-CMAC with a caller-owned PSA key authorized for VERIFY_MESSAGE.

Parameters
keypsa_key_id_t; borrowed non-null AES key handle permitting CMAC verification.
messageconst U8 *; message bytes; may be NULL only when messageLen=0.
messageLenU32; message length in bytes.
macconst U8 *; required expected CMAC.
macLenU16; nonzero MAC length in bytes, matching the provider CMAC contract.
Returns
int: 0 only when the MAC verifies; -1 for mismatch, invalid arguments, or provider failure.