Wraps a plaintext buffer according to the AES Key Wrap algorithm with the given AES parameters and key objects.
#include "huaes.h"
int hu_AESKeyWrap(sb_Params aesParams, sb_Key aesKey, size_t plaintextLength, const unsigned char *plaintext, size_t *ciphertextLength, unsigned char *ciphertext, sb_GlobalCtx sbCtx)
BlackBerry 10.0.0
The AES parameters object.
The AES key object.
The length (in bytes) of plaintext.
Plaintext buffer.
The length (in bytes) of ciphertext.
The ciphertext buffer.
A global context.
The AES parameters must have been created with SB_AES_KEYWRAP mode. The length of the plaintext must be a multiple of SB_AES_KEYWRAP_BLOCK_BYTES and at least 2 * SB_AES_KEYWRAP_BLOCK_BYTES. The length of the ciphertext will be SB_AES_KEYWRAP_BLOCK_BYTES bytes longer than the plaintext length. The plaintext and ciphertext buffers may overlap in memory subject to the constraints described in the API Reference section on overlapping buffers.
If the length of the ciphertext is known, a pointer to a buffer large enough to hold the ciphertext should be passed in ciphertext and its length in ciphertextLength. This function will copy the ciphertext value into ciphertext and set the actual length of the ciphertext in ciphertextLength.
If ciphertext is NULL, then this function will set the correct length of the ciphertext value in ciphertextLen. If ciphertext is not NULL but ciphertextLen is too small, this function will return an error and also will set the correct length of the ciphertext value in ciphertextLen.
The aesParams object is NULL.
The tag for the params object is not of the expected type.
The aesKey object is NULL.
The aesKey object is invalid.
aesParams uses an invalid mode of operation.
The plaintext buffer is NULL.
plaintextLength is incorrect.
The ciphertextLength pointer is NULL.
ciphertextLength is invalid.
Memory allocation failure.
Success.