Resets the given AES context so it can be reused.
Synopsis:
#include "huaes.h"
int hu_AESCtxReset(size_t ivLen, const unsigned char *iv, sb_Context aesContext, sb_GlobalCtx sbCtx)
Arguments:
- ivLen
-
The length (in bytes) of initial vector. The only acceptable value is SB_AES_128_BLOCK_BYTES.
- iv
-
The initial vector.
- aesContext
-
The AES context object.
- sbCtx
-
A global context.
Library:
libhuapi (For the qcc command, use the -l huapi option to link against this library)
Description:
For XTS mode, IV is used to specify the Data Unit Sequence Number and block index within the data unit to start the operation. The following rules apply to the value of IV for XTS mode:
-
The Data Unit Sequence Number is internally represented by size_t.
-
On platforms where the size of size_t is 4 bytes, the first 4 bytes of IV are used to specify the Data Unit Sequence Number, and the subsequent 4 bytes are ignored.
-
On platforms where the size of size_t is 8 bytes, the first 8 bytes of IV are used to specify the Data Unit Sequence Number.
-
The 9th to 11th bytes are used to specify the block index in a data unit.
-
Block index in a data unit starts at 0.
-
The remaining bytes in IV are ignored.
-
The Data Unit Sequence Number and block index are represented in little-endian order, where the first byte is the least significant byte.
-
If the specified block index exceeds the size of a data unit, SB_ERR_BAD_IV will be returned.
-
IV for the specified Data Unit Sequence Number and block index can be set by using the hu_AESXTSIVSet() function.
Returns:
- SB_ERR_NULL_CONTEXT
-
The aesContext object is NULL.
- SB_ERR_BAD_CONTEXT
-
The aesContext object is invalid.
- SB_ERR_NULL_IV
-
iv, the initial vector, is NULL.
- SB_ERR_BAD_IV_LEN
-
ivLen is an invalid vector length.
- SB_SUCCESS
-
Success.