MAC API#
A Message Authentication Code (MAC) is a cryptographic technique used to verify the authenticity and integrity of a message, ensuring that it has not been tampered during transmission.
Data Structures#
-
struct alc_hmac_info_t#
Stores details of HMAC.
- Param digest_mode:
Store info of digest used for HMAC
-
struct alc_cmac_info_t#
Stores details of CMAC.
- Param cmac_cipher:
Store info of cipher used for CMAC
-
struct alc_mac_handle_t#
Handle for maintaining session.
- Param ch_context:
pointer to the context of the mac
-
union alc_mac_info_t#
- #include <mac.h>
Stores details for algo info for mac.
- Param hmac:
Stores the hmac info in case MAC to be used is HMAC
- Param cmac:
Stores the cmac info in case MAC to be used is CMAC
Functions#
-
Uint64 alcp_mac_context_size(void)#
Gets the size of the context for a session described by pMacInfo.
This API can be called before alcp_mac_request to identify the memory to be allocated for context
- Returns:
Size of Context
-
alc_error_t alcp_mac_request(alc_mac_handle_p pMacHandle, alc_mac_type_t macType)#
Allows caller to request for a MAC as described by macType.
This API must be called before making any other API call
Note
Error needs to be checked after each call, valid only if alcp_is_error (ret) is false
- Parameters:
macType – [in] Description of the MAC session
pMacHandle – [out] Library populated session handle for future mac operations.
- Returns:
Error Code for the API called. If alc_error_t is not ALC_ERROR_NONE then, an error has occurred and handle will be invalid for future operations
-
alc_error_t alcp_mac_init(alc_mac_handle_p pMacHandle, const Uint8 *key, Uint64 size, alc_mac_info_t *info)#
Allows caller to set key and initialize hmac session.
This API must be called only after alcp_mac_request
Note
Error needs to be checked after each call, valid only if alcp_is_error (ret) is false
- Parameters:
pMacHandle – [in] Library populated session handle for future
key – [in] pointer to key for mac operations.
size – [in] size of key.
info – [in] Macinfo populated based on the type of the MAC
- Returns:
Error Code for the API called. If alc_error_t is not ALC_ERROR_NONE then, an error has occurred and handle will be invalid for future operations
-
alc_error_t alcp_mac_update(alc_mac_handle_p pMacHandle, const Uint8 *buff, Uint64 size)#
Allows caller to update MAC with chunk of data to be authenticated.
This API is called to update data to be authenticated. So should be called after alcp_mac_request and before the end of session call, alcp_mac_finish
Note
Error needs to be checked for each call, valid only if alcp_is_error (ret) is false
- Parameters:
pMacHandle – [in] Session handle for future MAC operation
buff – [in] The chunk of the message to be updated
size – [in] Length of input buffer in bytes
- Returns:
Error Code for the API called. If alc_error_t is not ALC_ERROR_NONE then, an error has occurred and handle will be invalid for future operations
-
alc_error_t alcp_mac_finalize(alc_mac_handle_p pMacHandle, Uint8 *buff, Uint64 size)#
Allows caller to finalize and copy final MAC.
This API is called to finalize mac so should be called after alcp_mac_init and before alcp_mac_finish
Note
Error needs to be checked for each call, valid only if alcp_is_error (ret) is false.
- Parameters:
pMacHandle – [in] Session handle for future MAC operation
buff – [in] The buffer holding mac
size – [in] mac size in bytes.
- Returns:
Error Code for the API called. If alc_error_t is not ALC_ERROR_NONE then, an error has occurred and handle will be invalid for future operations
-
alc_error_t alcp_mac_finish(alc_mac_handle_p pMacHandle)#
Free resources that was allotted by alcp_mac_request.
This API is called to free resources so should be called to free the session
Note
alcp_mac_request() should be called first to allocate the Handler.
- Parameters:
pMacHandle – [in] Session handle used for the MAC operations
- Returns:
Error Code for the API called. If alc_error_t is not ALC_ERROR_NONE then, an error has occurred and handle will be invalid for future operations
-
alc_error_t alcp_mac_reset(alc_mac_handle_p pMacHandle)#
resets the data given to it during alcp_mac_update or alcp_mac_finalize
This API is called to reset data so should be called after alcp_mac_request and before alcp_mac_finish
- Parameters:
pMacHandle – [in] Session handle for future MAC operation
- Returns:
Error Code for the API called. If alc_error_t is not ALC_ERROR_NONE, an error has occurred and handle will be invalid for future operations
-
alc_error_t alcp_mac_context_copy(const alc_mac_handle_p pSrcHandle, const alc_mac_handle_p pDestHandle)#
copies the context from source to destination
This API can be called only after alcp_mac_init and before alcp_mac_finish on pSrcHandle
- Parameters:
pSrcHandle – [in] source mac handle
pDestHandle – [out] destination mac handle
- Returns:
alc_error_t Error code to validate the operation
Variables#
-
enum _alc_mac_type alc_mac_type_t#
Stores info regarding the type of MAC used.