mbedtls_nist_kw_unwrap() function
This function decrypts a buffer using key wrapping.
Arguments
ctx
The key wrapping context to use for decryption.
mode
The key wrapping mode to use (MBEDTLS_KW_MODE_KW or MBEDTLS_KW_MODE_KWP)
input
The buffer holding the input data.
in_len
The length of the input data in Bytes. The input uses units of 8 Bytes called semiblocks. The input must be a multiple of semiblocks. For KW mode: a multiple of 8 bytes between 24 and 2^57 inclusive. For KWP mode: a multiple of 8 bytes between 16 and 2^32 inclusive.
output
The buffer holding the output data. The output buffer's minimal length is 8 bytes shorter than \p in_len.
out_len
The number of bytes written to the output buffer. \c 0 on failure. For KWP mode, the length could be up to 15 bytes shorter than \p in_len, depending on how much padding was added to the data.
out_size
The capacity of the output buffer.
Return value
\c 0 on success. \c MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA for invalid input length. \c MBEDTLS_ERR_CIPHER_AUTH_FAILED for verification failure of the ciphertext. cipher-specific error code on failure of the underlying cipher.