Documentation
Includes
config.h
#include "config.h"
MBEDTLS_CONFIG_FILE
#include MBEDTLS_CONFIG_FILE
cipher.h
#include "cipher.h"
nist_kw_alt.h
#include "nist_kw_alt.h"
Macros
Marco MBEDTLS_NIST_KW_H
#define MBEDTLS_NIST_KW_H
Functions
Func mbedtls_nist_kw_init
void mbedtls_nist_kw_init( mbedtls_nist_kw_context *ctx );
Func mbedtls_nist_kw_setkey
int mbedtls_nist_kw_setkey( mbedtls_nist_kw_context *ctx,
mbedtls_cipher_id_t cipher,
const unsigned char *key,
unsigned int keybits,
const int is_wrap );
Func mbedtls_nist_kw_free
void mbedtls_nist_kw_free( mbedtls_nist_kw_context *ctx );
Func mbedtls_nist_kw_wrap
int mbedtls_nist_kw_wrap( mbedtls_nist_kw_context *ctx, mbedtls_nist_kw_mode_t mode,
const unsigned char *input, size_t in_len,
unsigned char *output, size_t* out_len, size_t out_size );
- 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.
* \param[out] 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).
* \param[out] out_len The number of bytes written to the output buffer. \c 0 on failure.
* \param[in] out_size The capacity of the output buffer.
*
* \return \c 0 on success.
* \return \c MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA for invalid input length.
* \return cipher-specific error code on failure of the underlying cipher.
*/
Func mbedtls_nist_kw_unwrap
int mbedtls_nist_kw_unwrap( mbedtls_nist_kw_context *ctx, mbedtls_nist_kw_mode_t mode,
const unsigned char *input, size_t in_len,
unsigned char *output, size_t* out_len, size_t out_size);
- 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.
* \param[out] output The buffer holding the output data.
* The output buffer's minimal length is 8 bytes shorter than \p in_len.
* \param[out] 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.
* \param[in] out_size The capacity of the output buffer.
*
* \return \c 0 on success.
* \return \c MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA for invalid input length.
* \return \c MBEDTLS_ERR_CIPHER_AUTH_FAILED for verification failure of the ciphertext.
* \return cipher-specific error code on failure of the underlying cipher.
*/
Func mbedtls_nist_kw_self_test
int mbedtls_nist_kw_self_test( int verbose );
Vars
Consts
Types
Typedefs
Typedef mbedtls_nist_kw_mode_t;
typedef enum
{
MBEDTLS_KW_MODE_KW = 0,
MBEDTLS_KW_MODE_KWP = 1
} mbedtls_nist_kw_mode_t;
Typedef mbedtls_nist_kw_context;
typedef struct {
mbedtls_cipher_context_t cipher_ctx; /*!< The cipher context used. */
} mbedtls_nist_kw_context;