1a8e1175bSopenharmony_ci/** 2a8e1175bSopenharmony_ci * \file cipher_wrap.c 3a8e1175bSopenharmony_ci * 4a8e1175bSopenharmony_ci * \brief Generic cipher wrapper for Mbed TLS 5a8e1175bSopenharmony_ci * 6a8e1175bSopenharmony_ci * \author Adriaan de Jong <dejong@fox-it.com> 7a8e1175bSopenharmony_ci * 8a8e1175bSopenharmony_ci * Copyright The Mbed TLS Contributors 9a8e1175bSopenharmony_ci * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 10a8e1175bSopenharmony_ci */ 11a8e1175bSopenharmony_ci 12a8e1175bSopenharmony_ci#include "common.h" 13a8e1175bSopenharmony_ci 14a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_C) 15a8e1175bSopenharmony_ci 16a8e1175bSopenharmony_ci#include "cipher_wrap.h" 17a8e1175bSopenharmony_ci#include "mbedtls/error.h" 18a8e1175bSopenharmony_ci 19a8e1175bSopenharmony_ci#if defined(MBEDTLS_CHACHAPOLY_C) 20a8e1175bSopenharmony_ci#include "mbedtls/chachapoly.h" 21a8e1175bSopenharmony_ci#endif 22a8e1175bSopenharmony_ci 23a8e1175bSopenharmony_ci#if defined(MBEDTLS_AES_C) 24a8e1175bSopenharmony_ci#include "mbedtls/aes.h" 25a8e1175bSopenharmony_ci#endif 26a8e1175bSopenharmony_ci 27a8e1175bSopenharmony_ci#if defined(MBEDTLS_CAMELLIA_C) 28a8e1175bSopenharmony_ci#include "mbedtls/camellia.h" 29a8e1175bSopenharmony_ci#endif 30a8e1175bSopenharmony_ci 31a8e1175bSopenharmony_ci#if defined(MBEDTLS_ARIA_C) 32a8e1175bSopenharmony_ci#include "mbedtls/aria.h" 33a8e1175bSopenharmony_ci#endif 34a8e1175bSopenharmony_ci 35a8e1175bSopenharmony_ci#if defined(MBEDTLS_DES_C) 36a8e1175bSopenharmony_ci#include "mbedtls/des.h" 37a8e1175bSopenharmony_ci#endif 38a8e1175bSopenharmony_ci 39a8e1175bSopenharmony_ci#if defined(MBEDTLS_CHACHA20_C) 40a8e1175bSopenharmony_ci#include "mbedtls/chacha20.h" 41a8e1175bSopenharmony_ci#endif 42a8e1175bSopenharmony_ci 43a8e1175bSopenharmony_ci#if defined(MBEDTLS_GCM_C) 44a8e1175bSopenharmony_ci#include "mbedtls/gcm.h" 45a8e1175bSopenharmony_ci#endif 46a8e1175bSopenharmony_ci 47a8e1175bSopenharmony_ci#if defined(MBEDTLS_CCM_C) 48a8e1175bSopenharmony_ci#include "mbedtls/ccm.h" 49a8e1175bSopenharmony_ci#endif 50a8e1175bSopenharmony_ci 51a8e1175bSopenharmony_ci#if defined(MBEDTLS_NIST_KW_C) 52a8e1175bSopenharmony_ci#include "mbedtls/nist_kw.h" 53a8e1175bSopenharmony_ci#endif 54a8e1175bSopenharmony_ci 55a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_NULL_CIPHER) 56a8e1175bSopenharmony_ci#include <string.h> 57a8e1175bSopenharmony_ci#endif 58a8e1175bSopenharmony_ci 59a8e1175bSopenharmony_ci#include "mbedtls/platform.h" 60a8e1175bSopenharmony_ci 61a8e1175bSopenharmony_cienum mbedtls_cipher_base_index { 62a8e1175bSopenharmony_ci#if defined(MBEDTLS_AES_C) 63a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_AES, 64a8e1175bSopenharmony_ci#endif 65a8e1175bSopenharmony_ci#if defined(MBEDTLS_ARIA_C) 66a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_ARIA, 67a8e1175bSopenharmony_ci#endif 68a8e1175bSopenharmony_ci#if defined(MBEDTLS_CAMELLIA_C) 69a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CAMELLIA, 70a8e1175bSopenharmony_ci#endif 71a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_HAVE_CCM_AES_VIA_LEGACY_OR_USE_PSA) 72a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CCM_AES, 73a8e1175bSopenharmony_ci#endif 74a8e1175bSopenharmony_ci#if defined(MBEDTLS_CCM_C) && defined(MBEDTLS_ARIA_C) 75a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CCM_ARIA, 76a8e1175bSopenharmony_ci#endif 77a8e1175bSopenharmony_ci#if defined(MBEDTLS_CCM_C) && defined(MBEDTLS_CAMELLIA_C) 78a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CCM_CAMELLIA, 79a8e1175bSopenharmony_ci#endif 80a8e1175bSopenharmony_ci#if defined(MBEDTLS_CHACHA20_C) 81a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CHACHA20_BASE, 82a8e1175bSopenharmony_ci#endif 83a8e1175bSopenharmony_ci#if defined(MBEDTLS_CHACHAPOLY_C) 84a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CHACHAPOLY_BASE, 85a8e1175bSopenharmony_ci#endif 86a8e1175bSopenharmony_ci#if defined(MBEDTLS_DES_C) 87a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_DES_EDE3, 88a8e1175bSopenharmony_ci#endif 89a8e1175bSopenharmony_ci#if defined(MBEDTLS_DES_C) 90a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_DES_EDE, 91a8e1175bSopenharmony_ci#endif 92a8e1175bSopenharmony_ci#if defined(MBEDTLS_DES_C) 93a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_DES, 94a8e1175bSopenharmony_ci#endif 95a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_HAVE_GCM_AES_VIA_LEGACY_OR_USE_PSA) 96a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_GCM_AES, 97a8e1175bSopenharmony_ci#endif 98a8e1175bSopenharmony_ci#if defined(MBEDTLS_GCM_C) && defined(MBEDTLS_ARIA_C) 99a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_GCM_ARIA, 100a8e1175bSopenharmony_ci#endif 101a8e1175bSopenharmony_ci#if defined(MBEDTLS_GCM_C) && defined(MBEDTLS_CAMELLIA_C) 102a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_GCM_CAMELLIA, 103a8e1175bSopenharmony_ci#endif 104a8e1175bSopenharmony_ci#if defined(MBEDTLS_NIST_KW_C) 105a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_KW_AES, 106a8e1175bSopenharmony_ci#endif 107a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_NULL_CIPHER) 108a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_NULL_BASE, 109a8e1175bSopenharmony_ci#endif 110a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_XTS) && defined(MBEDTLS_AES_C) 111a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_XTS_AES, 112a8e1175bSopenharmony_ci#endif 113a8e1175bSopenharmony_ci /* Prevent compile failure due to empty enum */ 114a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_PREVENT_EMPTY_ENUM 115a8e1175bSopenharmony_ci}; 116a8e1175bSopenharmony_ci 117a8e1175bSopenharmony_ci#if defined(MBEDTLS_GCM_C) && \ 118a8e1175bSopenharmony_ci (defined(MBEDTLS_CIPHER_HAVE_GCM_AES_VIA_LEGACY_OR_USE_PSA) || \ 119a8e1175bSopenharmony_ci defined(MBEDTLS_ARIA_C) || defined(MBEDTLS_CAMELLIA_C)) 120a8e1175bSopenharmony_ci/* shared by all GCM ciphers */ 121a8e1175bSopenharmony_cistatic void *gcm_ctx_alloc(void) 122a8e1175bSopenharmony_ci{ 123a8e1175bSopenharmony_ci void *ctx = mbedtls_calloc(1, sizeof(mbedtls_gcm_context)); 124a8e1175bSopenharmony_ci 125a8e1175bSopenharmony_ci if (ctx != NULL) { 126a8e1175bSopenharmony_ci mbedtls_gcm_init((mbedtls_gcm_context *) ctx); 127a8e1175bSopenharmony_ci } 128a8e1175bSopenharmony_ci 129a8e1175bSopenharmony_ci return ctx; 130a8e1175bSopenharmony_ci} 131a8e1175bSopenharmony_ci 132a8e1175bSopenharmony_cistatic void gcm_ctx_free(void *ctx) 133a8e1175bSopenharmony_ci{ 134a8e1175bSopenharmony_ci mbedtls_gcm_free(ctx); 135a8e1175bSopenharmony_ci mbedtls_free(ctx); 136a8e1175bSopenharmony_ci} 137a8e1175bSopenharmony_ci#endif /* MBEDTLS_GCM_C */ 138a8e1175bSopenharmony_ci 139a8e1175bSopenharmony_ci#if defined(MBEDTLS_CCM_C) && \ 140a8e1175bSopenharmony_ci (defined(MBEDTLS_CIPHER_HAVE_CCM_AES_VIA_LEGACY_OR_USE_PSA) || \ 141a8e1175bSopenharmony_ci defined(MBEDTLS_ARIA_C) || defined(MBEDTLS_CAMELLIA_C)) 142a8e1175bSopenharmony_ci/* shared by all CCM ciphers */ 143a8e1175bSopenharmony_cistatic void *ccm_ctx_alloc(void) 144a8e1175bSopenharmony_ci{ 145a8e1175bSopenharmony_ci void *ctx = mbedtls_calloc(1, sizeof(mbedtls_ccm_context)); 146a8e1175bSopenharmony_ci 147a8e1175bSopenharmony_ci if (ctx != NULL) { 148a8e1175bSopenharmony_ci mbedtls_ccm_init((mbedtls_ccm_context *) ctx); 149a8e1175bSopenharmony_ci } 150a8e1175bSopenharmony_ci 151a8e1175bSopenharmony_ci return ctx; 152a8e1175bSopenharmony_ci} 153a8e1175bSopenharmony_ci 154a8e1175bSopenharmony_cistatic void ccm_ctx_free(void *ctx) 155a8e1175bSopenharmony_ci{ 156a8e1175bSopenharmony_ci mbedtls_ccm_free(ctx); 157a8e1175bSopenharmony_ci mbedtls_free(ctx); 158a8e1175bSopenharmony_ci} 159a8e1175bSopenharmony_ci#endif /* MBEDTLS_CCM_C */ 160a8e1175bSopenharmony_ci 161a8e1175bSopenharmony_ci#if defined(MBEDTLS_AES_C) 162a8e1175bSopenharmony_ci 163a8e1175bSopenharmony_cistatic int aes_crypt_ecb_wrap(void *ctx, mbedtls_operation_t operation, 164a8e1175bSopenharmony_ci const unsigned char *input, unsigned char *output) 165a8e1175bSopenharmony_ci{ 166a8e1175bSopenharmony_ci return mbedtls_aes_crypt_ecb((mbedtls_aes_context *) ctx, operation, input, output); 167a8e1175bSopenharmony_ci} 168a8e1175bSopenharmony_ci 169a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 170a8e1175bSopenharmony_cistatic int aes_crypt_cbc_wrap(void *ctx, mbedtls_operation_t operation, size_t length, 171a8e1175bSopenharmony_ci unsigned char *iv, const unsigned char *input, unsigned char *output) 172a8e1175bSopenharmony_ci{ 173a8e1175bSopenharmony_ci return mbedtls_aes_crypt_cbc((mbedtls_aes_context *) ctx, operation, length, iv, input, 174a8e1175bSopenharmony_ci output); 175a8e1175bSopenharmony_ci} 176a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_CBC */ 177a8e1175bSopenharmony_ci 178a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 179a8e1175bSopenharmony_cistatic int aes_crypt_cfb128_wrap(void *ctx, mbedtls_operation_t operation, 180a8e1175bSopenharmony_ci size_t length, size_t *iv_off, unsigned char *iv, 181a8e1175bSopenharmony_ci const unsigned char *input, unsigned char *output) 182a8e1175bSopenharmony_ci{ 183a8e1175bSopenharmony_ci return mbedtls_aes_crypt_cfb128((mbedtls_aes_context *) ctx, operation, length, iv_off, iv, 184a8e1175bSopenharmony_ci input, output); 185a8e1175bSopenharmony_ci} 186a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_CFB */ 187a8e1175bSopenharmony_ci 188a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_OFB) 189a8e1175bSopenharmony_cistatic int aes_crypt_ofb_wrap(void *ctx, size_t length, size_t *iv_off, 190a8e1175bSopenharmony_ci unsigned char *iv, const unsigned char *input, unsigned char *output) 191a8e1175bSopenharmony_ci{ 192a8e1175bSopenharmony_ci return mbedtls_aes_crypt_ofb((mbedtls_aes_context *) ctx, length, iv_off, 193a8e1175bSopenharmony_ci iv, input, output); 194a8e1175bSopenharmony_ci} 195a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_OFB */ 196a8e1175bSopenharmony_ci 197a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 198a8e1175bSopenharmony_cistatic int aes_crypt_ctr_wrap(void *ctx, size_t length, size_t *nc_off, 199a8e1175bSopenharmony_ci unsigned char *nonce_counter, unsigned char *stream_block, 200a8e1175bSopenharmony_ci const unsigned char *input, unsigned char *output) 201a8e1175bSopenharmony_ci{ 202a8e1175bSopenharmony_ci return mbedtls_aes_crypt_ctr((mbedtls_aes_context *) ctx, length, nc_off, nonce_counter, 203a8e1175bSopenharmony_ci stream_block, input, output); 204a8e1175bSopenharmony_ci} 205a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_CTR */ 206a8e1175bSopenharmony_ci 207a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_XTS) 208a8e1175bSopenharmony_cistatic int aes_crypt_xts_wrap(void *ctx, mbedtls_operation_t operation, 209a8e1175bSopenharmony_ci size_t length, 210a8e1175bSopenharmony_ci const unsigned char data_unit[16], 211a8e1175bSopenharmony_ci const unsigned char *input, 212a8e1175bSopenharmony_ci unsigned char *output) 213a8e1175bSopenharmony_ci{ 214a8e1175bSopenharmony_ci mbedtls_aes_xts_context *xts_ctx = ctx; 215a8e1175bSopenharmony_ci int mode; 216a8e1175bSopenharmony_ci 217a8e1175bSopenharmony_ci switch (operation) { 218a8e1175bSopenharmony_ci case MBEDTLS_ENCRYPT: 219a8e1175bSopenharmony_ci mode = MBEDTLS_AES_ENCRYPT; 220a8e1175bSopenharmony_ci break; 221a8e1175bSopenharmony_ci case MBEDTLS_DECRYPT: 222a8e1175bSopenharmony_ci mode = MBEDTLS_AES_DECRYPT; 223a8e1175bSopenharmony_ci break; 224a8e1175bSopenharmony_ci default: 225a8e1175bSopenharmony_ci return MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA; 226a8e1175bSopenharmony_ci } 227a8e1175bSopenharmony_ci 228a8e1175bSopenharmony_ci return mbedtls_aes_crypt_xts(xts_ctx, mode, length, 229a8e1175bSopenharmony_ci data_unit, input, output); 230a8e1175bSopenharmony_ci} 231a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_XTS */ 232a8e1175bSopenharmony_ci 233a8e1175bSopenharmony_ci#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT) 234a8e1175bSopenharmony_cistatic int aes_setkey_dec_wrap(void *ctx, const unsigned char *key, 235a8e1175bSopenharmony_ci unsigned int key_bitlen) 236a8e1175bSopenharmony_ci{ 237a8e1175bSopenharmony_ci return mbedtls_aes_setkey_dec((mbedtls_aes_context *) ctx, key, key_bitlen); 238a8e1175bSopenharmony_ci} 239a8e1175bSopenharmony_ci#endif 240a8e1175bSopenharmony_ci 241a8e1175bSopenharmony_cistatic int aes_setkey_enc_wrap(void *ctx, const unsigned char *key, 242a8e1175bSopenharmony_ci unsigned int key_bitlen) 243a8e1175bSopenharmony_ci{ 244a8e1175bSopenharmony_ci return mbedtls_aes_setkey_enc((mbedtls_aes_context *) ctx, key, key_bitlen); 245a8e1175bSopenharmony_ci} 246a8e1175bSopenharmony_ci 247a8e1175bSopenharmony_cistatic void *aes_ctx_alloc(void) 248a8e1175bSopenharmony_ci{ 249a8e1175bSopenharmony_ci mbedtls_aes_context *aes = mbedtls_calloc(1, sizeof(mbedtls_aes_context)); 250a8e1175bSopenharmony_ci 251a8e1175bSopenharmony_ci if (aes == NULL) { 252a8e1175bSopenharmony_ci return NULL; 253a8e1175bSopenharmony_ci } 254a8e1175bSopenharmony_ci 255a8e1175bSopenharmony_ci mbedtls_aes_init(aes); 256a8e1175bSopenharmony_ci 257a8e1175bSopenharmony_ci return aes; 258a8e1175bSopenharmony_ci} 259a8e1175bSopenharmony_ci 260a8e1175bSopenharmony_cistatic void aes_ctx_free(void *ctx) 261a8e1175bSopenharmony_ci{ 262a8e1175bSopenharmony_ci mbedtls_aes_free((mbedtls_aes_context *) ctx); 263a8e1175bSopenharmony_ci mbedtls_free(ctx); 264a8e1175bSopenharmony_ci} 265a8e1175bSopenharmony_ci 266a8e1175bSopenharmony_cistatic const mbedtls_cipher_base_t aes_info = { 267a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ID_AES, 268a8e1175bSopenharmony_ci aes_crypt_ecb_wrap, 269a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 270a8e1175bSopenharmony_ci aes_crypt_cbc_wrap, 271a8e1175bSopenharmony_ci#endif 272a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 273a8e1175bSopenharmony_ci aes_crypt_cfb128_wrap, 274a8e1175bSopenharmony_ci#endif 275a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_OFB) 276a8e1175bSopenharmony_ci aes_crypt_ofb_wrap, 277a8e1175bSopenharmony_ci#endif 278a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 279a8e1175bSopenharmony_ci aes_crypt_ctr_wrap, 280a8e1175bSopenharmony_ci#endif 281a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_XTS) 282a8e1175bSopenharmony_ci NULL, 283a8e1175bSopenharmony_ci#endif 284a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_STREAM) 285a8e1175bSopenharmony_ci NULL, 286a8e1175bSopenharmony_ci#endif 287a8e1175bSopenharmony_ci aes_setkey_enc_wrap, 288a8e1175bSopenharmony_ci#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT) 289a8e1175bSopenharmony_ci aes_setkey_dec_wrap, 290a8e1175bSopenharmony_ci#endif 291a8e1175bSopenharmony_ci aes_ctx_alloc, 292a8e1175bSopenharmony_ci aes_ctx_free 293a8e1175bSopenharmony_ci}; 294a8e1175bSopenharmony_ci 295a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_128_ecb_info = { 296a8e1175bSopenharmony_ci "AES-128-ECB", 297a8e1175bSopenharmony_ci 16, 298a8e1175bSopenharmony_ci 0 >> MBEDTLS_IV_SIZE_SHIFT, 299a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 300a8e1175bSopenharmony_ci MBEDTLS_MODE_ECB, 301a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_128_ECB, 302a8e1175bSopenharmony_ci 0, 303a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_AES 304a8e1175bSopenharmony_ci}; 305a8e1175bSopenharmony_ci 306a8e1175bSopenharmony_ci#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) 307a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_192_ecb_info = { 308a8e1175bSopenharmony_ci "AES-192-ECB", 309a8e1175bSopenharmony_ci 16, 310a8e1175bSopenharmony_ci 0 >> MBEDTLS_IV_SIZE_SHIFT, 311a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 312a8e1175bSopenharmony_ci MBEDTLS_MODE_ECB, 313a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_192_ECB, 314a8e1175bSopenharmony_ci 0, 315a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_AES 316a8e1175bSopenharmony_ci}; 317a8e1175bSopenharmony_ci 318a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_256_ecb_info = { 319a8e1175bSopenharmony_ci "AES-256-ECB", 320a8e1175bSopenharmony_ci 16, 321a8e1175bSopenharmony_ci 0 >> MBEDTLS_IV_SIZE_SHIFT, 322a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 323a8e1175bSopenharmony_ci MBEDTLS_MODE_ECB, 324a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_256_ECB, 325a8e1175bSopenharmony_ci 0, 326a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_AES 327a8e1175bSopenharmony_ci}; 328a8e1175bSopenharmony_ci#endif 329a8e1175bSopenharmony_ci 330a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 331a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_128_cbc_info = { 332a8e1175bSopenharmony_ci "AES-128-CBC", 333a8e1175bSopenharmony_ci 16, 334a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 335a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 336a8e1175bSopenharmony_ci MBEDTLS_MODE_CBC, 337a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_128_CBC, 338a8e1175bSopenharmony_ci 0, 339a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_AES 340a8e1175bSopenharmony_ci}; 341a8e1175bSopenharmony_ci 342a8e1175bSopenharmony_ci#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) 343a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_192_cbc_info = { 344a8e1175bSopenharmony_ci "AES-192-CBC", 345a8e1175bSopenharmony_ci 16, 346a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 347a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 348a8e1175bSopenharmony_ci MBEDTLS_MODE_CBC, 349a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_192_CBC, 350a8e1175bSopenharmony_ci 0, 351a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_AES 352a8e1175bSopenharmony_ci}; 353a8e1175bSopenharmony_ci 354a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_256_cbc_info = { 355a8e1175bSopenharmony_ci "AES-256-CBC", 356a8e1175bSopenharmony_ci 16, 357a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 358a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 359a8e1175bSopenharmony_ci MBEDTLS_MODE_CBC, 360a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_256_CBC, 361a8e1175bSopenharmony_ci 0, 362a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_AES 363a8e1175bSopenharmony_ci}; 364a8e1175bSopenharmony_ci#endif 365a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_CBC */ 366a8e1175bSopenharmony_ci 367a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 368a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_128_cfb128_info = { 369a8e1175bSopenharmony_ci "AES-128-CFB128", 370a8e1175bSopenharmony_ci 16, 371a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 372a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 373a8e1175bSopenharmony_ci MBEDTLS_MODE_CFB, 374a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_128_CFB128, 375a8e1175bSopenharmony_ci 0, 376a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_AES 377a8e1175bSopenharmony_ci}; 378a8e1175bSopenharmony_ci 379a8e1175bSopenharmony_ci#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) 380a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_192_cfb128_info = { 381a8e1175bSopenharmony_ci "AES-192-CFB128", 382a8e1175bSopenharmony_ci 16, 383a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 384a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 385a8e1175bSopenharmony_ci MBEDTLS_MODE_CFB, 386a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_192_CFB128, 387a8e1175bSopenharmony_ci 0, 388a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_AES 389a8e1175bSopenharmony_ci}; 390a8e1175bSopenharmony_ci 391a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_256_cfb128_info = { 392a8e1175bSopenharmony_ci "AES-256-CFB128", 393a8e1175bSopenharmony_ci 16, 394a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 395a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 396a8e1175bSopenharmony_ci MBEDTLS_MODE_CFB, 397a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_256_CFB128, 398a8e1175bSopenharmony_ci 0, 399a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_AES 400a8e1175bSopenharmony_ci}; 401a8e1175bSopenharmony_ci#endif 402a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_CFB */ 403a8e1175bSopenharmony_ci 404a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_OFB) 405a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_128_ofb_info = { 406a8e1175bSopenharmony_ci "AES-128-OFB", 407a8e1175bSopenharmony_ci 16, 408a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 409a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 410a8e1175bSopenharmony_ci MBEDTLS_MODE_OFB, 411a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_128_OFB, 412a8e1175bSopenharmony_ci 0, 413a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_AES 414a8e1175bSopenharmony_ci}; 415a8e1175bSopenharmony_ci 416a8e1175bSopenharmony_ci#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) 417a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_192_ofb_info = { 418a8e1175bSopenharmony_ci "AES-192-OFB", 419a8e1175bSopenharmony_ci 16, 420a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 421a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 422a8e1175bSopenharmony_ci MBEDTLS_MODE_OFB, 423a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_192_OFB, 424a8e1175bSopenharmony_ci 0, 425a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_AES 426a8e1175bSopenharmony_ci}; 427a8e1175bSopenharmony_ci 428a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_256_ofb_info = { 429a8e1175bSopenharmony_ci "AES-256-OFB", 430a8e1175bSopenharmony_ci 16, 431a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 432a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 433a8e1175bSopenharmony_ci MBEDTLS_MODE_OFB, 434a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_256_OFB, 435a8e1175bSopenharmony_ci 0, 436a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_AES 437a8e1175bSopenharmony_ci}; 438a8e1175bSopenharmony_ci#endif 439a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_OFB */ 440a8e1175bSopenharmony_ci 441a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 442a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_128_ctr_info = { 443a8e1175bSopenharmony_ci "AES-128-CTR", 444a8e1175bSopenharmony_ci 16, 445a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 446a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 447a8e1175bSopenharmony_ci MBEDTLS_MODE_CTR, 448a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_128_CTR, 449a8e1175bSopenharmony_ci 0, 450a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_AES 451a8e1175bSopenharmony_ci}; 452a8e1175bSopenharmony_ci 453a8e1175bSopenharmony_ci#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) 454a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_192_ctr_info = { 455a8e1175bSopenharmony_ci "AES-192-CTR", 456a8e1175bSopenharmony_ci 16, 457a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 458a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 459a8e1175bSopenharmony_ci MBEDTLS_MODE_CTR, 460a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_192_CTR, 461a8e1175bSopenharmony_ci 0, 462a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_AES 463a8e1175bSopenharmony_ci}; 464a8e1175bSopenharmony_ci 465a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_256_ctr_info = { 466a8e1175bSopenharmony_ci "AES-256-CTR", 467a8e1175bSopenharmony_ci 16, 468a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 469a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 470a8e1175bSopenharmony_ci MBEDTLS_MODE_CTR, 471a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_256_CTR, 472a8e1175bSopenharmony_ci 0, 473a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_AES 474a8e1175bSopenharmony_ci}; 475a8e1175bSopenharmony_ci#endif 476a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_CTR */ 477a8e1175bSopenharmony_ci 478a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_XTS) 479a8e1175bSopenharmony_cistatic int xts_aes_setkey_enc_wrap(void *ctx, const unsigned char *key, 480a8e1175bSopenharmony_ci unsigned int key_bitlen) 481a8e1175bSopenharmony_ci{ 482a8e1175bSopenharmony_ci mbedtls_aes_xts_context *xts_ctx = ctx; 483a8e1175bSopenharmony_ci return mbedtls_aes_xts_setkey_enc(xts_ctx, key, key_bitlen); 484a8e1175bSopenharmony_ci} 485a8e1175bSopenharmony_ci 486a8e1175bSopenharmony_cistatic int xts_aes_setkey_dec_wrap(void *ctx, const unsigned char *key, 487a8e1175bSopenharmony_ci unsigned int key_bitlen) 488a8e1175bSopenharmony_ci{ 489a8e1175bSopenharmony_ci mbedtls_aes_xts_context *xts_ctx = ctx; 490a8e1175bSopenharmony_ci return mbedtls_aes_xts_setkey_dec(xts_ctx, key, key_bitlen); 491a8e1175bSopenharmony_ci} 492a8e1175bSopenharmony_ci 493a8e1175bSopenharmony_cistatic void *xts_aes_ctx_alloc(void) 494a8e1175bSopenharmony_ci{ 495a8e1175bSopenharmony_ci mbedtls_aes_xts_context *xts_ctx = mbedtls_calloc(1, sizeof(*xts_ctx)); 496a8e1175bSopenharmony_ci 497a8e1175bSopenharmony_ci if (xts_ctx != NULL) { 498a8e1175bSopenharmony_ci mbedtls_aes_xts_init(xts_ctx); 499a8e1175bSopenharmony_ci } 500a8e1175bSopenharmony_ci 501a8e1175bSopenharmony_ci return xts_ctx; 502a8e1175bSopenharmony_ci} 503a8e1175bSopenharmony_ci 504a8e1175bSopenharmony_cistatic void xts_aes_ctx_free(void *ctx) 505a8e1175bSopenharmony_ci{ 506a8e1175bSopenharmony_ci mbedtls_aes_xts_context *xts_ctx = ctx; 507a8e1175bSopenharmony_ci 508a8e1175bSopenharmony_ci if (xts_ctx == NULL) { 509a8e1175bSopenharmony_ci return; 510a8e1175bSopenharmony_ci } 511a8e1175bSopenharmony_ci 512a8e1175bSopenharmony_ci mbedtls_aes_xts_free(xts_ctx); 513a8e1175bSopenharmony_ci mbedtls_free(xts_ctx); 514a8e1175bSopenharmony_ci} 515a8e1175bSopenharmony_ci 516a8e1175bSopenharmony_cistatic const mbedtls_cipher_base_t xts_aes_info = { 517a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ID_AES, 518a8e1175bSopenharmony_ci NULL, 519a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 520a8e1175bSopenharmony_ci NULL, 521a8e1175bSopenharmony_ci#endif 522a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 523a8e1175bSopenharmony_ci NULL, 524a8e1175bSopenharmony_ci#endif 525a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_OFB) 526a8e1175bSopenharmony_ci NULL, 527a8e1175bSopenharmony_ci#endif 528a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 529a8e1175bSopenharmony_ci NULL, 530a8e1175bSopenharmony_ci#endif 531a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_XTS) 532a8e1175bSopenharmony_ci aes_crypt_xts_wrap, 533a8e1175bSopenharmony_ci#endif 534a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_STREAM) 535a8e1175bSopenharmony_ci NULL, 536a8e1175bSopenharmony_ci#endif 537a8e1175bSopenharmony_ci xts_aes_setkey_enc_wrap, 538a8e1175bSopenharmony_ci xts_aes_setkey_dec_wrap, 539a8e1175bSopenharmony_ci xts_aes_ctx_alloc, 540a8e1175bSopenharmony_ci xts_aes_ctx_free 541a8e1175bSopenharmony_ci}; 542a8e1175bSopenharmony_ci 543a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_128_xts_info = { 544a8e1175bSopenharmony_ci "AES-128-XTS", 545a8e1175bSopenharmony_ci 16, 546a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 547a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 548a8e1175bSopenharmony_ci MBEDTLS_MODE_XTS, 549a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_128_XTS, 550a8e1175bSopenharmony_ci 0, 551a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_XTS_AES 552a8e1175bSopenharmony_ci}; 553a8e1175bSopenharmony_ci 554a8e1175bSopenharmony_ci#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) 555a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_256_xts_info = { 556a8e1175bSopenharmony_ci "AES-256-XTS", 557a8e1175bSopenharmony_ci 16, 558a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 559a8e1175bSopenharmony_ci 512 >> MBEDTLS_KEY_BITLEN_SHIFT, 560a8e1175bSopenharmony_ci MBEDTLS_MODE_XTS, 561a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_256_XTS, 562a8e1175bSopenharmony_ci 0, 563a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_XTS_AES 564a8e1175bSopenharmony_ci}; 565a8e1175bSopenharmony_ci#endif 566a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_XTS */ 567a8e1175bSopenharmony_ci#endif /* MBEDTLS_AES_C */ 568a8e1175bSopenharmony_ci 569a8e1175bSopenharmony_ci#if defined(MBEDTLS_GCM_C) && defined(MBEDTLS_CCM_GCM_CAN_AES) 570a8e1175bSopenharmony_cistatic int gcm_aes_setkey_wrap(void *ctx, const unsigned char *key, 571a8e1175bSopenharmony_ci unsigned int key_bitlen) 572a8e1175bSopenharmony_ci{ 573a8e1175bSopenharmony_ci return mbedtls_gcm_setkey((mbedtls_gcm_context *) ctx, MBEDTLS_CIPHER_ID_AES, 574a8e1175bSopenharmony_ci key, key_bitlen); 575a8e1175bSopenharmony_ci} 576a8e1175bSopenharmony_ci#endif /* MBEDTLS_GCM_C && MBEDTLS_CCM_GCM_CAN_AES */ 577a8e1175bSopenharmony_ci 578a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_HAVE_GCM_AES_VIA_LEGACY_OR_USE_PSA) 579a8e1175bSopenharmony_cistatic const mbedtls_cipher_base_t gcm_aes_info = { 580a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ID_AES, 581a8e1175bSopenharmony_ci NULL, 582a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 583a8e1175bSopenharmony_ci NULL, 584a8e1175bSopenharmony_ci#endif 585a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 586a8e1175bSopenharmony_ci NULL, 587a8e1175bSopenharmony_ci#endif 588a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_OFB) 589a8e1175bSopenharmony_ci NULL, 590a8e1175bSopenharmony_ci#endif 591a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 592a8e1175bSopenharmony_ci NULL, 593a8e1175bSopenharmony_ci#endif 594a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_XTS) 595a8e1175bSopenharmony_ci NULL, 596a8e1175bSopenharmony_ci#endif 597a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_STREAM) 598a8e1175bSopenharmony_ci NULL, 599a8e1175bSopenharmony_ci#endif 600a8e1175bSopenharmony_ci#if defined(MBEDTLS_GCM_C) 601a8e1175bSopenharmony_ci gcm_aes_setkey_wrap, 602a8e1175bSopenharmony_ci#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT) 603a8e1175bSopenharmony_ci gcm_aes_setkey_wrap, 604a8e1175bSopenharmony_ci#endif 605a8e1175bSopenharmony_ci gcm_ctx_alloc, 606a8e1175bSopenharmony_ci gcm_ctx_free, 607a8e1175bSopenharmony_ci#else 608a8e1175bSopenharmony_ci NULL, 609a8e1175bSopenharmony_ci NULL, 610a8e1175bSopenharmony_ci NULL, 611a8e1175bSopenharmony_ci NULL, 612a8e1175bSopenharmony_ci#endif /* MBEDTLS_GCM_C */ 613a8e1175bSopenharmony_ci}; 614a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_HAVE_GCM_AES_VIA_LEGACY_OR_USE_PSA */ 615a8e1175bSopenharmony_ci 616a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_HAVE_GCM_AES_VIA_LEGACY_OR_USE_PSA) 617a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_128_gcm_info = { 618a8e1175bSopenharmony_ci "AES-128-GCM", 619a8e1175bSopenharmony_ci 16, 620a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 621a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 622a8e1175bSopenharmony_ci MBEDTLS_MODE_GCM, 623a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_128_GCM, 624a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 625a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_GCM_AES 626a8e1175bSopenharmony_ci}; 627a8e1175bSopenharmony_ci 628a8e1175bSopenharmony_ci#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) 629a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_192_gcm_info = { 630a8e1175bSopenharmony_ci "AES-192-GCM", 631a8e1175bSopenharmony_ci 16, 632a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 633a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 634a8e1175bSopenharmony_ci MBEDTLS_MODE_GCM, 635a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_192_GCM, 636a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 637a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_GCM_AES 638a8e1175bSopenharmony_ci}; 639a8e1175bSopenharmony_ci 640a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_256_gcm_info = { 641a8e1175bSopenharmony_ci "AES-256-GCM", 642a8e1175bSopenharmony_ci 16, 643a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 644a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 645a8e1175bSopenharmony_ci MBEDTLS_MODE_GCM, 646a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_256_GCM, 647a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 648a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_GCM_AES 649a8e1175bSopenharmony_ci}; 650a8e1175bSopenharmony_ci#endif 651a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_HAVE_GCM_AES_VIA_LEGACY_OR_USE_PSA */ 652a8e1175bSopenharmony_ci 653a8e1175bSopenharmony_ci#if defined(MBEDTLS_CCM_C) && defined(MBEDTLS_CCM_GCM_CAN_AES) 654a8e1175bSopenharmony_cistatic int ccm_aes_setkey_wrap(void *ctx, const unsigned char *key, 655a8e1175bSopenharmony_ci unsigned int key_bitlen) 656a8e1175bSopenharmony_ci{ 657a8e1175bSopenharmony_ci return mbedtls_ccm_setkey((mbedtls_ccm_context *) ctx, MBEDTLS_CIPHER_ID_AES, 658a8e1175bSopenharmony_ci key, key_bitlen); 659a8e1175bSopenharmony_ci} 660a8e1175bSopenharmony_ci#endif /* MBEDTLS_CCM_C && MBEDTLS_CCM_GCM_CAN_AES */ 661a8e1175bSopenharmony_ci 662a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_HAVE_CCM_AES_VIA_LEGACY_OR_USE_PSA) 663a8e1175bSopenharmony_cistatic const mbedtls_cipher_base_t ccm_aes_info = { 664a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ID_AES, 665a8e1175bSopenharmony_ci NULL, 666a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 667a8e1175bSopenharmony_ci NULL, 668a8e1175bSopenharmony_ci#endif 669a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 670a8e1175bSopenharmony_ci NULL, 671a8e1175bSopenharmony_ci#endif 672a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_OFB) 673a8e1175bSopenharmony_ci NULL, 674a8e1175bSopenharmony_ci#endif 675a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 676a8e1175bSopenharmony_ci NULL, 677a8e1175bSopenharmony_ci#endif 678a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_XTS) 679a8e1175bSopenharmony_ci NULL, 680a8e1175bSopenharmony_ci#endif 681a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_STREAM) 682a8e1175bSopenharmony_ci NULL, 683a8e1175bSopenharmony_ci#endif 684a8e1175bSopenharmony_ci#if defined(MBEDTLS_CCM_C) 685a8e1175bSopenharmony_ci ccm_aes_setkey_wrap, 686a8e1175bSopenharmony_ci#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT) 687a8e1175bSopenharmony_ci ccm_aes_setkey_wrap, 688a8e1175bSopenharmony_ci#endif 689a8e1175bSopenharmony_ci ccm_ctx_alloc, 690a8e1175bSopenharmony_ci ccm_ctx_free, 691a8e1175bSopenharmony_ci#else 692a8e1175bSopenharmony_ci NULL, 693a8e1175bSopenharmony_ci NULL, 694a8e1175bSopenharmony_ci NULL, 695a8e1175bSopenharmony_ci NULL, 696a8e1175bSopenharmony_ci#endif 697a8e1175bSopenharmony_ci}; 698a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_HAVE_CCM_AES_VIA_LEGACY_OR_USE_PSA */ 699a8e1175bSopenharmony_ci 700a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_HAVE_CCM_AES_VIA_LEGACY_OR_USE_PSA) 701a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_128_ccm_info = { 702a8e1175bSopenharmony_ci "AES-128-CCM", 703a8e1175bSopenharmony_ci 16, 704a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 705a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 706a8e1175bSopenharmony_ci MBEDTLS_MODE_CCM, 707a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_128_CCM, 708a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 709a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CCM_AES 710a8e1175bSopenharmony_ci}; 711a8e1175bSopenharmony_ci 712a8e1175bSopenharmony_ci#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) 713a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_192_ccm_info = { 714a8e1175bSopenharmony_ci "AES-192-CCM", 715a8e1175bSopenharmony_ci 16, 716a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 717a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 718a8e1175bSopenharmony_ci MBEDTLS_MODE_CCM, 719a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_192_CCM, 720a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 721a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CCM_AES 722a8e1175bSopenharmony_ci}; 723a8e1175bSopenharmony_ci 724a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_256_ccm_info = { 725a8e1175bSopenharmony_ci "AES-256-CCM", 726a8e1175bSopenharmony_ci 16, 727a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 728a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 729a8e1175bSopenharmony_ci MBEDTLS_MODE_CCM, 730a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_256_CCM, 731a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 732a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CCM_AES 733a8e1175bSopenharmony_ci}; 734a8e1175bSopenharmony_ci#endif 735a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_HAVE_CCM_AES_VIA_LEGACY_OR_USE_PSA */ 736a8e1175bSopenharmony_ci 737a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_HAVE_CCM_STAR_NO_TAG_AES_VIA_LEGACY_OR_USE_PSA) 738a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_128_ccm_star_no_tag_info = { 739a8e1175bSopenharmony_ci "AES-128-CCM*-NO-TAG", 740a8e1175bSopenharmony_ci 16, 741a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 742a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 743a8e1175bSopenharmony_ci MBEDTLS_MODE_CCM_STAR_NO_TAG, 744a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG, 745a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 746a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CCM_AES 747a8e1175bSopenharmony_ci}; 748a8e1175bSopenharmony_ci 749a8e1175bSopenharmony_ci#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) 750a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_192_ccm_star_no_tag_info = { 751a8e1175bSopenharmony_ci "AES-192-CCM*-NO-TAG", 752a8e1175bSopenharmony_ci 16, 753a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 754a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 755a8e1175bSopenharmony_ci MBEDTLS_MODE_CCM_STAR_NO_TAG, 756a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG, 757a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 758a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CCM_AES 759a8e1175bSopenharmony_ci}; 760a8e1175bSopenharmony_ci 761a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_256_ccm_star_no_tag_info = { 762a8e1175bSopenharmony_ci "AES-256-CCM*-NO-TAG", 763a8e1175bSopenharmony_ci 16, 764a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 765a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 766a8e1175bSopenharmony_ci MBEDTLS_MODE_CCM_STAR_NO_TAG, 767a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG, 768a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 769a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CCM_AES 770a8e1175bSopenharmony_ci}; 771a8e1175bSopenharmony_ci#endif 772a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_HAVE_CCM_STAR_NO_TAG_AES_VIA_LEGACY_OR_USE_PSA */ 773a8e1175bSopenharmony_ci 774a8e1175bSopenharmony_ci 775a8e1175bSopenharmony_ci#if defined(MBEDTLS_CAMELLIA_C) 776a8e1175bSopenharmony_ci 777a8e1175bSopenharmony_cistatic int camellia_crypt_ecb_wrap(void *ctx, mbedtls_operation_t operation, 778a8e1175bSopenharmony_ci const unsigned char *input, unsigned char *output) 779a8e1175bSopenharmony_ci{ 780a8e1175bSopenharmony_ci return mbedtls_camellia_crypt_ecb((mbedtls_camellia_context *) ctx, operation, input, 781a8e1175bSopenharmony_ci output); 782a8e1175bSopenharmony_ci} 783a8e1175bSopenharmony_ci 784a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 785a8e1175bSopenharmony_cistatic int camellia_crypt_cbc_wrap(void *ctx, mbedtls_operation_t operation, 786a8e1175bSopenharmony_ci size_t length, unsigned char *iv, 787a8e1175bSopenharmony_ci const unsigned char *input, unsigned char *output) 788a8e1175bSopenharmony_ci{ 789a8e1175bSopenharmony_ci return mbedtls_camellia_crypt_cbc((mbedtls_camellia_context *) ctx, operation, length, iv, 790a8e1175bSopenharmony_ci input, output); 791a8e1175bSopenharmony_ci} 792a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_CBC */ 793a8e1175bSopenharmony_ci 794a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 795a8e1175bSopenharmony_cistatic int camellia_crypt_cfb128_wrap(void *ctx, mbedtls_operation_t operation, 796a8e1175bSopenharmony_ci size_t length, size_t *iv_off, unsigned char *iv, 797a8e1175bSopenharmony_ci const unsigned char *input, unsigned char *output) 798a8e1175bSopenharmony_ci{ 799a8e1175bSopenharmony_ci return mbedtls_camellia_crypt_cfb128((mbedtls_camellia_context *) ctx, operation, length, 800a8e1175bSopenharmony_ci iv_off, iv, input, output); 801a8e1175bSopenharmony_ci} 802a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_CFB */ 803a8e1175bSopenharmony_ci 804a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 805a8e1175bSopenharmony_cistatic int camellia_crypt_ctr_wrap(void *ctx, size_t length, size_t *nc_off, 806a8e1175bSopenharmony_ci unsigned char *nonce_counter, unsigned char *stream_block, 807a8e1175bSopenharmony_ci const unsigned char *input, unsigned char *output) 808a8e1175bSopenharmony_ci{ 809a8e1175bSopenharmony_ci return mbedtls_camellia_crypt_ctr((mbedtls_camellia_context *) ctx, length, nc_off, 810a8e1175bSopenharmony_ci nonce_counter, stream_block, input, output); 811a8e1175bSopenharmony_ci} 812a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_CTR */ 813a8e1175bSopenharmony_ci 814a8e1175bSopenharmony_ci#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT) 815a8e1175bSopenharmony_cistatic int camellia_setkey_dec_wrap(void *ctx, const unsigned char *key, 816a8e1175bSopenharmony_ci unsigned int key_bitlen) 817a8e1175bSopenharmony_ci{ 818a8e1175bSopenharmony_ci return mbedtls_camellia_setkey_dec((mbedtls_camellia_context *) ctx, key, key_bitlen); 819a8e1175bSopenharmony_ci} 820a8e1175bSopenharmony_ci#endif 821a8e1175bSopenharmony_ci 822a8e1175bSopenharmony_cistatic int camellia_setkey_enc_wrap(void *ctx, const unsigned char *key, 823a8e1175bSopenharmony_ci unsigned int key_bitlen) 824a8e1175bSopenharmony_ci{ 825a8e1175bSopenharmony_ci return mbedtls_camellia_setkey_enc((mbedtls_camellia_context *) ctx, key, key_bitlen); 826a8e1175bSopenharmony_ci} 827a8e1175bSopenharmony_ci 828a8e1175bSopenharmony_cistatic void *camellia_ctx_alloc(void) 829a8e1175bSopenharmony_ci{ 830a8e1175bSopenharmony_ci mbedtls_camellia_context *ctx; 831a8e1175bSopenharmony_ci ctx = mbedtls_calloc(1, sizeof(mbedtls_camellia_context)); 832a8e1175bSopenharmony_ci 833a8e1175bSopenharmony_ci if (ctx == NULL) { 834a8e1175bSopenharmony_ci return NULL; 835a8e1175bSopenharmony_ci } 836a8e1175bSopenharmony_ci 837a8e1175bSopenharmony_ci mbedtls_camellia_init(ctx); 838a8e1175bSopenharmony_ci 839a8e1175bSopenharmony_ci return ctx; 840a8e1175bSopenharmony_ci} 841a8e1175bSopenharmony_ci 842a8e1175bSopenharmony_cistatic void camellia_ctx_free(void *ctx) 843a8e1175bSopenharmony_ci{ 844a8e1175bSopenharmony_ci mbedtls_camellia_free((mbedtls_camellia_context *) ctx); 845a8e1175bSopenharmony_ci mbedtls_free(ctx); 846a8e1175bSopenharmony_ci} 847a8e1175bSopenharmony_ci 848a8e1175bSopenharmony_cistatic const mbedtls_cipher_base_t camellia_info = { 849a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ID_CAMELLIA, 850a8e1175bSopenharmony_ci camellia_crypt_ecb_wrap, 851a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 852a8e1175bSopenharmony_ci camellia_crypt_cbc_wrap, 853a8e1175bSopenharmony_ci#endif 854a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 855a8e1175bSopenharmony_ci camellia_crypt_cfb128_wrap, 856a8e1175bSopenharmony_ci#endif 857a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_OFB) 858a8e1175bSopenharmony_ci NULL, 859a8e1175bSopenharmony_ci#endif 860a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 861a8e1175bSopenharmony_ci camellia_crypt_ctr_wrap, 862a8e1175bSopenharmony_ci#endif 863a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_XTS) 864a8e1175bSopenharmony_ci NULL, 865a8e1175bSopenharmony_ci#endif 866a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_STREAM) 867a8e1175bSopenharmony_ci NULL, 868a8e1175bSopenharmony_ci#endif 869a8e1175bSopenharmony_ci camellia_setkey_enc_wrap, 870a8e1175bSopenharmony_ci#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT) 871a8e1175bSopenharmony_ci camellia_setkey_dec_wrap, 872a8e1175bSopenharmony_ci#endif 873a8e1175bSopenharmony_ci camellia_ctx_alloc, 874a8e1175bSopenharmony_ci camellia_ctx_free 875a8e1175bSopenharmony_ci}; 876a8e1175bSopenharmony_ci 877a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t camellia_128_ecb_info = { 878a8e1175bSopenharmony_ci "CAMELLIA-128-ECB", 879a8e1175bSopenharmony_ci 16, 880a8e1175bSopenharmony_ci 0 >> MBEDTLS_IV_SIZE_SHIFT, 881a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 882a8e1175bSopenharmony_ci MBEDTLS_MODE_ECB, 883a8e1175bSopenharmony_ci MBEDTLS_CIPHER_CAMELLIA_128_ECB, 884a8e1175bSopenharmony_ci 0, 885a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CAMELLIA 886a8e1175bSopenharmony_ci}; 887a8e1175bSopenharmony_ci 888a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t camellia_192_ecb_info = { 889a8e1175bSopenharmony_ci "CAMELLIA-192-ECB", 890a8e1175bSopenharmony_ci 16, 891a8e1175bSopenharmony_ci 0 >> MBEDTLS_IV_SIZE_SHIFT, 892a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 893a8e1175bSopenharmony_ci MBEDTLS_MODE_ECB, 894a8e1175bSopenharmony_ci MBEDTLS_CIPHER_CAMELLIA_192_ECB, 895a8e1175bSopenharmony_ci 0, 896a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CAMELLIA 897a8e1175bSopenharmony_ci}; 898a8e1175bSopenharmony_ci 899a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t camellia_256_ecb_info = { 900a8e1175bSopenharmony_ci "CAMELLIA-256-ECB", 901a8e1175bSopenharmony_ci 16, 902a8e1175bSopenharmony_ci 0 >> MBEDTLS_IV_SIZE_SHIFT, 903a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 904a8e1175bSopenharmony_ci MBEDTLS_MODE_ECB, 905a8e1175bSopenharmony_ci MBEDTLS_CIPHER_CAMELLIA_256_ECB, 906a8e1175bSopenharmony_ci 0, 907a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CAMELLIA 908a8e1175bSopenharmony_ci}; 909a8e1175bSopenharmony_ci 910a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 911a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t camellia_128_cbc_info = { 912a8e1175bSopenharmony_ci "CAMELLIA-128-CBC", 913a8e1175bSopenharmony_ci 16, 914a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 915a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 916a8e1175bSopenharmony_ci MBEDTLS_MODE_CBC, 917a8e1175bSopenharmony_ci MBEDTLS_CIPHER_CAMELLIA_128_CBC, 918a8e1175bSopenharmony_ci 0, 919a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CAMELLIA 920a8e1175bSopenharmony_ci}; 921a8e1175bSopenharmony_ci 922a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t camellia_192_cbc_info = { 923a8e1175bSopenharmony_ci "CAMELLIA-192-CBC", 924a8e1175bSopenharmony_ci 16, 925a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 926a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 927a8e1175bSopenharmony_ci MBEDTLS_MODE_CBC, 928a8e1175bSopenharmony_ci MBEDTLS_CIPHER_CAMELLIA_192_CBC, 929a8e1175bSopenharmony_ci 0, 930a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CAMELLIA 931a8e1175bSopenharmony_ci}; 932a8e1175bSopenharmony_ci 933a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t camellia_256_cbc_info = { 934a8e1175bSopenharmony_ci "CAMELLIA-256-CBC", 935a8e1175bSopenharmony_ci 16, 936a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 937a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 938a8e1175bSopenharmony_ci MBEDTLS_MODE_CBC, 939a8e1175bSopenharmony_ci MBEDTLS_CIPHER_CAMELLIA_256_CBC, 940a8e1175bSopenharmony_ci 0, 941a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CAMELLIA 942a8e1175bSopenharmony_ci}; 943a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_CBC */ 944a8e1175bSopenharmony_ci 945a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 946a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t camellia_128_cfb128_info = { 947a8e1175bSopenharmony_ci "CAMELLIA-128-CFB128", 948a8e1175bSopenharmony_ci 16, 949a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 950a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 951a8e1175bSopenharmony_ci MBEDTLS_MODE_CFB, 952a8e1175bSopenharmony_ci MBEDTLS_CIPHER_CAMELLIA_128_CFB128, 953a8e1175bSopenharmony_ci 0, 954a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CAMELLIA 955a8e1175bSopenharmony_ci}; 956a8e1175bSopenharmony_ci 957a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t camellia_192_cfb128_info = { 958a8e1175bSopenharmony_ci "CAMELLIA-192-CFB128", 959a8e1175bSopenharmony_ci 16, 960a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 961a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 962a8e1175bSopenharmony_ci MBEDTLS_MODE_CFB, 963a8e1175bSopenharmony_ci MBEDTLS_CIPHER_CAMELLIA_192_CFB128, 964a8e1175bSopenharmony_ci 0, 965a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CAMELLIA 966a8e1175bSopenharmony_ci}; 967a8e1175bSopenharmony_ci 968a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t camellia_256_cfb128_info = { 969a8e1175bSopenharmony_ci "CAMELLIA-256-CFB128", 970a8e1175bSopenharmony_ci 16, 971a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 972a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 973a8e1175bSopenharmony_ci MBEDTLS_MODE_CFB, 974a8e1175bSopenharmony_ci MBEDTLS_CIPHER_CAMELLIA_256_CFB128, 975a8e1175bSopenharmony_ci 0, 976a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CAMELLIA 977a8e1175bSopenharmony_ci}; 978a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_CFB */ 979a8e1175bSopenharmony_ci 980a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 981a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t camellia_128_ctr_info = { 982a8e1175bSopenharmony_ci "CAMELLIA-128-CTR", 983a8e1175bSopenharmony_ci 16, 984a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 985a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 986a8e1175bSopenharmony_ci MBEDTLS_MODE_CTR, 987a8e1175bSopenharmony_ci MBEDTLS_CIPHER_CAMELLIA_128_CTR, 988a8e1175bSopenharmony_ci 0, 989a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CAMELLIA 990a8e1175bSopenharmony_ci}; 991a8e1175bSopenharmony_ci 992a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t camellia_192_ctr_info = { 993a8e1175bSopenharmony_ci "CAMELLIA-192-CTR", 994a8e1175bSopenharmony_ci 16, 995a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 996a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 997a8e1175bSopenharmony_ci MBEDTLS_MODE_CTR, 998a8e1175bSopenharmony_ci MBEDTLS_CIPHER_CAMELLIA_192_CTR, 999a8e1175bSopenharmony_ci 0, 1000a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CAMELLIA 1001a8e1175bSopenharmony_ci}; 1002a8e1175bSopenharmony_ci 1003a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t camellia_256_ctr_info = { 1004a8e1175bSopenharmony_ci "CAMELLIA-256-CTR", 1005a8e1175bSopenharmony_ci 16, 1006a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 1007a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 1008a8e1175bSopenharmony_ci MBEDTLS_MODE_CTR, 1009a8e1175bSopenharmony_ci MBEDTLS_CIPHER_CAMELLIA_256_CTR, 1010a8e1175bSopenharmony_ci 0, 1011a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CAMELLIA 1012a8e1175bSopenharmony_ci}; 1013a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_CTR */ 1014a8e1175bSopenharmony_ci 1015a8e1175bSopenharmony_ci#if defined(MBEDTLS_GCM_C) 1016a8e1175bSopenharmony_cistatic int gcm_camellia_setkey_wrap(void *ctx, const unsigned char *key, 1017a8e1175bSopenharmony_ci unsigned int key_bitlen) 1018a8e1175bSopenharmony_ci{ 1019a8e1175bSopenharmony_ci return mbedtls_gcm_setkey((mbedtls_gcm_context *) ctx, MBEDTLS_CIPHER_ID_CAMELLIA, 1020a8e1175bSopenharmony_ci key, key_bitlen); 1021a8e1175bSopenharmony_ci} 1022a8e1175bSopenharmony_ci 1023a8e1175bSopenharmony_cistatic const mbedtls_cipher_base_t gcm_camellia_info = { 1024a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ID_CAMELLIA, 1025a8e1175bSopenharmony_ci NULL, 1026a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 1027a8e1175bSopenharmony_ci NULL, 1028a8e1175bSopenharmony_ci#endif 1029a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 1030a8e1175bSopenharmony_ci NULL, 1031a8e1175bSopenharmony_ci#endif 1032a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_OFB) 1033a8e1175bSopenharmony_ci NULL, 1034a8e1175bSopenharmony_ci#endif 1035a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 1036a8e1175bSopenharmony_ci NULL, 1037a8e1175bSopenharmony_ci#endif 1038a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_XTS) 1039a8e1175bSopenharmony_ci NULL, 1040a8e1175bSopenharmony_ci#endif 1041a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_STREAM) 1042a8e1175bSopenharmony_ci NULL, 1043a8e1175bSopenharmony_ci#endif 1044a8e1175bSopenharmony_ci gcm_camellia_setkey_wrap, 1045a8e1175bSopenharmony_ci#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT) 1046a8e1175bSopenharmony_ci gcm_camellia_setkey_wrap, 1047a8e1175bSopenharmony_ci#endif 1048a8e1175bSopenharmony_ci gcm_ctx_alloc, 1049a8e1175bSopenharmony_ci gcm_ctx_free, 1050a8e1175bSopenharmony_ci}; 1051a8e1175bSopenharmony_ci 1052a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t camellia_128_gcm_info = { 1053a8e1175bSopenharmony_ci "CAMELLIA-128-GCM", 1054a8e1175bSopenharmony_ci 16, 1055a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 1056a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 1057a8e1175bSopenharmony_ci MBEDTLS_MODE_GCM, 1058a8e1175bSopenharmony_ci MBEDTLS_CIPHER_CAMELLIA_128_GCM, 1059a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 1060a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_GCM_CAMELLIA 1061a8e1175bSopenharmony_ci}; 1062a8e1175bSopenharmony_ci 1063a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t camellia_192_gcm_info = { 1064a8e1175bSopenharmony_ci "CAMELLIA-192-GCM", 1065a8e1175bSopenharmony_ci 16, 1066a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 1067a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 1068a8e1175bSopenharmony_ci MBEDTLS_MODE_GCM, 1069a8e1175bSopenharmony_ci MBEDTLS_CIPHER_CAMELLIA_192_GCM, 1070a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 1071a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_GCM_CAMELLIA 1072a8e1175bSopenharmony_ci}; 1073a8e1175bSopenharmony_ci 1074a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t camellia_256_gcm_info = { 1075a8e1175bSopenharmony_ci "CAMELLIA-256-GCM", 1076a8e1175bSopenharmony_ci 16, 1077a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 1078a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 1079a8e1175bSopenharmony_ci MBEDTLS_MODE_GCM, 1080a8e1175bSopenharmony_ci MBEDTLS_CIPHER_CAMELLIA_256_GCM, 1081a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 1082a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_GCM_CAMELLIA 1083a8e1175bSopenharmony_ci}; 1084a8e1175bSopenharmony_ci#endif /* MBEDTLS_GCM_C */ 1085a8e1175bSopenharmony_ci 1086a8e1175bSopenharmony_ci#if defined(MBEDTLS_CCM_C) 1087a8e1175bSopenharmony_cistatic int ccm_camellia_setkey_wrap(void *ctx, const unsigned char *key, 1088a8e1175bSopenharmony_ci unsigned int key_bitlen) 1089a8e1175bSopenharmony_ci{ 1090a8e1175bSopenharmony_ci return mbedtls_ccm_setkey((mbedtls_ccm_context *) ctx, MBEDTLS_CIPHER_ID_CAMELLIA, 1091a8e1175bSopenharmony_ci key, key_bitlen); 1092a8e1175bSopenharmony_ci} 1093a8e1175bSopenharmony_ci 1094a8e1175bSopenharmony_cistatic const mbedtls_cipher_base_t ccm_camellia_info = { 1095a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ID_CAMELLIA, 1096a8e1175bSopenharmony_ci NULL, 1097a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 1098a8e1175bSopenharmony_ci NULL, 1099a8e1175bSopenharmony_ci#endif 1100a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 1101a8e1175bSopenharmony_ci NULL, 1102a8e1175bSopenharmony_ci#endif 1103a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_OFB) 1104a8e1175bSopenharmony_ci NULL, 1105a8e1175bSopenharmony_ci#endif 1106a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 1107a8e1175bSopenharmony_ci NULL, 1108a8e1175bSopenharmony_ci#endif 1109a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_XTS) 1110a8e1175bSopenharmony_ci NULL, 1111a8e1175bSopenharmony_ci#endif 1112a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_STREAM) 1113a8e1175bSopenharmony_ci NULL, 1114a8e1175bSopenharmony_ci#endif 1115a8e1175bSopenharmony_ci ccm_camellia_setkey_wrap, 1116a8e1175bSopenharmony_ci#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT) 1117a8e1175bSopenharmony_ci ccm_camellia_setkey_wrap, 1118a8e1175bSopenharmony_ci#endif 1119a8e1175bSopenharmony_ci ccm_ctx_alloc, 1120a8e1175bSopenharmony_ci ccm_ctx_free, 1121a8e1175bSopenharmony_ci}; 1122a8e1175bSopenharmony_ci 1123a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t camellia_128_ccm_info = { 1124a8e1175bSopenharmony_ci "CAMELLIA-128-CCM", 1125a8e1175bSopenharmony_ci 16, 1126a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 1127a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 1128a8e1175bSopenharmony_ci MBEDTLS_MODE_CCM, 1129a8e1175bSopenharmony_ci MBEDTLS_CIPHER_CAMELLIA_128_CCM, 1130a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 1131a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CCM_CAMELLIA 1132a8e1175bSopenharmony_ci}; 1133a8e1175bSopenharmony_ci 1134a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t camellia_192_ccm_info = { 1135a8e1175bSopenharmony_ci "CAMELLIA-192-CCM", 1136a8e1175bSopenharmony_ci 16, 1137a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 1138a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 1139a8e1175bSopenharmony_ci MBEDTLS_MODE_CCM, 1140a8e1175bSopenharmony_ci MBEDTLS_CIPHER_CAMELLIA_192_CCM, 1141a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 1142a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CCM_CAMELLIA 1143a8e1175bSopenharmony_ci}; 1144a8e1175bSopenharmony_ci 1145a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t camellia_256_ccm_info = { 1146a8e1175bSopenharmony_ci "CAMELLIA-256-CCM", 1147a8e1175bSopenharmony_ci 16, 1148a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 1149a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 1150a8e1175bSopenharmony_ci MBEDTLS_MODE_CCM, 1151a8e1175bSopenharmony_ci MBEDTLS_CIPHER_CAMELLIA_256_CCM, 1152a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 1153a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CCM_CAMELLIA 1154a8e1175bSopenharmony_ci}; 1155a8e1175bSopenharmony_ci 1156a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t camellia_128_ccm_star_no_tag_info = { 1157a8e1175bSopenharmony_ci "CAMELLIA-128-CCM*-NO-TAG", 1158a8e1175bSopenharmony_ci 16, 1159a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 1160a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 1161a8e1175bSopenharmony_ci MBEDTLS_MODE_CCM_STAR_NO_TAG, 1162a8e1175bSopenharmony_ci MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG, 1163a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 1164a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CCM_CAMELLIA 1165a8e1175bSopenharmony_ci}; 1166a8e1175bSopenharmony_ci 1167a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t camellia_192_ccm_star_no_tag_info = { 1168a8e1175bSopenharmony_ci "CAMELLIA-192-CCM*-NO-TAG", 1169a8e1175bSopenharmony_ci 16, 1170a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 1171a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 1172a8e1175bSopenharmony_ci MBEDTLS_MODE_CCM_STAR_NO_TAG, 1173a8e1175bSopenharmony_ci MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG, 1174a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 1175a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CCM_CAMELLIA 1176a8e1175bSopenharmony_ci}; 1177a8e1175bSopenharmony_ci 1178a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t camellia_256_ccm_star_no_tag_info = { 1179a8e1175bSopenharmony_ci "CAMELLIA-256-CCM*-NO-TAG", 1180a8e1175bSopenharmony_ci 16, 1181a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 1182a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 1183a8e1175bSopenharmony_ci MBEDTLS_MODE_CCM_STAR_NO_TAG, 1184a8e1175bSopenharmony_ci MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG, 1185a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 1186a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CCM_CAMELLIA 1187a8e1175bSopenharmony_ci}; 1188a8e1175bSopenharmony_ci#endif /* MBEDTLS_CCM_C */ 1189a8e1175bSopenharmony_ci 1190a8e1175bSopenharmony_ci#endif /* MBEDTLS_CAMELLIA_C */ 1191a8e1175bSopenharmony_ci 1192a8e1175bSopenharmony_ci#if defined(MBEDTLS_ARIA_C) 1193a8e1175bSopenharmony_ci 1194a8e1175bSopenharmony_cistatic int aria_crypt_ecb_wrap(void *ctx, mbedtls_operation_t operation, 1195a8e1175bSopenharmony_ci const unsigned char *input, unsigned char *output) 1196a8e1175bSopenharmony_ci{ 1197a8e1175bSopenharmony_ci (void) operation; 1198a8e1175bSopenharmony_ci return mbedtls_aria_crypt_ecb((mbedtls_aria_context *) ctx, input, 1199a8e1175bSopenharmony_ci output); 1200a8e1175bSopenharmony_ci} 1201a8e1175bSopenharmony_ci 1202a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 1203a8e1175bSopenharmony_cistatic int aria_crypt_cbc_wrap(void *ctx, mbedtls_operation_t operation, 1204a8e1175bSopenharmony_ci size_t length, unsigned char *iv, 1205a8e1175bSopenharmony_ci const unsigned char *input, unsigned char *output) 1206a8e1175bSopenharmony_ci{ 1207a8e1175bSopenharmony_ci return mbedtls_aria_crypt_cbc((mbedtls_aria_context *) ctx, operation, length, iv, 1208a8e1175bSopenharmony_ci input, output); 1209a8e1175bSopenharmony_ci} 1210a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_CBC */ 1211a8e1175bSopenharmony_ci 1212a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 1213a8e1175bSopenharmony_cistatic int aria_crypt_cfb128_wrap(void *ctx, mbedtls_operation_t operation, 1214a8e1175bSopenharmony_ci size_t length, size_t *iv_off, unsigned char *iv, 1215a8e1175bSopenharmony_ci const unsigned char *input, unsigned char *output) 1216a8e1175bSopenharmony_ci{ 1217a8e1175bSopenharmony_ci return mbedtls_aria_crypt_cfb128((mbedtls_aria_context *) ctx, operation, length, 1218a8e1175bSopenharmony_ci iv_off, iv, input, output); 1219a8e1175bSopenharmony_ci} 1220a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_CFB */ 1221a8e1175bSopenharmony_ci 1222a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 1223a8e1175bSopenharmony_cistatic int aria_crypt_ctr_wrap(void *ctx, size_t length, size_t *nc_off, 1224a8e1175bSopenharmony_ci unsigned char *nonce_counter, unsigned char *stream_block, 1225a8e1175bSopenharmony_ci const unsigned char *input, unsigned char *output) 1226a8e1175bSopenharmony_ci{ 1227a8e1175bSopenharmony_ci return mbedtls_aria_crypt_ctr((mbedtls_aria_context *) ctx, length, nc_off, 1228a8e1175bSopenharmony_ci nonce_counter, stream_block, input, output); 1229a8e1175bSopenharmony_ci} 1230a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_CTR */ 1231a8e1175bSopenharmony_ci 1232a8e1175bSopenharmony_ci#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT) 1233a8e1175bSopenharmony_cistatic int aria_setkey_dec_wrap(void *ctx, const unsigned char *key, 1234a8e1175bSopenharmony_ci unsigned int key_bitlen) 1235a8e1175bSopenharmony_ci{ 1236a8e1175bSopenharmony_ci return mbedtls_aria_setkey_dec((mbedtls_aria_context *) ctx, key, key_bitlen); 1237a8e1175bSopenharmony_ci} 1238a8e1175bSopenharmony_ci#endif 1239a8e1175bSopenharmony_ci 1240a8e1175bSopenharmony_cistatic int aria_setkey_enc_wrap(void *ctx, const unsigned char *key, 1241a8e1175bSopenharmony_ci unsigned int key_bitlen) 1242a8e1175bSopenharmony_ci{ 1243a8e1175bSopenharmony_ci return mbedtls_aria_setkey_enc((mbedtls_aria_context *) ctx, key, key_bitlen); 1244a8e1175bSopenharmony_ci} 1245a8e1175bSopenharmony_ci 1246a8e1175bSopenharmony_cistatic void *aria_ctx_alloc(void) 1247a8e1175bSopenharmony_ci{ 1248a8e1175bSopenharmony_ci mbedtls_aria_context *ctx; 1249a8e1175bSopenharmony_ci ctx = mbedtls_calloc(1, sizeof(mbedtls_aria_context)); 1250a8e1175bSopenharmony_ci 1251a8e1175bSopenharmony_ci if (ctx == NULL) { 1252a8e1175bSopenharmony_ci return NULL; 1253a8e1175bSopenharmony_ci } 1254a8e1175bSopenharmony_ci 1255a8e1175bSopenharmony_ci mbedtls_aria_init(ctx); 1256a8e1175bSopenharmony_ci 1257a8e1175bSopenharmony_ci return ctx; 1258a8e1175bSopenharmony_ci} 1259a8e1175bSopenharmony_ci 1260a8e1175bSopenharmony_cistatic void aria_ctx_free(void *ctx) 1261a8e1175bSopenharmony_ci{ 1262a8e1175bSopenharmony_ci mbedtls_aria_free((mbedtls_aria_context *) ctx); 1263a8e1175bSopenharmony_ci mbedtls_free(ctx); 1264a8e1175bSopenharmony_ci} 1265a8e1175bSopenharmony_ci 1266a8e1175bSopenharmony_cistatic const mbedtls_cipher_base_t aria_info = { 1267a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ID_ARIA, 1268a8e1175bSopenharmony_ci aria_crypt_ecb_wrap, 1269a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 1270a8e1175bSopenharmony_ci aria_crypt_cbc_wrap, 1271a8e1175bSopenharmony_ci#endif 1272a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 1273a8e1175bSopenharmony_ci aria_crypt_cfb128_wrap, 1274a8e1175bSopenharmony_ci#endif 1275a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_OFB) 1276a8e1175bSopenharmony_ci NULL, 1277a8e1175bSopenharmony_ci#endif 1278a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 1279a8e1175bSopenharmony_ci aria_crypt_ctr_wrap, 1280a8e1175bSopenharmony_ci#endif 1281a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_XTS) 1282a8e1175bSopenharmony_ci NULL, 1283a8e1175bSopenharmony_ci#endif 1284a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_STREAM) 1285a8e1175bSopenharmony_ci NULL, 1286a8e1175bSopenharmony_ci#endif 1287a8e1175bSopenharmony_ci aria_setkey_enc_wrap, 1288a8e1175bSopenharmony_ci#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT) 1289a8e1175bSopenharmony_ci aria_setkey_dec_wrap, 1290a8e1175bSopenharmony_ci#endif 1291a8e1175bSopenharmony_ci aria_ctx_alloc, 1292a8e1175bSopenharmony_ci aria_ctx_free 1293a8e1175bSopenharmony_ci}; 1294a8e1175bSopenharmony_ci 1295a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aria_128_ecb_info = { 1296a8e1175bSopenharmony_ci "ARIA-128-ECB", 1297a8e1175bSopenharmony_ci 16, 1298a8e1175bSopenharmony_ci 0 >> MBEDTLS_IV_SIZE_SHIFT, 1299a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 1300a8e1175bSopenharmony_ci MBEDTLS_MODE_ECB, 1301a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ARIA_128_ECB, 1302a8e1175bSopenharmony_ci 0, 1303a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_ARIA 1304a8e1175bSopenharmony_ci}; 1305a8e1175bSopenharmony_ci 1306a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aria_192_ecb_info = { 1307a8e1175bSopenharmony_ci "ARIA-192-ECB", 1308a8e1175bSopenharmony_ci 16, 1309a8e1175bSopenharmony_ci 0 >> MBEDTLS_IV_SIZE_SHIFT, 1310a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 1311a8e1175bSopenharmony_ci MBEDTLS_MODE_ECB, 1312a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ARIA_192_ECB, 1313a8e1175bSopenharmony_ci 0, 1314a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_ARIA 1315a8e1175bSopenharmony_ci}; 1316a8e1175bSopenharmony_ci 1317a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aria_256_ecb_info = { 1318a8e1175bSopenharmony_ci "ARIA-256-ECB", 1319a8e1175bSopenharmony_ci 16, 1320a8e1175bSopenharmony_ci 0 >> MBEDTLS_IV_SIZE_SHIFT, 1321a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 1322a8e1175bSopenharmony_ci MBEDTLS_MODE_ECB, 1323a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ARIA_256_ECB, 1324a8e1175bSopenharmony_ci 0, 1325a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_ARIA 1326a8e1175bSopenharmony_ci}; 1327a8e1175bSopenharmony_ci 1328a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 1329a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aria_128_cbc_info = { 1330a8e1175bSopenharmony_ci "ARIA-128-CBC", 1331a8e1175bSopenharmony_ci 16, 1332a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 1333a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 1334a8e1175bSopenharmony_ci MBEDTLS_MODE_CBC, 1335a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ARIA_128_CBC, 1336a8e1175bSopenharmony_ci 0, 1337a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_ARIA 1338a8e1175bSopenharmony_ci}; 1339a8e1175bSopenharmony_ci 1340a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aria_192_cbc_info = { 1341a8e1175bSopenharmony_ci "ARIA-192-CBC", 1342a8e1175bSopenharmony_ci 16, 1343a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 1344a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 1345a8e1175bSopenharmony_ci MBEDTLS_MODE_CBC, 1346a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ARIA_192_CBC, 1347a8e1175bSopenharmony_ci 0, 1348a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_ARIA 1349a8e1175bSopenharmony_ci}; 1350a8e1175bSopenharmony_ci 1351a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aria_256_cbc_info = { 1352a8e1175bSopenharmony_ci "ARIA-256-CBC", 1353a8e1175bSopenharmony_ci 16, 1354a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 1355a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 1356a8e1175bSopenharmony_ci MBEDTLS_MODE_CBC, 1357a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ARIA_256_CBC, 1358a8e1175bSopenharmony_ci 0, 1359a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_ARIA 1360a8e1175bSopenharmony_ci}; 1361a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_CBC */ 1362a8e1175bSopenharmony_ci 1363a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 1364a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aria_128_cfb128_info = { 1365a8e1175bSopenharmony_ci "ARIA-128-CFB128", 1366a8e1175bSopenharmony_ci 16, 1367a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 1368a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 1369a8e1175bSopenharmony_ci MBEDTLS_MODE_CFB, 1370a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ARIA_128_CFB128, 1371a8e1175bSopenharmony_ci 0, 1372a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_ARIA 1373a8e1175bSopenharmony_ci}; 1374a8e1175bSopenharmony_ci 1375a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aria_192_cfb128_info = { 1376a8e1175bSopenharmony_ci "ARIA-192-CFB128", 1377a8e1175bSopenharmony_ci 16, 1378a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 1379a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 1380a8e1175bSopenharmony_ci MBEDTLS_MODE_CFB, 1381a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ARIA_192_CFB128, 1382a8e1175bSopenharmony_ci 0, 1383a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_ARIA 1384a8e1175bSopenharmony_ci}; 1385a8e1175bSopenharmony_ci 1386a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aria_256_cfb128_info = { 1387a8e1175bSopenharmony_ci "ARIA-256-CFB128", 1388a8e1175bSopenharmony_ci 16, 1389a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 1390a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 1391a8e1175bSopenharmony_ci MBEDTLS_MODE_CFB, 1392a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ARIA_256_CFB128, 1393a8e1175bSopenharmony_ci 0, 1394a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_ARIA 1395a8e1175bSopenharmony_ci}; 1396a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_CFB */ 1397a8e1175bSopenharmony_ci 1398a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 1399a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aria_128_ctr_info = { 1400a8e1175bSopenharmony_ci "ARIA-128-CTR", 1401a8e1175bSopenharmony_ci 16, 1402a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 1403a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 1404a8e1175bSopenharmony_ci MBEDTLS_MODE_CTR, 1405a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ARIA_128_CTR, 1406a8e1175bSopenharmony_ci 0, 1407a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_ARIA 1408a8e1175bSopenharmony_ci}; 1409a8e1175bSopenharmony_ci 1410a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aria_192_ctr_info = { 1411a8e1175bSopenharmony_ci "ARIA-192-CTR", 1412a8e1175bSopenharmony_ci 16, 1413a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 1414a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 1415a8e1175bSopenharmony_ci MBEDTLS_MODE_CTR, 1416a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ARIA_192_CTR, 1417a8e1175bSopenharmony_ci 0, 1418a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_ARIA 1419a8e1175bSopenharmony_ci}; 1420a8e1175bSopenharmony_ci 1421a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aria_256_ctr_info = { 1422a8e1175bSopenharmony_ci "ARIA-256-CTR", 1423a8e1175bSopenharmony_ci 16, 1424a8e1175bSopenharmony_ci 16 >> MBEDTLS_IV_SIZE_SHIFT, 1425a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 1426a8e1175bSopenharmony_ci MBEDTLS_MODE_CTR, 1427a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ARIA_256_CTR, 1428a8e1175bSopenharmony_ci 0, 1429a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_ARIA 1430a8e1175bSopenharmony_ci}; 1431a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_CTR */ 1432a8e1175bSopenharmony_ci 1433a8e1175bSopenharmony_ci#if defined(MBEDTLS_GCM_C) 1434a8e1175bSopenharmony_cistatic int gcm_aria_setkey_wrap(void *ctx, const unsigned char *key, 1435a8e1175bSopenharmony_ci unsigned int key_bitlen) 1436a8e1175bSopenharmony_ci{ 1437a8e1175bSopenharmony_ci return mbedtls_gcm_setkey((mbedtls_gcm_context *) ctx, MBEDTLS_CIPHER_ID_ARIA, 1438a8e1175bSopenharmony_ci key, key_bitlen); 1439a8e1175bSopenharmony_ci} 1440a8e1175bSopenharmony_ci 1441a8e1175bSopenharmony_cistatic const mbedtls_cipher_base_t gcm_aria_info = { 1442a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ID_ARIA, 1443a8e1175bSopenharmony_ci NULL, 1444a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 1445a8e1175bSopenharmony_ci NULL, 1446a8e1175bSopenharmony_ci#endif 1447a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 1448a8e1175bSopenharmony_ci NULL, 1449a8e1175bSopenharmony_ci#endif 1450a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_OFB) 1451a8e1175bSopenharmony_ci NULL, 1452a8e1175bSopenharmony_ci#endif 1453a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 1454a8e1175bSopenharmony_ci NULL, 1455a8e1175bSopenharmony_ci#endif 1456a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_XTS) 1457a8e1175bSopenharmony_ci NULL, 1458a8e1175bSopenharmony_ci#endif 1459a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_STREAM) 1460a8e1175bSopenharmony_ci NULL, 1461a8e1175bSopenharmony_ci#endif 1462a8e1175bSopenharmony_ci gcm_aria_setkey_wrap, 1463a8e1175bSopenharmony_ci#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT) 1464a8e1175bSopenharmony_ci gcm_aria_setkey_wrap, 1465a8e1175bSopenharmony_ci#endif 1466a8e1175bSopenharmony_ci gcm_ctx_alloc, 1467a8e1175bSopenharmony_ci gcm_ctx_free, 1468a8e1175bSopenharmony_ci}; 1469a8e1175bSopenharmony_ci 1470a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aria_128_gcm_info = { 1471a8e1175bSopenharmony_ci "ARIA-128-GCM", 1472a8e1175bSopenharmony_ci 16, 1473a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 1474a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 1475a8e1175bSopenharmony_ci MBEDTLS_MODE_GCM, 1476a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ARIA_128_GCM, 1477a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 1478a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_GCM_ARIA 1479a8e1175bSopenharmony_ci}; 1480a8e1175bSopenharmony_ci 1481a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aria_192_gcm_info = { 1482a8e1175bSopenharmony_ci "ARIA-192-GCM", 1483a8e1175bSopenharmony_ci 16, 1484a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 1485a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 1486a8e1175bSopenharmony_ci MBEDTLS_MODE_GCM, 1487a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ARIA_192_GCM, 1488a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 1489a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_GCM_ARIA 1490a8e1175bSopenharmony_ci}; 1491a8e1175bSopenharmony_ci 1492a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aria_256_gcm_info = { 1493a8e1175bSopenharmony_ci "ARIA-256-GCM", 1494a8e1175bSopenharmony_ci 16, 1495a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 1496a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 1497a8e1175bSopenharmony_ci MBEDTLS_MODE_GCM, 1498a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ARIA_256_GCM, 1499a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 1500a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_GCM_ARIA 1501a8e1175bSopenharmony_ci}; 1502a8e1175bSopenharmony_ci#endif /* MBEDTLS_GCM_C */ 1503a8e1175bSopenharmony_ci 1504a8e1175bSopenharmony_ci#if defined(MBEDTLS_CCM_C) 1505a8e1175bSopenharmony_cistatic int ccm_aria_setkey_wrap(void *ctx, const unsigned char *key, 1506a8e1175bSopenharmony_ci unsigned int key_bitlen) 1507a8e1175bSopenharmony_ci{ 1508a8e1175bSopenharmony_ci return mbedtls_ccm_setkey((mbedtls_ccm_context *) ctx, MBEDTLS_CIPHER_ID_ARIA, 1509a8e1175bSopenharmony_ci key, key_bitlen); 1510a8e1175bSopenharmony_ci} 1511a8e1175bSopenharmony_ci 1512a8e1175bSopenharmony_cistatic const mbedtls_cipher_base_t ccm_aria_info = { 1513a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ID_ARIA, 1514a8e1175bSopenharmony_ci NULL, 1515a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 1516a8e1175bSopenharmony_ci NULL, 1517a8e1175bSopenharmony_ci#endif 1518a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 1519a8e1175bSopenharmony_ci NULL, 1520a8e1175bSopenharmony_ci#endif 1521a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_OFB) 1522a8e1175bSopenharmony_ci NULL, 1523a8e1175bSopenharmony_ci#endif 1524a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 1525a8e1175bSopenharmony_ci NULL, 1526a8e1175bSopenharmony_ci#endif 1527a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_XTS) 1528a8e1175bSopenharmony_ci NULL, 1529a8e1175bSopenharmony_ci#endif 1530a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_STREAM) 1531a8e1175bSopenharmony_ci NULL, 1532a8e1175bSopenharmony_ci#endif 1533a8e1175bSopenharmony_ci ccm_aria_setkey_wrap, 1534a8e1175bSopenharmony_ci#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT) 1535a8e1175bSopenharmony_ci ccm_aria_setkey_wrap, 1536a8e1175bSopenharmony_ci#endif 1537a8e1175bSopenharmony_ci ccm_ctx_alloc, 1538a8e1175bSopenharmony_ci ccm_ctx_free, 1539a8e1175bSopenharmony_ci}; 1540a8e1175bSopenharmony_ci 1541a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aria_128_ccm_info = { 1542a8e1175bSopenharmony_ci "ARIA-128-CCM", 1543a8e1175bSopenharmony_ci 16, 1544a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 1545a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 1546a8e1175bSopenharmony_ci MBEDTLS_MODE_CCM, 1547a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ARIA_128_CCM, 1548a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 1549a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CCM_ARIA 1550a8e1175bSopenharmony_ci}; 1551a8e1175bSopenharmony_ci 1552a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aria_192_ccm_info = { 1553a8e1175bSopenharmony_ci "ARIA-192-CCM", 1554a8e1175bSopenharmony_ci 16, 1555a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 1556a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 1557a8e1175bSopenharmony_ci MBEDTLS_MODE_CCM, 1558a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ARIA_192_CCM, 1559a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 1560a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CCM_ARIA 1561a8e1175bSopenharmony_ci}; 1562a8e1175bSopenharmony_ci 1563a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aria_256_ccm_info = { 1564a8e1175bSopenharmony_ci "ARIA-256-CCM", 1565a8e1175bSopenharmony_ci 16, 1566a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 1567a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 1568a8e1175bSopenharmony_ci MBEDTLS_MODE_CCM, 1569a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ARIA_256_CCM, 1570a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 1571a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CCM_ARIA 1572a8e1175bSopenharmony_ci}; 1573a8e1175bSopenharmony_ci 1574a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aria_128_ccm_star_no_tag_info = { 1575a8e1175bSopenharmony_ci "ARIA-128-CCM*-NO-TAG", 1576a8e1175bSopenharmony_ci 16, 1577a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 1578a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 1579a8e1175bSopenharmony_ci MBEDTLS_MODE_CCM_STAR_NO_TAG, 1580a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG, 1581a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 1582a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CCM_ARIA 1583a8e1175bSopenharmony_ci}; 1584a8e1175bSopenharmony_ci 1585a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aria_192_ccm_star_no_tag_info = { 1586a8e1175bSopenharmony_ci "ARIA-192-CCM*-NO-TAG", 1587a8e1175bSopenharmony_ci 16, 1588a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 1589a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 1590a8e1175bSopenharmony_ci MBEDTLS_MODE_CCM_STAR_NO_TAG, 1591a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG, 1592a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 1593a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CCM_ARIA 1594a8e1175bSopenharmony_ci}; 1595a8e1175bSopenharmony_ci 1596a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aria_256_ccm_star_no_tag_info = { 1597a8e1175bSopenharmony_ci "ARIA-256-CCM*-NO-TAG", 1598a8e1175bSopenharmony_ci 16, 1599a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 1600a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 1601a8e1175bSopenharmony_ci MBEDTLS_MODE_CCM_STAR_NO_TAG, 1602a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG, 1603a8e1175bSopenharmony_ci MBEDTLS_CIPHER_VARIABLE_IV_LEN, 1604a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CCM_ARIA 1605a8e1175bSopenharmony_ci}; 1606a8e1175bSopenharmony_ci#endif /* MBEDTLS_CCM_C */ 1607a8e1175bSopenharmony_ci 1608a8e1175bSopenharmony_ci#endif /* MBEDTLS_ARIA_C */ 1609a8e1175bSopenharmony_ci 1610a8e1175bSopenharmony_ci#if defined(MBEDTLS_DES_C) 1611a8e1175bSopenharmony_ci 1612a8e1175bSopenharmony_cistatic int des_crypt_ecb_wrap(void *ctx, mbedtls_operation_t operation, 1613a8e1175bSopenharmony_ci const unsigned char *input, unsigned char *output) 1614a8e1175bSopenharmony_ci{ 1615a8e1175bSopenharmony_ci ((void) operation); 1616a8e1175bSopenharmony_ci return mbedtls_des_crypt_ecb((mbedtls_des_context *) ctx, input, output); 1617a8e1175bSopenharmony_ci} 1618a8e1175bSopenharmony_ci 1619a8e1175bSopenharmony_cistatic int des3_crypt_ecb_wrap(void *ctx, mbedtls_operation_t operation, 1620a8e1175bSopenharmony_ci const unsigned char *input, unsigned char *output) 1621a8e1175bSopenharmony_ci{ 1622a8e1175bSopenharmony_ci ((void) operation); 1623a8e1175bSopenharmony_ci return mbedtls_des3_crypt_ecb((mbedtls_des3_context *) ctx, input, output); 1624a8e1175bSopenharmony_ci} 1625a8e1175bSopenharmony_ci 1626a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 1627a8e1175bSopenharmony_cistatic int des_crypt_cbc_wrap(void *ctx, mbedtls_operation_t operation, size_t length, 1628a8e1175bSopenharmony_ci unsigned char *iv, const unsigned char *input, unsigned char *output) 1629a8e1175bSopenharmony_ci{ 1630a8e1175bSopenharmony_ci return mbedtls_des_crypt_cbc((mbedtls_des_context *) ctx, operation, length, iv, input, 1631a8e1175bSopenharmony_ci output); 1632a8e1175bSopenharmony_ci} 1633a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_CBC */ 1634a8e1175bSopenharmony_ci 1635a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 1636a8e1175bSopenharmony_cistatic int des3_crypt_cbc_wrap(void *ctx, mbedtls_operation_t operation, size_t length, 1637a8e1175bSopenharmony_ci unsigned char *iv, const unsigned char *input, unsigned char *output) 1638a8e1175bSopenharmony_ci{ 1639a8e1175bSopenharmony_ci return mbedtls_des3_crypt_cbc((mbedtls_des3_context *) ctx, operation, length, iv, input, 1640a8e1175bSopenharmony_ci output); 1641a8e1175bSopenharmony_ci} 1642a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_CBC */ 1643a8e1175bSopenharmony_ci 1644a8e1175bSopenharmony_cistatic int des_setkey_dec_wrap(void *ctx, const unsigned char *key, 1645a8e1175bSopenharmony_ci unsigned int key_bitlen) 1646a8e1175bSopenharmony_ci{ 1647a8e1175bSopenharmony_ci ((void) key_bitlen); 1648a8e1175bSopenharmony_ci 1649a8e1175bSopenharmony_ci return mbedtls_des_setkey_dec((mbedtls_des_context *) ctx, key); 1650a8e1175bSopenharmony_ci} 1651a8e1175bSopenharmony_ci 1652a8e1175bSopenharmony_cistatic int des_setkey_enc_wrap(void *ctx, const unsigned char *key, 1653a8e1175bSopenharmony_ci unsigned int key_bitlen) 1654a8e1175bSopenharmony_ci{ 1655a8e1175bSopenharmony_ci ((void) key_bitlen); 1656a8e1175bSopenharmony_ci 1657a8e1175bSopenharmony_ci return mbedtls_des_setkey_enc((mbedtls_des_context *) ctx, key); 1658a8e1175bSopenharmony_ci} 1659a8e1175bSopenharmony_ci 1660a8e1175bSopenharmony_cistatic int des3_set2key_dec_wrap(void *ctx, const unsigned char *key, 1661a8e1175bSopenharmony_ci unsigned int key_bitlen) 1662a8e1175bSopenharmony_ci{ 1663a8e1175bSopenharmony_ci ((void) key_bitlen); 1664a8e1175bSopenharmony_ci 1665a8e1175bSopenharmony_ci return mbedtls_des3_set2key_dec((mbedtls_des3_context *) ctx, key); 1666a8e1175bSopenharmony_ci} 1667a8e1175bSopenharmony_ci 1668a8e1175bSopenharmony_cistatic int des3_set2key_enc_wrap(void *ctx, const unsigned char *key, 1669a8e1175bSopenharmony_ci unsigned int key_bitlen) 1670a8e1175bSopenharmony_ci{ 1671a8e1175bSopenharmony_ci ((void) key_bitlen); 1672a8e1175bSopenharmony_ci 1673a8e1175bSopenharmony_ci return mbedtls_des3_set2key_enc((mbedtls_des3_context *) ctx, key); 1674a8e1175bSopenharmony_ci} 1675a8e1175bSopenharmony_ci 1676a8e1175bSopenharmony_cistatic int des3_set3key_dec_wrap(void *ctx, const unsigned char *key, 1677a8e1175bSopenharmony_ci unsigned int key_bitlen) 1678a8e1175bSopenharmony_ci{ 1679a8e1175bSopenharmony_ci ((void) key_bitlen); 1680a8e1175bSopenharmony_ci 1681a8e1175bSopenharmony_ci return mbedtls_des3_set3key_dec((mbedtls_des3_context *) ctx, key); 1682a8e1175bSopenharmony_ci} 1683a8e1175bSopenharmony_ci 1684a8e1175bSopenharmony_cistatic int des3_set3key_enc_wrap(void *ctx, const unsigned char *key, 1685a8e1175bSopenharmony_ci unsigned int key_bitlen) 1686a8e1175bSopenharmony_ci{ 1687a8e1175bSopenharmony_ci ((void) key_bitlen); 1688a8e1175bSopenharmony_ci 1689a8e1175bSopenharmony_ci return mbedtls_des3_set3key_enc((mbedtls_des3_context *) ctx, key); 1690a8e1175bSopenharmony_ci} 1691a8e1175bSopenharmony_ci 1692a8e1175bSopenharmony_cistatic void *des_ctx_alloc(void) 1693a8e1175bSopenharmony_ci{ 1694a8e1175bSopenharmony_ci mbedtls_des_context *des = mbedtls_calloc(1, sizeof(mbedtls_des_context)); 1695a8e1175bSopenharmony_ci 1696a8e1175bSopenharmony_ci if (des == NULL) { 1697a8e1175bSopenharmony_ci return NULL; 1698a8e1175bSopenharmony_ci } 1699a8e1175bSopenharmony_ci 1700a8e1175bSopenharmony_ci mbedtls_des_init(des); 1701a8e1175bSopenharmony_ci 1702a8e1175bSopenharmony_ci return des; 1703a8e1175bSopenharmony_ci} 1704a8e1175bSopenharmony_ci 1705a8e1175bSopenharmony_cistatic void des_ctx_free(void *ctx) 1706a8e1175bSopenharmony_ci{ 1707a8e1175bSopenharmony_ci mbedtls_des_free((mbedtls_des_context *) ctx); 1708a8e1175bSopenharmony_ci mbedtls_free(ctx); 1709a8e1175bSopenharmony_ci} 1710a8e1175bSopenharmony_ci 1711a8e1175bSopenharmony_cistatic void *des3_ctx_alloc(void) 1712a8e1175bSopenharmony_ci{ 1713a8e1175bSopenharmony_ci mbedtls_des3_context *des3; 1714a8e1175bSopenharmony_ci des3 = mbedtls_calloc(1, sizeof(mbedtls_des3_context)); 1715a8e1175bSopenharmony_ci 1716a8e1175bSopenharmony_ci if (des3 == NULL) { 1717a8e1175bSopenharmony_ci return NULL; 1718a8e1175bSopenharmony_ci } 1719a8e1175bSopenharmony_ci 1720a8e1175bSopenharmony_ci mbedtls_des3_init(des3); 1721a8e1175bSopenharmony_ci 1722a8e1175bSopenharmony_ci return des3; 1723a8e1175bSopenharmony_ci} 1724a8e1175bSopenharmony_ci 1725a8e1175bSopenharmony_cistatic void des3_ctx_free(void *ctx) 1726a8e1175bSopenharmony_ci{ 1727a8e1175bSopenharmony_ci mbedtls_des3_free((mbedtls_des3_context *) ctx); 1728a8e1175bSopenharmony_ci mbedtls_free(ctx); 1729a8e1175bSopenharmony_ci} 1730a8e1175bSopenharmony_ci 1731a8e1175bSopenharmony_cistatic const mbedtls_cipher_base_t des_info = { 1732a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ID_DES, 1733a8e1175bSopenharmony_ci des_crypt_ecb_wrap, 1734a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 1735a8e1175bSopenharmony_ci des_crypt_cbc_wrap, 1736a8e1175bSopenharmony_ci#endif 1737a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 1738a8e1175bSopenharmony_ci NULL, 1739a8e1175bSopenharmony_ci#endif 1740a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_OFB) 1741a8e1175bSopenharmony_ci NULL, 1742a8e1175bSopenharmony_ci#endif 1743a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 1744a8e1175bSopenharmony_ci NULL, 1745a8e1175bSopenharmony_ci#endif 1746a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_XTS) 1747a8e1175bSopenharmony_ci NULL, 1748a8e1175bSopenharmony_ci#endif 1749a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_STREAM) 1750a8e1175bSopenharmony_ci NULL, 1751a8e1175bSopenharmony_ci#endif 1752a8e1175bSopenharmony_ci des_setkey_enc_wrap, 1753a8e1175bSopenharmony_ci des_setkey_dec_wrap, 1754a8e1175bSopenharmony_ci des_ctx_alloc, 1755a8e1175bSopenharmony_ci des_ctx_free 1756a8e1175bSopenharmony_ci}; 1757a8e1175bSopenharmony_ci 1758a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t des_ecb_info = { 1759a8e1175bSopenharmony_ci "DES-ECB", 1760a8e1175bSopenharmony_ci 8, 1761a8e1175bSopenharmony_ci 0 >> MBEDTLS_IV_SIZE_SHIFT, 1762a8e1175bSopenharmony_ci MBEDTLS_KEY_LENGTH_DES >> MBEDTLS_KEY_BITLEN_SHIFT, 1763a8e1175bSopenharmony_ci MBEDTLS_MODE_ECB, 1764a8e1175bSopenharmony_ci MBEDTLS_CIPHER_DES_ECB, 1765a8e1175bSopenharmony_ci 0, 1766a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_DES 1767a8e1175bSopenharmony_ci}; 1768a8e1175bSopenharmony_ci 1769a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 1770a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t des_cbc_info = { 1771a8e1175bSopenharmony_ci "DES-CBC", 1772a8e1175bSopenharmony_ci 8, 1773a8e1175bSopenharmony_ci 8 >> MBEDTLS_IV_SIZE_SHIFT, 1774a8e1175bSopenharmony_ci MBEDTLS_KEY_LENGTH_DES >> MBEDTLS_KEY_BITLEN_SHIFT, 1775a8e1175bSopenharmony_ci MBEDTLS_MODE_CBC, 1776a8e1175bSopenharmony_ci MBEDTLS_CIPHER_DES_CBC, 1777a8e1175bSopenharmony_ci 0, 1778a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_DES 1779a8e1175bSopenharmony_ci}; 1780a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_CBC */ 1781a8e1175bSopenharmony_ci 1782a8e1175bSopenharmony_cistatic const mbedtls_cipher_base_t des_ede_info = { 1783a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ID_DES, 1784a8e1175bSopenharmony_ci des3_crypt_ecb_wrap, 1785a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 1786a8e1175bSopenharmony_ci des3_crypt_cbc_wrap, 1787a8e1175bSopenharmony_ci#endif 1788a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 1789a8e1175bSopenharmony_ci NULL, 1790a8e1175bSopenharmony_ci#endif 1791a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_OFB) 1792a8e1175bSopenharmony_ci NULL, 1793a8e1175bSopenharmony_ci#endif 1794a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 1795a8e1175bSopenharmony_ci NULL, 1796a8e1175bSopenharmony_ci#endif 1797a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_XTS) 1798a8e1175bSopenharmony_ci NULL, 1799a8e1175bSopenharmony_ci#endif 1800a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_STREAM) 1801a8e1175bSopenharmony_ci NULL, 1802a8e1175bSopenharmony_ci#endif 1803a8e1175bSopenharmony_ci des3_set2key_enc_wrap, 1804a8e1175bSopenharmony_ci des3_set2key_dec_wrap, 1805a8e1175bSopenharmony_ci des3_ctx_alloc, 1806a8e1175bSopenharmony_ci des3_ctx_free 1807a8e1175bSopenharmony_ci}; 1808a8e1175bSopenharmony_ci 1809a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t des_ede_ecb_info = { 1810a8e1175bSopenharmony_ci "DES-EDE-ECB", 1811a8e1175bSopenharmony_ci 8, 1812a8e1175bSopenharmony_ci 0 >> MBEDTLS_IV_SIZE_SHIFT, 1813a8e1175bSopenharmony_ci MBEDTLS_KEY_LENGTH_DES_EDE >> MBEDTLS_KEY_BITLEN_SHIFT, 1814a8e1175bSopenharmony_ci MBEDTLS_MODE_ECB, 1815a8e1175bSopenharmony_ci MBEDTLS_CIPHER_DES_EDE_ECB, 1816a8e1175bSopenharmony_ci 0, 1817a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_DES_EDE 1818a8e1175bSopenharmony_ci}; 1819a8e1175bSopenharmony_ci 1820a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 1821a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t des_ede_cbc_info = { 1822a8e1175bSopenharmony_ci "DES-EDE-CBC", 1823a8e1175bSopenharmony_ci 8, 1824a8e1175bSopenharmony_ci 8 >> MBEDTLS_IV_SIZE_SHIFT, 1825a8e1175bSopenharmony_ci MBEDTLS_KEY_LENGTH_DES_EDE >> MBEDTLS_KEY_BITLEN_SHIFT, 1826a8e1175bSopenharmony_ci MBEDTLS_MODE_CBC, 1827a8e1175bSopenharmony_ci MBEDTLS_CIPHER_DES_EDE_CBC, 1828a8e1175bSopenharmony_ci 0, 1829a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_DES_EDE 1830a8e1175bSopenharmony_ci}; 1831a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_CBC */ 1832a8e1175bSopenharmony_ci 1833a8e1175bSopenharmony_cistatic const mbedtls_cipher_base_t des_ede3_info = { 1834a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ID_3DES, 1835a8e1175bSopenharmony_ci des3_crypt_ecb_wrap, 1836a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 1837a8e1175bSopenharmony_ci des3_crypt_cbc_wrap, 1838a8e1175bSopenharmony_ci#endif 1839a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 1840a8e1175bSopenharmony_ci NULL, 1841a8e1175bSopenharmony_ci#endif 1842a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_OFB) 1843a8e1175bSopenharmony_ci NULL, 1844a8e1175bSopenharmony_ci#endif 1845a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 1846a8e1175bSopenharmony_ci NULL, 1847a8e1175bSopenharmony_ci#endif 1848a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_XTS) 1849a8e1175bSopenharmony_ci NULL, 1850a8e1175bSopenharmony_ci#endif 1851a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_STREAM) 1852a8e1175bSopenharmony_ci NULL, 1853a8e1175bSopenharmony_ci#endif 1854a8e1175bSopenharmony_ci des3_set3key_enc_wrap, 1855a8e1175bSopenharmony_ci des3_set3key_dec_wrap, 1856a8e1175bSopenharmony_ci des3_ctx_alloc, 1857a8e1175bSopenharmony_ci des3_ctx_free 1858a8e1175bSopenharmony_ci}; 1859a8e1175bSopenharmony_ci 1860a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t des_ede3_ecb_info = { 1861a8e1175bSopenharmony_ci "DES-EDE3-ECB", 1862a8e1175bSopenharmony_ci 8, 1863a8e1175bSopenharmony_ci 0 >> MBEDTLS_IV_SIZE_SHIFT, 1864a8e1175bSopenharmony_ci MBEDTLS_KEY_LENGTH_DES_EDE3 >> MBEDTLS_KEY_BITLEN_SHIFT, 1865a8e1175bSopenharmony_ci MBEDTLS_MODE_ECB, 1866a8e1175bSopenharmony_ci MBEDTLS_CIPHER_DES_EDE3_ECB, 1867a8e1175bSopenharmony_ci 0, 1868a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_DES_EDE3 1869a8e1175bSopenharmony_ci}; 1870a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 1871a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t des_ede3_cbc_info = { 1872a8e1175bSopenharmony_ci "DES-EDE3-CBC", 1873a8e1175bSopenharmony_ci 8, 1874a8e1175bSopenharmony_ci 8 >> MBEDTLS_IV_SIZE_SHIFT, 1875a8e1175bSopenharmony_ci MBEDTLS_KEY_LENGTH_DES_EDE3 >> MBEDTLS_KEY_BITLEN_SHIFT, 1876a8e1175bSopenharmony_ci MBEDTLS_MODE_CBC, 1877a8e1175bSopenharmony_ci MBEDTLS_CIPHER_DES_EDE3_CBC, 1878a8e1175bSopenharmony_ci 0, 1879a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_DES_EDE3 1880a8e1175bSopenharmony_ci}; 1881a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_MODE_CBC */ 1882a8e1175bSopenharmony_ci#endif /* MBEDTLS_DES_C */ 1883a8e1175bSopenharmony_ci 1884a8e1175bSopenharmony_ci#if defined(MBEDTLS_CHACHA20_C) 1885a8e1175bSopenharmony_ci 1886a8e1175bSopenharmony_cistatic int chacha20_setkey_wrap(void *ctx, const unsigned char *key, 1887a8e1175bSopenharmony_ci unsigned int key_bitlen) 1888a8e1175bSopenharmony_ci{ 1889a8e1175bSopenharmony_ci if (key_bitlen != 256U) { 1890a8e1175bSopenharmony_ci return MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA; 1891a8e1175bSopenharmony_ci } 1892a8e1175bSopenharmony_ci 1893a8e1175bSopenharmony_ci if (0 != mbedtls_chacha20_setkey((mbedtls_chacha20_context *) ctx, key)) { 1894a8e1175bSopenharmony_ci return MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA; 1895a8e1175bSopenharmony_ci } 1896a8e1175bSopenharmony_ci 1897a8e1175bSopenharmony_ci return 0; 1898a8e1175bSopenharmony_ci} 1899a8e1175bSopenharmony_ci 1900a8e1175bSopenharmony_cistatic int chacha20_stream_wrap(void *ctx, size_t length, 1901a8e1175bSopenharmony_ci const unsigned char *input, 1902a8e1175bSopenharmony_ci unsigned char *output) 1903a8e1175bSopenharmony_ci{ 1904a8e1175bSopenharmony_ci int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED; 1905a8e1175bSopenharmony_ci 1906a8e1175bSopenharmony_ci ret = mbedtls_chacha20_update(ctx, length, input, output); 1907a8e1175bSopenharmony_ci if (ret == MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA) { 1908a8e1175bSopenharmony_ci return MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA; 1909a8e1175bSopenharmony_ci } 1910a8e1175bSopenharmony_ci 1911a8e1175bSopenharmony_ci return ret; 1912a8e1175bSopenharmony_ci} 1913a8e1175bSopenharmony_ci 1914a8e1175bSopenharmony_cistatic void *chacha20_ctx_alloc(void) 1915a8e1175bSopenharmony_ci{ 1916a8e1175bSopenharmony_ci mbedtls_chacha20_context *ctx; 1917a8e1175bSopenharmony_ci ctx = mbedtls_calloc(1, sizeof(mbedtls_chacha20_context)); 1918a8e1175bSopenharmony_ci 1919a8e1175bSopenharmony_ci if (ctx == NULL) { 1920a8e1175bSopenharmony_ci return NULL; 1921a8e1175bSopenharmony_ci } 1922a8e1175bSopenharmony_ci 1923a8e1175bSopenharmony_ci mbedtls_chacha20_init(ctx); 1924a8e1175bSopenharmony_ci 1925a8e1175bSopenharmony_ci return ctx; 1926a8e1175bSopenharmony_ci} 1927a8e1175bSopenharmony_ci 1928a8e1175bSopenharmony_cistatic void chacha20_ctx_free(void *ctx) 1929a8e1175bSopenharmony_ci{ 1930a8e1175bSopenharmony_ci mbedtls_chacha20_free((mbedtls_chacha20_context *) ctx); 1931a8e1175bSopenharmony_ci mbedtls_free(ctx); 1932a8e1175bSopenharmony_ci} 1933a8e1175bSopenharmony_ci 1934a8e1175bSopenharmony_cistatic const mbedtls_cipher_base_t chacha20_base_info = { 1935a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ID_CHACHA20, 1936a8e1175bSopenharmony_ci NULL, 1937a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 1938a8e1175bSopenharmony_ci NULL, 1939a8e1175bSopenharmony_ci#endif 1940a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 1941a8e1175bSopenharmony_ci NULL, 1942a8e1175bSopenharmony_ci#endif 1943a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_OFB) 1944a8e1175bSopenharmony_ci NULL, 1945a8e1175bSopenharmony_ci#endif 1946a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 1947a8e1175bSopenharmony_ci NULL, 1948a8e1175bSopenharmony_ci#endif 1949a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_XTS) 1950a8e1175bSopenharmony_ci NULL, 1951a8e1175bSopenharmony_ci#endif 1952a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_STREAM) 1953a8e1175bSopenharmony_ci chacha20_stream_wrap, 1954a8e1175bSopenharmony_ci#endif 1955a8e1175bSopenharmony_ci chacha20_setkey_wrap, 1956a8e1175bSopenharmony_ci#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT) 1957a8e1175bSopenharmony_ci chacha20_setkey_wrap, 1958a8e1175bSopenharmony_ci#endif 1959a8e1175bSopenharmony_ci chacha20_ctx_alloc, 1960a8e1175bSopenharmony_ci chacha20_ctx_free 1961a8e1175bSopenharmony_ci}; 1962a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t chacha20_info = { 1963a8e1175bSopenharmony_ci "CHACHA20", 1964a8e1175bSopenharmony_ci 1, 1965a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 1966a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 1967a8e1175bSopenharmony_ci MBEDTLS_MODE_STREAM, 1968a8e1175bSopenharmony_ci MBEDTLS_CIPHER_CHACHA20, 1969a8e1175bSopenharmony_ci 0, 1970a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CHACHA20_BASE 1971a8e1175bSopenharmony_ci}; 1972a8e1175bSopenharmony_ci#endif /* MBEDTLS_CHACHA20_C */ 1973a8e1175bSopenharmony_ci 1974a8e1175bSopenharmony_ci#if defined(MBEDTLS_CHACHAPOLY_C) 1975a8e1175bSopenharmony_ci 1976a8e1175bSopenharmony_cistatic int chachapoly_setkey_wrap(void *ctx, 1977a8e1175bSopenharmony_ci const unsigned char *key, 1978a8e1175bSopenharmony_ci unsigned int key_bitlen) 1979a8e1175bSopenharmony_ci{ 1980a8e1175bSopenharmony_ci if (key_bitlen != 256U) { 1981a8e1175bSopenharmony_ci return MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA; 1982a8e1175bSopenharmony_ci } 1983a8e1175bSopenharmony_ci 1984a8e1175bSopenharmony_ci if (0 != mbedtls_chachapoly_setkey((mbedtls_chachapoly_context *) ctx, key)) { 1985a8e1175bSopenharmony_ci return MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA; 1986a8e1175bSopenharmony_ci } 1987a8e1175bSopenharmony_ci 1988a8e1175bSopenharmony_ci return 0; 1989a8e1175bSopenharmony_ci} 1990a8e1175bSopenharmony_ci 1991a8e1175bSopenharmony_cistatic void *chachapoly_ctx_alloc(void) 1992a8e1175bSopenharmony_ci{ 1993a8e1175bSopenharmony_ci mbedtls_chachapoly_context *ctx; 1994a8e1175bSopenharmony_ci ctx = mbedtls_calloc(1, sizeof(mbedtls_chachapoly_context)); 1995a8e1175bSopenharmony_ci 1996a8e1175bSopenharmony_ci if (ctx == NULL) { 1997a8e1175bSopenharmony_ci return NULL; 1998a8e1175bSopenharmony_ci } 1999a8e1175bSopenharmony_ci 2000a8e1175bSopenharmony_ci mbedtls_chachapoly_init(ctx); 2001a8e1175bSopenharmony_ci 2002a8e1175bSopenharmony_ci return ctx; 2003a8e1175bSopenharmony_ci} 2004a8e1175bSopenharmony_ci 2005a8e1175bSopenharmony_cistatic void chachapoly_ctx_free(void *ctx) 2006a8e1175bSopenharmony_ci{ 2007a8e1175bSopenharmony_ci mbedtls_chachapoly_free((mbedtls_chachapoly_context *) ctx); 2008a8e1175bSopenharmony_ci mbedtls_free(ctx); 2009a8e1175bSopenharmony_ci} 2010a8e1175bSopenharmony_ci 2011a8e1175bSopenharmony_cistatic const mbedtls_cipher_base_t chachapoly_base_info = { 2012a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ID_CHACHA20, 2013a8e1175bSopenharmony_ci NULL, 2014a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 2015a8e1175bSopenharmony_ci NULL, 2016a8e1175bSopenharmony_ci#endif 2017a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 2018a8e1175bSopenharmony_ci NULL, 2019a8e1175bSopenharmony_ci#endif 2020a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_OFB) 2021a8e1175bSopenharmony_ci NULL, 2022a8e1175bSopenharmony_ci#endif 2023a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 2024a8e1175bSopenharmony_ci NULL, 2025a8e1175bSopenharmony_ci#endif 2026a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_XTS) 2027a8e1175bSopenharmony_ci NULL, 2028a8e1175bSopenharmony_ci#endif 2029a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_STREAM) 2030a8e1175bSopenharmony_ci NULL, 2031a8e1175bSopenharmony_ci#endif 2032a8e1175bSopenharmony_ci chachapoly_setkey_wrap, 2033a8e1175bSopenharmony_ci#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT) 2034a8e1175bSopenharmony_ci chachapoly_setkey_wrap, 2035a8e1175bSopenharmony_ci#endif 2036a8e1175bSopenharmony_ci chachapoly_ctx_alloc, 2037a8e1175bSopenharmony_ci chachapoly_ctx_free 2038a8e1175bSopenharmony_ci}; 2039a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t chachapoly_info = { 2040a8e1175bSopenharmony_ci "CHACHA20-POLY1305", 2041a8e1175bSopenharmony_ci 1, 2042a8e1175bSopenharmony_ci 12 >> MBEDTLS_IV_SIZE_SHIFT, 2043a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 2044a8e1175bSopenharmony_ci MBEDTLS_MODE_CHACHAPOLY, 2045a8e1175bSopenharmony_ci MBEDTLS_CIPHER_CHACHA20_POLY1305, 2046a8e1175bSopenharmony_ci 0, 2047a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_CHACHAPOLY_BASE 2048a8e1175bSopenharmony_ci}; 2049a8e1175bSopenharmony_ci#endif /* MBEDTLS_CHACHAPOLY_C */ 2050a8e1175bSopenharmony_ci 2051a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_NULL_CIPHER) 2052a8e1175bSopenharmony_cistatic int null_crypt_stream(void *ctx, size_t length, 2053a8e1175bSopenharmony_ci const unsigned char *input, 2054a8e1175bSopenharmony_ci unsigned char *output) 2055a8e1175bSopenharmony_ci{ 2056a8e1175bSopenharmony_ci ((void) ctx); 2057a8e1175bSopenharmony_ci memmove(output, input, length); 2058a8e1175bSopenharmony_ci return 0; 2059a8e1175bSopenharmony_ci} 2060a8e1175bSopenharmony_ci 2061a8e1175bSopenharmony_cistatic int null_setkey(void *ctx, const unsigned char *key, 2062a8e1175bSopenharmony_ci unsigned int key_bitlen) 2063a8e1175bSopenharmony_ci{ 2064a8e1175bSopenharmony_ci ((void) ctx); 2065a8e1175bSopenharmony_ci ((void) key); 2066a8e1175bSopenharmony_ci ((void) key_bitlen); 2067a8e1175bSopenharmony_ci 2068a8e1175bSopenharmony_ci return 0; 2069a8e1175bSopenharmony_ci} 2070a8e1175bSopenharmony_ci 2071a8e1175bSopenharmony_cistatic void *null_ctx_alloc(void) 2072a8e1175bSopenharmony_ci{ 2073a8e1175bSopenharmony_ci return (void *) 1; 2074a8e1175bSopenharmony_ci} 2075a8e1175bSopenharmony_ci 2076a8e1175bSopenharmony_cistatic void null_ctx_free(void *ctx) 2077a8e1175bSopenharmony_ci{ 2078a8e1175bSopenharmony_ci ((void) ctx); 2079a8e1175bSopenharmony_ci} 2080a8e1175bSopenharmony_ci 2081a8e1175bSopenharmony_cistatic const mbedtls_cipher_base_t null_base_info = { 2082a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ID_NULL, 2083a8e1175bSopenharmony_ci NULL, 2084a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 2085a8e1175bSopenharmony_ci NULL, 2086a8e1175bSopenharmony_ci#endif 2087a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 2088a8e1175bSopenharmony_ci NULL, 2089a8e1175bSopenharmony_ci#endif 2090a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_OFB) 2091a8e1175bSopenharmony_ci NULL, 2092a8e1175bSopenharmony_ci#endif 2093a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 2094a8e1175bSopenharmony_ci NULL, 2095a8e1175bSopenharmony_ci#endif 2096a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_XTS) 2097a8e1175bSopenharmony_ci NULL, 2098a8e1175bSopenharmony_ci#endif 2099a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_STREAM) 2100a8e1175bSopenharmony_ci null_crypt_stream, 2101a8e1175bSopenharmony_ci#endif 2102a8e1175bSopenharmony_ci null_setkey, 2103a8e1175bSopenharmony_ci#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT) 2104a8e1175bSopenharmony_ci null_setkey, 2105a8e1175bSopenharmony_ci#endif 2106a8e1175bSopenharmony_ci null_ctx_alloc, 2107a8e1175bSopenharmony_ci null_ctx_free 2108a8e1175bSopenharmony_ci}; 2109a8e1175bSopenharmony_ci 2110a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t null_cipher_info = { 2111a8e1175bSopenharmony_ci "NULL", 2112a8e1175bSopenharmony_ci 1, 2113a8e1175bSopenharmony_ci 0 >> MBEDTLS_IV_SIZE_SHIFT, 2114a8e1175bSopenharmony_ci 0 >> MBEDTLS_KEY_BITLEN_SHIFT, 2115a8e1175bSopenharmony_ci MBEDTLS_MODE_STREAM, 2116a8e1175bSopenharmony_ci MBEDTLS_CIPHER_NULL, 2117a8e1175bSopenharmony_ci 0, 2118a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_NULL_BASE 2119a8e1175bSopenharmony_ci}; 2120a8e1175bSopenharmony_ci#endif /* defined(MBEDTLS_CIPHER_NULL_CIPHER) */ 2121a8e1175bSopenharmony_ci 2122a8e1175bSopenharmony_ci#if defined(MBEDTLS_NIST_KW_C) 2123a8e1175bSopenharmony_cistatic void *kw_ctx_alloc(void) 2124a8e1175bSopenharmony_ci{ 2125a8e1175bSopenharmony_ci void *ctx = mbedtls_calloc(1, sizeof(mbedtls_nist_kw_context)); 2126a8e1175bSopenharmony_ci 2127a8e1175bSopenharmony_ci if (ctx != NULL) { 2128a8e1175bSopenharmony_ci mbedtls_nist_kw_init((mbedtls_nist_kw_context *) ctx); 2129a8e1175bSopenharmony_ci } 2130a8e1175bSopenharmony_ci 2131a8e1175bSopenharmony_ci return ctx; 2132a8e1175bSopenharmony_ci} 2133a8e1175bSopenharmony_ci 2134a8e1175bSopenharmony_cistatic void kw_ctx_free(void *ctx) 2135a8e1175bSopenharmony_ci{ 2136a8e1175bSopenharmony_ci mbedtls_nist_kw_free(ctx); 2137a8e1175bSopenharmony_ci mbedtls_free(ctx); 2138a8e1175bSopenharmony_ci} 2139a8e1175bSopenharmony_ci 2140a8e1175bSopenharmony_cistatic int kw_aes_setkey_wrap(void *ctx, const unsigned char *key, 2141a8e1175bSopenharmony_ci unsigned int key_bitlen) 2142a8e1175bSopenharmony_ci{ 2143a8e1175bSopenharmony_ci return mbedtls_nist_kw_setkey((mbedtls_nist_kw_context *) ctx, 2144a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ID_AES, key, key_bitlen, 1); 2145a8e1175bSopenharmony_ci} 2146a8e1175bSopenharmony_ci 2147a8e1175bSopenharmony_cistatic int kw_aes_setkey_unwrap(void *ctx, const unsigned char *key, 2148a8e1175bSopenharmony_ci unsigned int key_bitlen) 2149a8e1175bSopenharmony_ci{ 2150a8e1175bSopenharmony_ci return mbedtls_nist_kw_setkey((mbedtls_nist_kw_context *) ctx, 2151a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ID_AES, key, key_bitlen, 0); 2152a8e1175bSopenharmony_ci} 2153a8e1175bSopenharmony_ci 2154a8e1175bSopenharmony_cistatic const mbedtls_cipher_base_t kw_aes_info = { 2155a8e1175bSopenharmony_ci MBEDTLS_CIPHER_ID_AES, 2156a8e1175bSopenharmony_ci NULL, 2157a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 2158a8e1175bSopenharmony_ci NULL, 2159a8e1175bSopenharmony_ci#endif 2160a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 2161a8e1175bSopenharmony_ci NULL, 2162a8e1175bSopenharmony_ci#endif 2163a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_OFB) 2164a8e1175bSopenharmony_ci NULL, 2165a8e1175bSopenharmony_ci#endif 2166a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 2167a8e1175bSopenharmony_ci NULL, 2168a8e1175bSopenharmony_ci#endif 2169a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_XTS) 2170a8e1175bSopenharmony_ci NULL, 2171a8e1175bSopenharmony_ci#endif 2172a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_STREAM) 2173a8e1175bSopenharmony_ci NULL, 2174a8e1175bSopenharmony_ci#endif 2175a8e1175bSopenharmony_ci kw_aes_setkey_wrap, 2176a8e1175bSopenharmony_ci kw_aes_setkey_unwrap, 2177a8e1175bSopenharmony_ci kw_ctx_alloc, 2178a8e1175bSopenharmony_ci kw_ctx_free, 2179a8e1175bSopenharmony_ci}; 2180a8e1175bSopenharmony_ci 2181a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_128_nist_kw_info = { 2182a8e1175bSopenharmony_ci "AES-128-KW", 2183a8e1175bSopenharmony_ci 16, 2184a8e1175bSopenharmony_ci 0 >> MBEDTLS_IV_SIZE_SHIFT, 2185a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 2186a8e1175bSopenharmony_ci MBEDTLS_MODE_KW, 2187a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_128_KW, 2188a8e1175bSopenharmony_ci 0, 2189a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_KW_AES 2190a8e1175bSopenharmony_ci}; 2191a8e1175bSopenharmony_ci 2192a8e1175bSopenharmony_ci#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) 2193a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_192_nist_kw_info = { 2194a8e1175bSopenharmony_ci "AES-192-KW", 2195a8e1175bSopenharmony_ci 16, 2196a8e1175bSopenharmony_ci 0 >> MBEDTLS_IV_SIZE_SHIFT, 2197a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 2198a8e1175bSopenharmony_ci MBEDTLS_MODE_KW, 2199a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_192_KW, 2200a8e1175bSopenharmony_ci 0, 2201a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_KW_AES 2202a8e1175bSopenharmony_ci}; 2203a8e1175bSopenharmony_ci 2204a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_256_nist_kw_info = { 2205a8e1175bSopenharmony_ci "AES-256-KW", 2206a8e1175bSopenharmony_ci 16, 2207a8e1175bSopenharmony_ci 0 >> MBEDTLS_IV_SIZE_SHIFT, 2208a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 2209a8e1175bSopenharmony_ci MBEDTLS_MODE_KW, 2210a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_256_KW, 2211a8e1175bSopenharmony_ci 0, 2212a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_KW_AES 2213a8e1175bSopenharmony_ci}; 2214a8e1175bSopenharmony_ci#endif 2215a8e1175bSopenharmony_ci 2216a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_128_nist_kwp_info = { 2217a8e1175bSopenharmony_ci "AES-128-KWP", 2218a8e1175bSopenharmony_ci 16, 2219a8e1175bSopenharmony_ci 0 >> MBEDTLS_IV_SIZE_SHIFT, 2220a8e1175bSopenharmony_ci 128 >> MBEDTLS_KEY_BITLEN_SHIFT, 2221a8e1175bSopenharmony_ci MBEDTLS_MODE_KWP, 2222a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_128_KWP, 2223a8e1175bSopenharmony_ci 0, 2224a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_KW_AES 2225a8e1175bSopenharmony_ci}; 2226a8e1175bSopenharmony_ci 2227a8e1175bSopenharmony_ci#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) 2228a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_192_nist_kwp_info = { 2229a8e1175bSopenharmony_ci "AES-192-KWP", 2230a8e1175bSopenharmony_ci 16, 2231a8e1175bSopenharmony_ci 0 >> MBEDTLS_IV_SIZE_SHIFT, 2232a8e1175bSopenharmony_ci 192 >> MBEDTLS_KEY_BITLEN_SHIFT, 2233a8e1175bSopenharmony_ci MBEDTLS_MODE_KWP, 2234a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_192_KWP, 2235a8e1175bSopenharmony_ci 0, 2236a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_KW_AES 2237a8e1175bSopenharmony_ci}; 2238a8e1175bSopenharmony_ci 2239a8e1175bSopenharmony_cistatic const mbedtls_cipher_info_t aes_256_nist_kwp_info = { 2240a8e1175bSopenharmony_ci "AES-256-KWP", 2241a8e1175bSopenharmony_ci 16, 2242a8e1175bSopenharmony_ci 0 >> MBEDTLS_IV_SIZE_SHIFT, 2243a8e1175bSopenharmony_ci 256 >> MBEDTLS_KEY_BITLEN_SHIFT, 2244a8e1175bSopenharmony_ci MBEDTLS_MODE_KWP, 2245a8e1175bSopenharmony_ci MBEDTLS_CIPHER_AES_256_KWP, 2246a8e1175bSopenharmony_ci 0, 2247a8e1175bSopenharmony_ci MBEDTLS_CIPHER_BASE_INDEX_KW_AES 2248a8e1175bSopenharmony_ci}; 2249a8e1175bSopenharmony_ci#endif 2250a8e1175bSopenharmony_ci#endif /* MBEDTLS_NIST_KW_C */ 2251a8e1175bSopenharmony_ci 2252a8e1175bSopenharmony_ciconst mbedtls_cipher_definition_t mbedtls_cipher_definitions[] = 2253a8e1175bSopenharmony_ci{ 2254a8e1175bSopenharmony_ci#if defined(MBEDTLS_AES_C) 2255a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_128_ECB, &aes_128_ecb_info }, 2256a8e1175bSopenharmony_ci#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) 2257a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_192_ECB, &aes_192_ecb_info }, 2258a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_256_ECB, &aes_256_ecb_info }, 2259a8e1175bSopenharmony_ci#endif 2260a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 2261a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_128_CBC, &aes_128_cbc_info }, 2262a8e1175bSopenharmony_ci#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) 2263a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_192_CBC, &aes_192_cbc_info }, 2264a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_256_CBC, &aes_256_cbc_info }, 2265a8e1175bSopenharmony_ci#endif 2266a8e1175bSopenharmony_ci#endif 2267a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 2268a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_128_CFB128, &aes_128_cfb128_info }, 2269a8e1175bSopenharmony_ci#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) 2270a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_192_CFB128, &aes_192_cfb128_info }, 2271a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_256_CFB128, &aes_256_cfb128_info }, 2272a8e1175bSopenharmony_ci#endif 2273a8e1175bSopenharmony_ci#endif 2274a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_OFB) 2275a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_128_OFB, &aes_128_ofb_info }, 2276a8e1175bSopenharmony_ci#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) 2277a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_192_OFB, &aes_192_ofb_info }, 2278a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_256_OFB, &aes_256_ofb_info }, 2279a8e1175bSopenharmony_ci#endif 2280a8e1175bSopenharmony_ci#endif 2281a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 2282a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_128_CTR, &aes_128_ctr_info }, 2283a8e1175bSopenharmony_ci#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) 2284a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_192_CTR, &aes_192_ctr_info }, 2285a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_256_CTR, &aes_256_ctr_info }, 2286a8e1175bSopenharmony_ci#endif 2287a8e1175bSopenharmony_ci#endif 2288a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_XTS) 2289a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_128_XTS, &aes_128_xts_info }, 2290a8e1175bSopenharmony_ci#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) 2291a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_256_XTS, &aes_256_xts_info }, 2292a8e1175bSopenharmony_ci#endif 2293a8e1175bSopenharmony_ci#endif 2294a8e1175bSopenharmony_ci#endif /* MBEDTLS_AES_C */ 2295a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_HAVE_GCM_AES_VIA_LEGACY_OR_USE_PSA) 2296a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_128_GCM, &aes_128_gcm_info }, 2297a8e1175bSopenharmony_ci#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) 2298a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_192_GCM, &aes_192_gcm_info }, 2299a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_256_GCM, &aes_256_gcm_info }, 2300a8e1175bSopenharmony_ci#endif 2301a8e1175bSopenharmony_ci#endif 2302a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_HAVE_CCM_AES_VIA_LEGACY_OR_USE_PSA) 2303a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_128_CCM, &aes_128_ccm_info }, 2304a8e1175bSopenharmony_ci#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) 2305a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_192_CCM, &aes_192_ccm_info }, 2306a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_256_CCM, &aes_256_ccm_info }, 2307a8e1175bSopenharmony_ci#endif 2308a8e1175bSopenharmony_ci#endif 2309a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_HAVE_CCM_STAR_NO_TAG_AES_VIA_LEGACY_OR_USE_PSA) 2310a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG, &aes_128_ccm_star_no_tag_info }, 2311a8e1175bSopenharmony_ci#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) 2312a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG, &aes_192_ccm_star_no_tag_info }, 2313a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG, &aes_256_ccm_star_no_tag_info }, 2314a8e1175bSopenharmony_ci#endif 2315a8e1175bSopenharmony_ci#endif 2316a8e1175bSopenharmony_ci 2317a8e1175bSopenharmony_ci#if defined(MBEDTLS_CAMELLIA_C) 2318a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_CAMELLIA_128_ECB, &camellia_128_ecb_info }, 2319a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_CAMELLIA_192_ECB, &camellia_192_ecb_info }, 2320a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_CAMELLIA_256_ECB, &camellia_256_ecb_info }, 2321a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 2322a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_CAMELLIA_128_CBC, &camellia_128_cbc_info }, 2323a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_CAMELLIA_192_CBC, &camellia_192_cbc_info }, 2324a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_CAMELLIA_256_CBC, &camellia_256_cbc_info }, 2325a8e1175bSopenharmony_ci#endif 2326a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 2327a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_CAMELLIA_128_CFB128, &camellia_128_cfb128_info }, 2328a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_CAMELLIA_192_CFB128, &camellia_192_cfb128_info }, 2329a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_CAMELLIA_256_CFB128, &camellia_256_cfb128_info }, 2330a8e1175bSopenharmony_ci#endif 2331a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 2332a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_CAMELLIA_128_CTR, &camellia_128_ctr_info }, 2333a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_CAMELLIA_192_CTR, &camellia_192_ctr_info }, 2334a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_CAMELLIA_256_CTR, &camellia_256_ctr_info }, 2335a8e1175bSopenharmony_ci#endif 2336a8e1175bSopenharmony_ci#if defined(MBEDTLS_GCM_C) 2337a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_CAMELLIA_128_GCM, &camellia_128_gcm_info }, 2338a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_CAMELLIA_192_GCM, &camellia_192_gcm_info }, 2339a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_CAMELLIA_256_GCM, &camellia_256_gcm_info }, 2340a8e1175bSopenharmony_ci#endif 2341a8e1175bSopenharmony_ci#if defined(MBEDTLS_CCM_C) 2342a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_CAMELLIA_128_CCM, &camellia_128_ccm_info }, 2343a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_CAMELLIA_192_CCM, &camellia_192_ccm_info }, 2344a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_CAMELLIA_256_CCM, &camellia_256_ccm_info }, 2345a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG, &camellia_128_ccm_star_no_tag_info }, 2346a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG, &camellia_192_ccm_star_no_tag_info }, 2347a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG, &camellia_256_ccm_star_no_tag_info }, 2348a8e1175bSopenharmony_ci#endif 2349a8e1175bSopenharmony_ci#endif /* MBEDTLS_CAMELLIA_C */ 2350a8e1175bSopenharmony_ci 2351a8e1175bSopenharmony_ci#if defined(MBEDTLS_ARIA_C) 2352a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_ARIA_128_ECB, &aria_128_ecb_info }, 2353a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_ARIA_192_ECB, &aria_192_ecb_info }, 2354a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_ARIA_256_ECB, &aria_256_ecb_info }, 2355a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 2356a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_ARIA_128_CBC, &aria_128_cbc_info }, 2357a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_ARIA_192_CBC, &aria_192_cbc_info }, 2358a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_ARIA_256_CBC, &aria_256_cbc_info }, 2359a8e1175bSopenharmony_ci#endif 2360a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CFB) 2361a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_ARIA_128_CFB128, &aria_128_cfb128_info }, 2362a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_ARIA_192_CFB128, &aria_192_cfb128_info }, 2363a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_ARIA_256_CFB128, &aria_256_cfb128_info }, 2364a8e1175bSopenharmony_ci#endif 2365a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CTR) 2366a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_ARIA_128_CTR, &aria_128_ctr_info }, 2367a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_ARIA_192_CTR, &aria_192_ctr_info }, 2368a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_ARIA_256_CTR, &aria_256_ctr_info }, 2369a8e1175bSopenharmony_ci#endif 2370a8e1175bSopenharmony_ci#if defined(MBEDTLS_GCM_C) 2371a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_ARIA_128_GCM, &aria_128_gcm_info }, 2372a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_ARIA_192_GCM, &aria_192_gcm_info }, 2373a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_ARIA_256_GCM, &aria_256_gcm_info }, 2374a8e1175bSopenharmony_ci#endif 2375a8e1175bSopenharmony_ci#if defined(MBEDTLS_CCM_C) 2376a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_ARIA_128_CCM, &aria_128_ccm_info }, 2377a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_ARIA_192_CCM, &aria_192_ccm_info }, 2378a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_ARIA_256_CCM, &aria_256_ccm_info }, 2379a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG, &aria_128_ccm_star_no_tag_info }, 2380a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG, &aria_192_ccm_star_no_tag_info }, 2381a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG, &aria_256_ccm_star_no_tag_info }, 2382a8e1175bSopenharmony_ci#endif 2383a8e1175bSopenharmony_ci#endif /* MBEDTLS_ARIA_C */ 2384a8e1175bSopenharmony_ci 2385a8e1175bSopenharmony_ci#if defined(MBEDTLS_DES_C) 2386a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_DES_ECB, &des_ecb_info }, 2387a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_DES_EDE_ECB, &des_ede_ecb_info }, 2388a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_DES_EDE3_ECB, &des_ede3_ecb_info }, 2389a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_CBC) 2390a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_DES_CBC, &des_cbc_info }, 2391a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_DES_EDE_CBC, &des_ede_cbc_info }, 2392a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_DES_EDE3_CBC, &des_ede3_cbc_info }, 2393a8e1175bSopenharmony_ci#endif 2394a8e1175bSopenharmony_ci#endif /* MBEDTLS_DES_C */ 2395a8e1175bSopenharmony_ci 2396a8e1175bSopenharmony_ci#if defined(MBEDTLS_CHACHA20_C) 2397a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_CHACHA20, &chacha20_info }, 2398a8e1175bSopenharmony_ci#endif 2399a8e1175bSopenharmony_ci 2400a8e1175bSopenharmony_ci#if defined(MBEDTLS_CHACHAPOLY_C) 2401a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_CHACHA20_POLY1305, &chachapoly_info }, 2402a8e1175bSopenharmony_ci#endif 2403a8e1175bSopenharmony_ci 2404a8e1175bSopenharmony_ci#if defined(MBEDTLS_NIST_KW_C) 2405a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_128_KW, &aes_128_nist_kw_info }, 2406a8e1175bSopenharmony_ci#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) 2407a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_192_KW, &aes_192_nist_kw_info }, 2408a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_256_KW, &aes_256_nist_kw_info }, 2409a8e1175bSopenharmony_ci#endif 2410a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_128_KWP, &aes_128_nist_kwp_info }, 2411a8e1175bSopenharmony_ci#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH) 2412a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_192_KWP, &aes_192_nist_kwp_info }, 2413a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_AES_256_KWP, &aes_256_nist_kwp_info }, 2414a8e1175bSopenharmony_ci#endif 2415a8e1175bSopenharmony_ci#endif 2416a8e1175bSopenharmony_ci 2417a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_NULL_CIPHER) 2418a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_NULL, &null_cipher_info }, 2419a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_NULL_CIPHER */ 2420a8e1175bSopenharmony_ci 2421a8e1175bSopenharmony_ci { MBEDTLS_CIPHER_NONE, NULL } 2422a8e1175bSopenharmony_ci}; 2423a8e1175bSopenharmony_ci 2424a8e1175bSopenharmony_ci#define NUM_CIPHERS (sizeof(mbedtls_cipher_definitions) / \ 2425a8e1175bSopenharmony_ci sizeof(mbedtls_cipher_definitions[0])) 2426a8e1175bSopenharmony_ciint mbedtls_cipher_supported[NUM_CIPHERS]; 2427a8e1175bSopenharmony_ci 2428a8e1175bSopenharmony_ciconst mbedtls_cipher_base_t *mbedtls_cipher_base_lookup_table[] = { 2429a8e1175bSopenharmony_ci#if defined(MBEDTLS_AES_C) 2430a8e1175bSopenharmony_ci [MBEDTLS_CIPHER_BASE_INDEX_AES] = &aes_info, 2431a8e1175bSopenharmony_ci#endif 2432a8e1175bSopenharmony_ci#if defined(MBEDTLS_ARIA_C) 2433a8e1175bSopenharmony_ci [MBEDTLS_CIPHER_BASE_INDEX_ARIA] = &aria_info, 2434a8e1175bSopenharmony_ci#endif 2435a8e1175bSopenharmony_ci#if defined(MBEDTLS_CAMELLIA_C) 2436a8e1175bSopenharmony_ci [MBEDTLS_CIPHER_BASE_INDEX_CAMELLIA] = &camellia_info, 2437a8e1175bSopenharmony_ci#endif 2438a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_HAVE_CCM_AES_VIA_LEGACY_OR_USE_PSA) 2439a8e1175bSopenharmony_ci [MBEDTLS_CIPHER_BASE_INDEX_CCM_AES] = &ccm_aes_info, 2440a8e1175bSopenharmony_ci#endif 2441a8e1175bSopenharmony_ci#if defined(MBEDTLS_CCM_C) && defined(MBEDTLS_ARIA_C) 2442a8e1175bSopenharmony_ci [MBEDTLS_CIPHER_BASE_INDEX_CCM_ARIA] = &ccm_aria_info, 2443a8e1175bSopenharmony_ci#endif 2444a8e1175bSopenharmony_ci#if defined(MBEDTLS_CCM_C) && defined(MBEDTLS_CAMELLIA_C) 2445a8e1175bSopenharmony_ci [MBEDTLS_CIPHER_BASE_INDEX_CCM_CAMELLIA] = &ccm_camellia_info, 2446a8e1175bSopenharmony_ci#endif 2447a8e1175bSopenharmony_ci#if defined(MBEDTLS_CHACHA20_C) 2448a8e1175bSopenharmony_ci [MBEDTLS_CIPHER_BASE_INDEX_CHACHA20_BASE] = &chacha20_base_info, 2449a8e1175bSopenharmony_ci#endif 2450a8e1175bSopenharmony_ci#if defined(MBEDTLS_CHACHAPOLY_C) 2451a8e1175bSopenharmony_ci [MBEDTLS_CIPHER_BASE_INDEX_CHACHAPOLY_BASE] = &chachapoly_base_info, 2452a8e1175bSopenharmony_ci#endif 2453a8e1175bSopenharmony_ci#if defined(MBEDTLS_DES_C) 2454a8e1175bSopenharmony_ci [MBEDTLS_CIPHER_BASE_INDEX_DES_EDE3] = &des_ede3_info, 2455a8e1175bSopenharmony_ci#endif 2456a8e1175bSopenharmony_ci#if defined(MBEDTLS_DES_C) 2457a8e1175bSopenharmony_ci [MBEDTLS_CIPHER_BASE_INDEX_DES_EDE] = &des_ede_info, 2458a8e1175bSopenharmony_ci#endif 2459a8e1175bSopenharmony_ci#if defined(MBEDTLS_DES_C) 2460a8e1175bSopenharmony_ci [MBEDTLS_CIPHER_BASE_INDEX_DES] = &des_info, 2461a8e1175bSopenharmony_ci#endif 2462a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_HAVE_GCM_AES_VIA_LEGACY_OR_USE_PSA) 2463a8e1175bSopenharmony_ci [MBEDTLS_CIPHER_BASE_INDEX_GCM_AES] = &gcm_aes_info, 2464a8e1175bSopenharmony_ci#endif 2465a8e1175bSopenharmony_ci#if defined(MBEDTLS_GCM_C) && defined(MBEDTLS_ARIA_C) 2466a8e1175bSopenharmony_ci [MBEDTLS_CIPHER_BASE_INDEX_GCM_ARIA] = &gcm_aria_info, 2467a8e1175bSopenharmony_ci#endif 2468a8e1175bSopenharmony_ci#if defined(MBEDTLS_GCM_C) && defined(MBEDTLS_CAMELLIA_C) 2469a8e1175bSopenharmony_ci [MBEDTLS_CIPHER_BASE_INDEX_GCM_CAMELLIA] = &gcm_camellia_info, 2470a8e1175bSopenharmony_ci#endif 2471a8e1175bSopenharmony_ci#if defined(MBEDTLS_NIST_KW_C) 2472a8e1175bSopenharmony_ci [MBEDTLS_CIPHER_BASE_INDEX_KW_AES] = &kw_aes_info, 2473a8e1175bSopenharmony_ci#endif 2474a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_NULL_CIPHER) 2475a8e1175bSopenharmony_ci [MBEDTLS_CIPHER_BASE_INDEX_NULL_BASE] = &null_base_info, 2476a8e1175bSopenharmony_ci#endif 2477a8e1175bSopenharmony_ci#if defined(MBEDTLS_CIPHER_MODE_XTS) && defined(MBEDTLS_AES_C) 2478a8e1175bSopenharmony_ci [MBEDTLS_CIPHER_BASE_INDEX_XTS_AES] = &xts_aes_info 2479a8e1175bSopenharmony_ci#endif 2480a8e1175bSopenharmony_ci}; 2481a8e1175bSopenharmony_ci 2482a8e1175bSopenharmony_ci#endif /* MBEDTLS_CIPHER_C */ 2483