mbedtls_nist_kw_wrap() function
This function encrypts a buffer using key wrapping.
Arguments
ctx
The key wrapping context to use for encryption.
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. For KW mode: a multiple of 8 bytes between 16 and 2^57-8 inclusive. For KWP mode: any length between 1 and 2^32-1 inclusive.
output
The buffer holding the output data. For KW mode: Must be at least 8 bytes larger than \p in_len. For KWP mode: Must be at least 8 bytes larger rounded up to a multiple of 8 bytes for KWP (15 bytes at most).
out_len
The number of bytes written to the output buffer. \c 0 on failure.
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. cipher-specific error code on failure of the underlying cipher.