hu_AuthEncBegin()
Creates an Authenticated Encryption context initialized with the given symmetric parameters and key.
Synopsis:
#include "huauthenc.h"
int hu_AuthEncBegin(sb_Params symParams, sb_Key authEncKey, size_t nonceLen, const unsigned char *nonce, size_t addDataLen, size_t plaintextLen, size_t macLen, sb_Context *authEncCtx, sb_GlobalCtx sbCtx)
Arguments:
- symParams
-
The symmetric algorithm parameters object. AES is the only algorithm currently supported.
- authEncKey
-
An authenticated encryption key
- nonceLen
-
The length (in bytes) of the 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.
- plaintextLen
-
The length (in bytes) of plaintext that will be processed. This is optional for SB_GCM.
- macLen
-
The length of the MAC used for authentication. For SB_CCM and SB_CCM_STAR, acceptable values are 4, 6, 8, 10, 12, 14 and 16. SB_CCM_STAR may also specify a macLen of 0 if authentication is not required. For SB_GCM, macLen must be greater than or equal to 4 and less than or equal to 16.
- authEncCtx
-
The Authenticated Encryption context object pointer.
- sbCtx
-
Global context.
Library:
libhuapiDescription:
The addDataLen and plaintextLen parameters are required for the SB_CCM and SB_CCM_STAR modes, and are optional for the SB_GCM mode. If those parameters are provided for the SB_GCM mode, then a check will be done in the hu_AuthEncEncryptEnd() and hu_AuthEncDecryptEnd() functions to ensure the length of plaintext and additional data processed matches the lengths specified in the hu_AuthEncBegin() function.
Returns:
- SB_ERR_BAD_KEY
-
The authEncKey parameter is of the wrong type.
- SB_ERR_BAD_INPUT_BUF_LEN
-
The nonceLen parameter violates acceptable values
- SB_ERR_NULL_INPUT_BUF
-
The nonce parameter is NULL
- SB_ERR_BAD_LENGTH
-
The macLen parameter violates acceptable values.