Preliminary main mbed library for nexpaq development

Committer:
nexpaq
Date:
Fri Nov 04 20:54:50 2016 +0000
Revision:
1:d96dbedaebdb
Parent:
0:6c56fb4bc5f0
Removed extra directories for other platforms

Who changed what in which revision?

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