Pinned to some recent date

Committer:
Simon Cooksey
Date:
Thu Nov 17 16:43:53 2016 +0000
Revision:
0:fb7af294d5d9
Initial commit

Who changed what in which revision?

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