Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
cipher_wrap.c
00001 /** 00002 * \file cipher_wrap.c 00003 * 00004 * \brief Generic cipher wrapper for mbed TLS 00005 * 00006 * \author Adriaan de Jong <dejong@fox-it.com> 00007 * 00008 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 00009 * SPDX-License-Identifier: Apache-2.0 00010 * 00011 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00012 * not use this file except in compliance with the License. 00013 * You may obtain a copy of the License at 00014 * 00015 * http://www.apache.org/licenses/LICENSE-2.0 00016 * 00017 * Unless required by applicable law or agreed to in writing, software 00018 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00019 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00020 * See the License for the specific language governing permissions and 00021 * limitations under the License. 00022 * 00023 * This file is part of mbed TLS (https://tls.mbed.org) 00024 */ 00025 00026 #if !defined(MBEDTLS_CONFIG_FILE) 00027 #include "mbedtls/config.h" 00028 #else 00029 #include MBEDTLS_CONFIG_FILE 00030 #endif 00031 00032 #if defined(MBEDTLS_CIPHER_C) 00033 00034 #include "mbedtls/cipher_internal.h" 00035 00036 #if defined(MBEDTLS_AES_C) 00037 #include "mbedtls/aes.h" 00038 #endif 00039 00040 #if defined(MBEDTLS_ARC4_C) 00041 #include "mbedtls/arc4.h" 00042 #endif 00043 00044 #if defined(MBEDTLS_CAMELLIA_C) 00045 #include "mbedtls/camellia.h" 00046 #endif 00047 00048 #if defined(MBEDTLS_ARIA_C) 00049 #include "mbedtls/aria.h" 00050 #endif 00051 00052 #if defined(MBEDTLS_DES_C) 00053 #include "mbedtls/des.h" 00054 #endif 00055 00056 #if defined(MBEDTLS_BLOWFISH_C) 00057 #include "mbedtls/blowfish.h" 00058 #endif 00059 00060 #if defined(MBEDTLS_GCM_C) 00061 #include "mbedtls/gcm.h" 00062 #endif 00063 00064 #if defined(MBEDTLS_CCM_C) 00065 #include "mbedtls/ccm.h" 00066 #endif 00067 00068 #if defined(MBEDTLS_CIPHER_NULL_CIPHER) 00069 #include <string.h> 00070 #endif 00071 00072 #if defined(MBEDTLS_PLATFORM_C) 00073 #include "mbedtls/platform.h" 00074 #else 00075 #include <stdlib.h> 00076 #define mbedtls_calloc calloc 00077 #define mbedtls_free free 00078 #endif 00079 00080 #if defined(MBEDTLS_GCM_C) 00081 /* shared by all GCM ciphers */ 00082 static void *gcm_ctx_alloc( void ) 00083 { 00084 void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_gcm_context ) ); 00085 00086 if( ctx != NULL ) 00087 mbedtls_gcm_init( (mbedtls_gcm_context *) ctx ); 00088 00089 return( ctx ); 00090 } 00091 00092 static void gcm_ctx_free( void *ctx ) 00093 { 00094 mbedtls_gcm_free( ctx ); 00095 mbedtls_free( ctx ); 00096 } 00097 #endif /* MBEDTLS_GCM_C */ 00098 00099 #if defined(MBEDTLS_CCM_C) 00100 /* shared by all CCM ciphers */ 00101 static void *ccm_ctx_alloc( void ) 00102 { 00103 void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ccm_context ) ); 00104 00105 if( ctx != NULL ) 00106 mbedtls_ccm_init( (mbedtls_ccm_context *) ctx ); 00107 00108 return( ctx ); 00109 } 00110 00111 static void ccm_ctx_free( void *ctx ) 00112 { 00113 mbedtls_ccm_free( ctx ); 00114 mbedtls_free( ctx ); 00115 } 00116 #endif /* MBEDTLS_CCM_C */ 00117 00118 #if defined(MBEDTLS_AES_C) 00119 00120 static int aes_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation, 00121 const unsigned char *input, unsigned char *output ) 00122 { 00123 return mbedtls_aes_crypt_ecb( (mbedtls_aes_context *) ctx, operation, input, output ); 00124 } 00125 00126 #if defined(MBEDTLS_CIPHER_MODE_CBC) 00127 static int aes_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, size_t length, 00128 unsigned char *iv, const unsigned char *input, unsigned char *output ) 00129 { 00130 return mbedtls_aes_crypt_cbc( (mbedtls_aes_context *) ctx, operation, length, iv, input, 00131 output ); 00132 } 00133 #endif /* MBEDTLS_CIPHER_MODE_CBC */ 00134 00135 #if defined(MBEDTLS_CIPHER_MODE_CFB) 00136 static int aes_crypt_cfb128_wrap( void *ctx, mbedtls_operation_t operation, 00137 size_t length, size_t *iv_off, unsigned char *iv, 00138 const unsigned char *input, unsigned char *output ) 00139 { 00140 return mbedtls_aes_crypt_cfb128( (mbedtls_aes_context *) ctx, operation, length, iv_off, iv, 00141 input, output ); 00142 } 00143 #endif /* MBEDTLS_CIPHER_MODE_CFB */ 00144 00145 #if defined(MBEDTLS_CIPHER_MODE_CTR) 00146 static int aes_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off, 00147 unsigned char *nonce_counter, unsigned char *stream_block, 00148 const unsigned char *input, unsigned char *output ) 00149 { 00150 return mbedtls_aes_crypt_ctr( (mbedtls_aes_context *) ctx, length, nc_off, nonce_counter, 00151 stream_block, input, output ); 00152 } 00153 #endif /* MBEDTLS_CIPHER_MODE_CTR */ 00154 00155 static int aes_setkey_dec_wrap( void *ctx, const unsigned char *key, 00156 unsigned int key_bitlen ) 00157 { 00158 return mbedtls_aes_setkey_dec( (mbedtls_aes_context *) ctx, key, key_bitlen ); 00159 } 00160 00161 static int aes_setkey_enc_wrap( void *ctx, const unsigned char *key, 00162 unsigned int key_bitlen ) 00163 { 00164 return mbedtls_aes_setkey_enc( (mbedtls_aes_context *) ctx, key, key_bitlen ); 00165 } 00166 00167 static void * aes_ctx_alloc( void ) 00168 { 00169 mbedtls_aes_context *aes = mbedtls_calloc( 1, sizeof( mbedtls_aes_context ) ); 00170 00171 if( aes == NULL ) 00172 return( NULL ); 00173 00174 mbedtls_aes_init( aes ); 00175 00176 return( aes ); 00177 } 00178 00179 static void aes_ctx_free( void *ctx ) 00180 { 00181 mbedtls_aes_free( (mbedtls_aes_context *) ctx ); 00182 mbedtls_free( ctx ); 00183 } 00184 00185 static const mbedtls_cipher_base_t aes_info = { 00186 MBEDTLS_CIPHER_ID_AES, 00187 aes_crypt_ecb_wrap, 00188 #if defined(MBEDTLS_CIPHER_MODE_CBC) 00189 aes_crypt_cbc_wrap, 00190 #endif 00191 #if defined(MBEDTLS_CIPHER_MODE_CFB) 00192 aes_crypt_cfb128_wrap, 00193 #endif 00194 #if defined(MBEDTLS_CIPHER_MODE_CTR) 00195 aes_crypt_ctr_wrap, 00196 #endif 00197 #if defined(MBEDTLS_CIPHER_MODE_STREAM) 00198 NULL, 00199 #endif 00200 aes_setkey_enc_wrap, 00201 aes_setkey_dec_wrap, 00202 aes_ctx_alloc, 00203 aes_ctx_free 00204 }; 00205 00206 static const mbedtls_cipher_info_t aes_128_ecb_info = { 00207 MBEDTLS_CIPHER_AES_128_ECB, 00208 MBEDTLS_MODE_ECB, 00209 128, 00210 "AES-128-ECB", 00211 16, 00212 0, 00213 16, 00214 &aes_info 00215 }; 00216 00217 static const mbedtls_cipher_info_t aes_192_ecb_info = { 00218 MBEDTLS_CIPHER_AES_192_ECB, 00219 MBEDTLS_MODE_ECB, 00220 192, 00221 "AES-192-ECB", 00222 16, 00223 0, 00224 16, 00225 &aes_info 00226 }; 00227 00228 static const mbedtls_cipher_info_t aes_256_ecb_info = { 00229 MBEDTLS_CIPHER_AES_256_ECB, 00230 MBEDTLS_MODE_ECB, 00231 256, 00232 "AES-256-ECB", 00233 16, 00234 0, 00235 16, 00236 &aes_info 00237 }; 00238 00239 #if defined(MBEDTLS_CIPHER_MODE_CBC) 00240 static const mbedtls_cipher_info_t aes_128_cbc_info = { 00241 MBEDTLS_CIPHER_AES_128_CBC, 00242 MBEDTLS_MODE_CBC, 00243 128, 00244 "AES-128-CBC", 00245 16, 00246 0, 00247 16, 00248 &aes_info 00249 }; 00250 00251 static const mbedtls_cipher_info_t aes_192_cbc_info = { 00252 MBEDTLS_CIPHER_AES_192_CBC, 00253 MBEDTLS_MODE_CBC, 00254 192, 00255 "AES-192-CBC", 00256 16, 00257 0, 00258 16, 00259 &aes_info 00260 }; 00261 00262 static const mbedtls_cipher_info_t aes_256_cbc_info = { 00263 MBEDTLS_CIPHER_AES_256_CBC, 00264 MBEDTLS_MODE_CBC, 00265 256, 00266 "AES-256-CBC", 00267 16, 00268 0, 00269 16, 00270 &aes_info 00271 }; 00272 #endif /* MBEDTLS_CIPHER_MODE_CBC */ 00273 00274 #if defined(MBEDTLS_CIPHER_MODE_CFB) 00275 static const mbedtls_cipher_info_t aes_128_cfb128_info = { 00276 MBEDTLS_CIPHER_AES_128_CFB128, 00277 MBEDTLS_MODE_CFB, 00278 128, 00279 "AES-128-CFB128", 00280 16, 00281 0, 00282 16, 00283 &aes_info 00284 }; 00285 00286 static const mbedtls_cipher_info_t aes_192_cfb128_info = { 00287 MBEDTLS_CIPHER_AES_192_CFB128, 00288 MBEDTLS_MODE_CFB, 00289 192, 00290 "AES-192-CFB128", 00291 16, 00292 0, 00293 16, 00294 &aes_info 00295 }; 00296 00297 static const mbedtls_cipher_info_t aes_256_cfb128_info = { 00298 MBEDTLS_CIPHER_AES_256_CFB128, 00299 MBEDTLS_MODE_CFB, 00300 256, 00301 "AES-256-CFB128", 00302 16, 00303 0, 00304 16, 00305 &aes_info 00306 }; 00307 #endif /* MBEDTLS_CIPHER_MODE_CFB */ 00308 00309 #if defined(MBEDTLS_CIPHER_MODE_CTR) 00310 static const mbedtls_cipher_info_t aes_128_ctr_info = { 00311 MBEDTLS_CIPHER_AES_128_CTR, 00312 MBEDTLS_MODE_CTR, 00313 128, 00314 "AES-128-CTR", 00315 16, 00316 0, 00317 16, 00318 &aes_info 00319 }; 00320 00321 static const mbedtls_cipher_info_t aes_192_ctr_info = { 00322 MBEDTLS_CIPHER_AES_192_CTR, 00323 MBEDTLS_MODE_CTR, 00324 192, 00325 "AES-192-CTR", 00326 16, 00327 0, 00328 16, 00329 &aes_info 00330 }; 00331 00332 static const mbedtls_cipher_info_t aes_256_ctr_info = { 00333 MBEDTLS_CIPHER_AES_256_CTR, 00334 MBEDTLS_MODE_CTR, 00335 256, 00336 "AES-256-CTR", 00337 16, 00338 0, 00339 16, 00340 &aes_info 00341 }; 00342 #endif /* MBEDTLS_CIPHER_MODE_CTR */ 00343 00344 #if defined(MBEDTLS_GCM_C) 00345 static int gcm_aes_setkey_wrap( void *ctx, const unsigned char *key, 00346 unsigned int key_bitlen ) 00347 { 00348 return mbedtls_gcm_setkey( (mbedtls_gcm_context *) ctx, MBEDTLS_CIPHER_ID_AES, 00349 key, key_bitlen ); 00350 } 00351 00352 static const mbedtls_cipher_base_t gcm_aes_info = { 00353 MBEDTLS_CIPHER_ID_AES, 00354 NULL, 00355 #if defined(MBEDTLS_CIPHER_MODE_CBC) 00356 NULL, 00357 #endif 00358 #if defined(MBEDTLS_CIPHER_MODE_CFB) 00359 NULL, 00360 #endif 00361 #if defined(MBEDTLS_CIPHER_MODE_CTR) 00362 NULL, 00363 #endif 00364 #if defined(MBEDTLS_CIPHER_MODE_STREAM) 00365 NULL, 00366 #endif 00367 gcm_aes_setkey_wrap, 00368 gcm_aes_setkey_wrap, 00369 gcm_ctx_alloc, 00370 gcm_ctx_free, 00371 }; 00372 00373 static const mbedtls_cipher_info_t aes_128_gcm_info = { 00374 MBEDTLS_CIPHER_AES_128_GCM, 00375 MBEDTLS_MODE_GCM, 00376 128, 00377 "AES-128-GCM", 00378 12, 00379 MBEDTLS_CIPHER_VARIABLE_IV_LEN, 00380 16, 00381 &gcm_aes_info 00382 }; 00383 00384 static const mbedtls_cipher_info_t aes_192_gcm_info = { 00385 MBEDTLS_CIPHER_AES_192_GCM, 00386 MBEDTLS_MODE_GCM, 00387 192, 00388 "AES-192-GCM", 00389 12, 00390 MBEDTLS_CIPHER_VARIABLE_IV_LEN, 00391 16, 00392 &gcm_aes_info 00393 }; 00394 00395 static const mbedtls_cipher_info_t aes_256_gcm_info = { 00396 MBEDTLS_CIPHER_AES_256_GCM, 00397 MBEDTLS_MODE_GCM, 00398 256, 00399 "AES-256-GCM", 00400 12, 00401 MBEDTLS_CIPHER_VARIABLE_IV_LEN, 00402 16, 00403 &gcm_aes_info 00404 }; 00405 #endif /* MBEDTLS_GCM_C */ 00406 00407 #if defined(MBEDTLS_CCM_C) 00408 static int ccm_aes_setkey_wrap( void *ctx, const unsigned char *key, 00409 unsigned int key_bitlen ) 00410 { 00411 return mbedtls_ccm_setkey( (mbedtls_ccm_context *) ctx, MBEDTLS_CIPHER_ID_AES, 00412 key, key_bitlen ); 00413 } 00414 00415 static const mbedtls_cipher_base_t ccm_aes_info = { 00416 MBEDTLS_CIPHER_ID_AES, 00417 NULL, 00418 #if defined(MBEDTLS_CIPHER_MODE_CBC) 00419 NULL, 00420 #endif 00421 #if defined(MBEDTLS_CIPHER_MODE_CFB) 00422 NULL, 00423 #endif 00424 #if defined(MBEDTLS_CIPHER_MODE_CTR) 00425 NULL, 00426 #endif 00427 #if defined(MBEDTLS_CIPHER_MODE_STREAM) 00428 NULL, 00429 #endif 00430 ccm_aes_setkey_wrap, 00431 ccm_aes_setkey_wrap, 00432 ccm_ctx_alloc, 00433 ccm_ctx_free, 00434 }; 00435 00436 static const mbedtls_cipher_info_t aes_128_ccm_info = { 00437 MBEDTLS_CIPHER_AES_128_CCM, 00438 MBEDTLS_MODE_CCM, 00439 128, 00440 "AES-128-CCM", 00441 12, 00442 MBEDTLS_CIPHER_VARIABLE_IV_LEN, 00443 16, 00444 &ccm_aes_info 00445 }; 00446 00447 static const mbedtls_cipher_info_t aes_192_ccm_info = { 00448 MBEDTLS_CIPHER_AES_192_CCM, 00449 MBEDTLS_MODE_CCM, 00450 192, 00451 "AES-192-CCM", 00452 12, 00453 MBEDTLS_CIPHER_VARIABLE_IV_LEN, 00454 16, 00455 &ccm_aes_info 00456 }; 00457 00458 static const mbedtls_cipher_info_t aes_256_ccm_info = { 00459 MBEDTLS_CIPHER_AES_256_CCM, 00460 MBEDTLS_MODE_CCM, 00461 256, 00462 "AES-256-CCM", 00463 12, 00464 MBEDTLS_CIPHER_VARIABLE_IV_LEN, 00465 16, 00466 &ccm_aes_info 00467 }; 00468 #endif /* MBEDTLS_CCM_C */ 00469 00470 #endif /* MBEDTLS_AES_C */ 00471 00472 #if defined(MBEDTLS_CAMELLIA_C) 00473 00474 static int camellia_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation, 00475 const unsigned char *input, unsigned char *output ) 00476 { 00477 return mbedtls_camellia_crypt_ecb( (mbedtls_camellia_context *) ctx, operation, input, 00478 output ); 00479 } 00480 00481 #if defined(MBEDTLS_CIPHER_MODE_CBC) 00482 static int camellia_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, 00483 size_t length, unsigned char *iv, 00484 const unsigned char *input, unsigned char *output ) 00485 { 00486 return mbedtls_camellia_crypt_cbc( (mbedtls_camellia_context *) ctx, operation, length, iv, 00487 input, output ); 00488 } 00489 #endif /* MBEDTLS_CIPHER_MODE_CBC */ 00490 00491 #if defined(MBEDTLS_CIPHER_MODE_CFB) 00492 static int camellia_crypt_cfb128_wrap( void *ctx, mbedtls_operation_t operation, 00493 size_t length, size_t *iv_off, unsigned char *iv, 00494 const unsigned char *input, unsigned char *output ) 00495 { 00496 return mbedtls_camellia_crypt_cfb128( (mbedtls_camellia_context *) ctx, operation, length, 00497 iv_off, iv, input, output ); 00498 } 00499 #endif /* MBEDTLS_CIPHER_MODE_CFB */ 00500 00501 #if defined(MBEDTLS_CIPHER_MODE_CTR) 00502 static int camellia_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off, 00503 unsigned char *nonce_counter, unsigned char *stream_block, 00504 const unsigned char *input, unsigned char *output ) 00505 { 00506 return mbedtls_camellia_crypt_ctr( (mbedtls_camellia_context *) ctx, length, nc_off, 00507 nonce_counter, stream_block, input, output ); 00508 } 00509 #endif /* MBEDTLS_CIPHER_MODE_CTR */ 00510 00511 static int camellia_setkey_dec_wrap( void *ctx, const unsigned char *key, 00512 unsigned int key_bitlen ) 00513 { 00514 return mbedtls_camellia_setkey_dec( (mbedtls_camellia_context *) ctx, key, key_bitlen ); 00515 } 00516 00517 static int camellia_setkey_enc_wrap( void *ctx, const unsigned char *key, 00518 unsigned int key_bitlen ) 00519 { 00520 return mbedtls_camellia_setkey_enc( (mbedtls_camellia_context *) ctx, key, key_bitlen ); 00521 } 00522 00523 static void * camellia_ctx_alloc( void ) 00524 { 00525 mbedtls_camellia_context *ctx; 00526 ctx = mbedtls_calloc( 1, sizeof( mbedtls_camellia_context ) ); 00527 00528 if( ctx == NULL ) 00529 return( NULL ); 00530 00531 mbedtls_camellia_init( ctx ); 00532 00533 return( ctx ); 00534 } 00535 00536 static void camellia_ctx_free( void *ctx ) 00537 { 00538 mbedtls_camellia_free( (mbedtls_camellia_context *) ctx ); 00539 mbedtls_free( ctx ); 00540 } 00541 00542 static const mbedtls_cipher_base_t camellia_info = { 00543 MBEDTLS_CIPHER_ID_CAMELLIA, 00544 camellia_crypt_ecb_wrap, 00545 #if defined(MBEDTLS_CIPHER_MODE_CBC) 00546 camellia_crypt_cbc_wrap, 00547 #endif 00548 #if defined(MBEDTLS_CIPHER_MODE_CFB) 00549 camellia_crypt_cfb128_wrap, 00550 #endif 00551 #if defined(MBEDTLS_CIPHER_MODE_CTR) 00552 camellia_crypt_ctr_wrap, 00553 #endif 00554 #if defined(MBEDTLS_CIPHER_MODE_STREAM) 00555 NULL, 00556 #endif 00557 camellia_setkey_enc_wrap, 00558 camellia_setkey_dec_wrap, 00559 camellia_ctx_alloc, 00560 camellia_ctx_free 00561 }; 00562 00563 static const mbedtls_cipher_info_t camellia_128_ecb_info = { 00564 MBEDTLS_CIPHER_CAMELLIA_128_ECB, 00565 MBEDTLS_MODE_ECB, 00566 128, 00567 "CAMELLIA-128-ECB", 00568 16, 00569 0, 00570 16, 00571 &camellia_info 00572 }; 00573 00574 static const mbedtls_cipher_info_t camellia_192_ecb_info = { 00575 MBEDTLS_CIPHER_CAMELLIA_192_ECB, 00576 MBEDTLS_MODE_ECB, 00577 192, 00578 "CAMELLIA-192-ECB", 00579 16, 00580 0, 00581 16, 00582 &camellia_info 00583 }; 00584 00585 static const mbedtls_cipher_info_t camellia_256_ecb_info = { 00586 MBEDTLS_CIPHER_CAMELLIA_256_ECB, 00587 MBEDTLS_MODE_ECB, 00588 256, 00589 "CAMELLIA-256-ECB", 00590 16, 00591 0, 00592 16, 00593 &camellia_info 00594 }; 00595 00596 #if defined(MBEDTLS_CIPHER_MODE_CBC) 00597 static const mbedtls_cipher_info_t camellia_128_cbc_info = { 00598 MBEDTLS_CIPHER_CAMELLIA_128_CBC, 00599 MBEDTLS_MODE_CBC, 00600 128, 00601 "CAMELLIA-128-CBC", 00602 16, 00603 0, 00604 16, 00605 &camellia_info 00606 }; 00607 00608 static const mbedtls_cipher_info_t camellia_192_cbc_info = { 00609 MBEDTLS_CIPHER_CAMELLIA_192_CBC, 00610 MBEDTLS_MODE_CBC, 00611 192, 00612 "CAMELLIA-192-CBC", 00613 16, 00614 0, 00615 16, 00616 &camellia_info 00617 }; 00618 00619 static const mbedtls_cipher_info_t camellia_256_cbc_info = { 00620 MBEDTLS_CIPHER_CAMELLIA_256_CBC, 00621 MBEDTLS_MODE_CBC, 00622 256, 00623 "CAMELLIA-256-CBC", 00624 16, 00625 0, 00626 16, 00627 &camellia_info 00628 }; 00629 #endif /* MBEDTLS_CIPHER_MODE_CBC */ 00630 00631 #if defined(MBEDTLS_CIPHER_MODE_CFB) 00632 static const mbedtls_cipher_info_t camellia_128_cfb128_info = { 00633 MBEDTLS_CIPHER_CAMELLIA_128_CFB128, 00634 MBEDTLS_MODE_CFB, 00635 128, 00636 "CAMELLIA-128-CFB128", 00637 16, 00638 0, 00639 16, 00640 &camellia_info 00641 }; 00642 00643 static const mbedtls_cipher_info_t camellia_192_cfb128_info = { 00644 MBEDTLS_CIPHER_CAMELLIA_192_CFB128, 00645 MBEDTLS_MODE_CFB, 00646 192, 00647 "CAMELLIA-192-CFB128", 00648 16, 00649 0, 00650 16, 00651 &camellia_info 00652 }; 00653 00654 static const mbedtls_cipher_info_t camellia_256_cfb128_info = { 00655 MBEDTLS_CIPHER_CAMELLIA_256_CFB128, 00656 MBEDTLS_MODE_CFB, 00657 256, 00658 "CAMELLIA-256-CFB128", 00659 16, 00660 0, 00661 16, 00662 &camellia_info 00663 }; 00664 #endif /* MBEDTLS_CIPHER_MODE_CFB */ 00665 00666 #if defined(MBEDTLS_CIPHER_MODE_CTR) 00667 static const mbedtls_cipher_info_t camellia_128_ctr_info = { 00668 MBEDTLS_CIPHER_CAMELLIA_128_CTR, 00669 MBEDTLS_MODE_CTR, 00670 128, 00671 "CAMELLIA-128-CTR", 00672 16, 00673 0, 00674 16, 00675 &camellia_info 00676 }; 00677 00678 static const mbedtls_cipher_info_t camellia_192_ctr_info = { 00679 MBEDTLS_CIPHER_CAMELLIA_192_CTR, 00680 MBEDTLS_MODE_CTR, 00681 192, 00682 "CAMELLIA-192-CTR", 00683 16, 00684 0, 00685 16, 00686 &camellia_info 00687 }; 00688 00689 static const mbedtls_cipher_info_t camellia_256_ctr_info = { 00690 MBEDTLS_CIPHER_CAMELLIA_256_CTR, 00691 MBEDTLS_MODE_CTR, 00692 256, 00693 "CAMELLIA-256-CTR", 00694 16, 00695 0, 00696 16, 00697 &camellia_info 00698 }; 00699 #endif /* MBEDTLS_CIPHER_MODE_CTR */ 00700 00701 #if defined(MBEDTLS_GCM_C) 00702 static int gcm_camellia_setkey_wrap( void *ctx, const unsigned char *key, 00703 unsigned int key_bitlen ) 00704 { 00705 return mbedtls_gcm_setkey( (mbedtls_gcm_context *) ctx, MBEDTLS_CIPHER_ID_CAMELLIA, 00706 key, key_bitlen ); 00707 } 00708 00709 static const mbedtls_cipher_base_t gcm_camellia_info = { 00710 MBEDTLS_CIPHER_ID_CAMELLIA, 00711 NULL, 00712 #if defined(MBEDTLS_CIPHER_MODE_CBC) 00713 NULL, 00714 #endif 00715 #if defined(MBEDTLS_CIPHER_MODE_CFB) 00716 NULL, 00717 #endif 00718 #if defined(MBEDTLS_CIPHER_MODE_CTR) 00719 NULL, 00720 #endif 00721 #if defined(MBEDTLS_CIPHER_MODE_STREAM) 00722 NULL, 00723 #endif 00724 gcm_camellia_setkey_wrap, 00725 gcm_camellia_setkey_wrap, 00726 gcm_ctx_alloc, 00727 gcm_ctx_free, 00728 }; 00729 00730 static const mbedtls_cipher_info_t camellia_128_gcm_info = { 00731 MBEDTLS_CIPHER_CAMELLIA_128_GCM, 00732 MBEDTLS_MODE_GCM, 00733 128, 00734 "CAMELLIA-128-GCM", 00735 12, 00736 MBEDTLS_CIPHER_VARIABLE_IV_LEN, 00737 16, 00738 &gcm_camellia_info 00739 }; 00740 00741 static const mbedtls_cipher_info_t camellia_192_gcm_info = { 00742 MBEDTLS_CIPHER_CAMELLIA_192_GCM, 00743 MBEDTLS_MODE_GCM, 00744 192, 00745 "CAMELLIA-192-GCM", 00746 12, 00747 MBEDTLS_CIPHER_VARIABLE_IV_LEN, 00748 16, 00749 &gcm_camellia_info 00750 }; 00751 00752 static const mbedtls_cipher_info_t camellia_256_gcm_info = { 00753 MBEDTLS_CIPHER_CAMELLIA_256_GCM, 00754 MBEDTLS_MODE_GCM, 00755 256, 00756 "CAMELLIA-256-GCM", 00757 12, 00758 MBEDTLS_CIPHER_VARIABLE_IV_LEN, 00759 16, 00760 &gcm_camellia_info 00761 }; 00762 #endif /* MBEDTLS_GCM_C */ 00763 00764 #if defined(MBEDTLS_CCM_C) 00765 static int ccm_camellia_setkey_wrap( void *ctx, const unsigned char *key, 00766 unsigned int key_bitlen ) 00767 { 00768 return mbedtls_ccm_setkey( (mbedtls_ccm_context *) ctx, MBEDTLS_CIPHER_ID_CAMELLIA, 00769 key, key_bitlen ); 00770 } 00771 00772 static const mbedtls_cipher_base_t ccm_camellia_info = { 00773 MBEDTLS_CIPHER_ID_CAMELLIA, 00774 NULL, 00775 #if defined(MBEDTLS_CIPHER_MODE_CBC) 00776 NULL, 00777 #endif 00778 #if defined(MBEDTLS_CIPHER_MODE_CFB) 00779 NULL, 00780 #endif 00781 #if defined(MBEDTLS_CIPHER_MODE_CTR) 00782 NULL, 00783 #endif 00784 #if defined(MBEDTLS_CIPHER_MODE_STREAM) 00785 NULL, 00786 #endif 00787 ccm_camellia_setkey_wrap, 00788 ccm_camellia_setkey_wrap, 00789 ccm_ctx_alloc, 00790 ccm_ctx_free, 00791 }; 00792 00793 static const mbedtls_cipher_info_t camellia_128_ccm_info = { 00794 MBEDTLS_CIPHER_CAMELLIA_128_CCM, 00795 MBEDTLS_MODE_CCM, 00796 128, 00797 "CAMELLIA-128-CCM", 00798 12, 00799 MBEDTLS_CIPHER_VARIABLE_IV_LEN, 00800 16, 00801 &ccm_camellia_info 00802 }; 00803 00804 static const mbedtls_cipher_info_t camellia_192_ccm_info = { 00805 MBEDTLS_CIPHER_CAMELLIA_192_CCM, 00806 MBEDTLS_MODE_CCM, 00807 192, 00808 "CAMELLIA-192-CCM", 00809 12, 00810 MBEDTLS_CIPHER_VARIABLE_IV_LEN, 00811 16, 00812 &ccm_camellia_info 00813 }; 00814 00815 static const mbedtls_cipher_info_t camellia_256_ccm_info = { 00816 MBEDTLS_CIPHER_CAMELLIA_256_CCM, 00817 MBEDTLS_MODE_CCM, 00818 256, 00819 "CAMELLIA-256-CCM", 00820 12, 00821 MBEDTLS_CIPHER_VARIABLE_IV_LEN, 00822 16, 00823 &ccm_camellia_info 00824 }; 00825 #endif /* MBEDTLS_CCM_C */ 00826 00827 #endif /* MBEDTLS_CAMELLIA_C */ 00828 00829 #if defined(MBEDTLS_ARIA_C) 00830 00831 static int aria_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation, 00832 const unsigned char *input, unsigned char *output ) 00833 { 00834 (void) operation; 00835 return mbedtls_aria_crypt_ecb( (mbedtls_aria_context *) ctx, input, 00836 output ); 00837 } 00838 00839 #if defined(MBEDTLS_CIPHER_MODE_CBC) 00840 static int aria_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, 00841 size_t length, unsigned char *iv, 00842 const unsigned char *input, unsigned char *output ) 00843 { 00844 return mbedtls_aria_crypt_cbc( (mbedtls_aria_context *) ctx, operation, length, iv, 00845 input, output ); 00846 } 00847 #endif /* MBEDTLS_CIPHER_MODE_CBC */ 00848 00849 #if defined(MBEDTLS_CIPHER_MODE_CFB) 00850 static int aria_crypt_cfb128_wrap( void *ctx, mbedtls_operation_t operation, 00851 size_t length, size_t *iv_off, unsigned char *iv, 00852 const unsigned char *input, unsigned char *output ) 00853 { 00854 return mbedtls_aria_crypt_cfb128( (mbedtls_aria_context *) ctx, operation, length, 00855 iv_off, iv, input, output ); 00856 } 00857 #endif /* MBEDTLS_CIPHER_MODE_CFB */ 00858 00859 #if defined(MBEDTLS_CIPHER_MODE_CTR) 00860 static int aria_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off, 00861 unsigned char *nonce_counter, unsigned char *stream_block, 00862 const unsigned char *input, unsigned char *output ) 00863 { 00864 return mbedtls_aria_crypt_ctr( (mbedtls_aria_context *) ctx, length, nc_off, 00865 nonce_counter, stream_block, input, output ); 00866 } 00867 #endif /* MBEDTLS_CIPHER_MODE_CTR */ 00868 00869 static int aria_setkey_dec_wrap( void *ctx, const unsigned char *key, 00870 unsigned int key_bitlen ) 00871 { 00872 return mbedtls_aria_setkey_dec( (mbedtls_aria_context *) ctx, key, key_bitlen ); 00873 } 00874 00875 static int aria_setkey_enc_wrap( void *ctx, const unsigned char *key, 00876 unsigned int key_bitlen ) 00877 { 00878 return mbedtls_aria_setkey_enc( (mbedtls_aria_context *) ctx, key, key_bitlen ); 00879 } 00880 00881 static void * aria_ctx_alloc( void ) 00882 { 00883 mbedtls_aria_context *ctx; 00884 ctx = mbedtls_calloc( 1, sizeof( mbedtls_aria_context ) ); 00885 00886 if( ctx == NULL ) 00887 return( NULL ); 00888 00889 mbedtls_aria_init( ctx ); 00890 00891 return( ctx ); 00892 } 00893 00894 static void aria_ctx_free( void *ctx ) 00895 { 00896 mbedtls_aria_free( (mbedtls_aria_context *) ctx ); 00897 mbedtls_free( ctx ); 00898 } 00899 00900 static const mbedtls_cipher_base_t aria_info = { 00901 MBEDTLS_CIPHER_ID_ARIA, 00902 aria_crypt_ecb_wrap, 00903 #if defined(MBEDTLS_CIPHER_MODE_CBC) 00904 aria_crypt_cbc_wrap, 00905 #endif 00906 #if defined(MBEDTLS_CIPHER_MODE_CFB) 00907 aria_crypt_cfb128_wrap, 00908 #endif 00909 #if defined(MBEDTLS_CIPHER_MODE_CTR) 00910 aria_crypt_ctr_wrap, 00911 #endif 00912 #if defined(MBEDTLS_CIPHER_MODE_STREAM) 00913 NULL, 00914 #endif 00915 aria_setkey_enc_wrap, 00916 aria_setkey_dec_wrap, 00917 aria_ctx_alloc, 00918 aria_ctx_free 00919 }; 00920 00921 static const mbedtls_cipher_info_t aria_128_ecb_info = { 00922 MBEDTLS_CIPHER_ARIA_128_ECB, 00923 MBEDTLS_MODE_ECB, 00924 128, 00925 "ARIA-128-ECB", 00926 16, 00927 0, 00928 16, 00929 &aria_info 00930 }; 00931 00932 static const mbedtls_cipher_info_t aria_192_ecb_info = { 00933 MBEDTLS_CIPHER_ARIA_192_ECB, 00934 MBEDTLS_MODE_ECB, 00935 192, 00936 "ARIA-192-ECB", 00937 16, 00938 0, 00939 16, 00940 &aria_info 00941 }; 00942 00943 static const mbedtls_cipher_info_t aria_256_ecb_info = { 00944 MBEDTLS_CIPHER_ARIA_256_ECB, 00945 MBEDTLS_MODE_ECB, 00946 256, 00947 "ARIA-256-ECB", 00948 16, 00949 0, 00950 16, 00951 &aria_info 00952 }; 00953 00954 #if defined(MBEDTLS_CIPHER_MODE_CBC) 00955 static const mbedtls_cipher_info_t aria_128_cbc_info = { 00956 MBEDTLS_CIPHER_ARIA_128_CBC, 00957 MBEDTLS_MODE_CBC, 00958 128, 00959 "ARIA-128-CBC", 00960 16, 00961 0, 00962 16, 00963 &aria_info 00964 }; 00965 00966 static const mbedtls_cipher_info_t aria_192_cbc_info = { 00967 MBEDTLS_CIPHER_ARIA_192_CBC, 00968 MBEDTLS_MODE_CBC, 00969 192, 00970 "ARIA-192-CBC", 00971 16, 00972 0, 00973 16, 00974 &aria_info 00975 }; 00976 00977 static const mbedtls_cipher_info_t aria_256_cbc_info = { 00978 MBEDTLS_CIPHER_ARIA_256_CBC, 00979 MBEDTLS_MODE_CBC, 00980 256, 00981 "ARIA-256-CBC", 00982 16, 00983 0, 00984 16, 00985 &aria_info 00986 }; 00987 #endif /* MBEDTLS_CIPHER_MODE_CBC */ 00988 00989 #if defined(MBEDTLS_CIPHER_MODE_CFB) 00990 static const mbedtls_cipher_info_t aria_128_cfb128_info = { 00991 MBEDTLS_CIPHER_ARIA_128_CFB128, 00992 MBEDTLS_MODE_CFB, 00993 128, 00994 "ARIA-128-CFB128", 00995 16, 00996 0, 00997 16, 00998 &aria_info 00999 }; 01000 01001 static const mbedtls_cipher_info_t aria_192_cfb128_info = { 01002 MBEDTLS_CIPHER_ARIA_192_CFB128, 01003 MBEDTLS_MODE_CFB, 01004 192, 01005 "ARIA-192-CFB128", 01006 16, 01007 0, 01008 16, 01009 &aria_info 01010 }; 01011 01012 static const mbedtls_cipher_info_t aria_256_cfb128_info = { 01013 MBEDTLS_CIPHER_ARIA_256_CFB128, 01014 MBEDTLS_MODE_CFB, 01015 256, 01016 "ARIA-256-CFB128", 01017 16, 01018 0, 01019 16, 01020 &aria_info 01021 }; 01022 #endif /* MBEDTLS_CIPHER_MODE_CFB */ 01023 01024 #if defined(MBEDTLS_CIPHER_MODE_CTR) 01025 static const mbedtls_cipher_info_t aria_128_ctr_info = { 01026 MBEDTLS_CIPHER_ARIA_128_CTR, 01027 MBEDTLS_MODE_CTR, 01028 128, 01029 "ARIA-128-CTR", 01030 16, 01031 0, 01032 16, 01033 &aria_info 01034 }; 01035 01036 static const mbedtls_cipher_info_t aria_192_ctr_info = { 01037 MBEDTLS_CIPHER_ARIA_192_CTR, 01038 MBEDTLS_MODE_CTR, 01039 192, 01040 "ARIA-192-CTR", 01041 16, 01042 0, 01043 16, 01044 &aria_info 01045 }; 01046 01047 static const mbedtls_cipher_info_t aria_256_ctr_info = { 01048 MBEDTLS_CIPHER_ARIA_256_CTR, 01049 MBEDTLS_MODE_CTR, 01050 256, 01051 "ARIA-256-CTR", 01052 16, 01053 0, 01054 16, 01055 &aria_info 01056 }; 01057 #endif /* MBEDTLS_CIPHER_MODE_CTR */ 01058 01059 #if defined(MBEDTLS_GCM_C) 01060 static int gcm_aria_setkey_wrap( void *ctx, const unsigned char *key, 01061 unsigned int key_bitlen ) 01062 { 01063 return mbedtls_gcm_setkey( (mbedtls_gcm_context *) ctx, MBEDTLS_CIPHER_ID_ARIA, 01064 key, key_bitlen ); 01065 } 01066 01067 static const mbedtls_cipher_base_t gcm_aria_info = { 01068 MBEDTLS_CIPHER_ID_ARIA, 01069 NULL, 01070 #if defined(MBEDTLS_CIPHER_MODE_CBC) 01071 NULL, 01072 #endif 01073 #if defined(MBEDTLS_CIPHER_MODE_CFB) 01074 NULL, 01075 #endif 01076 #if defined(MBEDTLS_CIPHER_MODE_CTR) 01077 NULL, 01078 #endif 01079 #if defined(MBEDTLS_CIPHER_MODE_STREAM) 01080 NULL, 01081 #endif 01082 gcm_aria_setkey_wrap, 01083 gcm_aria_setkey_wrap, 01084 gcm_ctx_alloc, 01085 gcm_ctx_free, 01086 }; 01087 01088 static const mbedtls_cipher_info_t aria_128_gcm_info = { 01089 MBEDTLS_CIPHER_ARIA_128_GCM, 01090 MBEDTLS_MODE_GCM, 01091 128, 01092 "ARIA-128-GCM", 01093 12, 01094 MBEDTLS_CIPHER_VARIABLE_IV_LEN, 01095 16, 01096 &gcm_aria_info 01097 }; 01098 01099 static const mbedtls_cipher_info_t aria_192_gcm_info = { 01100 MBEDTLS_CIPHER_ARIA_192_GCM, 01101 MBEDTLS_MODE_GCM, 01102 192, 01103 "ARIA-192-GCM", 01104 12, 01105 MBEDTLS_CIPHER_VARIABLE_IV_LEN, 01106 16, 01107 &gcm_aria_info 01108 }; 01109 01110 static const mbedtls_cipher_info_t aria_256_gcm_info = { 01111 MBEDTLS_CIPHER_ARIA_256_GCM, 01112 MBEDTLS_MODE_GCM, 01113 256, 01114 "ARIA-256-GCM", 01115 12, 01116 MBEDTLS_CIPHER_VARIABLE_IV_LEN, 01117 16, 01118 &gcm_aria_info 01119 }; 01120 #endif /* MBEDTLS_GCM_C */ 01121 01122 #if defined(MBEDTLS_CCM_C) 01123 static int ccm_aria_setkey_wrap( void *ctx, const unsigned char *key, 01124 unsigned int key_bitlen ) 01125 { 01126 return mbedtls_ccm_setkey( (mbedtls_ccm_context *) ctx, MBEDTLS_CIPHER_ID_ARIA, 01127 key, key_bitlen ); 01128 } 01129 01130 static const mbedtls_cipher_base_t ccm_aria_info = { 01131 MBEDTLS_CIPHER_ID_ARIA, 01132 NULL, 01133 #if defined(MBEDTLS_CIPHER_MODE_CBC) 01134 NULL, 01135 #endif 01136 #if defined(MBEDTLS_CIPHER_MODE_CFB) 01137 NULL, 01138 #endif 01139 #if defined(MBEDTLS_CIPHER_MODE_CTR) 01140 NULL, 01141 #endif 01142 #if defined(MBEDTLS_CIPHER_MODE_STREAM) 01143 NULL, 01144 #endif 01145 ccm_aria_setkey_wrap, 01146 ccm_aria_setkey_wrap, 01147 ccm_ctx_alloc, 01148 ccm_ctx_free, 01149 }; 01150 01151 static const mbedtls_cipher_info_t aria_128_ccm_info = { 01152 MBEDTLS_CIPHER_ARIA_128_CCM, 01153 MBEDTLS_MODE_CCM, 01154 128, 01155 "ARIA-128-CCM", 01156 12, 01157 MBEDTLS_CIPHER_VARIABLE_IV_LEN, 01158 16, 01159 &ccm_aria_info 01160 }; 01161 01162 static const mbedtls_cipher_info_t aria_192_ccm_info = { 01163 MBEDTLS_CIPHER_ARIA_192_CCM, 01164 MBEDTLS_MODE_CCM, 01165 192, 01166 "ARIA-192-CCM", 01167 12, 01168 MBEDTLS_CIPHER_VARIABLE_IV_LEN, 01169 16, 01170 &ccm_aria_info 01171 }; 01172 01173 static const mbedtls_cipher_info_t aria_256_ccm_info = { 01174 MBEDTLS_CIPHER_ARIA_256_CCM, 01175 MBEDTLS_MODE_CCM, 01176 256, 01177 "ARIA-256-CCM", 01178 12, 01179 MBEDTLS_CIPHER_VARIABLE_IV_LEN, 01180 16, 01181 &ccm_aria_info 01182 }; 01183 #endif /* MBEDTLS_CCM_C */ 01184 01185 #endif /* MBEDTLS_ARIA_C */ 01186 01187 #if defined(MBEDTLS_DES_C) 01188 01189 static int des_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation, 01190 const unsigned char *input, unsigned char *output ) 01191 { 01192 ((void) operation); 01193 return mbedtls_des_crypt_ecb( (mbedtls_des_context *) ctx, input, output ); 01194 } 01195 01196 static int des3_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation, 01197 const unsigned char *input, unsigned char *output ) 01198 { 01199 ((void) operation); 01200 return mbedtls_des3_crypt_ecb( (mbedtls_des3_context *) ctx, input, output ); 01201 } 01202 01203 #if defined(MBEDTLS_CIPHER_MODE_CBC) 01204 static int des_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, size_t length, 01205 unsigned char *iv, const unsigned char *input, unsigned char *output ) 01206 { 01207 return mbedtls_des_crypt_cbc( (mbedtls_des_context *) ctx, operation, length, iv, input, 01208 output ); 01209 } 01210 #endif /* MBEDTLS_CIPHER_MODE_CBC */ 01211 01212 #if defined(MBEDTLS_CIPHER_MODE_CBC) 01213 static int des3_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, size_t length, 01214 unsigned char *iv, const unsigned char *input, unsigned char *output ) 01215 { 01216 return mbedtls_des3_crypt_cbc( (mbedtls_des3_context *) ctx, operation, length, iv, input, 01217 output ); 01218 } 01219 #endif /* MBEDTLS_CIPHER_MODE_CBC */ 01220 01221 static int des_setkey_dec_wrap( void *ctx, const unsigned char *key, 01222 unsigned int key_bitlen ) 01223 { 01224 ((void) key_bitlen); 01225 01226 return mbedtls_des_setkey_dec( (mbedtls_des_context *) ctx, key ); 01227 } 01228 01229 static int des_setkey_enc_wrap( void *ctx, const unsigned char *key, 01230 unsigned int key_bitlen ) 01231 { 01232 ((void) key_bitlen); 01233 01234 return mbedtls_des_setkey_enc( (mbedtls_des_context *) ctx, key ); 01235 } 01236 01237 static int des3_set2key_dec_wrap( void *ctx, const unsigned char *key, 01238 unsigned int key_bitlen ) 01239 { 01240 ((void) key_bitlen); 01241 01242 return mbedtls_des3_set2key_dec( (mbedtls_des3_context *) ctx, key ); 01243 } 01244 01245 static int des3_set2key_enc_wrap( void *ctx, const unsigned char *key, 01246 unsigned int key_bitlen ) 01247 { 01248 ((void) key_bitlen); 01249 01250 return mbedtls_des3_set2key_enc( (mbedtls_des3_context *) ctx, key ); 01251 } 01252 01253 static int des3_set3key_dec_wrap( void *ctx, const unsigned char *key, 01254 unsigned int key_bitlen ) 01255 { 01256 ((void) key_bitlen); 01257 01258 return mbedtls_des3_set3key_dec( (mbedtls_des3_context *) ctx, key ); 01259 } 01260 01261 static int des3_set3key_enc_wrap( void *ctx, const unsigned char *key, 01262 unsigned int key_bitlen ) 01263 { 01264 ((void) key_bitlen); 01265 01266 return mbedtls_des3_set3key_enc( (mbedtls_des3_context *) ctx, key ); 01267 } 01268 01269 static void * des_ctx_alloc( void ) 01270 { 01271 mbedtls_des_context *des = mbedtls_calloc( 1, sizeof( mbedtls_des_context ) ); 01272 01273 if( des == NULL ) 01274 return( NULL ); 01275 01276 mbedtls_des_init( des ); 01277 01278 return( des ); 01279 } 01280 01281 static void des_ctx_free( void *ctx ) 01282 { 01283 mbedtls_des_free( (mbedtls_des_context *) ctx ); 01284 mbedtls_free( ctx ); 01285 } 01286 01287 static void * des3_ctx_alloc( void ) 01288 { 01289 mbedtls_des3_context *des3; 01290 des3 = mbedtls_calloc( 1, sizeof( mbedtls_des3_context ) ); 01291 01292 if( des3 == NULL ) 01293 return( NULL ); 01294 01295 mbedtls_des3_init( des3 ); 01296 01297 return( des3 ); 01298 } 01299 01300 static void des3_ctx_free( void *ctx ) 01301 { 01302 mbedtls_des3_free( (mbedtls_des3_context *) ctx ); 01303 mbedtls_free( ctx ); 01304 } 01305 01306 static const mbedtls_cipher_base_t des_info = { 01307 MBEDTLS_CIPHER_ID_DES, 01308 des_crypt_ecb_wrap, 01309 #if defined(MBEDTLS_CIPHER_MODE_CBC) 01310 des_crypt_cbc_wrap, 01311 #endif 01312 #if defined(MBEDTLS_CIPHER_MODE_CFB) 01313 NULL, 01314 #endif 01315 #if defined(MBEDTLS_CIPHER_MODE_CTR) 01316 NULL, 01317 #endif 01318 #if defined(MBEDTLS_CIPHER_MODE_STREAM) 01319 NULL, 01320 #endif 01321 des_setkey_enc_wrap, 01322 des_setkey_dec_wrap, 01323 des_ctx_alloc, 01324 des_ctx_free 01325 }; 01326 01327 static const mbedtls_cipher_info_t des_ecb_info = { 01328 MBEDTLS_CIPHER_DES_ECB, 01329 MBEDTLS_MODE_ECB, 01330 MBEDTLS_KEY_LENGTH_DES, 01331 "DES-ECB", 01332 8, 01333 0, 01334 8, 01335 &des_info 01336 }; 01337 01338 #if defined(MBEDTLS_CIPHER_MODE_CBC) 01339 static const mbedtls_cipher_info_t des_cbc_info = { 01340 MBEDTLS_CIPHER_DES_CBC, 01341 MBEDTLS_MODE_CBC, 01342 MBEDTLS_KEY_LENGTH_DES, 01343 "DES-CBC", 01344 8, 01345 0, 01346 8, 01347 &des_info 01348 }; 01349 #endif /* MBEDTLS_CIPHER_MODE_CBC */ 01350 01351 static const mbedtls_cipher_base_t des_ede_info = { 01352 MBEDTLS_CIPHER_ID_DES, 01353 des3_crypt_ecb_wrap, 01354 #if defined(MBEDTLS_CIPHER_MODE_CBC) 01355 des3_crypt_cbc_wrap, 01356 #endif 01357 #if defined(MBEDTLS_CIPHER_MODE_CFB) 01358 NULL, 01359 #endif 01360 #if defined(MBEDTLS_CIPHER_MODE_CTR) 01361 NULL, 01362 #endif 01363 #if defined(MBEDTLS_CIPHER_MODE_STREAM) 01364 NULL, 01365 #endif 01366 des3_set2key_enc_wrap, 01367 des3_set2key_dec_wrap, 01368 des3_ctx_alloc, 01369 des3_ctx_free 01370 }; 01371 01372 static const mbedtls_cipher_info_t des_ede_ecb_info = { 01373 MBEDTLS_CIPHER_DES_EDE_ECB, 01374 MBEDTLS_MODE_ECB, 01375 MBEDTLS_KEY_LENGTH_DES_EDE, 01376 "DES-EDE-ECB", 01377 8, 01378 0, 01379 8, 01380 &des_ede_info 01381 }; 01382 01383 #if defined(MBEDTLS_CIPHER_MODE_CBC) 01384 static const mbedtls_cipher_info_t des_ede_cbc_info = { 01385 MBEDTLS_CIPHER_DES_EDE_CBC, 01386 MBEDTLS_MODE_CBC, 01387 MBEDTLS_KEY_LENGTH_DES_EDE, 01388 "DES-EDE-CBC", 01389 8, 01390 0, 01391 8, 01392 &des_ede_info 01393 }; 01394 #endif /* MBEDTLS_CIPHER_MODE_CBC */ 01395 01396 static const mbedtls_cipher_base_t des_ede3_info = { 01397 MBEDTLS_CIPHER_ID_3DES, 01398 des3_crypt_ecb_wrap, 01399 #if defined(MBEDTLS_CIPHER_MODE_CBC) 01400 des3_crypt_cbc_wrap, 01401 #endif 01402 #if defined(MBEDTLS_CIPHER_MODE_CFB) 01403 NULL, 01404 #endif 01405 #if defined(MBEDTLS_CIPHER_MODE_CTR) 01406 NULL, 01407 #endif 01408 #if defined(MBEDTLS_CIPHER_MODE_STREAM) 01409 NULL, 01410 #endif 01411 des3_set3key_enc_wrap, 01412 des3_set3key_dec_wrap, 01413 des3_ctx_alloc, 01414 des3_ctx_free 01415 }; 01416 01417 static const mbedtls_cipher_info_t des_ede3_ecb_info = { 01418 MBEDTLS_CIPHER_DES_EDE3_ECB, 01419 MBEDTLS_MODE_ECB, 01420 MBEDTLS_KEY_LENGTH_DES_EDE3, 01421 "DES-EDE3-ECB", 01422 8, 01423 0, 01424 8, 01425 &des_ede3_info 01426 }; 01427 #if defined(MBEDTLS_CIPHER_MODE_CBC) 01428 static const mbedtls_cipher_info_t des_ede3_cbc_info = { 01429 MBEDTLS_CIPHER_DES_EDE3_CBC, 01430 MBEDTLS_MODE_CBC, 01431 MBEDTLS_KEY_LENGTH_DES_EDE3, 01432 "DES-EDE3-CBC", 01433 8, 01434 0, 01435 8, 01436 &des_ede3_info 01437 }; 01438 #endif /* MBEDTLS_CIPHER_MODE_CBC */ 01439 #endif /* MBEDTLS_DES_C */ 01440 01441 #if defined(MBEDTLS_BLOWFISH_C) 01442 01443 static int blowfish_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation, 01444 const unsigned char *input, unsigned char *output ) 01445 { 01446 return mbedtls_blowfish_crypt_ecb( (mbedtls_blowfish_context *) ctx, operation, input, 01447 output ); 01448 } 01449 01450 #if defined(MBEDTLS_CIPHER_MODE_CBC) 01451 static int blowfish_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, 01452 size_t length, unsigned char *iv, const unsigned char *input, 01453 unsigned char *output ) 01454 { 01455 return mbedtls_blowfish_crypt_cbc( (mbedtls_blowfish_context *) ctx, operation, length, iv, 01456 input, output ); 01457 } 01458 #endif /* MBEDTLS_CIPHER_MODE_CBC */ 01459 01460 #if defined(MBEDTLS_CIPHER_MODE_CFB) 01461 static int blowfish_crypt_cfb64_wrap( void *ctx, mbedtls_operation_t operation, 01462 size_t length, size_t *iv_off, unsigned char *iv, 01463 const unsigned char *input, unsigned char *output ) 01464 { 01465 return mbedtls_blowfish_crypt_cfb64( (mbedtls_blowfish_context *) ctx, operation, length, 01466 iv_off, iv, input, output ); 01467 } 01468 #endif /* MBEDTLS_CIPHER_MODE_CFB */ 01469 01470 #if defined(MBEDTLS_CIPHER_MODE_CTR) 01471 static int blowfish_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off, 01472 unsigned char *nonce_counter, unsigned char *stream_block, 01473 const unsigned char *input, unsigned char *output ) 01474 { 01475 return mbedtls_blowfish_crypt_ctr( (mbedtls_blowfish_context *) ctx, length, nc_off, 01476 nonce_counter, stream_block, input, output ); 01477 } 01478 #endif /* MBEDTLS_CIPHER_MODE_CTR */ 01479 01480 static int blowfish_setkey_wrap( void *ctx, const unsigned char *key, 01481 unsigned int key_bitlen ) 01482 { 01483 return mbedtls_blowfish_setkey( (mbedtls_blowfish_context *) ctx, key, key_bitlen ); 01484 } 01485 01486 static void * blowfish_ctx_alloc( void ) 01487 { 01488 mbedtls_blowfish_context *ctx; 01489 ctx = mbedtls_calloc( 1, sizeof( mbedtls_blowfish_context ) ); 01490 01491 if( ctx == NULL ) 01492 return( NULL ); 01493 01494 mbedtls_blowfish_init( ctx ); 01495 01496 return( ctx ); 01497 } 01498 01499 static void blowfish_ctx_free( void *ctx ) 01500 { 01501 mbedtls_blowfish_free( (mbedtls_blowfish_context *) ctx ); 01502 mbedtls_free( ctx ); 01503 } 01504 01505 static const mbedtls_cipher_base_t blowfish_info = { 01506 MBEDTLS_CIPHER_ID_BLOWFISH, 01507 blowfish_crypt_ecb_wrap, 01508 #if defined(MBEDTLS_CIPHER_MODE_CBC) 01509 blowfish_crypt_cbc_wrap, 01510 #endif 01511 #if defined(MBEDTLS_CIPHER_MODE_CFB) 01512 blowfish_crypt_cfb64_wrap, 01513 #endif 01514 #if defined(MBEDTLS_CIPHER_MODE_CTR) 01515 blowfish_crypt_ctr_wrap, 01516 #endif 01517 #if defined(MBEDTLS_CIPHER_MODE_STREAM) 01518 NULL, 01519 #endif 01520 blowfish_setkey_wrap, 01521 blowfish_setkey_wrap, 01522 blowfish_ctx_alloc, 01523 blowfish_ctx_free 01524 }; 01525 01526 static const mbedtls_cipher_info_t blowfish_ecb_info = { 01527 MBEDTLS_CIPHER_BLOWFISH_ECB, 01528 MBEDTLS_MODE_ECB, 01529 128, 01530 "BLOWFISH-ECB", 01531 8, 01532 MBEDTLS_CIPHER_VARIABLE_KEY_LEN, 01533 8, 01534 &blowfish_info 01535 }; 01536 01537 #if defined(MBEDTLS_CIPHER_MODE_CBC) 01538 static const mbedtls_cipher_info_t blowfish_cbc_info = { 01539 MBEDTLS_CIPHER_BLOWFISH_CBC, 01540 MBEDTLS_MODE_CBC, 01541 128, 01542 "BLOWFISH-CBC", 01543 8, 01544 MBEDTLS_CIPHER_VARIABLE_KEY_LEN, 01545 8, 01546 &blowfish_info 01547 }; 01548 #endif /* MBEDTLS_CIPHER_MODE_CBC */ 01549 01550 #if defined(MBEDTLS_CIPHER_MODE_CFB) 01551 static const mbedtls_cipher_info_t blowfish_cfb64_info = { 01552 MBEDTLS_CIPHER_BLOWFISH_CFB64, 01553 MBEDTLS_MODE_CFB, 01554 128, 01555 "BLOWFISH-CFB64", 01556 8, 01557 MBEDTLS_CIPHER_VARIABLE_KEY_LEN, 01558 8, 01559 &blowfish_info 01560 }; 01561 #endif /* MBEDTLS_CIPHER_MODE_CFB */ 01562 01563 #if defined(MBEDTLS_CIPHER_MODE_CTR) 01564 static const mbedtls_cipher_info_t blowfish_ctr_info = { 01565 MBEDTLS_CIPHER_BLOWFISH_CTR, 01566 MBEDTLS_MODE_CTR, 01567 128, 01568 "BLOWFISH-CTR", 01569 8, 01570 MBEDTLS_CIPHER_VARIABLE_KEY_LEN, 01571 8, 01572 &blowfish_info 01573 }; 01574 #endif /* MBEDTLS_CIPHER_MODE_CTR */ 01575 #endif /* MBEDTLS_BLOWFISH_C */ 01576 01577 #if defined(MBEDTLS_ARC4_C) 01578 static int arc4_crypt_stream_wrap( void *ctx, size_t length, 01579 const unsigned char *input, 01580 unsigned char *output ) 01581 { 01582 return( mbedtls_arc4_crypt( (mbedtls_arc4_context *) ctx, length, input, output ) ); 01583 } 01584 01585 static int arc4_setkey_wrap( void *ctx, const unsigned char *key, 01586 unsigned int key_bitlen ) 01587 { 01588 /* we get key_bitlen in bits, arc4 expects it in bytes */ 01589 if( key_bitlen % 8 != 0 ) 01590 return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); 01591 01592 mbedtls_arc4_setup( (mbedtls_arc4_context *) ctx, key, key_bitlen / 8 ); 01593 return( 0 ); 01594 } 01595 01596 static void * arc4_ctx_alloc( void ) 01597 { 01598 mbedtls_arc4_context *ctx; 01599 ctx = mbedtls_calloc( 1, sizeof( mbedtls_arc4_context ) ); 01600 01601 if( ctx == NULL ) 01602 return( NULL ); 01603 01604 mbedtls_arc4_init( ctx ); 01605 01606 return( ctx ); 01607 } 01608 01609 static void arc4_ctx_free( void *ctx ) 01610 { 01611 mbedtls_arc4_free( (mbedtls_arc4_context *) ctx ); 01612 mbedtls_free( ctx ); 01613 } 01614 01615 static const mbedtls_cipher_base_t arc4_base_info = { 01616 MBEDTLS_CIPHER_ID_ARC4, 01617 NULL, 01618 #if defined(MBEDTLS_CIPHER_MODE_CBC) 01619 NULL, 01620 #endif 01621 #if defined(MBEDTLS_CIPHER_MODE_CFB) 01622 NULL, 01623 #endif 01624 #if defined(MBEDTLS_CIPHER_MODE_CTR) 01625 NULL, 01626 #endif 01627 #if defined(MBEDTLS_CIPHER_MODE_STREAM) 01628 arc4_crypt_stream_wrap, 01629 #endif 01630 arc4_setkey_wrap, 01631 arc4_setkey_wrap, 01632 arc4_ctx_alloc, 01633 arc4_ctx_free 01634 }; 01635 01636 static const mbedtls_cipher_info_t arc4_128_info = { 01637 MBEDTLS_CIPHER_ARC4_128, 01638 MBEDTLS_MODE_STREAM, 01639 128, 01640 "ARC4-128", 01641 0, 01642 0, 01643 1, 01644 &arc4_base_info 01645 }; 01646 #endif /* MBEDTLS_ARC4_C */ 01647 01648 #if defined(MBEDTLS_CIPHER_NULL_CIPHER) 01649 static int null_crypt_stream( void *ctx, size_t length, 01650 const unsigned char *input, 01651 unsigned char *output ) 01652 { 01653 ((void) ctx); 01654 memmove( output, input, length ); 01655 return( 0 ); 01656 } 01657 01658 static int null_setkey( void *ctx, const unsigned char *key, 01659 unsigned int key_bitlen ) 01660 { 01661 ((void) ctx); 01662 ((void) key); 01663 ((void) key_bitlen); 01664 01665 return( 0 ); 01666 } 01667 01668 static void * null_ctx_alloc( void ) 01669 { 01670 return( (void *) 1 ); 01671 } 01672 01673 static void null_ctx_free( void *ctx ) 01674 { 01675 ((void) ctx); 01676 } 01677 01678 static const mbedtls_cipher_base_t null_base_info = { 01679 MBEDTLS_CIPHER_ID_NULL, 01680 NULL, 01681 #if defined(MBEDTLS_CIPHER_MODE_CBC) 01682 NULL, 01683 #endif 01684 #if defined(MBEDTLS_CIPHER_MODE_CFB) 01685 NULL, 01686 #endif 01687 #if defined(MBEDTLS_CIPHER_MODE_CTR) 01688 NULL, 01689 #endif 01690 #if defined(MBEDTLS_CIPHER_MODE_STREAM) 01691 null_crypt_stream, 01692 #endif 01693 null_setkey, 01694 null_setkey, 01695 null_ctx_alloc, 01696 null_ctx_free 01697 }; 01698 01699 static const mbedtls_cipher_info_t null_cipher_info = { 01700 MBEDTLS_CIPHER_NULL, 01701 MBEDTLS_MODE_STREAM, 01702 0, 01703 "NULL", 01704 0, 01705 0, 01706 1, 01707 &null_base_info 01708 }; 01709 #endif /* defined(MBEDTLS_CIPHER_NULL_CIPHER) */ 01710 01711 const mbedtls_cipher_definition_t mbedtls_cipher_definitions[] = 01712 { 01713 #if defined(MBEDTLS_AES_C) 01714 { MBEDTLS_CIPHER_AES_128_ECB, &aes_128_ecb_info }, 01715 { MBEDTLS_CIPHER_AES_192_ECB, &aes_192_ecb_info }, 01716 { MBEDTLS_CIPHER_AES_256_ECB, &aes_256_ecb_info }, 01717 #if defined(MBEDTLS_CIPHER_MODE_CBC) 01718 { MBEDTLS_CIPHER_AES_128_CBC, &aes_128_cbc_info }, 01719 { MBEDTLS_CIPHER_AES_192_CBC, &aes_192_cbc_info }, 01720 { MBEDTLS_CIPHER_AES_256_CBC, &aes_256_cbc_info }, 01721 #endif 01722 #if defined(MBEDTLS_CIPHER_MODE_CFB) 01723 { MBEDTLS_CIPHER_AES_128_CFB128, &aes_128_cfb128_info }, 01724 { MBEDTLS_CIPHER_AES_192_CFB128, &aes_192_cfb128_info }, 01725 { MBEDTLS_CIPHER_AES_256_CFB128, &aes_256_cfb128_info }, 01726 #endif 01727 #if defined(MBEDTLS_CIPHER_MODE_CTR) 01728 { MBEDTLS_CIPHER_AES_128_CTR, &aes_128_ctr_info }, 01729 { MBEDTLS_CIPHER_AES_192_CTR, &aes_192_ctr_info }, 01730 { MBEDTLS_CIPHER_AES_256_CTR, &aes_256_ctr_info }, 01731 #endif 01732 #if defined(MBEDTLS_GCM_C) 01733 { MBEDTLS_CIPHER_AES_128_GCM, &aes_128_gcm_info }, 01734 { MBEDTLS_CIPHER_AES_192_GCM, &aes_192_gcm_info }, 01735 { MBEDTLS_CIPHER_AES_256_GCM, &aes_256_gcm_info }, 01736 #endif 01737 #if defined(MBEDTLS_CCM_C) 01738 { MBEDTLS_CIPHER_AES_128_CCM, &aes_128_ccm_info }, 01739 { MBEDTLS_CIPHER_AES_192_CCM, &aes_192_ccm_info }, 01740 { MBEDTLS_CIPHER_AES_256_CCM, &aes_256_ccm_info }, 01741 #endif 01742 #endif /* MBEDTLS_AES_C */ 01743 01744 #if defined(MBEDTLS_ARC4_C) 01745 { MBEDTLS_CIPHER_ARC4_128, &arc4_128_info }, 01746 #endif 01747 01748 #if defined(MBEDTLS_BLOWFISH_C) 01749 { MBEDTLS_CIPHER_BLOWFISH_ECB, &blowfish_ecb_info }, 01750 #if defined(MBEDTLS_CIPHER_MODE_CBC) 01751 { MBEDTLS_CIPHER_BLOWFISH_CBC, &blowfish_cbc_info }, 01752 #endif 01753 #if defined(MBEDTLS_CIPHER_MODE_CFB) 01754 { MBEDTLS_CIPHER_BLOWFISH_CFB64, &blowfish_cfb64_info }, 01755 #endif 01756 #if defined(MBEDTLS_CIPHER_MODE_CTR) 01757 { MBEDTLS_CIPHER_BLOWFISH_CTR, &blowfish_ctr_info }, 01758 #endif 01759 #endif /* MBEDTLS_BLOWFISH_C */ 01760 01761 #if defined(MBEDTLS_CAMELLIA_C) 01762 { MBEDTLS_CIPHER_CAMELLIA_128_ECB, &camellia_128_ecb_info }, 01763 { MBEDTLS_CIPHER_CAMELLIA_192_ECB, &camellia_192_ecb_info }, 01764 { MBEDTLS_CIPHER_CAMELLIA_256_ECB, &camellia_256_ecb_info }, 01765 #if defined(MBEDTLS_CIPHER_MODE_CBC) 01766 { MBEDTLS_CIPHER_CAMELLIA_128_CBC, &camellia_128_cbc_info }, 01767 { MBEDTLS_CIPHER_CAMELLIA_192_CBC, &camellia_192_cbc_info }, 01768 { MBEDTLS_CIPHER_CAMELLIA_256_CBC, &camellia_256_cbc_info }, 01769 #endif 01770 #if defined(MBEDTLS_CIPHER_MODE_CFB) 01771 { MBEDTLS_CIPHER_CAMELLIA_128_CFB128, &camellia_128_cfb128_info }, 01772 { MBEDTLS_CIPHER_CAMELLIA_192_CFB128, &camellia_192_cfb128_info }, 01773 { MBEDTLS_CIPHER_CAMELLIA_256_CFB128, &camellia_256_cfb128_info }, 01774 #endif 01775 #if defined(MBEDTLS_CIPHER_MODE_CTR) 01776 { MBEDTLS_CIPHER_CAMELLIA_128_CTR, &camellia_128_ctr_info }, 01777 { MBEDTLS_CIPHER_CAMELLIA_192_CTR, &camellia_192_ctr_info }, 01778 { MBEDTLS_CIPHER_CAMELLIA_256_CTR, &camellia_256_ctr_info }, 01779 #endif 01780 #if defined(MBEDTLS_GCM_C) 01781 { MBEDTLS_CIPHER_CAMELLIA_128_GCM, &camellia_128_gcm_info }, 01782 { MBEDTLS_CIPHER_CAMELLIA_192_GCM, &camellia_192_gcm_info }, 01783 { MBEDTLS_CIPHER_CAMELLIA_256_GCM, &camellia_256_gcm_info }, 01784 #endif 01785 #if defined(MBEDTLS_CCM_C) 01786 { MBEDTLS_CIPHER_CAMELLIA_128_CCM, &camellia_128_ccm_info }, 01787 { MBEDTLS_CIPHER_CAMELLIA_192_CCM, &camellia_192_ccm_info }, 01788 { MBEDTLS_CIPHER_CAMELLIA_256_CCM, &camellia_256_ccm_info }, 01789 #endif 01790 #endif /* MBEDTLS_CAMELLIA_C */ 01791 01792 #if defined(MBEDTLS_ARIA_C) 01793 { MBEDTLS_CIPHER_ARIA_128_ECB, &aria_128_ecb_info }, 01794 { MBEDTLS_CIPHER_ARIA_192_ECB, &aria_192_ecb_info }, 01795 { MBEDTLS_CIPHER_ARIA_256_ECB, &aria_256_ecb_info }, 01796 #if defined(MBEDTLS_CIPHER_MODE_CBC) 01797 { MBEDTLS_CIPHER_ARIA_128_CBC, &aria_128_cbc_info }, 01798 { MBEDTLS_CIPHER_ARIA_192_CBC, &aria_192_cbc_info }, 01799 { MBEDTLS_CIPHER_ARIA_256_CBC, &aria_256_cbc_info }, 01800 #endif 01801 #if defined(MBEDTLS_CIPHER_MODE_CFB) 01802 { MBEDTLS_CIPHER_ARIA_128_CFB128, &aria_128_cfb128_info }, 01803 { MBEDTLS_CIPHER_ARIA_192_CFB128, &aria_192_cfb128_info }, 01804 { MBEDTLS_CIPHER_ARIA_256_CFB128, &aria_256_cfb128_info }, 01805 #endif 01806 #if defined(MBEDTLS_CIPHER_MODE_CTR) 01807 { MBEDTLS_CIPHER_ARIA_128_CTR, &aria_128_ctr_info }, 01808 { MBEDTLS_CIPHER_ARIA_192_CTR, &aria_192_ctr_info }, 01809 { MBEDTLS_CIPHER_ARIA_256_CTR, &aria_256_ctr_info }, 01810 #endif 01811 #if defined(MBEDTLS_GCM_C) 01812 { MBEDTLS_CIPHER_ARIA_128_GCM, &aria_128_gcm_info }, 01813 { MBEDTLS_CIPHER_ARIA_192_GCM, &aria_192_gcm_info }, 01814 { MBEDTLS_CIPHER_ARIA_256_GCM, &aria_256_gcm_info }, 01815 #endif 01816 #if defined(MBEDTLS_CCM_C) 01817 { MBEDTLS_CIPHER_ARIA_128_CCM, &aria_128_ccm_info }, 01818 { MBEDTLS_CIPHER_ARIA_192_CCM, &aria_192_ccm_info }, 01819 { MBEDTLS_CIPHER_ARIA_256_CCM, &aria_256_ccm_info }, 01820 #endif 01821 #endif /* MBEDTLS_ARIA_C */ 01822 01823 #if defined(MBEDTLS_DES_C) 01824 { MBEDTLS_CIPHER_DES_ECB, &des_ecb_info }, 01825 { MBEDTLS_CIPHER_DES_EDE_ECB, &des_ede_ecb_info }, 01826 { MBEDTLS_CIPHER_DES_EDE3_ECB, &des_ede3_ecb_info }, 01827 #if defined(MBEDTLS_CIPHER_MODE_CBC) 01828 { MBEDTLS_CIPHER_DES_CBC, &des_cbc_info }, 01829 { MBEDTLS_CIPHER_DES_EDE_CBC, &des_ede_cbc_info }, 01830 { MBEDTLS_CIPHER_DES_EDE3_CBC, &des_ede3_cbc_info }, 01831 #endif 01832 #endif /* MBEDTLS_DES_C */ 01833 01834 #if defined(MBEDTLS_CIPHER_NULL_CIPHER) 01835 { MBEDTLS_CIPHER_NULL, &null_cipher_info }, 01836 #endif /* MBEDTLS_CIPHER_NULL_CIPHER */ 01837 01838 { MBEDTLS_CIPHER_NONE, NULL } 01839 }; 01840 01841 #define NUM_CIPHERS sizeof mbedtls_cipher_definitions / sizeof mbedtls_cipher_definitions[0] 01842 int mbedtls_cipher_supported[NUM_CIPHERS]; 01843 01844 #endif /* MBEDTLS_CIPHER_C */
Generated on Tue Jul 12 2022 12:43:39 by
