The WDCInterface is is a drop-in replacement for an EthernetInterface class that allows the user to connect to the Internet with a Wistron NeWeb Corporation (WNC) M14A2A Series data module using the standard network Socket API's. This interface class is used in the AT&T Cellular IoT Starter Kit which is sold by Avnet (http://cloudconnectkits.org/product/att-cellular-iot-starter-kit).
Dependencies: WncControllerK64F
Dependents: WNCProximityMqtt Pubnub_ATT_IoT_SK_WNC_sync BluemixDemo BluemixQS ... more
See the WNCInterface README in the Wiki tab for detailed information on this library.
mbedtls/source/cipher_wrap.c@12:0071cb144c7a, 2016-11-01 (annotated)
- Committer:
- JMF
- Date:
- Tue Nov 01 14:22:56 2016 +0000
- Revision:
- 12:0071cb144c7a
Adding mbedtls files
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JMF | 12:0071cb144c7a | 1 | /** |
JMF | 12:0071cb144c7a | 2 | * \file cipher_wrap.c |
JMF | 12:0071cb144c7a | 3 | * |
JMF | 12:0071cb144c7a | 4 | * \brief Generic cipher wrapper for mbed TLS |
JMF | 12:0071cb144c7a | 5 | * |
JMF | 12:0071cb144c7a | 6 | * \author Adriaan de Jong <dejong@fox-it.com> |
JMF | 12:0071cb144c7a | 7 | * |
JMF | 12:0071cb144c7a | 8 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved |
JMF | 12:0071cb144c7a | 9 | * SPDX-License-Identifier: Apache-2.0 |
JMF | 12:0071cb144c7a | 10 | * |
JMF | 12:0071cb144c7a | 11 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
JMF | 12:0071cb144c7a | 12 | * not use this file except in compliance with the License. |
JMF | 12:0071cb144c7a | 13 | * You may obtain a copy of the License at |
JMF | 12:0071cb144c7a | 14 | * |
JMF | 12:0071cb144c7a | 15 | * http://www.apache.org/licenses/LICENSE-2.0 |
JMF | 12:0071cb144c7a | 16 | * |
JMF | 12:0071cb144c7a | 17 | * Unless required by applicable law or agreed to in writing, software |
JMF | 12:0071cb144c7a | 18 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
JMF | 12:0071cb144c7a | 19 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
JMF | 12:0071cb144c7a | 20 | * See the License for the specific language governing permissions and |
JMF | 12:0071cb144c7a | 21 | * limitations under the License. |
JMF | 12:0071cb144c7a | 22 | * |
JMF | 12:0071cb144c7a | 23 | * This file is part of mbed TLS (https://tls.mbed.org) |
JMF | 12:0071cb144c7a | 24 | */ |
JMF | 12:0071cb144c7a | 25 | |
JMF | 12:0071cb144c7a | 26 | #if !defined(MBEDTLS_CONFIG_FILE) |
JMF | 12:0071cb144c7a | 27 | #include "mbedtls/config.h" |
JMF | 12:0071cb144c7a | 28 | #else |
JMF | 12:0071cb144c7a | 29 | #include MBEDTLS_CONFIG_FILE |
JMF | 12:0071cb144c7a | 30 | #endif |
JMF | 12:0071cb144c7a | 31 | |
JMF | 12:0071cb144c7a | 32 | #if defined(MBEDTLS_CIPHER_C) |
JMF | 12:0071cb144c7a | 33 | |
JMF | 12:0071cb144c7a | 34 | #include "mbedtls/cipher_internal.h" |
JMF | 12:0071cb144c7a | 35 | |
JMF | 12:0071cb144c7a | 36 | #if defined(MBEDTLS_AES_C) |
JMF | 12:0071cb144c7a | 37 | #include "mbedtls/aes.h" |
JMF | 12:0071cb144c7a | 38 | #endif |
JMF | 12:0071cb144c7a | 39 | |
JMF | 12:0071cb144c7a | 40 | #if defined(MBEDTLS_ARC4_C) |
JMF | 12:0071cb144c7a | 41 | #include "mbedtls/arc4.h" |
JMF | 12:0071cb144c7a | 42 | #endif |
JMF | 12:0071cb144c7a | 43 | |
JMF | 12:0071cb144c7a | 44 | #if defined(MBEDTLS_CAMELLIA_C) |
JMF | 12:0071cb144c7a | 45 | #include "mbedtls/camellia.h" |
JMF | 12:0071cb144c7a | 46 | #endif |
JMF | 12:0071cb144c7a | 47 | |
JMF | 12:0071cb144c7a | 48 | #if defined(MBEDTLS_DES_C) |
JMF | 12:0071cb144c7a | 49 | #include "mbedtls/des.h" |
JMF | 12:0071cb144c7a | 50 | #endif |
JMF | 12:0071cb144c7a | 51 | |
JMF | 12:0071cb144c7a | 52 | #if defined(MBEDTLS_BLOWFISH_C) |
JMF | 12:0071cb144c7a | 53 | #include "mbedtls/blowfish.h" |
JMF | 12:0071cb144c7a | 54 | #endif |
JMF | 12:0071cb144c7a | 55 | |
JMF | 12:0071cb144c7a | 56 | #if defined(MBEDTLS_GCM_C) |
JMF | 12:0071cb144c7a | 57 | #include "mbedtls/gcm.h" |
JMF | 12:0071cb144c7a | 58 | #endif |
JMF | 12:0071cb144c7a | 59 | |
JMF | 12:0071cb144c7a | 60 | #if defined(MBEDTLS_CCM_C) |
JMF | 12:0071cb144c7a | 61 | #include "mbedtls/ccm.h" |
JMF | 12:0071cb144c7a | 62 | #endif |
JMF | 12:0071cb144c7a | 63 | |
JMF | 12:0071cb144c7a | 64 | #if defined(MBEDTLS_CIPHER_NULL_CIPHER) |
JMF | 12:0071cb144c7a | 65 | #include <string.h> |
JMF | 12:0071cb144c7a | 66 | #endif |
JMF | 12:0071cb144c7a | 67 | |
JMF | 12:0071cb144c7a | 68 | #if defined(MBEDTLS_PLATFORM_C) |
JMF | 12:0071cb144c7a | 69 | #include "mbedtls/platform.h" |
JMF | 12:0071cb144c7a | 70 | #else |
JMF | 12:0071cb144c7a | 71 | #include <stdlib.h> |
JMF | 12:0071cb144c7a | 72 | #define mbedtls_calloc calloc |
JMF | 12:0071cb144c7a | 73 | #define mbedtls_free free |
JMF | 12:0071cb144c7a | 74 | #endif |
JMF | 12:0071cb144c7a | 75 | |
JMF | 12:0071cb144c7a | 76 | #if defined(MBEDTLS_GCM_C) |
JMF | 12:0071cb144c7a | 77 | /* shared by all GCM ciphers */ |
JMF | 12:0071cb144c7a | 78 | static void *gcm_ctx_alloc( void ) |
JMF | 12:0071cb144c7a | 79 | { |
JMF | 12:0071cb144c7a | 80 | void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_gcm_context ) ); |
JMF | 12:0071cb144c7a | 81 | |
JMF | 12:0071cb144c7a | 82 | if( ctx != NULL ) |
JMF | 12:0071cb144c7a | 83 | mbedtls_gcm_init( (mbedtls_gcm_context *) ctx ); |
JMF | 12:0071cb144c7a | 84 | |
JMF | 12:0071cb144c7a | 85 | return( ctx ); |
JMF | 12:0071cb144c7a | 86 | } |
JMF | 12:0071cb144c7a | 87 | |
JMF | 12:0071cb144c7a | 88 | static void gcm_ctx_free( void *ctx ) |
JMF | 12:0071cb144c7a | 89 | { |
JMF | 12:0071cb144c7a | 90 | mbedtls_gcm_free( ctx ); |
JMF | 12:0071cb144c7a | 91 | mbedtls_free( ctx ); |
JMF | 12:0071cb144c7a | 92 | } |
JMF | 12:0071cb144c7a | 93 | #endif /* MBEDTLS_GCM_C */ |
JMF | 12:0071cb144c7a | 94 | |
JMF | 12:0071cb144c7a | 95 | #if defined(MBEDTLS_CCM_C) |
JMF | 12:0071cb144c7a | 96 | /* shared by all CCM ciphers */ |
JMF | 12:0071cb144c7a | 97 | static void *ccm_ctx_alloc( void ) |
JMF | 12:0071cb144c7a | 98 | { |
JMF | 12:0071cb144c7a | 99 | void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ccm_context ) ); |
JMF | 12:0071cb144c7a | 100 | |
JMF | 12:0071cb144c7a | 101 | if( ctx != NULL ) |
JMF | 12:0071cb144c7a | 102 | mbedtls_ccm_init( (mbedtls_ccm_context *) ctx ); |
JMF | 12:0071cb144c7a | 103 | |
JMF | 12:0071cb144c7a | 104 | return( ctx ); |
JMF | 12:0071cb144c7a | 105 | } |
JMF | 12:0071cb144c7a | 106 | |
JMF | 12:0071cb144c7a | 107 | static void ccm_ctx_free( void *ctx ) |
JMF | 12:0071cb144c7a | 108 | { |
JMF | 12:0071cb144c7a | 109 | mbedtls_ccm_free( ctx ); |
JMF | 12:0071cb144c7a | 110 | mbedtls_free( ctx ); |
JMF | 12:0071cb144c7a | 111 | } |
JMF | 12:0071cb144c7a | 112 | #endif /* MBEDTLS_CCM_C */ |
JMF | 12:0071cb144c7a | 113 | |
JMF | 12:0071cb144c7a | 114 | #if defined(MBEDTLS_AES_C) |
JMF | 12:0071cb144c7a | 115 | |
JMF | 12:0071cb144c7a | 116 | static int aes_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation, |
JMF | 12:0071cb144c7a | 117 | const unsigned char *input, unsigned char *output ) |
JMF | 12:0071cb144c7a | 118 | { |
JMF | 12:0071cb144c7a | 119 | return mbedtls_aes_crypt_ecb( (mbedtls_aes_context *) ctx, operation, input, output ); |
JMF | 12:0071cb144c7a | 120 | } |
JMF | 12:0071cb144c7a | 121 | |
JMF | 12:0071cb144c7a | 122 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 123 | static int aes_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, size_t length, |
JMF | 12:0071cb144c7a | 124 | unsigned char *iv, const unsigned char *input, unsigned char *output ) |
JMF | 12:0071cb144c7a | 125 | { |
JMF | 12:0071cb144c7a | 126 | return mbedtls_aes_crypt_cbc( (mbedtls_aes_context *) ctx, operation, length, iv, input, |
JMF | 12:0071cb144c7a | 127 | output ); |
JMF | 12:0071cb144c7a | 128 | } |
JMF | 12:0071cb144c7a | 129 | #endif /* MBEDTLS_CIPHER_MODE_CBC */ |
JMF | 12:0071cb144c7a | 130 | |
JMF | 12:0071cb144c7a | 131 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
JMF | 12:0071cb144c7a | 132 | static int aes_crypt_cfb128_wrap( void *ctx, mbedtls_operation_t operation, |
JMF | 12:0071cb144c7a | 133 | size_t length, size_t *iv_off, unsigned char *iv, |
JMF | 12:0071cb144c7a | 134 | const unsigned char *input, unsigned char *output ) |
JMF | 12:0071cb144c7a | 135 | { |
JMF | 12:0071cb144c7a | 136 | return mbedtls_aes_crypt_cfb128( (mbedtls_aes_context *) ctx, operation, length, iv_off, iv, |
JMF | 12:0071cb144c7a | 137 | input, output ); |
JMF | 12:0071cb144c7a | 138 | } |
JMF | 12:0071cb144c7a | 139 | #endif /* MBEDTLS_CIPHER_MODE_CFB */ |
JMF | 12:0071cb144c7a | 140 | |
JMF | 12:0071cb144c7a | 141 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
JMF | 12:0071cb144c7a | 142 | static int aes_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off, |
JMF | 12:0071cb144c7a | 143 | unsigned char *nonce_counter, unsigned char *stream_block, |
JMF | 12:0071cb144c7a | 144 | const unsigned char *input, unsigned char *output ) |
JMF | 12:0071cb144c7a | 145 | { |
JMF | 12:0071cb144c7a | 146 | return mbedtls_aes_crypt_ctr( (mbedtls_aes_context *) ctx, length, nc_off, nonce_counter, |
JMF | 12:0071cb144c7a | 147 | stream_block, input, output ); |
JMF | 12:0071cb144c7a | 148 | } |
JMF | 12:0071cb144c7a | 149 | #endif /* MBEDTLS_CIPHER_MODE_CTR */ |
JMF | 12:0071cb144c7a | 150 | |
JMF | 12:0071cb144c7a | 151 | static int aes_setkey_dec_wrap( void *ctx, const unsigned char *key, |
JMF | 12:0071cb144c7a | 152 | unsigned int key_bitlen ) |
JMF | 12:0071cb144c7a | 153 | { |
JMF | 12:0071cb144c7a | 154 | return mbedtls_aes_setkey_dec( (mbedtls_aes_context *) ctx, key, key_bitlen ); |
JMF | 12:0071cb144c7a | 155 | } |
JMF | 12:0071cb144c7a | 156 | |
JMF | 12:0071cb144c7a | 157 | static int aes_setkey_enc_wrap( void *ctx, const unsigned char *key, |
JMF | 12:0071cb144c7a | 158 | unsigned int key_bitlen ) |
JMF | 12:0071cb144c7a | 159 | { |
JMF | 12:0071cb144c7a | 160 | return mbedtls_aes_setkey_enc( (mbedtls_aes_context *) ctx, key, key_bitlen ); |
JMF | 12:0071cb144c7a | 161 | } |
JMF | 12:0071cb144c7a | 162 | |
JMF | 12:0071cb144c7a | 163 | static void * aes_ctx_alloc( void ) |
JMF | 12:0071cb144c7a | 164 | { |
JMF | 12:0071cb144c7a | 165 | mbedtls_aes_context *aes = mbedtls_calloc( 1, sizeof( mbedtls_aes_context ) ); |
JMF | 12:0071cb144c7a | 166 | |
JMF | 12:0071cb144c7a | 167 | if( aes == NULL ) |
JMF | 12:0071cb144c7a | 168 | return( NULL ); |
JMF | 12:0071cb144c7a | 169 | |
JMF | 12:0071cb144c7a | 170 | mbedtls_aes_init( aes ); |
JMF | 12:0071cb144c7a | 171 | |
JMF | 12:0071cb144c7a | 172 | return( aes ); |
JMF | 12:0071cb144c7a | 173 | } |
JMF | 12:0071cb144c7a | 174 | |
JMF | 12:0071cb144c7a | 175 | static void aes_ctx_free( void *ctx ) |
JMF | 12:0071cb144c7a | 176 | { |
JMF | 12:0071cb144c7a | 177 | mbedtls_aes_free( (mbedtls_aes_context *) ctx ); |
JMF | 12:0071cb144c7a | 178 | mbedtls_free( ctx ); |
JMF | 12:0071cb144c7a | 179 | } |
JMF | 12:0071cb144c7a | 180 | |
JMF | 12:0071cb144c7a | 181 | static const mbedtls_cipher_base_t aes_info = { |
JMF | 12:0071cb144c7a | 182 | MBEDTLS_CIPHER_ID_AES, |
JMF | 12:0071cb144c7a | 183 | aes_crypt_ecb_wrap, |
JMF | 12:0071cb144c7a | 184 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 185 | aes_crypt_cbc_wrap, |
JMF | 12:0071cb144c7a | 186 | #endif |
JMF | 12:0071cb144c7a | 187 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
JMF | 12:0071cb144c7a | 188 | aes_crypt_cfb128_wrap, |
JMF | 12:0071cb144c7a | 189 | #endif |
JMF | 12:0071cb144c7a | 190 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
JMF | 12:0071cb144c7a | 191 | aes_crypt_ctr_wrap, |
JMF | 12:0071cb144c7a | 192 | #endif |
JMF | 12:0071cb144c7a | 193 | #if defined(MBEDTLS_CIPHER_MODE_STREAM) |
JMF | 12:0071cb144c7a | 194 | NULL, |
JMF | 12:0071cb144c7a | 195 | #endif |
JMF | 12:0071cb144c7a | 196 | aes_setkey_enc_wrap, |
JMF | 12:0071cb144c7a | 197 | aes_setkey_dec_wrap, |
JMF | 12:0071cb144c7a | 198 | aes_ctx_alloc, |
JMF | 12:0071cb144c7a | 199 | aes_ctx_free |
JMF | 12:0071cb144c7a | 200 | }; |
JMF | 12:0071cb144c7a | 201 | |
JMF | 12:0071cb144c7a | 202 | static const mbedtls_cipher_info_t aes_128_ecb_info = { |
JMF | 12:0071cb144c7a | 203 | MBEDTLS_CIPHER_AES_128_ECB, |
JMF | 12:0071cb144c7a | 204 | MBEDTLS_MODE_ECB, |
JMF | 12:0071cb144c7a | 205 | 128, |
JMF | 12:0071cb144c7a | 206 | "AES-128-ECB", |
JMF | 12:0071cb144c7a | 207 | 16, |
JMF | 12:0071cb144c7a | 208 | 0, |
JMF | 12:0071cb144c7a | 209 | 16, |
JMF | 12:0071cb144c7a | 210 | &aes_info |
JMF | 12:0071cb144c7a | 211 | }; |
JMF | 12:0071cb144c7a | 212 | |
JMF | 12:0071cb144c7a | 213 | static const mbedtls_cipher_info_t aes_192_ecb_info = { |
JMF | 12:0071cb144c7a | 214 | MBEDTLS_CIPHER_AES_192_ECB, |
JMF | 12:0071cb144c7a | 215 | MBEDTLS_MODE_ECB, |
JMF | 12:0071cb144c7a | 216 | 192, |
JMF | 12:0071cb144c7a | 217 | "AES-192-ECB", |
JMF | 12:0071cb144c7a | 218 | 16, |
JMF | 12:0071cb144c7a | 219 | 0, |
JMF | 12:0071cb144c7a | 220 | 16, |
JMF | 12:0071cb144c7a | 221 | &aes_info |
JMF | 12:0071cb144c7a | 222 | }; |
JMF | 12:0071cb144c7a | 223 | |
JMF | 12:0071cb144c7a | 224 | static const mbedtls_cipher_info_t aes_256_ecb_info = { |
JMF | 12:0071cb144c7a | 225 | MBEDTLS_CIPHER_AES_256_ECB, |
JMF | 12:0071cb144c7a | 226 | MBEDTLS_MODE_ECB, |
JMF | 12:0071cb144c7a | 227 | 256, |
JMF | 12:0071cb144c7a | 228 | "AES-256-ECB", |
JMF | 12:0071cb144c7a | 229 | 16, |
JMF | 12:0071cb144c7a | 230 | 0, |
JMF | 12:0071cb144c7a | 231 | 16, |
JMF | 12:0071cb144c7a | 232 | &aes_info |
JMF | 12:0071cb144c7a | 233 | }; |
JMF | 12:0071cb144c7a | 234 | |
JMF | 12:0071cb144c7a | 235 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 236 | static const mbedtls_cipher_info_t aes_128_cbc_info = { |
JMF | 12:0071cb144c7a | 237 | MBEDTLS_CIPHER_AES_128_CBC, |
JMF | 12:0071cb144c7a | 238 | MBEDTLS_MODE_CBC, |
JMF | 12:0071cb144c7a | 239 | 128, |
JMF | 12:0071cb144c7a | 240 | "AES-128-CBC", |
JMF | 12:0071cb144c7a | 241 | 16, |
JMF | 12:0071cb144c7a | 242 | 0, |
JMF | 12:0071cb144c7a | 243 | 16, |
JMF | 12:0071cb144c7a | 244 | &aes_info |
JMF | 12:0071cb144c7a | 245 | }; |
JMF | 12:0071cb144c7a | 246 | |
JMF | 12:0071cb144c7a | 247 | static const mbedtls_cipher_info_t aes_192_cbc_info = { |
JMF | 12:0071cb144c7a | 248 | MBEDTLS_CIPHER_AES_192_CBC, |
JMF | 12:0071cb144c7a | 249 | MBEDTLS_MODE_CBC, |
JMF | 12:0071cb144c7a | 250 | 192, |
JMF | 12:0071cb144c7a | 251 | "AES-192-CBC", |
JMF | 12:0071cb144c7a | 252 | 16, |
JMF | 12:0071cb144c7a | 253 | 0, |
JMF | 12:0071cb144c7a | 254 | 16, |
JMF | 12:0071cb144c7a | 255 | &aes_info |
JMF | 12:0071cb144c7a | 256 | }; |
JMF | 12:0071cb144c7a | 257 | |
JMF | 12:0071cb144c7a | 258 | static const mbedtls_cipher_info_t aes_256_cbc_info = { |
JMF | 12:0071cb144c7a | 259 | MBEDTLS_CIPHER_AES_256_CBC, |
JMF | 12:0071cb144c7a | 260 | MBEDTLS_MODE_CBC, |
JMF | 12:0071cb144c7a | 261 | 256, |
JMF | 12:0071cb144c7a | 262 | "AES-256-CBC", |
JMF | 12:0071cb144c7a | 263 | 16, |
JMF | 12:0071cb144c7a | 264 | 0, |
JMF | 12:0071cb144c7a | 265 | 16, |
JMF | 12:0071cb144c7a | 266 | &aes_info |
JMF | 12:0071cb144c7a | 267 | }; |
JMF | 12:0071cb144c7a | 268 | #endif /* MBEDTLS_CIPHER_MODE_CBC */ |
JMF | 12:0071cb144c7a | 269 | |
JMF | 12:0071cb144c7a | 270 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
JMF | 12:0071cb144c7a | 271 | static const mbedtls_cipher_info_t aes_128_cfb128_info = { |
JMF | 12:0071cb144c7a | 272 | MBEDTLS_CIPHER_AES_128_CFB128, |
JMF | 12:0071cb144c7a | 273 | MBEDTLS_MODE_CFB, |
JMF | 12:0071cb144c7a | 274 | 128, |
JMF | 12:0071cb144c7a | 275 | "AES-128-CFB128", |
JMF | 12:0071cb144c7a | 276 | 16, |
JMF | 12:0071cb144c7a | 277 | 0, |
JMF | 12:0071cb144c7a | 278 | 16, |
JMF | 12:0071cb144c7a | 279 | &aes_info |
JMF | 12:0071cb144c7a | 280 | }; |
JMF | 12:0071cb144c7a | 281 | |
JMF | 12:0071cb144c7a | 282 | static const mbedtls_cipher_info_t aes_192_cfb128_info = { |
JMF | 12:0071cb144c7a | 283 | MBEDTLS_CIPHER_AES_192_CFB128, |
JMF | 12:0071cb144c7a | 284 | MBEDTLS_MODE_CFB, |
JMF | 12:0071cb144c7a | 285 | 192, |
JMF | 12:0071cb144c7a | 286 | "AES-192-CFB128", |
JMF | 12:0071cb144c7a | 287 | 16, |
JMF | 12:0071cb144c7a | 288 | 0, |
JMF | 12:0071cb144c7a | 289 | 16, |
JMF | 12:0071cb144c7a | 290 | &aes_info |
JMF | 12:0071cb144c7a | 291 | }; |
JMF | 12:0071cb144c7a | 292 | |
JMF | 12:0071cb144c7a | 293 | static const mbedtls_cipher_info_t aes_256_cfb128_info = { |
JMF | 12:0071cb144c7a | 294 | MBEDTLS_CIPHER_AES_256_CFB128, |
JMF | 12:0071cb144c7a | 295 | MBEDTLS_MODE_CFB, |
JMF | 12:0071cb144c7a | 296 | 256, |
JMF | 12:0071cb144c7a | 297 | "AES-256-CFB128", |
JMF | 12:0071cb144c7a | 298 | 16, |
JMF | 12:0071cb144c7a | 299 | 0, |
JMF | 12:0071cb144c7a | 300 | 16, |
JMF | 12:0071cb144c7a | 301 | &aes_info |
JMF | 12:0071cb144c7a | 302 | }; |
JMF | 12:0071cb144c7a | 303 | #endif /* MBEDTLS_CIPHER_MODE_CFB */ |
JMF | 12:0071cb144c7a | 304 | |
JMF | 12:0071cb144c7a | 305 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
JMF | 12:0071cb144c7a | 306 | static const mbedtls_cipher_info_t aes_128_ctr_info = { |
JMF | 12:0071cb144c7a | 307 | MBEDTLS_CIPHER_AES_128_CTR, |
JMF | 12:0071cb144c7a | 308 | MBEDTLS_MODE_CTR, |
JMF | 12:0071cb144c7a | 309 | 128, |
JMF | 12:0071cb144c7a | 310 | "AES-128-CTR", |
JMF | 12:0071cb144c7a | 311 | 16, |
JMF | 12:0071cb144c7a | 312 | 0, |
JMF | 12:0071cb144c7a | 313 | 16, |
JMF | 12:0071cb144c7a | 314 | &aes_info |
JMF | 12:0071cb144c7a | 315 | }; |
JMF | 12:0071cb144c7a | 316 | |
JMF | 12:0071cb144c7a | 317 | static const mbedtls_cipher_info_t aes_192_ctr_info = { |
JMF | 12:0071cb144c7a | 318 | MBEDTLS_CIPHER_AES_192_CTR, |
JMF | 12:0071cb144c7a | 319 | MBEDTLS_MODE_CTR, |
JMF | 12:0071cb144c7a | 320 | 192, |
JMF | 12:0071cb144c7a | 321 | "AES-192-CTR", |
JMF | 12:0071cb144c7a | 322 | 16, |
JMF | 12:0071cb144c7a | 323 | 0, |
JMF | 12:0071cb144c7a | 324 | 16, |
JMF | 12:0071cb144c7a | 325 | &aes_info |
JMF | 12:0071cb144c7a | 326 | }; |
JMF | 12:0071cb144c7a | 327 | |
JMF | 12:0071cb144c7a | 328 | static const mbedtls_cipher_info_t aes_256_ctr_info = { |
JMF | 12:0071cb144c7a | 329 | MBEDTLS_CIPHER_AES_256_CTR, |
JMF | 12:0071cb144c7a | 330 | MBEDTLS_MODE_CTR, |
JMF | 12:0071cb144c7a | 331 | 256, |
JMF | 12:0071cb144c7a | 332 | "AES-256-CTR", |
JMF | 12:0071cb144c7a | 333 | 16, |
JMF | 12:0071cb144c7a | 334 | 0, |
JMF | 12:0071cb144c7a | 335 | 16, |
JMF | 12:0071cb144c7a | 336 | &aes_info |
JMF | 12:0071cb144c7a | 337 | }; |
JMF | 12:0071cb144c7a | 338 | #endif /* MBEDTLS_CIPHER_MODE_CTR */ |
JMF | 12:0071cb144c7a | 339 | |
JMF | 12:0071cb144c7a | 340 | #if defined(MBEDTLS_GCM_C) |
JMF | 12:0071cb144c7a | 341 | static int gcm_aes_setkey_wrap( void *ctx, const unsigned char *key, |
JMF | 12:0071cb144c7a | 342 | unsigned int key_bitlen ) |
JMF | 12:0071cb144c7a | 343 | { |
JMF | 12:0071cb144c7a | 344 | return mbedtls_gcm_setkey( (mbedtls_gcm_context *) ctx, MBEDTLS_CIPHER_ID_AES, |
JMF | 12:0071cb144c7a | 345 | key, key_bitlen ); |
JMF | 12:0071cb144c7a | 346 | } |
JMF | 12:0071cb144c7a | 347 | |
JMF | 12:0071cb144c7a | 348 | static const mbedtls_cipher_base_t gcm_aes_info = { |
JMF | 12:0071cb144c7a | 349 | MBEDTLS_CIPHER_ID_AES, |
JMF | 12:0071cb144c7a | 350 | NULL, |
JMF | 12:0071cb144c7a | 351 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 352 | NULL, |
JMF | 12:0071cb144c7a | 353 | #endif |
JMF | 12:0071cb144c7a | 354 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
JMF | 12:0071cb144c7a | 355 | NULL, |
JMF | 12:0071cb144c7a | 356 | #endif |
JMF | 12:0071cb144c7a | 357 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
JMF | 12:0071cb144c7a | 358 | NULL, |
JMF | 12:0071cb144c7a | 359 | #endif |
JMF | 12:0071cb144c7a | 360 | #if defined(MBEDTLS_CIPHER_MODE_STREAM) |
JMF | 12:0071cb144c7a | 361 | NULL, |
JMF | 12:0071cb144c7a | 362 | #endif |
JMF | 12:0071cb144c7a | 363 | gcm_aes_setkey_wrap, |
JMF | 12:0071cb144c7a | 364 | gcm_aes_setkey_wrap, |
JMF | 12:0071cb144c7a | 365 | gcm_ctx_alloc, |
JMF | 12:0071cb144c7a | 366 | gcm_ctx_free, |
JMF | 12:0071cb144c7a | 367 | }; |
JMF | 12:0071cb144c7a | 368 | |
JMF | 12:0071cb144c7a | 369 | static const mbedtls_cipher_info_t aes_128_gcm_info = { |
JMF | 12:0071cb144c7a | 370 | MBEDTLS_CIPHER_AES_128_GCM, |
JMF | 12:0071cb144c7a | 371 | MBEDTLS_MODE_GCM, |
JMF | 12:0071cb144c7a | 372 | 128, |
JMF | 12:0071cb144c7a | 373 | "AES-128-GCM", |
JMF | 12:0071cb144c7a | 374 | 12, |
JMF | 12:0071cb144c7a | 375 | MBEDTLS_CIPHER_VARIABLE_IV_LEN, |
JMF | 12:0071cb144c7a | 376 | 16, |
JMF | 12:0071cb144c7a | 377 | &gcm_aes_info |
JMF | 12:0071cb144c7a | 378 | }; |
JMF | 12:0071cb144c7a | 379 | |
JMF | 12:0071cb144c7a | 380 | static const mbedtls_cipher_info_t aes_192_gcm_info = { |
JMF | 12:0071cb144c7a | 381 | MBEDTLS_CIPHER_AES_192_GCM, |
JMF | 12:0071cb144c7a | 382 | MBEDTLS_MODE_GCM, |
JMF | 12:0071cb144c7a | 383 | 192, |
JMF | 12:0071cb144c7a | 384 | "AES-192-GCM", |
JMF | 12:0071cb144c7a | 385 | 12, |
JMF | 12:0071cb144c7a | 386 | MBEDTLS_CIPHER_VARIABLE_IV_LEN, |
JMF | 12:0071cb144c7a | 387 | 16, |
JMF | 12:0071cb144c7a | 388 | &gcm_aes_info |
JMF | 12:0071cb144c7a | 389 | }; |
JMF | 12:0071cb144c7a | 390 | |
JMF | 12:0071cb144c7a | 391 | static const mbedtls_cipher_info_t aes_256_gcm_info = { |
JMF | 12:0071cb144c7a | 392 | MBEDTLS_CIPHER_AES_256_GCM, |
JMF | 12:0071cb144c7a | 393 | MBEDTLS_MODE_GCM, |
JMF | 12:0071cb144c7a | 394 | 256, |
JMF | 12:0071cb144c7a | 395 | "AES-256-GCM", |
JMF | 12:0071cb144c7a | 396 | 12, |
JMF | 12:0071cb144c7a | 397 | MBEDTLS_CIPHER_VARIABLE_IV_LEN, |
JMF | 12:0071cb144c7a | 398 | 16, |
JMF | 12:0071cb144c7a | 399 | &gcm_aes_info |
JMF | 12:0071cb144c7a | 400 | }; |
JMF | 12:0071cb144c7a | 401 | #endif /* MBEDTLS_GCM_C */ |
JMF | 12:0071cb144c7a | 402 | |
JMF | 12:0071cb144c7a | 403 | #if defined(MBEDTLS_CCM_C) |
JMF | 12:0071cb144c7a | 404 | static int ccm_aes_setkey_wrap( void *ctx, const unsigned char *key, |
JMF | 12:0071cb144c7a | 405 | unsigned int key_bitlen ) |
JMF | 12:0071cb144c7a | 406 | { |
JMF | 12:0071cb144c7a | 407 | return mbedtls_ccm_setkey( (mbedtls_ccm_context *) ctx, MBEDTLS_CIPHER_ID_AES, |
JMF | 12:0071cb144c7a | 408 | key, key_bitlen ); |
JMF | 12:0071cb144c7a | 409 | } |
JMF | 12:0071cb144c7a | 410 | |
JMF | 12:0071cb144c7a | 411 | static const mbedtls_cipher_base_t ccm_aes_info = { |
JMF | 12:0071cb144c7a | 412 | MBEDTLS_CIPHER_ID_AES, |
JMF | 12:0071cb144c7a | 413 | NULL, |
JMF | 12:0071cb144c7a | 414 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 415 | NULL, |
JMF | 12:0071cb144c7a | 416 | #endif |
JMF | 12:0071cb144c7a | 417 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
JMF | 12:0071cb144c7a | 418 | NULL, |
JMF | 12:0071cb144c7a | 419 | #endif |
JMF | 12:0071cb144c7a | 420 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
JMF | 12:0071cb144c7a | 421 | NULL, |
JMF | 12:0071cb144c7a | 422 | #endif |
JMF | 12:0071cb144c7a | 423 | #if defined(MBEDTLS_CIPHER_MODE_STREAM) |
JMF | 12:0071cb144c7a | 424 | NULL, |
JMF | 12:0071cb144c7a | 425 | #endif |
JMF | 12:0071cb144c7a | 426 | ccm_aes_setkey_wrap, |
JMF | 12:0071cb144c7a | 427 | ccm_aes_setkey_wrap, |
JMF | 12:0071cb144c7a | 428 | ccm_ctx_alloc, |
JMF | 12:0071cb144c7a | 429 | ccm_ctx_free, |
JMF | 12:0071cb144c7a | 430 | }; |
JMF | 12:0071cb144c7a | 431 | |
JMF | 12:0071cb144c7a | 432 | static const mbedtls_cipher_info_t aes_128_ccm_info = { |
JMF | 12:0071cb144c7a | 433 | MBEDTLS_CIPHER_AES_128_CCM, |
JMF | 12:0071cb144c7a | 434 | MBEDTLS_MODE_CCM, |
JMF | 12:0071cb144c7a | 435 | 128, |
JMF | 12:0071cb144c7a | 436 | "AES-128-CCM", |
JMF | 12:0071cb144c7a | 437 | 12, |
JMF | 12:0071cb144c7a | 438 | MBEDTLS_CIPHER_VARIABLE_IV_LEN, |
JMF | 12:0071cb144c7a | 439 | 16, |
JMF | 12:0071cb144c7a | 440 | &ccm_aes_info |
JMF | 12:0071cb144c7a | 441 | }; |
JMF | 12:0071cb144c7a | 442 | |
JMF | 12:0071cb144c7a | 443 | static const mbedtls_cipher_info_t aes_192_ccm_info = { |
JMF | 12:0071cb144c7a | 444 | MBEDTLS_CIPHER_AES_192_CCM, |
JMF | 12:0071cb144c7a | 445 | MBEDTLS_MODE_CCM, |
JMF | 12:0071cb144c7a | 446 | 192, |
JMF | 12:0071cb144c7a | 447 | "AES-192-CCM", |
JMF | 12:0071cb144c7a | 448 | 12, |
JMF | 12:0071cb144c7a | 449 | MBEDTLS_CIPHER_VARIABLE_IV_LEN, |
JMF | 12:0071cb144c7a | 450 | 16, |
JMF | 12:0071cb144c7a | 451 | &ccm_aes_info |
JMF | 12:0071cb144c7a | 452 | }; |
JMF | 12:0071cb144c7a | 453 | |
JMF | 12:0071cb144c7a | 454 | static const mbedtls_cipher_info_t aes_256_ccm_info = { |
JMF | 12:0071cb144c7a | 455 | MBEDTLS_CIPHER_AES_256_CCM, |
JMF | 12:0071cb144c7a | 456 | MBEDTLS_MODE_CCM, |
JMF | 12:0071cb144c7a | 457 | 256, |
JMF | 12:0071cb144c7a | 458 | "AES-256-CCM", |
JMF | 12:0071cb144c7a | 459 | 12, |
JMF | 12:0071cb144c7a | 460 | MBEDTLS_CIPHER_VARIABLE_IV_LEN, |
JMF | 12:0071cb144c7a | 461 | 16, |
JMF | 12:0071cb144c7a | 462 | &ccm_aes_info |
JMF | 12:0071cb144c7a | 463 | }; |
JMF | 12:0071cb144c7a | 464 | #endif /* MBEDTLS_CCM_C */ |
JMF | 12:0071cb144c7a | 465 | |
JMF | 12:0071cb144c7a | 466 | #endif /* MBEDTLS_AES_C */ |
JMF | 12:0071cb144c7a | 467 | |
JMF | 12:0071cb144c7a | 468 | #if defined(MBEDTLS_CAMELLIA_C) |
JMF | 12:0071cb144c7a | 469 | |
JMF | 12:0071cb144c7a | 470 | static int camellia_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation, |
JMF | 12:0071cb144c7a | 471 | const unsigned char *input, unsigned char *output ) |
JMF | 12:0071cb144c7a | 472 | { |
JMF | 12:0071cb144c7a | 473 | return mbedtls_camellia_crypt_ecb( (mbedtls_camellia_context *) ctx, operation, input, |
JMF | 12:0071cb144c7a | 474 | output ); |
JMF | 12:0071cb144c7a | 475 | } |
JMF | 12:0071cb144c7a | 476 | |
JMF | 12:0071cb144c7a | 477 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 478 | static int camellia_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, |
JMF | 12:0071cb144c7a | 479 | size_t length, unsigned char *iv, |
JMF | 12:0071cb144c7a | 480 | const unsigned char *input, unsigned char *output ) |
JMF | 12:0071cb144c7a | 481 | { |
JMF | 12:0071cb144c7a | 482 | return mbedtls_camellia_crypt_cbc( (mbedtls_camellia_context *) ctx, operation, length, iv, |
JMF | 12:0071cb144c7a | 483 | input, output ); |
JMF | 12:0071cb144c7a | 484 | } |
JMF | 12:0071cb144c7a | 485 | #endif /* MBEDTLS_CIPHER_MODE_CBC */ |
JMF | 12:0071cb144c7a | 486 | |
JMF | 12:0071cb144c7a | 487 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
JMF | 12:0071cb144c7a | 488 | static int camellia_crypt_cfb128_wrap( void *ctx, mbedtls_operation_t operation, |
JMF | 12:0071cb144c7a | 489 | size_t length, size_t *iv_off, unsigned char *iv, |
JMF | 12:0071cb144c7a | 490 | const unsigned char *input, unsigned char *output ) |
JMF | 12:0071cb144c7a | 491 | { |
JMF | 12:0071cb144c7a | 492 | return mbedtls_camellia_crypt_cfb128( (mbedtls_camellia_context *) ctx, operation, length, |
JMF | 12:0071cb144c7a | 493 | iv_off, iv, input, output ); |
JMF | 12:0071cb144c7a | 494 | } |
JMF | 12:0071cb144c7a | 495 | #endif /* MBEDTLS_CIPHER_MODE_CFB */ |
JMF | 12:0071cb144c7a | 496 | |
JMF | 12:0071cb144c7a | 497 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
JMF | 12:0071cb144c7a | 498 | static int camellia_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off, |
JMF | 12:0071cb144c7a | 499 | unsigned char *nonce_counter, unsigned char *stream_block, |
JMF | 12:0071cb144c7a | 500 | const unsigned char *input, unsigned char *output ) |
JMF | 12:0071cb144c7a | 501 | { |
JMF | 12:0071cb144c7a | 502 | return mbedtls_camellia_crypt_ctr( (mbedtls_camellia_context *) ctx, length, nc_off, |
JMF | 12:0071cb144c7a | 503 | nonce_counter, stream_block, input, output ); |
JMF | 12:0071cb144c7a | 504 | } |
JMF | 12:0071cb144c7a | 505 | #endif /* MBEDTLS_CIPHER_MODE_CTR */ |
JMF | 12:0071cb144c7a | 506 | |
JMF | 12:0071cb144c7a | 507 | static int camellia_setkey_dec_wrap( void *ctx, const unsigned char *key, |
JMF | 12:0071cb144c7a | 508 | unsigned int key_bitlen ) |
JMF | 12:0071cb144c7a | 509 | { |
JMF | 12:0071cb144c7a | 510 | return mbedtls_camellia_setkey_dec( (mbedtls_camellia_context *) ctx, key, key_bitlen ); |
JMF | 12:0071cb144c7a | 511 | } |
JMF | 12:0071cb144c7a | 512 | |
JMF | 12:0071cb144c7a | 513 | static int camellia_setkey_enc_wrap( void *ctx, const unsigned char *key, |
JMF | 12:0071cb144c7a | 514 | unsigned int key_bitlen ) |
JMF | 12:0071cb144c7a | 515 | { |
JMF | 12:0071cb144c7a | 516 | return mbedtls_camellia_setkey_enc( (mbedtls_camellia_context *) ctx, key, key_bitlen ); |
JMF | 12:0071cb144c7a | 517 | } |
JMF | 12:0071cb144c7a | 518 | |
JMF | 12:0071cb144c7a | 519 | static void * camellia_ctx_alloc( void ) |
JMF | 12:0071cb144c7a | 520 | { |
JMF | 12:0071cb144c7a | 521 | mbedtls_camellia_context *ctx; |
JMF | 12:0071cb144c7a | 522 | ctx = mbedtls_calloc( 1, sizeof( mbedtls_camellia_context ) ); |
JMF | 12:0071cb144c7a | 523 | |
JMF | 12:0071cb144c7a | 524 | if( ctx == NULL ) |
JMF | 12:0071cb144c7a | 525 | return( NULL ); |
JMF | 12:0071cb144c7a | 526 | |
JMF | 12:0071cb144c7a | 527 | mbedtls_camellia_init( ctx ); |
JMF | 12:0071cb144c7a | 528 | |
JMF | 12:0071cb144c7a | 529 | return( ctx ); |
JMF | 12:0071cb144c7a | 530 | } |
JMF | 12:0071cb144c7a | 531 | |
JMF | 12:0071cb144c7a | 532 | static void camellia_ctx_free( void *ctx ) |
JMF | 12:0071cb144c7a | 533 | { |
JMF | 12:0071cb144c7a | 534 | mbedtls_camellia_free( (mbedtls_camellia_context *) ctx ); |
JMF | 12:0071cb144c7a | 535 | mbedtls_free( ctx ); |
JMF | 12:0071cb144c7a | 536 | } |
JMF | 12:0071cb144c7a | 537 | |
JMF | 12:0071cb144c7a | 538 | static const mbedtls_cipher_base_t camellia_info = { |
JMF | 12:0071cb144c7a | 539 | MBEDTLS_CIPHER_ID_CAMELLIA, |
JMF | 12:0071cb144c7a | 540 | camellia_crypt_ecb_wrap, |
JMF | 12:0071cb144c7a | 541 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 542 | camellia_crypt_cbc_wrap, |
JMF | 12:0071cb144c7a | 543 | #endif |
JMF | 12:0071cb144c7a | 544 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
JMF | 12:0071cb144c7a | 545 | camellia_crypt_cfb128_wrap, |
JMF | 12:0071cb144c7a | 546 | #endif |
JMF | 12:0071cb144c7a | 547 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
JMF | 12:0071cb144c7a | 548 | camellia_crypt_ctr_wrap, |
JMF | 12:0071cb144c7a | 549 | #endif |
JMF | 12:0071cb144c7a | 550 | #if defined(MBEDTLS_CIPHER_MODE_STREAM) |
JMF | 12:0071cb144c7a | 551 | NULL, |
JMF | 12:0071cb144c7a | 552 | #endif |
JMF | 12:0071cb144c7a | 553 | camellia_setkey_enc_wrap, |
JMF | 12:0071cb144c7a | 554 | camellia_setkey_dec_wrap, |
JMF | 12:0071cb144c7a | 555 | camellia_ctx_alloc, |
JMF | 12:0071cb144c7a | 556 | camellia_ctx_free |
JMF | 12:0071cb144c7a | 557 | }; |
JMF | 12:0071cb144c7a | 558 | |
JMF | 12:0071cb144c7a | 559 | static const mbedtls_cipher_info_t camellia_128_ecb_info = { |
JMF | 12:0071cb144c7a | 560 | MBEDTLS_CIPHER_CAMELLIA_128_ECB, |
JMF | 12:0071cb144c7a | 561 | MBEDTLS_MODE_ECB, |
JMF | 12:0071cb144c7a | 562 | 128, |
JMF | 12:0071cb144c7a | 563 | "CAMELLIA-128-ECB", |
JMF | 12:0071cb144c7a | 564 | 16, |
JMF | 12:0071cb144c7a | 565 | 0, |
JMF | 12:0071cb144c7a | 566 | 16, |
JMF | 12:0071cb144c7a | 567 | &camellia_info |
JMF | 12:0071cb144c7a | 568 | }; |
JMF | 12:0071cb144c7a | 569 | |
JMF | 12:0071cb144c7a | 570 | static const mbedtls_cipher_info_t camellia_192_ecb_info = { |
JMF | 12:0071cb144c7a | 571 | MBEDTLS_CIPHER_CAMELLIA_192_ECB, |
JMF | 12:0071cb144c7a | 572 | MBEDTLS_MODE_ECB, |
JMF | 12:0071cb144c7a | 573 | 192, |
JMF | 12:0071cb144c7a | 574 | "CAMELLIA-192-ECB", |
JMF | 12:0071cb144c7a | 575 | 16, |
JMF | 12:0071cb144c7a | 576 | 0, |
JMF | 12:0071cb144c7a | 577 | 16, |
JMF | 12:0071cb144c7a | 578 | &camellia_info |
JMF | 12:0071cb144c7a | 579 | }; |
JMF | 12:0071cb144c7a | 580 | |
JMF | 12:0071cb144c7a | 581 | static const mbedtls_cipher_info_t camellia_256_ecb_info = { |
JMF | 12:0071cb144c7a | 582 | MBEDTLS_CIPHER_CAMELLIA_256_ECB, |
JMF | 12:0071cb144c7a | 583 | MBEDTLS_MODE_ECB, |
JMF | 12:0071cb144c7a | 584 | 256, |
JMF | 12:0071cb144c7a | 585 | "CAMELLIA-256-ECB", |
JMF | 12:0071cb144c7a | 586 | 16, |
JMF | 12:0071cb144c7a | 587 | 0, |
JMF | 12:0071cb144c7a | 588 | 16, |
JMF | 12:0071cb144c7a | 589 | &camellia_info |
JMF | 12:0071cb144c7a | 590 | }; |
JMF | 12:0071cb144c7a | 591 | |
JMF | 12:0071cb144c7a | 592 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 593 | static const mbedtls_cipher_info_t camellia_128_cbc_info = { |
JMF | 12:0071cb144c7a | 594 | MBEDTLS_CIPHER_CAMELLIA_128_CBC, |
JMF | 12:0071cb144c7a | 595 | MBEDTLS_MODE_CBC, |
JMF | 12:0071cb144c7a | 596 | 128, |
JMF | 12:0071cb144c7a | 597 | "CAMELLIA-128-CBC", |
JMF | 12:0071cb144c7a | 598 | 16, |
JMF | 12:0071cb144c7a | 599 | 0, |
JMF | 12:0071cb144c7a | 600 | 16, |
JMF | 12:0071cb144c7a | 601 | &camellia_info |
JMF | 12:0071cb144c7a | 602 | }; |
JMF | 12:0071cb144c7a | 603 | |
JMF | 12:0071cb144c7a | 604 | static const mbedtls_cipher_info_t camellia_192_cbc_info = { |
JMF | 12:0071cb144c7a | 605 | MBEDTLS_CIPHER_CAMELLIA_192_CBC, |
JMF | 12:0071cb144c7a | 606 | MBEDTLS_MODE_CBC, |
JMF | 12:0071cb144c7a | 607 | 192, |
JMF | 12:0071cb144c7a | 608 | "CAMELLIA-192-CBC", |
JMF | 12:0071cb144c7a | 609 | 16, |
JMF | 12:0071cb144c7a | 610 | 0, |
JMF | 12:0071cb144c7a | 611 | 16, |
JMF | 12:0071cb144c7a | 612 | &camellia_info |
JMF | 12:0071cb144c7a | 613 | }; |
JMF | 12:0071cb144c7a | 614 | |
JMF | 12:0071cb144c7a | 615 | static const mbedtls_cipher_info_t camellia_256_cbc_info = { |
JMF | 12:0071cb144c7a | 616 | MBEDTLS_CIPHER_CAMELLIA_256_CBC, |
JMF | 12:0071cb144c7a | 617 | MBEDTLS_MODE_CBC, |
JMF | 12:0071cb144c7a | 618 | 256, |
JMF | 12:0071cb144c7a | 619 | "CAMELLIA-256-CBC", |
JMF | 12:0071cb144c7a | 620 | 16, |
JMF | 12:0071cb144c7a | 621 | 0, |
JMF | 12:0071cb144c7a | 622 | 16, |
JMF | 12:0071cb144c7a | 623 | &camellia_info |
JMF | 12:0071cb144c7a | 624 | }; |
JMF | 12:0071cb144c7a | 625 | #endif /* MBEDTLS_CIPHER_MODE_CBC */ |
JMF | 12:0071cb144c7a | 626 | |
JMF | 12:0071cb144c7a | 627 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
JMF | 12:0071cb144c7a | 628 | static const mbedtls_cipher_info_t camellia_128_cfb128_info = { |
JMF | 12:0071cb144c7a | 629 | MBEDTLS_CIPHER_CAMELLIA_128_CFB128, |
JMF | 12:0071cb144c7a | 630 | MBEDTLS_MODE_CFB, |
JMF | 12:0071cb144c7a | 631 | 128, |
JMF | 12:0071cb144c7a | 632 | "CAMELLIA-128-CFB128", |
JMF | 12:0071cb144c7a | 633 | 16, |
JMF | 12:0071cb144c7a | 634 | 0, |
JMF | 12:0071cb144c7a | 635 | 16, |
JMF | 12:0071cb144c7a | 636 | &camellia_info |
JMF | 12:0071cb144c7a | 637 | }; |
JMF | 12:0071cb144c7a | 638 | |
JMF | 12:0071cb144c7a | 639 | static const mbedtls_cipher_info_t camellia_192_cfb128_info = { |
JMF | 12:0071cb144c7a | 640 | MBEDTLS_CIPHER_CAMELLIA_192_CFB128, |
JMF | 12:0071cb144c7a | 641 | MBEDTLS_MODE_CFB, |
JMF | 12:0071cb144c7a | 642 | 192, |
JMF | 12:0071cb144c7a | 643 | "CAMELLIA-192-CFB128", |
JMF | 12:0071cb144c7a | 644 | 16, |
JMF | 12:0071cb144c7a | 645 | 0, |
JMF | 12:0071cb144c7a | 646 | 16, |
JMF | 12:0071cb144c7a | 647 | &camellia_info |
JMF | 12:0071cb144c7a | 648 | }; |
JMF | 12:0071cb144c7a | 649 | |
JMF | 12:0071cb144c7a | 650 | static const mbedtls_cipher_info_t camellia_256_cfb128_info = { |
JMF | 12:0071cb144c7a | 651 | MBEDTLS_CIPHER_CAMELLIA_256_CFB128, |
JMF | 12:0071cb144c7a | 652 | MBEDTLS_MODE_CFB, |
JMF | 12:0071cb144c7a | 653 | 256, |
JMF | 12:0071cb144c7a | 654 | "CAMELLIA-256-CFB128", |
JMF | 12:0071cb144c7a | 655 | 16, |
JMF | 12:0071cb144c7a | 656 | 0, |
JMF | 12:0071cb144c7a | 657 | 16, |
JMF | 12:0071cb144c7a | 658 | &camellia_info |
JMF | 12:0071cb144c7a | 659 | }; |
JMF | 12:0071cb144c7a | 660 | #endif /* MBEDTLS_CIPHER_MODE_CFB */ |
JMF | 12:0071cb144c7a | 661 | |
JMF | 12:0071cb144c7a | 662 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
JMF | 12:0071cb144c7a | 663 | static const mbedtls_cipher_info_t camellia_128_ctr_info = { |
JMF | 12:0071cb144c7a | 664 | MBEDTLS_CIPHER_CAMELLIA_128_CTR, |
JMF | 12:0071cb144c7a | 665 | MBEDTLS_MODE_CTR, |
JMF | 12:0071cb144c7a | 666 | 128, |
JMF | 12:0071cb144c7a | 667 | "CAMELLIA-128-CTR", |
JMF | 12:0071cb144c7a | 668 | 16, |
JMF | 12:0071cb144c7a | 669 | 0, |
JMF | 12:0071cb144c7a | 670 | 16, |
JMF | 12:0071cb144c7a | 671 | &camellia_info |
JMF | 12:0071cb144c7a | 672 | }; |
JMF | 12:0071cb144c7a | 673 | |
JMF | 12:0071cb144c7a | 674 | static const mbedtls_cipher_info_t camellia_192_ctr_info = { |
JMF | 12:0071cb144c7a | 675 | MBEDTLS_CIPHER_CAMELLIA_192_CTR, |
JMF | 12:0071cb144c7a | 676 | MBEDTLS_MODE_CTR, |
JMF | 12:0071cb144c7a | 677 | 192, |
JMF | 12:0071cb144c7a | 678 | "CAMELLIA-192-CTR", |
JMF | 12:0071cb144c7a | 679 | 16, |
JMF | 12:0071cb144c7a | 680 | 0, |
JMF | 12:0071cb144c7a | 681 | 16, |
JMF | 12:0071cb144c7a | 682 | &camellia_info |
JMF | 12:0071cb144c7a | 683 | }; |
JMF | 12:0071cb144c7a | 684 | |
JMF | 12:0071cb144c7a | 685 | static const mbedtls_cipher_info_t camellia_256_ctr_info = { |
JMF | 12:0071cb144c7a | 686 | MBEDTLS_CIPHER_CAMELLIA_256_CTR, |
JMF | 12:0071cb144c7a | 687 | MBEDTLS_MODE_CTR, |
JMF | 12:0071cb144c7a | 688 | 256, |
JMF | 12:0071cb144c7a | 689 | "CAMELLIA-256-CTR", |
JMF | 12:0071cb144c7a | 690 | 16, |
JMF | 12:0071cb144c7a | 691 | 0, |
JMF | 12:0071cb144c7a | 692 | 16, |
JMF | 12:0071cb144c7a | 693 | &camellia_info |
JMF | 12:0071cb144c7a | 694 | }; |
JMF | 12:0071cb144c7a | 695 | #endif /* MBEDTLS_CIPHER_MODE_CTR */ |
JMF | 12:0071cb144c7a | 696 | |
JMF | 12:0071cb144c7a | 697 | #if defined(MBEDTLS_GCM_C) |
JMF | 12:0071cb144c7a | 698 | static int gcm_camellia_setkey_wrap( void *ctx, const unsigned char *key, |
JMF | 12:0071cb144c7a | 699 | unsigned int key_bitlen ) |
JMF | 12:0071cb144c7a | 700 | { |
JMF | 12:0071cb144c7a | 701 | return mbedtls_gcm_setkey( (mbedtls_gcm_context *) ctx, MBEDTLS_CIPHER_ID_CAMELLIA, |
JMF | 12:0071cb144c7a | 702 | key, key_bitlen ); |
JMF | 12:0071cb144c7a | 703 | } |
JMF | 12:0071cb144c7a | 704 | |
JMF | 12:0071cb144c7a | 705 | static const mbedtls_cipher_base_t gcm_camellia_info = { |
JMF | 12:0071cb144c7a | 706 | MBEDTLS_CIPHER_ID_CAMELLIA, |
JMF | 12:0071cb144c7a | 707 | NULL, |
JMF | 12:0071cb144c7a | 708 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 709 | NULL, |
JMF | 12:0071cb144c7a | 710 | #endif |
JMF | 12:0071cb144c7a | 711 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
JMF | 12:0071cb144c7a | 712 | NULL, |
JMF | 12:0071cb144c7a | 713 | #endif |
JMF | 12:0071cb144c7a | 714 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
JMF | 12:0071cb144c7a | 715 | NULL, |
JMF | 12:0071cb144c7a | 716 | #endif |
JMF | 12:0071cb144c7a | 717 | #if defined(MBEDTLS_CIPHER_MODE_STREAM) |
JMF | 12:0071cb144c7a | 718 | NULL, |
JMF | 12:0071cb144c7a | 719 | #endif |
JMF | 12:0071cb144c7a | 720 | gcm_camellia_setkey_wrap, |
JMF | 12:0071cb144c7a | 721 | gcm_camellia_setkey_wrap, |
JMF | 12:0071cb144c7a | 722 | gcm_ctx_alloc, |
JMF | 12:0071cb144c7a | 723 | gcm_ctx_free, |
JMF | 12:0071cb144c7a | 724 | }; |
JMF | 12:0071cb144c7a | 725 | |
JMF | 12:0071cb144c7a | 726 | static const mbedtls_cipher_info_t camellia_128_gcm_info = { |
JMF | 12:0071cb144c7a | 727 | MBEDTLS_CIPHER_CAMELLIA_128_GCM, |
JMF | 12:0071cb144c7a | 728 | MBEDTLS_MODE_GCM, |
JMF | 12:0071cb144c7a | 729 | 128, |
JMF | 12:0071cb144c7a | 730 | "CAMELLIA-128-GCM", |
JMF | 12:0071cb144c7a | 731 | 12, |
JMF | 12:0071cb144c7a | 732 | MBEDTLS_CIPHER_VARIABLE_IV_LEN, |
JMF | 12:0071cb144c7a | 733 | 16, |
JMF | 12:0071cb144c7a | 734 | &gcm_camellia_info |
JMF | 12:0071cb144c7a | 735 | }; |
JMF | 12:0071cb144c7a | 736 | |
JMF | 12:0071cb144c7a | 737 | static const mbedtls_cipher_info_t camellia_192_gcm_info = { |
JMF | 12:0071cb144c7a | 738 | MBEDTLS_CIPHER_CAMELLIA_192_GCM, |
JMF | 12:0071cb144c7a | 739 | MBEDTLS_MODE_GCM, |
JMF | 12:0071cb144c7a | 740 | 192, |
JMF | 12:0071cb144c7a | 741 | "CAMELLIA-192-GCM", |
JMF | 12:0071cb144c7a | 742 | 12, |
JMF | 12:0071cb144c7a | 743 | MBEDTLS_CIPHER_VARIABLE_IV_LEN, |
JMF | 12:0071cb144c7a | 744 | 16, |
JMF | 12:0071cb144c7a | 745 | &gcm_camellia_info |
JMF | 12:0071cb144c7a | 746 | }; |
JMF | 12:0071cb144c7a | 747 | |
JMF | 12:0071cb144c7a | 748 | static const mbedtls_cipher_info_t camellia_256_gcm_info = { |
JMF | 12:0071cb144c7a | 749 | MBEDTLS_CIPHER_CAMELLIA_256_GCM, |
JMF | 12:0071cb144c7a | 750 | MBEDTLS_MODE_GCM, |
JMF | 12:0071cb144c7a | 751 | 256, |
JMF | 12:0071cb144c7a | 752 | "CAMELLIA-256-GCM", |
JMF | 12:0071cb144c7a | 753 | 12, |
JMF | 12:0071cb144c7a | 754 | MBEDTLS_CIPHER_VARIABLE_IV_LEN, |
JMF | 12:0071cb144c7a | 755 | 16, |
JMF | 12:0071cb144c7a | 756 | &gcm_camellia_info |
JMF | 12:0071cb144c7a | 757 | }; |
JMF | 12:0071cb144c7a | 758 | #endif /* MBEDTLS_GCM_C */ |
JMF | 12:0071cb144c7a | 759 | |
JMF | 12:0071cb144c7a | 760 | #if defined(MBEDTLS_CCM_C) |
JMF | 12:0071cb144c7a | 761 | static int ccm_camellia_setkey_wrap( void *ctx, const unsigned char *key, |
JMF | 12:0071cb144c7a | 762 | unsigned int key_bitlen ) |
JMF | 12:0071cb144c7a | 763 | { |
JMF | 12:0071cb144c7a | 764 | return mbedtls_ccm_setkey( (mbedtls_ccm_context *) ctx, MBEDTLS_CIPHER_ID_CAMELLIA, |
JMF | 12:0071cb144c7a | 765 | key, key_bitlen ); |
JMF | 12:0071cb144c7a | 766 | } |
JMF | 12:0071cb144c7a | 767 | |
JMF | 12:0071cb144c7a | 768 | static const mbedtls_cipher_base_t ccm_camellia_info = { |
JMF | 12:0071cb144c7a | 769 | MBEDTLS_CIPHER_ID_CAMELLIA, |
JMF | 12:0071cb144c7a | 770 | NULL, |
JMF | 12:0071cb144c7a | 771 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 772 | NULL, |
JMF | 12:0071cb144c7a | 773 | #endif |
JMF | 12:0071cb144c7a | 774 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
JMF | 12:0071cb144c7a | 775 | NULL, |
JMF | 12:0071cb144c7a | 776 | #endif |
JMF | 12:0071cb144c7a | 777 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
JMF | 12:0071cb144c7a | 778 | NULL, |
JMF | 12:0071cb144c7a | 779 | #endif |
JMF | 12:0071cb144c7a | 780 | #if defined(MBEDTLS_CIPHER_MODE_STREAM) |
JMF | 12:0071cb144c7a | 781 | NULL, |
JMF | 12:0071cb144c7a | 782 | #endif |
JMF | 12:0071cb144c7a | 783 | ccm_camellia_setkey_wrap, |
JMF | 12:0071cb144c7a | 784 | ccm_camellia_setkey_wrap, |
JMF | 12:0071cb144c7a | 785 | ccm_ctx_alloc, |
JMF | 12:0071cb144c7a | 786 | ccm_ctx_free, |
JMF | 12:0071cb144c7a | 787 | }; |
JMF | 12:0071cb144c7a | 788 | |
JMF | 12:0071cb144c7a | 789 | static const mbedtls_cipher_info_t camellia_128_ccm_info = { |
JMF | 12:0071cb144c7a | 790 | MBEDTLS_CIPHER_CAMELLIA_128_CCM, |
JMF | 12:0071cb144c7a | 791 | MBEDTLS_MODE_CCM, |
JMF | 12:0071cb144c7a | 792 | 128, |
JMF | 12:0071cb144c7a | 793 | "CAMELLIA-128-CCM", |
JMF | 12:0071cb144c7a | 794 | 12, |
JMF | 12:0071cb144c7a | 795 | MBEDTLS_CIPHER_VARIABLE_IV_LEN, |
JMF | 12:0071cb144c7a | 796 | 16, |
JMF | 12:0071cb144c7a | 797 | &ccm_camellia_info |
JMF | 12:0071cb144c7a | 798 | }; |
JMF | 12:0071cb144c7a | 799 | |
JMF | 12:0071cb144c7a | 800 | static const mbedtls_cipher_info_t camellia_192_ccm_info = { |
JMF | 12:0071cb144c7a | 801 | MBEDTLS_CIPHER_CAMELLIA_192_CCM, |
JMF | 12:0071cb144c7a | 802 | MBEDTLS_MODE_CCM, |
JMF | 12:0071cb144c7a | 803 | 192, |
JMF | 12:0071cb144c7a | 804 | "CAMELLIA-192-CCM", |
JMF | 12:0071cb144c7a | 805 | 12, |
JMF | 12:0071cb144c7a | 806 | MBEDTLS_CIPHER_VARIABLE_IV_LEN, |
JMF | 12:0071cb144c7a | 807 | 16, |
JMF | 12:0071cb144c7a | 808 | &ccm_camellia_info |
JMF | 12:0071cb144c7a | 809 | }; |
JMF | 12:0071cb144c7a | 810 | |
JMF | 12:0071cb144c7a | 811 | static const mbedtls_cipher_info_t camellia_256_ccm_info = { |
JMF | 12:0071cb144c7a | 812 | MBEDTLS_CIPHER_CAMELLIA_256_CCM, |
JMF | 12:0071cb144c7a | 813 | MBEDTLS_MODE_CCM, |
JMF | 12:0071cb144c7a | 814 | 256, |
JMF | 12:0071cb144c7a | 815 | "CAMELLIA-256-CCM", |
JMF | 12:0071cb144c7a | 816 | 12, |
JMF | 12:0071cb144c7a | 817 | MBEDTLS_CIPHER_VARIABLE_IV_LEN, |
JMF | 12:0071cb144c7a | 818 | 16, |
JMF | 12:0071cb144c7a | 819 | &ccm_camellia_info |
JMF | 12:0071cb144c7a | 820 | }; |
JMF | 12:0071cb144c7a | 821 | #endif /* MBEDTLS_CCM_C */ |
JMF | 12:0071cb144c7a | 822 | |
JMF | 12:0071cb144c7a | 823 | #endif /* MBEDTLS_CAMELLIA_C */ |
JMF | 12:0071cb144c7a | 824 | |
JMF | 12:0071cb144c7a | 825 | #if defined(MBEDTLS_DES_C) |
JMF | 12:0071cb144c7a | 826 | |
JMF | 12:0071cb144c7a | 827 | static int des_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation, |
JMF | 12:0071cb144c7a | 828 | const unsigned char *input, unsigned char *output ) |
JMF | 12:0071cb144c7a | 829 | { |
JMF | 12:0071cb144c7a | 830 | ((void) operation); |
JMF | 12:0071cb144c7a | 831 | return mbedtls_des_crypt_ecb( (mbedtls_des_context *) ctx, input, output ); |
JMF | 12:0071cb144c7a | 832 | } |
JMF | 12:0071cb144c7a | 833 | |
JMF | 12:0071cb144c7a | 834 | static int des3_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation, |
JMF | 12:0071cb144c7a | 835 | const unsigned char *input, unsigned char *output ) |
JMF | 12:0071cb144c7a | 836 | { |
JMF | 12:0071cb144c7a | 837 | ((void) operation); |
JMF | 12:0071cb144c7a | 838 | return mbedtls_des3_crypt_ecb( (mbedtls_des3_context *) ctx, input, output ); |
JMF | 12:0071cb144c7a | 839 | } |
JMF | 12:0071cb144c7a | 840 | |
JMF | 12:0071cb144c7a | 841 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 842 | static int des_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, size_t length, |
JMF | 12:0071cb144c7a | 843 | unsigned char *iv, const unsigned char *input, unsigned char *output ) |
JMF | 12:0071cb144c7a | 844 | { |
JMF | 12:0071cb144c7a | 845 | return mbedtls_des_crypt_cbc( (mbedtls_des_context *) ctx, operation, length, iv, input, |
JMF | 12:0071cb144c7a | 846 | output ); |
JMF | 12:0071cb144c7a | 847 | } |
JMF | 12:0071cb144c7a | 848 | #endif /* MBEDTLS_CIPHER_MODE_CBC */ |
JMF | 12:0071cb144c7a | 849 | |
JMF | 12:0071cb144c7a | 850 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 851 | static int des3_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, size_t length, |
JMF | 12:0071cb144c7a | 852 | unsigned char *iv, const unsigned char *input, unsigned char *output ) |
JMF | 12:0071cb144c7a | 853 | { |
JMF | 12:0071cb144c7a | 854 | return mbedtls_des3_crypt_cbc( (mbedtls_des3_context *) ctx, operation, length, iv, input, |
JMF | 12:0071cb144c7a | 855 | output ); |
JMF | 12:0071cb144c7a | 856 | } |
JMF | 12:0071cb144c7a | 857 | #endif /* MBEDTLS_CIPHER_MODE_CBC */ |
JMF | 12:0071cb144c7a | 858 | |
JMF | 12:0071cb144c7a | 859 | static int des_setkey_dec_wrap( void *ctx, const unsigned char *key, |
JMF | 12:0071cb144c7a | 860 | unsigned int key_bitlen ) |
JMF | 12:0071cb144c7a | 861 | { |
JMF | 12:0071cb144c7a | 862 | ((void) key_bitlen); |
JMF | 12:0071cb144c7a | 863 | |
JMF | 12:0071cb144c7a | 864 | return mbedtls_des_setkey_dec( (mbedtls_des_context *) ctx, key ); |
JMF | 12:0071cb144c7a | 865 | } |
JMF | 12:0071cb144c7a | 866 | |
JMF | 12:0071cb144c7a | 867 | static int des_setkey_enc_wrap( void *ctx, const unsigned char *key, |
JMF | 12:0071cb144c7a | 868 | unsigned int key_bitlen ) |
JMF | 12:0071cb144c7a | 869 | { |
JMF | 12:0071cb144c7a | 870 | ((void) key_bitlen); |
JMF | 12:0071cb144c7a | 871 | |
JMF | 12:0071cb144c7a | 872 | return mbedtls_des_setkey_enc( (mbedtls_des_context *) ctx, key ); |
JMF | 12:0071cb144c7a | 873 | } |
JMF | 12:0071cb144c7a | 874 | |
JMF | 12:0071cb144c7a | 875 | static int des3_set2key_dec_wrap( void *ctx, const unsigned char *key, |
JMF | 12:0071cb144c7a | 876 | unsigned int key_bitlen ) |
JMF | 12:0071cb144c7a | 877 | { |
JMF | 12:0071cb144c7a | 878 | ((void) key_bitlen); |
JMF | 12:0071cb144c7a | 879 | |
JMF | 12:0071cb144c7a | 880 | return mbedtls_des3_set2key_dec( (mbedtls_des3_context *) ctx, key ); |
JMF | 12:0071cb144c7a | 881 | } |
JMF | 12:0071cb144c7a | 882 | |
JMF | 12:0071cb144c7a | 883 | static int des3_set2key_enc_wrap( void *ctx, const unsigned char *key, |
JMF | 12:0071cb144c7a | 884 | unsigned int key_bitlen ) |
JMF | 12:0071cb144c7a | 885 | { |
JMF | 12:0071cb144c7a | 886 | ((void) key_bitlen); |
JMF | 12:0071cb144c7a | 887 | |
JMF | 12:0071cb144c7a | 888 | return mbedtls_des3_set2key_enc( (mbedtls_des3_context *) ctx, key ); |
JMF | 12:0071cb144c7a | 889 | } |
JMF | 12:0071cb144c7a | 890 | |
JMF | 12:0071cb144c7a | 891 | static int des3_set3key_dec_wrap( void *ctx, const unsigned char *key, |
JMF | 12:0071cb144c7a | 892 | unsigned int key_bitlen ) |
JMF | 12:0071cb144c7a | 893 | { |
JMF | 12:0071cb144c7a | 894 | ((void) key_bitlen); |
JMF | 12:0071cb144c7a | 895 | |
JMF | 12:0071cb144c7a | 896 | return mbedtls_des3_set3key_dec( (mbedtls_des3_context *) ctx, key ); |
JMF | 12:0071cb144c7a | 897 | } |
JMF | 12:0071cb144c7a | 898 | |
JMF | 12:0071cb144c7a | 899 | static int des3_set3key_enc_wrap( void *ctx, const unsigned char *key, |
JMF | 12:0071cb144c7a | 900 | unsigned int key_bitlen ) |
JMF | 12:0071cb144c7a | 901 | { |
JMF | 12:0071cb144c7a | 902 | ((void) key_bitlen); |
JMF | 12:0071cb144c7a | 903 | |
JMF | 12:0071cb144c7a | 904 | return mbedtls_des3_set3key_enc( (mbedtls_des3_context *) ctx, key ); |
JMF | 12:0071cb144c7a | 905 | } |
JMF | 12:0071cb144c7a | 906 | |
JMF | 12:0071cb144c7a | 907 | static void * des_ctx_alloc( void ) |
JMF | 12:0071cb144c7a | 908 | { |
JMF | 12:0071cb144c7a | 909 | mbedtls_des_context *des = mbedtls_calloc( 1, sizeof( mbedtls_des_context ) ); |
JMF | 12:0071cb144c7a | 910 | |
JMF | 12:0071cb144c7a | 911 | if( des == NULL ) |
JMF | 12:0071cb144c7a | 912 | return( NULL ); |
JMF | 12:0071cb144c7a | 913 | |
JMF | 12:0071cb144c7a | 914 | mbedtls_des_init( des ); |
JMF | 12:0071cb144c7a | 915 | |
JMF | 12:0071cb144c7a | 916 | return( des ); |
JMF | 12:0071cb144c7a | 917 | } |
JMF | 12:0071cb144c7a | 918 | |
JMF | 12:0071cb144c7a | 919 | static void des_ctx_free( void *ctx ) |
JMF | 12:0071cb144c7a | 920 | { |
JMF | 12:0071cb144c7a | 921 | mbedtls_des_free( (mbedtls_des_context *) ctx ); |
JMF | 12:0071cb144c7a | 922 | mbedtls_free( ctx ); |
JMF | 12:0071cb144c7a | 923 | } |
JMF | 12:0071cb144c7a | 924 | |
JMF | 12:0071cb144c7a | 925 | static void * des3_ctx_alloc( void ) |
JMF | 12:0071cb144c7a | 926 | { |
JMF | 12:0071cb144c7a | 927 | mbedtls_des3_context *des3; |
JMF | 12:0071cb144c7a | 928 | des3 = mbedtls_calloc( 1, sizeof( mbedtls_des3_context ) ); |
JMF | 12:0071cb144c7a | 929 | |
JMF | 12:0071cb144c7a | 930 | if( des3 == NULL ) |
JMF | 12:0071cb144c7a | 931 | return( NULL ); |
JMF | 12:0071cb144c7a | 932 | |
JMF | 12:0071cb144c7a | 933 | mbedtls_des3_init( des3 ); |
JMF | 12:0071cb144c7a | 934 | |
JMF | 12:0071cb144c7a | 935 | return( des3 ); |
JMF | 12:0071cb144c7a | 936 | } |
JMF | 12:0071cb144c7a | 937 | |
JMF | 12:0071cb144c7a | 938 | static void des3_ctx_free( void *ctx ) |
JMF | 12:0071cb144c7a | 939 | { |
JMF | 12:0071cb144c7a | 940 | mbedtls_des3_free( (mbedtls_des3_context *) ctx ); |
JMF | 12:0071cb144c7a | 941 | mbedtls_free( ctx ); |
JMF | 12:0071cb144c7a | 942 | } |
JMF | 12:0071cb144c7a | 943 | |
JMF | 12:0071cb144c7a | 944 | static const mbedtls_cipher_base_t des_info = { |
JMF | 12:0071cb144c7a | 945 | MBEDTLS_CIPHER_ID_DES, |
JMF | 12:0071cb144c7a | 946 | des_crypt_ecb_wrap, |
JMF | 12:0071cb144c7a | 947 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 948 | des_crypt_cbc_wrap, |
JMF | 12:0071cb144c7a | 949 | #endif |
JMF | 12:0071cb144c7a | 950 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
JMF | 12:0071cb144c7a | 951 | NULL, |
JMF | 12:0071cb144c7a | 952 | #endif |
JMF | 12:0071cb144c7a | 953 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
JMF | 12:0071cb144c7a | 954 | NULL, |
JMF | 12:0071cb144c7a | 955 | #endif |
JMF | 12:0071cb144c7a | 956 | #if defined(MBEDTLS_CIPHER_MODE_STREAM) |
JMF | 12:0071cb144c7a | 957 | NULL, |
JMF | 12:0071cb144c7a | 958 | #endif |
JMF | 12:0071cb144c7a | 959 | des_setkey_enc_wrap, |
JMF | 12:0071cb144c7a | 960 | des_setkey_dec_wrap, |
JMF | 12:0071cb144c7a | 961 | des_ctx_alloc, |
JMF | 12:0071cb144c7a | 962 | des_ctx_free |
JMF | 12:0071cb144c7a | 963 | }; |
JMF | 12:0071cb144c7a | 964 | |
JMF | 12:0071cb144c7a | 965 | static const mbedtls_cipher_info_t des_ecb_info = { |
JMF | 12:0071cb144c7a | 966 | MBEDTLS_CIPHER_DES_ECB, |
JMF | 12:0071cb144c7a | 967 | MBEDTLS_MODE_ECB, |
JMF | 12:0071cb144c7a | 968 | MBEDTLS_KEY_LENGTH_DES, |
JMF | 12:0071cb144c7a | 969 | "DES-ECB", |
JMF | 12:0071cb144c7a | 970 | 8, |
JMF | 12:0071cb144c7a | 971 | 0, |
JMF | 12:0071cb144c7a | 972 | 8, |
JMF | 12:0071cb144c7a | 973 | &des_info |
JMF | 12:0071cb144c7a | 974 | }; |
JMF | 12:0071cb144c7a | 975 | |
JMF | 12:0071cb144c7a | 976 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 977 | static const mbedtls_cipher_info_t des_cbc_info = { |
JMF | 12:0071cb144c7a | 978 | MBEDTLS_CIPHER_DES_CBC, |
JMF | 12:0071cb144c7a | 979 | MBEDTLS_MODE_CBC, |
JMF | 12:0071cb144c7a | 980 | MBEDTLS_KEY_LENGTH_DES, |
JMF | 12:0071cb144c7a | 981 | "DES-CBC", |
JMF | 12:0071cb144c7a | 982 | 8, |
JMF | 12:0071cb144c7a | 983 | 0, |
JMF | 12:0071cb144c7a | 984 | 8, |
JMF | 12:0071cb144c7a | 985 | &des_info |
JMF | 12:0071cb144c7a | 986 | }; |
JMF | 12:0071cb144c7a | 987 | #endif /* MBEDTLS_CIPHER_MODE_CBC */ |
JMF | 12:0071cb144c7a | 988 | |
JMF | 12:0071cb144c7a | 989 | static const mbedtls_cipher_base_t des_ede_info = { |
JMF | 12:0071cb144c7a | 990 | MBEDTLS_CIPHER_ID_DES, |
JMF | 12:0071cb144c7a | 991 | des3_crypt_ecb_wrap, |
JMF | 12:0071cb144c7a | 992 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 993 | des3_crypt_cbc_wrap, |
JMF | 12:0071cb144c7a | 994 | #endif |
JMF | 12:0071cb144c7a | 995 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
JMF | 12:0071cb144c7a | 996 | NULL, |
JMF | 12:0071cb144c7a | 997 | #endif |
JMF | 12:0071cb144c7a | 998 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
JMF | 12:0071cb144c7a | 999 | NULL, |
JMF | 12:0071cb144c7a | 1000 | #endif |
JMF | 12:0071cb144c7a | 1001 | #if defined(MBEDTLS_CIPHER_MODE_STREAM) |
JMF | 12:0071cb144c7a | 1002 | NULL, |
JMF | 12:0071cb144c7a | 1003 | #endif |
JMF | 12:0071cb144c7a | 1004 | des3_set2key_enc_wrap, |
JMF | 12:0071cb144c7a | 1005 | des3_set2key_dec_wrap, |
JMF | 12:0071cb144c7a | 1006 | des3_ctx_alloc, |
JMF | 12:0071cb144c7a | 1007 | des3_ctx_free |
JMF | 12:0071cb144c7a | 1008 | }; |
JMF | 12:0071cb144c7a | 1009 | |
JMF | 12:0071cb144c7a | 1010 | static const mbedtls_cipher_info_t des_ede_ecb_info = { |
JMF | 12:0071cb144c7a | 1011 | MBEDTLS_CIPHER_DES_EDE_ECB, |
JMF | 12:0071cb144c7a | 1012 | MBEDTLS_MODE_ECB, |
JMF | 12:0071cb144c7a | 1013 | MBEDTLS_KEY_LENGTH_DES_EDE, |
JMF | 12:0071cb144c7a | 1014 | "DES-EDE-ECB", |
JMF | 12:0071cb144c7a | 1015 | 8, |
JMF | 12:0071cb144c7a | 1016 | 0, |
JMF | 12:0071cb144c7a | 1017 | 8, |
JMF | 12:0071cb144c7a | 1018 | &des_ede_info |
JMF | 12:0071cb144c7a | 1019 | }; |
JMF | 12:0071cb144c7a | 1020 | |
JMF | 12:0071cb144c7a | 1021 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 1022 | static const mbedtls_cipher_info_t des_ede_cbc_info = { |
JMF | 12:0071cb144c7a | 1023 | MBEDTLS_CIPHER_DES_EDE_CBC, |
JMF | 12:0071cb144c7a | 1024 | MBEDTLS_MODE_CBC, |
JMF | 12:0071cb144c7a | 1025 | MBEDTLS_KEY_LENGTH_DES_EDE, |
JMF | 12:0071cb144c7a | 1026 | "DES-EDE-CBC", |
JMF | 12:0071cb144c7a | 1027 | 8, |
JMF | 12:0071cb144c7a | 1028 | 0, |
JMF | 12:0071cb144c7a | 1029 | 8, |
JMF | 12:0071cb144c7a | 1030 | &des_ede_info |
JMF | 12:0071cb144c7a | 1031 | }; |
JMF | 12:0071cb144c7a | 1032 | #endif /* MBEDTLS_CIPHER_MODE_CBC */ |
JMF | 12:0071cb144c7a | 1033 | |
JMF | 12:0071cb144c7a | 1034 | static const mbedtls_cipher_base_t des_ede3_info = { |
JMF | 12:0071cb144c7a | 1035 | MBEDTLS_CIPHER_ID_3DES, |
JMF | 12:0071cb144c7a | 1036 | des3_crypt_ecb_wrap, |
JMF | 12:0071cb144c7a | 1037 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 1038 | des3_crypt_cbc_wrap, |
JMF | 12:0071cb144c7a | 1039 | #endif |
JMF | 12:0071cb144c7a | 1040 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
JMF | 12:0071cb144c7a | 1041 | NULL, |
JMF | 12:0071cb144c7a | 1042 | #endif |
JMF | 12:0071cb144c7a | 1043 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
JMF | 12:0071cb144c7a | 1044 | NULL, |
JMF | 12:0071cb144c7a | 1045 | #endif |
JMF | 12:0071cb144c7a | 1046 | #if defined(MBEDTLS_CIPHER_MODE_STREAM) |
JMF | 12:0071cb144c7a | 1047 | NULL, |
JMF | 12:0071cb144c7a | 1048 | #endif |
JMF | 12:0071cb144c7a | 1049 | des3_set3key_enc_wrap, |
JMF | 12:0071cb144c7a | 1050 | des3_set3key_dec_wrap, |
JMF | 12:0071cb144c7a | 1051 | des3_ctx_alloc, |
JMF | 12:0071cb144c7a | 1052 | des3_ctx_free |
JMF | 12:0071cb144c7a | 1053 | }; |
JMF | 12:0071cb144c7a | 1054 | |
JMF | 12:0071cb144c7a | 1055 | static const mbedtls_cipher_info_t des_ede3_ecb_info = { |
JMF | 12:0071cb144c7a | 1056 | MBEDTLS_CIPHER_DES_EDE3_ECB, |
JMF | 12:0071cb144c7a | 1057 | MBEDTLS_MODE_ECB, |
JMF | 12:0071cb144c7a | 1058 | MBEDTLS_KEY_LENGTH_DES_EDE3, |
JMF | 12:0071cb144c7a | 1059 | "DES-EDE3-ECB", |
JMF | 12:0071cb144c7a | 1060 | 8, |
JMF | 12:0071cb144c7a | 1061 | 0, |
JMF | 12:0071cb144c7a | 1062 | 8, |
JMF | 12:0071cb144c7a | 1063 | &des_ede3_info |
JMF | 12:0071cb144c7a | 1064 | }; |
JMF | 12:0071cb144c7a | 1065 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 1066 | static const mbedtls_cipher_info_t des_ede3_cbc_info = { |
JMF | 12:0071cb144c7a | 1067 | MBEDTLS_CIPHER_DES_EDE3_CBC, |
JMF | 12:0071cb144c7a | 1068 | MBEDTLS_MODE_CBC, |
JMF | 12:0071cb144c7a | 1069 | MBEDTLS_KEY_LENGTH_DES_EDE3, |
JMF | 12:0071cb144c7a | 1070 | "DES-EDE3-CBC", |
JMF | 12:0071cb144c7a | 1071 | 8, |
JMF | 12:0071cb144c7a | 1072 | 0, |
JMF | 12:0071cb144c7a | 1073 | 8, |
JMF | 12:0071cb144c7a | 1074 | &des_ede3_info |
JMF | 12:0071cb144c7a | 1075 | }; |
JMF | 12:0071cb144c7a | 1076 | #endif /* MBEDTLS_CIPHER_MODE_CBC */ |
JMF | 12:0071cb144c7a | 1077 | #endif /* MBEDTLS_DES_C */ |
JMF | 12:0071cb144c7a | 1078 | |
JMF | 12:0071cb144c7a | 1079 | #if defined(MBEDTLS_BLOWFISH_C) |
JMF | 12:0071cb144c7a | 1080 | |
JMF | 12:0071cb144c7a | 1081 | static int blowfish_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation, |
JMF | 12:0071cb144c7a | 1082 | const unsigned char *input, unsigned char *output ) |
JMF | 12:0071cb144c7a | 1083 | { |
JMF | 12:0071cb144c7a | 1084 | return mbedtls_blowfish_crypt_ecb( (mbedtls_blowfish_context *) ctx, operation, input, |
JMF | 12:0071cb144c7a | 1085 | output ); |
JMF | 12:0071cb144c7a | 1086 | } |
JMF | 12:0071cb144c7a | 1087 | |
JMF | 12:0071cb144c7a | 1088 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 1089 | static int blowfish_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, |
JMF | 12:0071cb144c7a | 1090 | size_t length, unsigned char *iv, const unsigned char *input, |
JMF | 12:0071cb144c7a | 1091 | unsigned char *output ) |
JMF | 12:0071cb144c7a | 1092 | { |
JMF | 12:0071cb144c7a | 1093 | return mbedtls_blowfish_crypt_cbc( (mbedtls_blowfish_context *) ctx, operation, length, iv, |
JMF | 12:0071cb144c7a | 1094 | input, output ); |
JMF | 12:0071cb144c7a | 1095 | } |
JMF | 12:0071cb144c7a | 1096 | #endif /* MBEDTLS_CIPHER_MODE_CBC */ |
JMF | 12:0071cb144c7a | 1097 | |
JMF | 12:0071cb144c7a | 1098 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
JMF | 12:0071cb144c7a | 1099 | static int blowfish_crypt_cfb64_wrap( void *ctx, mbedtls_operation_t operation, |
JMF | 12:0071cb144c7a | 1100 | size_t length, size_t *iv_off, unsigned char *iv, |
JMF | 12:0071cb144c7a | 1101 | const unsigned char *input, unsigned char *output ) |
JMF | 12:0071cb144c7a | 1102 | { |
JMF | 12:0071cb144c7a | 1103 | return mbedtls_blowfish_crypt_cfb64( (mbedtls_blowfish_context *) ctx, operation, length, |
JMF | 12:0071cb144c7a | 1104 | iv_off, iv, input, output ); |
JMF | 12:0071cb144c7a | 1105 | } |
JMF | 12:0071cb144c7a | 1106 | #endif /* MBEDTLS_CIPHER_MODE_CFB */ |
JMF | 12:0071cb144c7a | 1107 | |
JMF | 12:0071cb144c7a | 1108 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
JMF | 12:0071cb144c7a | 1109 | static int blowfish_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off, |
JMF | 12:0071cb144c7a | 1110 | unsigned char *nonce_counter, unsigned char *stream_block, |
JMF | 12:0071cb144c7a | 1111 | const unsigned char *input, unsigned char *output ) |
JMF | 12:0071cb144c7a | 1112 | { |
JMF | 12:0071cb144c7a | 1113 | return mbedtls_blowfish_crypt_ctr( (mbedtls_blowfish_context *) ctx, length, nc_off, |
JMF | 12:0071cb144c7a | 1114 | nonce_counter, stream_block, input, output ); |
JMF | 12:0071cb144c7a | 1115 | } |
JMF | 12:0071cb144c7a | 1116 | #endif /* MBEDTLS_CIPHER_MODE_CTR */ |
JMF | 12:0071cb144c7a | 1117 | |
JMF | 12:0071cb144c7a | 1118 | static int blowfish_setkey_wrap( void *ctx, const unsigned char *key, |
JMF | 12:0071cb144c7a | 1119 | unsigned int key_bitlen ) |
JMF | 12:0071cb144c7a | 1120 | { |
JMF | 12:0071cb144c7a | 1121 | return mbedtls_blowfish_setkey( (mbedtls_blowfish_context *) ctx, key, key_bitlen ); |
JMF | 12:0071cb144c7a | 1122 | } |
JMF | 12:0071cb144c7a | 1123 | |
JMF | 12:0071cb144c7a | 1124 | static void * blowfish_ctx_alloc( void ) |
JMF | 12:0071cb144c7a | 1125 | { |
JMF | 12:0071cb144c7a | 1126 | mbedtls_blowfish_context *ctx; |
JMF | 12:0071cb144c7a | 1127 | ctx = mbedtls_calloc( 1, sizeof( mbedtls_blowfish_context ) ); |
JMF | 12:0071cb144c7a | 1128 | |
JMF | 12:0071cb144c7a | 1129 | if( ctx == NULL ) |
JMF | 12:0071cb144c7a | 1130 | return( NULL ); |
JMF | 12:0071cb144c7a | 1131 | |
JMF | 12:0071cb144c7a | 1132 | mbedtls_blowfish_init( ctx ); |
JMF | 12:0071cb144c7a | 1133 | |
JMF | 12:0071cb144c7a | 1134 | return( ctx ); |
JMF | 12:0071cb144c7a | 1135 | } |
JMF | 12:0071cb144c7a | 1136 | |
JMF | 12:0071cb144c7a | 1137 | static void blowfish_ctx_free( void *ctx ) |
JMF | 12:0071cb144c7a | 1138 | { |
JMF | 12:0071cb144c7a | 1139 | mbedtls_blowfish_free( (mbedtls_blowfish_context *) ctx ); |
JMF | 12:0071cb144c7a | 1140 | mbedtls_free( ctx ); |
JMF | 12:0071cb144c7a | 1141 | } |
JMF | 12:0071cb144c7a | 1142 | |
JMF | 12:0071cb144c7a | 1143 | static const mbedtls_cipher_base_t blowfish_info = { |
JMF | 12:0071cb144c7a | 1144 | MBEDTLS_CIPHER_ID_BLOWFISH, |
JMF | 12:0071cb144c7a | 1145 | blowfish_crypt_ecb_wrap, |
JMF | 12:0071cb144c7a | 1146 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 1147 | blowfish_crypt_cbc_wrap, |
JMF | 12:0071cb144c7a | 1148 | #endif |
JMF | 12:0071cb144c7a | 1149 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
JMF | 12:0071cb144c7a | 1150 | blowfish_crypt_cfb64_wrap, |
JMF | 12:0071cb144c7a | 1151 | #endif |
JMF | 12:0071cb144c7a | 1152 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
JMF | 12:0071cb144c7a | 1153 | blowfish_crypt_ctr_wrap, |
JMF | 12:0071cb144c7a | 1154 | #endif |
JMF | 12:0071cb144c7a | 1155 | #if defined(MBEDTLS_CIPHER_MODE_STREAM) |
JMF | 12:0071cb144c7a | 1156 | NULL, |
JMF | 12:0071cb144c7a | 1157 | #endif |
JMF | 12:0071cb144c7a | 1158 | blowfish_setkey_wrap, |
JMF | 12:0071cb144c7a | 1159 | blowfish_setkey_wrap, |
JMF | 12:0071cb144c7a | 1160 | blowfish_ctx_alloc, |
JMF | 12:0071cb144c7a | 1161 | blowfish_ctx_free |
JMF | 12:0071cb144c7a | 1162 | }; |
JMF | 12:0071cb144c7a | 1163 | |
JMF | 12:0071cb144c7a | 1164 | static const mbedtls_cipher_info_t blowfish_ecb_info = { |
JMF | 12:0071cb144c7a | 1165 | MBEDTLS_CIPHER_BLOWFISH_ECB, |
JMF | 12:0071cb144c7a | 1166 | MBEDTLS_MODE_ECB, |
JMF | 12:0071cb144c7a | 1167 | 128, |
JMF | 12:0071cb144c7a | 1168 | "BLOWFISH-ECB", |
JMF | 12:0071cb144c7a | 1169 | 8, |
JMF | 12:0071cb144c7a | 1170 | MBEDTLS_CIPHER_VARIABLE_KEY_LEN, |
JMF | 12:0071cb144c7a | 1171 | 8, |
JMF | 12:0071cb144c7a | 1172 | &blowfish_info |
JMF | 12:0071cb144c7a | 1173 | }; |
JMF | 12:0071cb144c7a | 1174 | |
JMF | 12:0071cb144c7a | 1175 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 1176 | static const mbedtls_cipher_info_t blowfish_cbc_info = { |
JMF | 12:0071cb144c7a | 1177 | MBEDTLS_CIPHER_BLOWFISH_CBC, |
JMF | 12:0071cb144c7a | 1178 | MBEDTLS_MODE_CBC, |
JMF | 12:0071cb144c7a | 1179 | 128, |
JMF | 12:0071cb144c7a | 1180 | "BLOWFISH-CBC", |
JMF | 12:0071cb144c7a | 1181 | 8, |
JMF | 12:0071cb144c7a | 1182 | MBEDTLS_CIPHER_VARIABLE_KEY_LEN, |
JMF | 12:0071cb144c7a | 1183 | 8, |
JMF | 12:0071cb144c7a | 1184 | &blowfish_info |
JMF | 12:0071cb144c7a | 1185 | }; |
JMF | 12:0071cb144c7a | 1186 | #endif /* MBEDTLS_CIPHER_MODE_CBC */ |
JMF | 12:0071cb144c7a | 1187 | |
JMF | 12:0071cb144c7a | 1188 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
JMF | 12:0071cb144c7a | 1189 | static const mbedtls_cipher_info_t blowfish_cfb64_info = { |
JMF | 12:0071cb144c7a | 1190 | MBEDTLS_CIPHER_BLOWFISH_CFB64, |
JMF | 12:0071cb144c7a | 1191 | MBEDTLS_MODE_CFB, |
JMF | 12:0071cb144c7a | 1192 | 128, |
JMF | 12:0071cb144c7a | 1193 | "BLOWFISH-CFB64", |
JMF | 12:0071cb144c7a | 1194 | 8, |
JMF | 12:0071cb144c7a | 1195 | MBEDTLS_CIPHER_VARIABLE_KEY_LEN, |
JMF | 12:0071cb144c7a | 1196 | 8, |
JMF | 12:0071cb144c7a | 1197 | &blowfish_info |
JMF | 12:0071cb144c7a | 1198 | }; |
JMF | 12:0071cb144c7a | 1199 | #endif /* MBEDTLS_CIPHER_MODE_CFB */ |
JMF | 12:0071cb144c7a | 1200 | |
JMF | 12:0071cb144c7a | 1201 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
JMF | 12:0071cb144c7a | 1202 | static const mbedtls_cipher_info_t blowfish_ctr_info = { |
JMF | 12:0071cb144c7a | 1203 | MBEDTLS_CIPHER_BLOWFISH_CTR, |
JMF | 12:0071cb144c7a | 1204 | MBEDTLS_MODE_CTR, |
JMF | 12:0071cb144c7a | 1205 | 128, |
JMF | 12:0071cb144c7a | 1206 | "BLOWFISH-CTR", |
JMF | 12:0071cb144c7a | 1207 | 8, |
JMF | 12:0071cb144c7a | 1208 | MBEDTLS_CIPHER_VARIABLE_KEY_LEN, |
JMF | 12:0071cb144c7a | 1209 | 8, |
JMF | 12:0071cb144c7a | 1210 | &blowfish_info |
JMF | 12:0071cb144c7a | 1211 | }; |
JMF | 12:0071cb144c7a | 1212 | #endif /* MBEDTLS_CIPHER_MODE_CTR */ |
JMF | 12:0071cb144c7a | 1213 | #endif /* MBEDTLS_BLOWFISH_C */ |
JMF | 12:0071cb144c7a | 1214 | |
JMF | 12:0071cb144c7a | 1215 | #if defined(MBEDTLS_ARC4_C) |
JMF | 12:0071cb144c7a | 1216 | static int arc4_crypt_stream_wrap( void *ctx, size_t length, |
JMF | 12:0071cb144c7a | 1217 | const unsigned char *input, |
JMF | 12:0071cb144c7a | 1218 | unsigned char *output ) |
JMF | 12:0071cb144c7a | 1219 | { |
JMF | 12:0071cb144c7a | 1220 | return( mbedtls_arc4_crypt( (mbedtls_arc4_context *) ctx, length, input, output ) ); |
JMF | 12:0071cb144c7a | 1221 | } |
JMF | 12:0071cb144c7a | 1222 | |
JMF | 12:0071cb144c7a | 1223 | static int arc4_setkey_wrap( void *ctx, const unsigned char *key, |
JMF | 12:0071cb144c7a | 1224 | unsigned int key_bitlen ) |
JMF | 12:0071cb144c7a | 1225 | { |
JMF | 12:0071cb144c7a | 1226 | /* we get key_bitlen in bits, arc4 expects it in bytes */ |
JMF | 12:0071cb144c7a | 1227 | if( key_bitlen % 8 != 0 ) |
JMF | 12:0071cb144c7a | 1228 | return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); |
JMF | 12:0071cb144c7a | 1229 | |
JMF | 12:0071cb144c7a | 1230 | mbedtls_arc4_setup( (mbedtls_arc4_context *) ctx, key, key_bitlen / 8 ); |
JMF | 12:0071cb144c7a | 1231 | return( 0 ); |
JMF | 12:0071cb144c7a | 1232 | } |
JMF | 12:0071cb144c7a | 1233 | |
JMF | 12:0071cb144c7a | 1234 | static void * arc4_ctx_alloc( void ) |
JMF | 12:0071cb144c7a | 1235 | { |
JMF | 12:0071cb144c7a | 1236 | mbedtls_arc4_context *ctx; |
JMF | 12:0071cb144c7a | 1237 | ctx = mbedtls_calloc( 1, sizeof( mbedtls_arc4_context ) ); |
JMF | 12:0071cb144c7a | 1238 | |
JMF | 12:0071cb144c7a | 1239 | if( ctx == NULL ) |
JMF | 12:0071cb144c7a | 1240 | return( NULL ); |
JMF | 12:0071cb144c7a | 1241 | |
JMF | 12:0071cb144c7a | 1242 | mbedtls_arc4_init( ctx ); |
JMF | 12:0071cb144c7a | 1243 | |
JMF | 12:0071cb144c7a | 1244 | return( ctx ); |
JMF | 12:0071cb144c7a | 1245 | } |
JMF | 12:0071cb144c7a | 1246 | |
JMF | 12:0071cb144c7a | 1247 | static void arc4_ctx_free( void *ctx ) |
JMF | 12:0071cb144c7a | 1248 | { |
JMF | 12:0071cb144c7a | 1249 | mbedtls_arc4_free( (mbedtls_arc4_context *) ctx ); |
JMF | 12:0071cb144c7a | 1250 | mbedtls_free( ctx ); |
JMF | 12:0071cb144c7a | 1251 | } |
JMF | 12:0071cb144c7a | 1252 | |
JMF | 12:0071cb144c7a | 1253 | static const mbedtls_cipher_base_t arc4_base_info = { |
JMF | 12:0071cb144c7a | 1254 | MBEDTLS_CIPHER_ID_ARC4, |
JMF | 12:0071cb144c7a | 1255 | NULL, |
JMF | 12:0071cb144c7a | 1256 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 1257 | NULL, |
JMF | 12:0071cb144c7a | 1258 | #endif |
JMF | 12:0071cb144c7a | 1259 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
JMF | 12:0071cb144c7a | 1260 | NULL, |
JMF | 12:0071cb144c7a | 1261 | #endif |
JMF | 12:0071cb144c7a | 1262 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
JMF | 12:0071cb144c7a | 1263 | NULL, |
JMF | 12:0071cb144c7a | 1264 | #endif |
JMF | 12:0071cb144c7a | 1265 | #if defined(MBEDTLS_CIPHER_MODE_STREAM) |
JMF | 12:0071cb144c7a | 1266 | arc4_crypt_stream_wrap, |
JMF | 12:0071cb144c7a | 1267 | #endif |
JMF | 12:0071cb144c7a | 1268 | arc4_setkey_wrap, |
JMF | 12:0071cb144c7a | 1269 | arc4_setkey_wrap, |
JMF | 12:0071cb144c7a | 1270 | arc4_ctx_alloc, |
JMF | 12:0071cb144c7a | 1271 | arc4_ctx_free |
JMF | 12:0071cb144c7a | 1272 | }; |
JMF | 12:0071cb144c7a | 1273 | |
JMF | 12:0071cb144c7a | 1274 | static const mbedtls_cipher_info_t arc4_128_info = { |
JMF | 12:0071cb144c7a | 1275 | MBEDTLS_CIPHER_ARC4_128, |
JMF | 12:0071cb144c7a | 1276 | MBEDTLS_MODE_STREAM, |
JMF | 12:0071cb144c7a | 1277 | 128, |
JMF | 12:0071cb144c7a | 1278 | "ARC4-128", |
JMF | 12:0071cb144c7a | 1279 | 0, |
JMF | 12:0071cb144c7a | 1280 | 0, |
JMF | 12:0071cb144c7a | 1281 | 1, |
JMF | 12:0071cb144c7a | 1282 | &arc4_base_info |
JMF | 12:0071cb144c7a | 1283 | }; |
JMF | 12:0071cb144c7a | 1284 | #endif /* MBEDTLS_ARC4_C */ |
JMF | 12:0071cb144c7a | 1285 | |
JMF | 12:0071cb144c7a | 1286 | #if defined(MBEDTLS_CIPHER_NULL_CIPHER) |
JMF | 12:0071cb144c7a | 1287 | static int null_crypt_stream( void *ctx, size_t length, |
JMF | 12:0071cb144c7a | 1288 | const unsigned char *input, |
JMF | 12:0071cb144c7a | 1289 | unsigned char *output ) |
JMF | 12:0071cb144c7a | 1290 | { |
JMF | 12:0071cb144c7a | 1291 | ((void) ctx); |
JMF | 12:0071cb144c7a | 1292 | memmove( output, input, length ); |
JMF | 12:0071cb144c7a | 1293 | return( 0 ); |
JMF | 12:0071cb144c7a | 1294 | } |
JMF | 12:0071cb144c7a | 1295 | |
JMF | 12:0071cb144c7a | 1296 | static int null_setkey( void *ctx, const unsigned char *key, |
JMF | 12:0071cb144c7a | 1297 | unsigned int key_bitlen ) |
JMF | 12:0071cb144c7a | 1298 | { |
JMF | 12:0071cb144c7a | 1299 | ((void) ctx); |
JMF | 12:0071cb144c7a | 1300 | ((void) key); |
JMF | 12:0071cb144c7a | 1301 | ((void) key_bitlen); |
JMF | 12:0071cb144c7a | 1302 | |
JMF | 12:0071cb144c7a | 1303 | return( 0 ); |
JMF | 12:0071cb144c7a | 1304 | } |
JMF | 12:0071cb144c7a | 1305 | |
JMF | 12:0071cb144c7a | 1306 | static void * null_ctx_alloc( void ) |
JMF | 12:0071cb144c7a | 1307 | { |
JMF | 12:0071cb144c7a | 1308 | return( (void *) 1 ); |
JMF | 12:0071cb144c7a | 1309 | } |
JMF | 12:0071cb144c7a | 1310 | |
JMF | 12:0071cb144c7a | 1311 | static void null_ctx_free( void *ctx ) |
JMF | 12:0071cb144c7a | 1312 | { |
JMF | 12:0071cb144c7a | 1313 | ((void) ctx); |
JMF | 12:0071cb144c7a | 1314 | } |
JMF | 12:0071cb144c7a | 1315 | |
JMF | 12:0071cb144c7a | 1316 | static const mbedtls_cipher_base_t null_base_info = { |
JMF | 12:0071cb144c7a | 1317 | MBEDTLS_CIPHER_ID_NULL, |
JMF | 12:0071cb144c7a | 1318 | NULL, |
JMF | 12:0071cb144c7a | 1319 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 1320 | NULL, |
JMF | 12:0071cb144c7a | 1321 | #endif |
JMF | 12:0071cb144c7a | 1322 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
JMF | 12:0071cb144c7a | 1323 | NULL, |
JMF | 12:0071cb144c7a | 1324 | #endif |
JMF | 12:0071cb144c7a | 1325 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
JMF | 12:0071cb144c7a | 1326 | NULL, |
JMF | 12:0071cb144c7a | 1327 | #endif |
JMF | 12:0071cb144c7a | 1328 | #if defined(MBEDTLS_CIPHER_MODE_STREAM) |
JMF | 12:0071cb144c7a | 1329 | null_crypt_stream, |
JMF | 12:0071cb144c7a | 1330 | #endif |
JMF | 12:0071cb144c7a | 1331 | null_setkey, |
JMF | 12:0071cb144c7a | 1332 | null_setkey, |
JMF | 12:0071cb144c7a | 1333 | null_ctx_alloc, |
JMF | 12:0071cb144c7a | 1334 | null_ctx_free |
JMF | 12:0071cb144c7a | 1335 | }; |
JMF | 12:0071cb144c7a | 1336 | |
JMF | 12:0071cb144c7a | 1337 | static const mbedtls_cipher_info_t null_cipher_info = { |
JMF | 12:0071cb144c7a | 1338 | MBEDTLS_CIPHER_NULL, |
JMF | 12:0071cb144c7a | 1339 | MBEDTLS_MODE_STREAM, |
JMF | 12:0071cb144c7a | 1340 | 0, |
JMF | 12:0071cb144c7a | 1341 | "NULL", |
JMF | 12:0071cb144c7a | 1342 | 0, |
JMF | 12:0071cb144c7a | 1343 | 0, |
JMF | 12:0071cb144c7a | 1344 | 1, |
JMF | 12:0071cb144c7a | 1345 | &null_base_info |
JMF | 12:0071cb144c7a | 1346 | }; |
JMF | 12:0071cb144c7a | 1347 | #endif /* defined(MBEDTLS_CIPHER_NULL_CIPHER) */ |
JMF | 12:0071cb144c7a | 1348 | |
JMF | 12:0071cb144c7a | 1349 | const mbedtls_cipher_definition_t mbedtls_cipher_definitions[] = |
JMF | 12:0071cb144c7a | 1350 | { |
JMF | 12:0071cb144c7a | 1351 | #if defined(MBEDTLS_AES_C) |
JMF | 12:0071cb144c7a | 1352 | { MBEDTLS_CIPHER_AES_128_ECB, &aes_128_ecb_info }, |
JMF | 12:0071cb144c7a | 1353 | { MBEDTLS_CIPHER_AES_192_ECB, &aes_192_ecb_info }, |
JMF | 12:0071cb144c7a | 1354 | { MBEDTLS_CIPHER_AES_256_ECB, &aes_256_ecb_info }, |
JMF | 12:0071cb144c7a | 1355 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 1356 | { MBEDTLS_CIPHER_AES_128_CBC, &aes_128_cbc_info }, |
JMF | 12:0071cb144c7a | 1357 | { MBEDTLS_CIPHER_AES_192_CBC, &aes_192_cbc_info }, |
JMF | 12:0071cb144c7a | 1358 | { MBEDTLS_CIPHER_AES_256_CBC, &aes_256_cbc_info }, |
JMF | 12:0071cb144c7a | 1359 | #endif |
JMF | 12:0071cb144c7a | 1360 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
JMF | 12:0071cb144c7a | 1361 | { MBEDTLS_CIPHER_AES_128_CFB128, &aes_128_cfb128_info }, |
JMF | 12:0071cb144c7a | 1362 | { MBEDTLS_CIPHER_AES_192_CFB128, &aes_192_cfb128_info }, |
JMF | 12:0071cb144c7a | 1363 | { MBEDTLS_CIPHER_AES_256_CFB128, &aes_256_cfb128_info }, |
JMF | 12:0071cb144c7a | 1364 | #endif |
JMF | 12:0071cb144c7a | 1365 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
JMF | 12:0071cb144c7a | 1366 | { MBEDTLS_CIPHER_AES_128_CTR, &aes_128_ctr_info }, |
JMF | 12:0071cb144c7a | 1367 | { MBEDTLS_CIPHER_AES_192_CTR, &aes_192_ctr_info }, |
JMF | 12:0071cb144c7a | 1368 | { MBEDTLS_CIPHER_AES_256_CTR, &aes_256_ctr_info }, |
JMF | 12:0071cb144c7a | 1369 | #endif |
JMF | 12:0071cb144c7a | 1370 | #if defined(MBEDTLS_GCM_C) |
JMF | 12:0071cb144c7a | 1371 | { MBEDTLS_CIPHER_AES_128_GCM, &aes_128_gcm_info }, |
JMF | 12:0071cb144c7a | 1372 | { MBEDTLS_CIPHER_AES_192_GCM, &aes_192_gcm_info }, |
JMF | 12:0071cb144c7a | 1373 | { MBEDTLS_CIPHER_AES_256_GCM, &aes_256_gcm_info }, |
JMF | 12:0071cb144c7a | 1374 | #endif |
JMF | 12:0071cb144c7a | 1375 | #if defined(MBEDTLS_CCM_C) |
JMF | 12:0071cb144c7a | 1376 | { MBEDTLS_CIPHER_AES_128_CCM, &aes_128_ccm_info }, |
JMF | 12:0071cb144c7a | 1377 | { MBEDTLS_CIPHER_AES_192_CCM, &aes_192_ccm_info }, |
JMF | 12:0071cb144c7a | 1378 | { MBEDTLS_CIPHER_AES_256_CCM, &aes_256_ccm_info }, |
JMF | 12:0071cb144c7a | 1379 | #endif |
JMF | 12:0071cb144c7a | 1380 | #endif /* MBEDTLS_AES_C */ |
JMF | 12:0071cb144c7a | 1381 | |
JMF | 12:0071cb144c7a | 1382 | #if defined(MBEDTLS_ARC4_C) |
JMF | 12:0071cb144c7a | 1383 | { MBEDTLS_CIPHER_ARC4_128, &arc4_128_info }, |
JMF | 12:0071cb144c7a | 1384 | #endif |
JMF | 12:0071cb144c7a | 1385 | |
JMF | 12:0071cb144c7a | 1386 | #if defined(MBEDTLS_BLOWFISH_C) |
JMF | 12:0071cb144c7a | 1387 | { MBEDTLS_CIPHER_BLOWFISH_ECB, &blowfish_ecb_info }, |
JMF | 12:0071cb144c7a | 1388 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 1389 | { MBEDTLS_CIPHER_BLOWFISH_CBC, &blowfish_cbc_info }, |
JMF | 12:0071cb144c7a | 1390 | #endif |
JMF | 12:0071cb144c7a | 1391 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
JMF | 12:0071cb144c7a | 1392 | { MBEDTLS_CIPHER_BLOWFISH_CFB64, &blowfish_cfb64_info }, |
JMF | 12:0071cb144c7a | 1393 | #endif |
JMF | 12:0071cb144c7a | 1394 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
JMF | 12:0071cb144c7a | 1395 | { MBEDTLS_CIPHER_BLOWFISH_CTR, &blowfish_ctr_info }, |
JMF | 12:0071cb144c7a | 1396 | #endif |
JMF | 12:0071cb144c7a | 1397 | #endif /* MBEDTLS_BLOWFISH_C */ |
JMF | 12:0071cb144c7a | 1398 | |
JMF | 12:0071cb144c7a | 1399 | #if defined(MBEDTLS_CAMELLIA_C) |
JMF | 12:0071cb144c7a | 1400 | { MBEDTLS_CIPHER_CAMELLIA_128_ECB, &camellia_128_ecb_info }, |
JMF | 12:0071cb144c7a | 1401 | { MBEDTLS_CIPHER_CAMELLIA_192_ECB, &camellia_192_ecb_info }, |
JMF | 12:0071cb144c7a | 1402 | { MBEDTLS_CIPHER_CAMELLIA_256_ECB, &camellia_256_ecb_info }, |
JMF | 12:0071cb144c7a | 1403 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 1404 | { MBEDTLS_CIPHER_CAMELLIA_128_CBC, &camellia_128_cbc_info }, |
JMF | 12:0071cb144c7a | 1405 | { MBEDTLS_CIPHER_CAMELLIA_192_CBC, &camellia_192_cbc_info }, |
JMF | 12:0071cb144c7a | 1406 | { MBEDTLS_CIPHER_CAMELLIA_256_CBC, &camellia_256_cbc_info }, |
JMF | 12:0071cb144c7a | 1407 | #endif |
JMF | 12:0071cb144c7a | 1408 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
JMF | 12:0071cb144c7a | 1409 | { MBEDTLS_CIPHER_CAMELLIA_128_CFB128, &camellia_128_cfb128_info }, |
JMF | 12:0071cb144c7a | 1410 | { MBEDTLS_CIPHER_CAMELLIA_192_CFB128, &camellia_192_cfb128_info }, |
JMF | 12:0071cb144c7a | 1411 | { MBEDTLS_CIPHER_CAMELLIA_256_CFB128, &camellia_256_cfb128_info }, |
JMF | 12:0071cb144c7a | 1412 | #endif |
JMF | 12:0071cb144c7a | 1413 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
JMF | 12:0071cb144c7a | 1414 | { MBEDTLS_CIPHER_CAMELLIA_128_CTR, &camellia_128_ctr_info }, |
JMF | 12:0071cb144c7a | 1415 | { MBEDTLS_CIPHER_CAMELLIA_192_CTR, &camellia_192_ctr_info }, |
JMF | 12:0071cb144c7a | 1416 | { MBEDTLS_CIPHER_CAMELLIA_256_CTR, &camellia_256_ctr_info }, |
JMF | 12:0071cb144c7a | 1417 | #endif |
JMF | 12:0071cb144c7a | 1418 | #if defined(MBEDTLS_GCM_C) |
JMF | 12:0071cb144c7a | 1419 | { MBEDTLS_CIPHER_CAMELLIA_128_GCM, &camellia_128_gcm_info }, |
JMF | 12:0071cb144c7a | 1420 | { MBEDTLS_CIPHER_CAMELLIA_192_GCM, &camellia_192_gcm_info }, |
JMF | 12:0071cb144c7a | 1421 | { MBEDTLS_CIPHER_CAMELLIA_256_GCM, &camellia_256_gcm_info }, |
JMF | 12:0071cb144c7a | 1422 | #endif |
JMF | 12:0071cb144c7a | 1423 | #if defined(MBEDTLS_CCM_C) |
JMF | 12:0071cb144c7a | 1424 | { MBEDTLS_CIPHER_CAMELLIA_128_CCM, &camellia_128_ccm_info }, |
JMF | 12:0071cb144c7a | 1425 | { MBEDTLS_CIPHER_CAMELLIA_192_CCM, &camellia_192_ccm_info }, |
JMF | 12:0071cb144c7a | 1426 | { MBEDTLS_CIPHER_CAMELLIA_256_CCM, &camellia_256_ccm_info }, |
JMF | 12:0071cb144c7a | 1427 | #endif |
JMF | 12:0071cb144c7a | 1428 | #endif /* MBEDTLS_CAMELLIA_C */ |
JMF | 12:0071cb144c7a | 1429 | |
JMF | 12:0071cb144c7a | 1430 | #if defined(MBEDTLS_DES_C) |
JMF | 12:0071cb144c7a | 1431 | { MBEDTLS_CIPHER_DES_ECB, &des_ecb_info }, |
JMF | 12:0071cb144c7a | 1432 | { MBEDTLS_CIPHER_DES_EDE_ECB, &des_ede_ecb_info }, |
JMF | 12:0071cb144c7a | 1433 | { MBEDTLS_CIPHER_DES_EDE3_ECB, &des_ede3_ecb_info }, |
JMF | 12:0071cb144c7a | 1434 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
JMF | 12:0071cb144c7a | 1435 | { MBEDTLS_CIPHER_DES_CBC, &des_cbc_info }, |
JMF | 12:0071cb144c7a | 1436 | { MBEDTLS_CIPHER_DES_EDE_CBC, &des_ede_cbc_info }, |
JMF | 12:0071cb144c7a | 1437 | { MBEDTLS_CIPHER_DES_EDE3_CBC, &des_ede3_cbc_info }, |
JMF | 12:0071cb144c7a | 1438 | #endif |
JMF | 12:0071cb144c7a | 1439 | #endif /* MBEDTLS_DES_C */ |
JMF | 12:0071cb144c7a | 1440 | |
JMF | 12:0071cb144c7a | 1441 | #if defined(MBEDTLS_CIPHER_NULL_CIPHER) |
JMF | 12:0071cb144c7a | 1442 | { MBEDTLS_CIPHER_NULL, &null_cipher_info }, |
JMF | 12:0071cb144c7a | 1443 | #endif /* MBEDTLS_CIPHER_NULL_CIPHER */ |
JMF | 12:0071cb144c7a | 1444 | |
JMF | 12:0071cb144c7a | 1445 | { MBEDTLS_CIPHER_NONE, NULL } |
JMF | 12:0071cb144c7a | 1446 | }; |
JMF | 12:0071cb144c7a | 1447 | |
JMF | 12:0071cb144c7a | 1448 | #define NUM_CIPHERS sizeof mbedtls_cipher_definitions / sizeof mbedtls_cipher_definitions[0] |
JMF | 12:0071cb144c7a | 1449 | int mbedtls_cipher_supported[NUM_CIPHERS]; |
JMF | 12:0071cb144c7a | 1450 | |
JMF | 12:0071cb144c7a | 1451 | #endif /* MBEDTLS_CIPHER_C */ |