mbed TLS Build

Dependents:   Slave-prot-prod

Committer:
markrad
Date:
Thu Jan 05 00:18:44 2017 +0000
Revision:
0:cdf462088d13
Initial commit

Who changed what in which revision?

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