#include "common.h"
#if defined(MBEDTLS_CIPHER_C)
#include "cipher_wrap.h"
#include "mbedtls/error.h"
#if defined(MBEDTLS_CHACHAPOLY_C)
#include "mbedtls/chachapoly.h"
#endif
#if defined(MBEDTLS_AES_C)
#include "mbedtls/aes.h"
#endif
#if defined(MBEDTLS_CAMELLIA_C)
#include "mbedtls/camellia.h"
#endif
#if defined(MBEDTLS_ARIA_C)
#include "mbedtls/aria.h"
#endif
#if defined(MBEDTLS_DES_C)
#include "mbedtls/des.h"
#endif
#if defined(MBEDTLS_CHACHA20_C)
#include "mbedtls/chacha20.h"
#endif
#if defined(MBEDTLS_GCM_C)
#include "mbedtls/gcm.h"
#endif
#if defined(MBEDTLS_CCM_C)
#include "mbedtls/ccm.h"
#endif
#if defined(MBEDTLS_NIST_KW_C)
#include "mbedtls/nist_kw.h"
#endif
#if defined(MBEDTLS_CIPHER_NULL_CIPHER)
#include <string.h>
#endif
#include "mbedtls/platform.h"
enum mbedtls_cipher_base_index { … };
#if defined(MBEDTLS_GCM_C) && \
(defined(MBEDTLS_CIPHER_HAVE_GCM_AES_VIA_LEGACY_OR_USE_PSA) || \
defined(MBEDTLS_ARIA_C) || defined(MBEDTLS_CAMELLIA_C))
static void *gcm_ctx_alloc(void)
{ … }
static void gcm_ctx_free(void *ctx)
{ … }
#endif
#if defined(MBEDTLS_CCM_C) && \
(defined(MBEDTLS_CIPHER_HAVE_CCM_AES_VIA_LEGACY_OR_USE_PSA) || \
defined(MBEDTLS_ARIA_C) || defined(MBEDTLS_CAMELLIA_C))
static void *ccm_ctx_alloc(void)
{ … }
static void ccm_ctx_free(void *ctx)
{ … }
#endif
#if defined(MBEDTLS_AES_C)
static int aes_crypt_ecb_wrap(void *ctx, mbedtls_operation_t operation,
const unsigned char *input, unsigned char *output)
{ … }
#if defined(MBEDTLS_CIPHER_MODE_CBC)
static int aes_crypt_cbc_wrap(void *ctx, mbedtls_operation_t operation, size_t length,
unsigned char *iv, const unsigned char *input, unsigned char *output)
{ … }
#endif
#if defined(MBEDTLS_CIPHER_MODE_CFB)
static int aes_crypt_cfb128_wrap(void *ctx, mbedtls_operation_t operation,
size_t length, size_t *iv_off, unsigned char *iv,
const unsigned char *input, unsigned char *output)
{ … }
#endif
#if defined(MBEDTLS_CIPHER_MODE_OFB)
static int aes_crypt_ofb_wrap(void *ctx, size_t length, size_t *iv_off,
unsigned char *iv, const unsigned char *input, unsigned char *output)
{ … }
#endif
#if defined(MBEDTLS_CIPHER_MODE_CTR)
static int aes_crypt_ctr_wrap(void *ctx, size_t length, size_t *nc_off,
unsigned char *nonce_counter, unsigned char *stream_block,
const unsigned char *input, unsigned char *output)
{ … }
#endif
#if defined(MBEDTLS_CIPHER_MODE_XTS)
static int aes_crypt_xts_wrap(void *ctx, mbedtls_operation_t operation,
size_t length,
const unsigned char data_unit[16],
const unsigned char *input,
unsigned char *output)
{ … }
#endif
#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT)
static int aes_setkey_dec_wrap(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{ … }
#endif
static int aes_setkey_enc_wrap(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{ … }
static void *aes_ctx_alloc(void)
{ … }
static void aes_ctx_free(void *ctx)
{ … }
static const mbedtls_cipher_base_t aes_info = …;
static const mbedtls_cipher_info_t aes_128_ecb_info = …;
#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH)
static const mbedtls_cipher_info_t aes_192_ecb_info = …;
static const mbedtls_cipher_info_t aes_256_ecb_info = …;
#endif
#if defined(MBEDTLS_CIPHER_MODE_CBC)
static const mbedtls_cipher_info_t aes_128_cbc_info = …;
#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH)
static const mbedtls_cipher_info_t aes_192_cbc_info = …;
static const mbedtls_cipher_info_t aes_256_cbc_info = …;
#endif
#endif
#if defined(MBEDTLS_CIPHER_MODE_CFB)
static const mbedtls_cipher_info_t aes_128_cfb128_info = …;
#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH)
static const mbedtls_cipher_info_t aes_192_cfb128_info = …;
static const mbedtls_cipher_info_t aes_256_cfb128_info = …;
#endif
#endif
#if defined(MBEDTLS_CIPHER_MODE_OFB)
static const mbedtls_cipher_info_t aes_128_ofb_info = …;
#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH)
static const mbedtls_cipher_info_t aes_192_ofb_info = …;
static const mbedtls_cipher_info_t aes_256_ofb_info = …;
#endif
#endif
#if defined(MBEDTLS_CIPHER_MODE_CTR)
static const mbedtls_cipher_info_t aes_128_ctr_info = …;
#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH)
static const mbedtls_cipher_info_t aes_192_ctr_info = …;
static const mbedtls_cipher_info_t aes_256_ctr_info = …;
#endif
#endif
#if defined(MBEDTLS_CIPHER_MODE_XTS)
static int xts_aes_setkey_enc_wrap(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{ … }
static int xts_aes_setkey_dec_wrap(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{ … }
static void *xts_aes_ctx_alloc(void)
{ … }
static void xts_aes_ctx_free(void *ctx)
{ … }
static const mbedtls_cipher_base_t xts_aes_info = …;
static const mbedtls_cipher_info_t aes_128_xts_info = …;
#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH)
static const mbedtls_cipher_info_t aes_256_xts_info = …;
#endif
#endif
#endif
#if defined(MBEDTLS_GCM_C) && defined(MBEDTLS_CCM_GCM_CAN_AES)
static int gcm_aes_setkey_wrap(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{ … }
#endif
#if defined(MBEDTLS_CIPHER_HAVE_GCM_AES_VIA_LEGACY_OR_USE_PSA)
static const mbedtls_cipher_base_t gcm_aes_info = …;
#endif
#if defined(MBEDTLS_CIPHER_HAVE_GCM_AES_VIA_LEGACY_OR_USE_PSA)
static const mbedtls_cipher_info_t aes_128_gcm_info = …;
#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH)
static const mbedtls_cipher_info_t aes_192_gcm_info = …;
static const mbedtls_cipher_info_t aes_256_gcm_info = …;
#endif
#endif
#if defined(MBEDTLS_CCM_C) && defined(MBEDTLS_CCM_GCM_CAN_AES)
static int ccm_aes_setkey_wrap(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{ … }
#endif
#if defined(MBEDTLS_CIPHER_HAVE_CCM_AES_VIA_LEGACY_OR_USE_PSA)
static const mbedtls_cipher_base_t ccm_aes_info = …;
#endif
#if defined(MBEDTLS_CIPHER_HAVE_CCM_AES_VIA_LEGACY_OR_USE_PSA)
static const mbedtls_cipher_info_t aes_128_ccm_info = …;
#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH)
static const mbedtls_cipher_info_t aes_192_ccm_info = …;
static const mbedtls_cipher_info_t aes_256_ccm_info = …;
#endif
#endif
#if defined(MBEDTLS_CIPHER_HAVE_CCM_STAR_NO_TAG_AES_VIA_LEGACY_OR_USE_PSA)
static const mbedtls_cipher_info_t aes_128_ccm_star_no_tag_info = …;
#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH)
static const mbedtls_cipher_info_t aes_192_ccm_star_no_tag_info = …;
static const mbedtls_cipher_info_t aes_256_ccm_star_no_tag_info = …;
#endif
#endif
#if defined(MBEDTLS_CAMELLIA_C)
static int camellia_crypt_ecb_wrap(void *ctx, mbedtls_operation_t operation,
const unsigned char *input, unsigned char *output)
{ … }
#if defined(MBEDTLS_CIPHER_MODE_CBC)
static int camellia_crypt_cbc_wrap(void *ctx, mbedtls_operation_t operation,
size_t length, unsigned char *iv,
const unsigned char *input, unsigned char *output)
{ … }
#endif
#if defined(MBEDTLS_CIPHER_MODE_CFB)
static int camellia_crypt_cfb128_wrap(void *ctx, mbedtls_operation_t operation,
size_t length, size_t *iv_off, unsigned char *iv,
const unsigned char *input, unsigned char *output)
{ … }
#endif
#if defined(MBEDTLS_CIPHER_MODE_CTR)
static int camellia_crypt_ctr_wrap(void *ctx, size_t length, size_t *nc_off,
unsigned char *nonce_counter, unsigned char *stream_block,
const unsigned char *input, unsigned char *output)
{ … }
#endif
#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT)
static int camellia_setkey_dec_wrap(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{ … }
#endif
static int camellia_setkey_enc_wrap(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{ … }
static void *camellia_ctx_alloc(void)
{ … }
static void camellia_ctx_free(void *ctx)
{ … }
static const mbedtls_cipher_base_t camellia_info = …;
static const mbedtls_cipher_info_t camellia_128_ecb_info = …;
static const mbedtls_cipher_info_t camellia_192_ecb_info = …;
static const mbedtls_cipher_info_t camellia_256_ecb_info = …;
#if defined(MBEDTLS_CIPHER_MODE_CBC)
static const mbedtls_cipher_info_t camellia_128_cbc_info = …;
static const mbedtls_cipher_info_t camellia_192_cbc_info = …;
static const mbedtls_cipher_info_t camellia_256_cbc_info = …;
#endif
#if defined(MBEDTLS_CIPHER_MODE_CFB)
static const mbedtls_cipher_info_t camellia_128_cfb128_info = …;
static const mbedtls_cipher_info_t camellia_192_cfb128_info = …;
static const mbedtls_cipher_info_t camellia_256_cfb128_info = …;
#endif
#if defined(MBEDTLS_CIPHER_MODE_CTR)
static const mbedtls_cipher_info_t camellia_128_ctr_info = …;
static const mbedtls_cipher_info_t camellia_192_ctr_info = …;
static const mbedtls_cipher_info_t camellia_256_ctr_info = …;
#endif
#if defined(MBEDTLS_GCM_C)
static int gcm_camellia_setkey_wrap(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{ … }
static const mbedtls_cipher_base_t gcm_camellia_info = …;
static const mbedtls_cipher_info_t camellia_128_gcm_info = …;
static const mbedtls_cipher_info_t camellia_192_gcm_info = …;
static const mbedtls_cipher_info_t camellia_256_gcm_info = …;
#endif
#if defined(MBEDTLS_CCM_C)
static int ccm_camellia_setkey_wrap(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{ … }
static const mbedtls_cipher_base_t ccm_camellia_info = …;
static const mbedtls_cipher_info_t camellia_128_ccm_info = …;
static const mbedtls_cipher_info_t camellia_192_ccm_info = …;
static const mbedtls_cipher_info_t camellia_256_ccm_info = …;
static const mbedtls_cipher_info_t camellia_128_ccm_star_no_tag_info = …;
static const mbedtls_cipher_info_t camellia_192_ccm_star_no_tag_info = …;
static const mbedtls_cipher_info_t camellia_256_ccm_star_no_tag_info = …;
#endif
#endif
#if defined(MBEDTLS_ARIA_C)
static int aria_crypt_ecb_wrap(void *ctx, mbedtls_operation_t operation,
const unsigned char *input, unsigned char *output)
{ … }
#if defined(MBEDTLS_CIPHER_MODE_CBC)
static int aria_crypt_cbc_wrap(void *ctx, mbedtls_operation_t operation,
size_t length, unsigned char *iv,
const unsigned char *input, unsigned char *output)
{ … }
#endif
#if defined(MBEDTLS_CIPHER_MODE_CFB)
static int aria_crypt_cfb128_wrap(void *ctx, mbedtls_operation_t operation,
size_t length, size_t *iv_off, unsigned char *iv,
const unsigned char *input, unsigned char *output)
{ … }
#endif
#if defined(MBEDTLS_CIPHER_MODE_CTR)
static int aria_crypt_ctr_wrap(void *ctx, size_t length, size_t *nc_off,
unsigned char *nonce_counter, unsigned char *stream_block,
const unsigned char *input, unsigned char *output)
{ … }
#endif
#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT)
static int aria_setkey_dec_wrap(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{ … }
#endif
static int aria_setkey_enc_wrap(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{ … }
static void *aria_ctx_alloc(void)
{ … }
static void aria_ctx_free(void *ctx)
{ … }
static const mbedtls_cipher_base_t aria_info = …;
static const mbedtls_cipher_info_t aria_128_ecb_info = …;
static const mbedtls_cipher_info_t aria_192_ecb_info = …;
static const mbedtls_cipher_info_t aria_256_ecb_info = …;
#if defined(MBEDTLS_CIPHER_MODE_CBC)
static const mbedtls_cipher_info_t aria_128_cbc_info = …;
static const mbedtls_cipher_info_t aria_192_cbc_info = …;
static const mbedtls_cipher_info_t aria_256_cbc_info = …;
#endif
#if defined(MBEDTLS_CIPHER_MODE_CFB)
static const mbedtls_cipher_info_t aria_128_cfb128_info = …;
static const mbedtls_cipher_info_t aria_192_cfb128_info = …;
static const mbedtls_cipher_info_t aria_256_cfb128_info = …;
#endif
#if defined(MBEDTLS_CIPHER_MODE_CTR)
static const mbedtls_cipher_info_t aria_128_ctr_info = …;
static const mbedtls_cipher_info_t aria_192_ctr_info = …;
static const mbedtls_cipher_info_t aria_256_ctr_info = …;
#endif
#if defined(MBEDTLS_GCM_C)
static int gcm_aria_setkey_wrap(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{ … }
static const mbedtls_cipher_base_t gcm_aria_info = …;
static const mbedtls_cipher_info_t aria_128_gcm_info = …;
static const mbedtls_cipher_info_t aria_192_gcm_info = …;
static const mbedtls_cipher_info_t aria_256_gcm_info = …;
#endif
#if defined(MBEDTLS_CCM_C)
static int ccm_aria_setkey_wrap(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{ … }
static const mbedtls_cipher_base_t ccm_aria_info = …;
static const mbedtls_cipher_info_t aria_128_ccm_info = …;
static const mbedtls_cipher_info_t aria_192_ccm_info = …;
static const mbedtls_cipher_info_t aria_256_ccm_info = …;
static const mbedtls_cipher_info_t aria_128_ccm_star_no_tag_info = …;
static const mbedtls_cipher_info_t aria_192_ccm_star_no_tag_info = …;
static const mbedtls_cipher_info_t aria_256_ccm_star_no_tag_info = …;
#endif
#endif
#if defined(MBEDTLS_DES_C)
static int des_crypt_ecb_wrap(void *ctx, mbedtls_operation_t operation,
const unsigned char *input, unsigned char *output)
{
((void) operation);
return mbedtls_des_crypt_ecb((mbedtls_des_context *) ctx, input, output);
}
static int des3_crypt_ecb_wrap(void *ctx, mbedtls_operation_t operation,
const unsigned char *input, unsigned char *output)
{
((void) operation);
return mbedtls_des3_crypt_ecb((mbedtls_des3_context *) ctx, input, output);
}
#if defined(MBEDTLS_CIPHER_MODE_CBC)
static int des_crypt_cbc_wrap(void *ctx, mbedtls_operation_t operation, size_t length,
unsigned char *iv, const unsigned char *input, unsigned char *output)
{
return mbedtls_des_crypt_cbc((mbedtls_des_context *) ctx, operation, length, iv, input,
output);
}
#endif
#if defined(MBEDTLS_CIPHER_MODE_CBC)
static int des3_crypt_cbc_wrap(void *ctx, mbedtls_operation_t operation, size_t length,
unsigned char *iv, const unsigned char *input, unsigned char *output)
{
return mbedtls_des3_crypt_cbc((mbedtls_des3_context *) ctx, operation, length, iv, input,
output);
}
#endif
static int des_setkey_dec_wrap(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{
((void) key_bitlen);
return mbedtls_des_setkey_dec((mbedtls_des_context *) ctx, key);
}
static int des_setkey_enc_wrap(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{
((void) key_bitlen);
return mbedtls_des_setkey_enc((mbedtls_des_context *) ctx, key);
}
static int des3_set2key_dec_wrap(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{
((void) key_bitlen);
return mbedtls_des3_set2key_dec((mbedtls_des3_context *) ctx, key);
}
static int des3_set2key_enc_wrap(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{
((void) key_bitlen);
return mbedtls_des3_set2key_enc((mbedtls_des3_context *) ctx, key);
}
static int des3_set3key_dec_wrap(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{
((void) key_bitlen);
return mbedtls_des3_set3key_dec((mbedtls_des3_context *) ctx, key);
}
static int des3_set3key_enc_wrap(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{
((void) key_bitlen);
return mbedtls_des3_set3key_enc((mbedtls_des3_context *) ctx, key);
}
static void *des_ctx_alloc(void)
{
mbedtls_des_context *des = mbedtls_calloc(1, sizeof(mbedtls_des_context));
if (des == NULL) {
return NULL;
}
mbedtls_des_init(des);
return des;
}
static void des_ctx_free(void *ctx)
{
mbedtls_des_free((mbedtls_des_context *) ctx);
mbedtls_free(ctx);
}
static void *des3_ctx_alloc(void)
{
mbedtls_des3_context *des3;
des3 = mbedtls_calloc(1, sizeof(mbedtls_des3_context));
if (des3 == NULL) {
return NULL;
}
mbedtls_des3_init(des3);
return des3;
}
static void des3_ctx_free(void *ctx)
{
mbedtls_des3_free((mbedtls_des3_context *) ctx);
mbedtls_free(ctx);
}
static const mbedtls_cipher_base_t des_info = {
MBEDTLS_CIPHER_ID_DES,
des_crypt_ecb_wrap,
#if defined(MBEDTLS_CIPHER_MODE_CBC)
des_crypt_cbc_wrap,
#endif
#if defined(MBEDTLS_CIPHER_MODE_CFB)
NULL,
#endif
#if defined(MBEDTLS_CIPHER_MODE_OFB)
NULL,
#endif
#if defined(MBEDTLS_CIPHER_MODE_CTR)
NULL,
#endif
#if defined(MBEDTLS_CIPHER_MODE_XTS)
NULL,
#endif
#if defined(MBEDTLS_CIPHER_MODE_STREAM)
NULL,
#endif
des_setkey_enc_wrap,
des_setkey_dec_wrap,
des_ctx_alloc,
des_ctx_free
};
static const mbedtls_cipher_info_t des_ecb_info = {
"DES-ECB",
8,
0 >> MBEDTLS_IV_SIZE_SHIFT,
MBEDTLS_KEY_LENGTH_DES >> MBEDTLS_KEY_BITLEN_SHIFT,
MBEDTLS_MODE_ECB,
MBEDTLS_CIPHER_DES_ECB,
0,
MBEDTLS_CIPHER_BASE_INDEX_DES
};
#if defined(MBEDTLS_CIPHER_MODE_CBC)
static const mbedtls_cipher_info_t des_cbc_info = {
"DES-CBC",
8,
8 >> MBEDTLS_IV_SIZE_SHIFT,
MBEDTLS_KEY_LENGTH_DES >> MBEDTLS_KEY_BITLEN_SHIFT,
MBEDTLS_MODE_CBC,
MBEDTLS_CIPHER_DES_CBC,
0,
MBEDTLS_CIPHER_BASE_INDEX_DES
};
#endif
static const mbedtls_cipher_base_t des_ede_info = {
MBEDTLS_CIPHER_ID_DES,
des3_crypt_ecb_wrap,
#if defined(MBEDTLS_CIPHER_MODE_CBC)
des3_crypt_cbc_wrap,
#endif
#if defined(MBEDTLS_CIPHER_MODE_CFB)
NULL,
#endif
#if defined(MBEDTLS_CIPHER_MODE_OFB)
NULL,
#endif
#if defined(MBEDTLS_CIPHER_MODE_CTR)
NULL,
#endif
#if defined(MBEDTLS_CIPHER_MODE_XTS)
NULL,
#endif
#if defined(MBEDTLS_CIPHER_MODE_STREAM)
NULL,
#endif
des3_set2key_enc_wrap,
des3_set2key_dec_wrap,
des3_ctx_alloc,
des3_ctx_free
};
static const mbedtls_cipher_info_t des_ede_ecb_info = {
"DES-EDE-ECB",
8,
0 >> MBEDTLS_IV_SIZE_SHIFT,
MBEDTLS_KEY_LENGTH_DES_EDE >> MBEDTLS_KEY_BITLEN_SHIFT,
MBEDTLS_MODE_ECB,
MBEDTLS_CIPHER_DES_EDE_ECB,
0,
MBEDTLS_CIPHER_BASE_INDEX_DES_EDE
};
#if defined(MBEDTLS_CIPHER_MODE_CBC)
static const mbedtls_cipher_info_t des_ede_cbc_info = {
"DES-EDE-CBC",
8,
8 >> MBEDTLS_IV_SIZE_SHIFT,
MBEDTLS_KEY_LENGTH_DES_EDE >> MBEDTLS_KEY_BITLEN_SHIFT,
MBEDTLS_MODE_CBC,
MBEDTLS_CIPHER_DES_EDE_CBC,
0,
MBEDTLS_CIPHER_BASE_INDEX_DES_EDE
};
#endif
static const mbedtls_cipher_base_t des_ede3_info = {
MBEDTLS_CIPHER_ID_3DES,
des3_crypt_ecb_wrap,
#if defined(MBEDTLS_CIPHER_MODE_CBC)
des3_crypt_cbc_wrap,
#endif
#if defined(MBEDTLS_CIPHER_MODE_CFB)
NULL,
#endif
#if defined(MBEDTLS_CIPHER_MODE_OFB)
NULL,
#endif
#if defined(MBEDTLS_CIPHER_MODE_CTR)
NULL,
#endif
#if defined(MBEDTLS_CIPHER_MODE_XTS)
NULL,
#endif
#if defined(MBEDTLS_CIPHER_MODE_STREAM)
NULL,
#endif
des3_set3key_enc_wrap,
des3_set3key_dec_wrap,
des3_ctx_alloc,
des3_ctx_free
};
static const mbedtls_cipher_info_t des_ede3_ecb_info = {
"DES-EDE3-ECB",
8,
0 >> MBEDTLS_IV_SIZE_SHIFT,
MBEDTLS_KEY_LENGTH_DES_EDE3 >> MBEDTLS_KEY_BITLEN_SHIFT,
MBEDTLS_MODE_ECB,
MBEDTLS_CIPHER_DES_EDE3_ECB,
0,
MBEDTLS_CIPHER_BASE_INDEX_DES_EDE3
};
#if defined(MBEDTLS_CIPHER_MODE_CBC)
static const mbedtls_cipher_info_t des_ede3_cbc_info = {
"DES-EDE3-CBC",
8,
8 >> MBEDTLS_IV_SIZE_SHIFT,
MBEDTLS_KEY_LENGTH_DES_EDE3 >> MBEDTLS_KEY_BITLEN_SHIFT,
MBEDTLS_MODE_CBC,
MBEDTLS_CIPHER_DES_EDE3_CBC,
0,
MBEDTLS_CIPHER_BASE_INDEX_DES_EDE3
};
#endif
#endif
#if defined(MBEDTLS_CHACHA20_C)
static int chacha20_setkey_wrap(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{ … }
static int chacha20_stream_wrap(void *ctx, size_t length,
const unsigned char *input,
unsigned char *output)
{ … }
static void *chacha20_ctx_alloc(void)
{ … }
static void chacha20_ctx_free(void *ctx)
{ … }
static const mbedtls_cipher_base_t chacha20_base_info = …;
static const mbedtls_cipher_info_t chacha20_info = …;
#endif
#if defined(MBEDTLS_CHACHAPOLY_C)
static int chachapoly_setkey_wrap(void *ctx,
const unsigned char *key,
unsigned int key_bitlen)
{ … }
static void *chachapoly_ctx_alloc(void)
{ … }
static void chachapoly_ctx_free(void *ctx)
{ … }
static const mbedtls_cipher_base_t chachapoly_base_info = …;
static const mbedtls_cipher_info_t chachapoly_info = …;
#endif
#if defined(MBEDTLS_CIPHER_NULL_CIPHER)
static int null_crypt_stream(void *ctx, size_t length,
const unsigned char *input,
unsigned char *output)
{
((void) ctx);
memmove(output, input, length);
return 0;
}
static int null_setkey(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{
((void) ctx);
((void) key);
((void) key_bitlen);
return 0;
}
static void *null_ctx_alloc(void)
{
return (void *) 1;
}
static void null_ctx_free(void *ctx)
{
((void) ctx);
}
static const mbedtls_cipher_base_t null_base_info = {
MBEDTLS_CIPHER_ID_NULL,
NULL,
#if defined(MBEDTLS_CIPHER_MODE_CBC)
NULL,
#endif
#if defined(MBEDTLS_CIPHER_MODE_CFB)
NULL,
#endif
#if defined(MBEDTLS_CIPHER_MODE_OFB)
NULL,
#endif
#if defined(MBEDTLS_CIPHER_MODE_CTR)
NULL,
#endif
#if defined(MBEDTLS_CIPHER_MODE_XTS)
NULL,
#endif
#if defined(MBEDTLS_CIPHER_MODE_STREAM)
null_crypt_stream,
#endif
null_setkey,
#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT)
null_setkey,
#endif
null_ctx_alloc,
null_ctx_free
};
static const mbedtls_cipher_info_t null_cipher_info = {
"NULL",
1,
0 >> MBEDTLS_IV_SIZE_SHIFT,
0 >> MBEDTLS_KEY_BITLEN_SHIFT,
MBEDTLS_MODE_STREAM,
MBEDTLS_CIPHER_NULL,
0,
MBEDTLS_CIPHER_BASE_INDEX_NULL_BASE
};
#endif
#if defined(MBEDTLS_NIST_KW_C)
static void *kw_ctx_alloc(void)
{ … }
static void kw_ctx_free(void *ctx)
{ … }
static int kw_aes_setkey_wrap(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{ … }
static int kw_aes_setkey_unwrap(void *ctx, const unsigned char *key,
unsigned int key_bitlen)
{ … }
static const mbedtls_cipher_base_t kw_aes_info = …;
static const mbedtls_cipher_info_t aes_128_nist_kw_info = …;
#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH)
static const mbedtls_cipher_info_t aes_192_nist_kw_info = …;
static const mbedtls_cipher_info_t aes_256_nist_kw_info = …;
#endif
static const mbedtls_cipher_info_t aes_128_nist_kwp_info = …;
#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH)
static const mbedtls_cipher_info_t aes_192_nist_kwp_info = …;
static const mbedtls_cipher_info_t aes_256_nist_kwp_info = …;
#endif
#endif
const mbedtls_cipher_definition_t mbedtls_cipher_definitions[] = …;
#define NUM_CIPHERS …
int mbedtls_cipher_supported[NUM_CIPHERS];
const mbedtls_cipher_base_t *mbedtls_cipher_base_lookup_table[] = …;
#endif