hu_AuthEncAuthenticateDecryptMsg()
Does an Authenticated Decryption according to the mode desired, using the given symmetric parameters, the mode and the decryption parameters.
Synopsis:
#include "huauthenc.h"
int hu_AuthEncAuthenticateDecryptMsg(sb_Params symParams, int mode, sb_Key authEncKey, size_t nonceLen, const unsigned char *nonce, size_t addDataLen, const unsigned char *addData, size_t ciphertextLen, const unsigned char *ciphertext, size_t macLen, const unsigned char *mac, unsigned char *plaintext, sb_GlobalCtx sbCtx)
Arguments:
- symParams
-
A symmetric algorithm parameters object. AES is the only algorithm currently supported.
- mode
-
The mode of operation. The acceptable values are SB_CCM, SB_CCM_STAR and SB_GCM.
- authEncKey
-
An authenticated encryption key
- nonceLen
-
The length (in bytes) of nonce. For SB_CCM and SB_CCM_STAR, acceptable values are 7, 8, 9, 10, 11, 12 and 13. For SB_GCM, nonceLen must be greater than 0, and the recommended value is 12.
- nonce
-
Nonce buffer.
- addDataLen
-
The length (in bytes) of additional data that will be processed. This is optional for SB_GCM.
- addData
-
The additional data buffer.
- ciphertextLen
-
The length (in bytes) of ciphertext.
- ciphertext
-
The ciphertext buffer.
- macLen
-
The length of the mac buffer in bytes. The macLen must match the value supplied in the hu_AuthEncBegin() function.
- mac
-
The mac buffer.
- plaintext
-
The plaintext buffer.
- sbCtx
-
A global context.
Library:
libhuapiDescription:
Returns:
- SB_ERR_NULL_PARAMS
-
The aesParams object is NULL.
- SB_ERR_BAD_PARAMS
-
The tag for the params object is not of the expected type.
- SB_ERR_NULL_KEY
-
The aesKey object is NULL.
- SB_ERR_BAD_KEY
-
The aesKey object is invalid.
- SB_ERR_BAD_MODE
-
aesParams uses an invalid mode of operation.
- SB_ERR_NULL_INPUT_BUF
-
The ciphertext, nonce, or addData buffer is NULL.
- SB_ERR_BAD_INPUT_BUF_LEN
-
The nonceLen or ciphertextLen is invalid.
- SB_ERR_BAD_LENGTH
-
The macLen is invalid.
- SB_ERR_NULL_OUTPUT_BUF
-
The plaintext buffer is NULL.
- SB_ERR_BAD_OUTPUT_BUF_LEN
-
ciphertextLen is not consistent with nonceLen.
- SB_ERR_MAC_INVALID
-
The MAC is invalid.
- SB_FAIL_ALLOC
-
Memory allocation failure.
- SB_SUCCESS
-
Success.