12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270 |
- /**
- * \file cipher_wrap.c
- *
- * \brief Generic cipher wrapper for mbed TLS
- *
- * \author Adriaan de Jong <[email protected]>
- *
- * Copyright The Mbed TLS Contributors
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- #include "common.h"
- #if defined(MBEDTLS_CIPHER_C)
- #include "cipher_wrap.h"
- #include "mbedtls/error.h"
- #if defined(MBEDTLS_CHACHAPOLY_C)
- #include "mbedtls/chachapoly.h"
- #endif
- #if defined(MBEDTLS_AES_C)
- #include "mbedtls/aes.h"
- #endif
- #if defined(MBEDTLS_CAMELLIA_C)
- #include "mbedtls/camellia.h"
- #endif
- #if defined(MBEDTLS_ARIA_C)
- #include "mbedtls/aria.h"
- #endif
- #if defined(MBEDTLS_DES_C)
- #include "mbedtls/des.h"
- #endif
- #if defined(MBEDTLS_CHACHA20_C)
- #include "mbedtls/chacha20.h"
- #endif
- #if defined(MBEDTLS_GCM_C)
- #include "mbedtls/gcm.h"
- #endif
- #if defined(MBEDTLS_CCM_C)
- #include "mbedtls/ccm.h"
- #endif
- #if defined(MBEDTLS_NIST_KW_C)
- #include "mbedtls/nist_kw.h"
- #endif
- #if defined(MBEDTLS_CIPHER_NULL_CIPHER)
- #include <string.h>
- #endif
- #if defined(MBEDTLS_PLATFORM_C)
- #include "mbedtls/platform.h"
- #else
- #include <stdlib.h>
- #define mbedtls_calloc calloc
- #define mbedtls_free free
- #endif
- #if defined(MBEDTLS_GCM_C)
- /* shared by all GCM ciphers */
- static void *gcm_ctx_alloc( void )
- {
- void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_gcm_context ) );
- if( ctx != NULL )
- mbedtls_gcm_init( (mbedtls_gcm_context *) ctx );
- return( ctx );
- }
- static void gcm_ctx_free( void *ctx )
- {
- mbedtls_gcm_free( ctx );
- mbedtls_free( ctx );
- }
- #endif /* MBEDTLS_GCM_C */
- #if defined(MBEDTLS_CCM_C)
- /* shared by all CCM ciphers */
- static void *ccm_ctx_alloc( void )
- {
- void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ccm_context ) );
- if( ctx != NULL )
- mbedtls_ccm_init( (mbedtls_ccm_context *) ctx );
- return( ctx );
- }
- static void ccm_ctx_free( void *ctx )
- {
- mbedtls_ccm_free( ctx );
- mbedtls_free( ctx );
- }
- #endif /* MBEDTLS_CCM_C */
- #if defined(MBEDTLS_AES_C)
- static int aes_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
- const unsigned char *input, unsigned char *output )
- {
- return mbedtls_aes_crypt_ecb( (mbedtls_aes_context *) ctx, operation, input, output );
- }
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- static int aes_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, size_t length,
- unsigned char *iv, const unsigned char *input, unsigned char *output )
- {
- return mbedtls_aes_crypt_cbc( (mbedtls_aes_context *) ctx, operation, length, iv, input,
- output );
- }
- #endif /* MBEDTLS_CIPHER_MODE_CBC */
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- static int aes_crypt_cfb128_wrap( void *ctx, mbedtls_operation_t operation,
- size_t length, size_t *iv_off, unsigned char *iv,
- const unsigned char *input, unsigned char *output )
- {
- return mbedtls_aes_crypt_cfb128( (mbedtls_aes_context *) ctx, operation, length, iv_off, iv,
- input, output );
- }
- #endif /* MBEDTLS_CIPHER_MODE_CFB */
- #if defined(MBEDTLS_CIPHER_MODE_OFB)
- static int aes_crypt_ofb_wrap( void *ctx, size_t length, size_t *iv_off,
- unsigned char *iv, const unsigned char *input, unsigned char *output )
- {
- return mbedtls_aes_crypt_ofb( (mbedtls_aes_context *) ctx, length, iv_off,
- iv, input, output );
- }
- #endif /* MBEDTLS_CIPHER_MODE_OFB */
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- static int aes_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
- unsigned char *nonce_counter, unsigned char *stream_block,
- const unsigned char *input, unsigned char *output )
- {
- return mbedtls_aes_crypt_ctr( (mbedtls_aes_context *) ctx, length, nc_off, nonce_counter,
- stream_block, input, output );
- }
- #endif /* MBEDTLS_CIPHER_MODE_CTR */
- #if defined(MBEDTLS_CIPHER_MODE_XTS)
- static int aes_crypt_xts_wrap( void *ctx, mbedtls_operation_t operation,
- size_t length,
- const unsigned char data_unit[16],
- const unsigned char *input,
- unsigned char *output )
- {
- mbedtls_aes_xts_context *xts_ctx = ctx;
- int mode;
- switch( operation )
- {
- case MBEDTLS_ENCRYPT:
- mode = MBEDTLS_AES_ENCRYPT;
- break;
- case MBEDTLS_DECRYPT:
- mode = MBEDTLS_AES_DECRYPT;
- break;
- default:
- return MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA;
- }
- return mbedtls_aes_crypt_xts( xts_ctx, mode, length,
- data_unit, input, output );
- }
- #endif /* MBEDTLS_CIPHER_MODE_XTS */
- static int aes_setkey_dec_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- return mbedtls_aes_setkey_dec( (mbedtls_aes_context *) ctx, key, key_bitlen );
- }
- static int aes_setkey_enc_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- return mbedtls_aes_setkey_enc( (mbedtls_aes_context *) ctx, key, key_bitlen );
- }
- static void * aes_ctx_alloc( void )
- {
- mbedtls_aes_context *aes = mbedtls_calloc( 1, sizeof( mbedtls_aes_context ) );
- if( aes == NULL )
- return( NULL );
- mbedtls_aes_init( aes );
- return( aes );
- }
- static void aes_ctx_free( void *ctx )
- {
- mbedtls_aes_free( (mbedtls_aes_context *) ctx );
- mbedtls_free( ctx );
- }
- static const mbedtls_cipher_base_t aes_info = {
- MBEDTLS_CIPHER_ID_AES,
- aes_crypt_ecb_wrap,
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- aes_crypt_cbc_wrap,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- aes_crypt_cfb128_wrap,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_OFB)
- aes_crypt_ofb_wrap,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- aes_crypt_ctr_wrap,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_XTS)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_STREAM)
- NULL,
- #endif
- aes_setkey_enc_wrap,
- aes_setkey_dec_wrap,
- aes_ctx_alloc,
- aes_ctx_free
- };
- static const mbedtls_cipher_info_t aes_128_ecb_info = {
- MBEDTLS_CIPHER_AES_128_ECB,
- MBEDTLS_MODE_ECB,
- 128,
- "AES-128-ECB",
- 0,
- 0,
- 16,
- &aes_info
- };
- static const mbedtls_cipher_info_t aes_192_ecb_info = {
- MBEDTLS_CIPHER_AES_192_ECB,
- MBEDTLS_MODE_ECB,
- 192,
- "AES-192-ECB",
- 0,
- 0,
- 16,
- &aes_info
- };
- static const mbedtls_cipher_info_t aes_256_ecb_info = {
- MBEDTLS_CIPHER_AES_256_ECB,
- MBEDTLS_MODE_ECB,
- 256,
- "AES-256-ECB",
- 0,
- 0,
- 16,
- &aes_info
- };
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- static const mbedtls_cipher_info_t aes_128_cbc_info = {
- MBEDTLS_CIPHER_AES_128_CBC,
- MBEDTLS_MODE_CBC,
- 128,
- "AES-128-CBC",
- 16,
- 0,
- 16,
- &aes_info
- };
- static const mbedtls_cipher_info_t aes_192_cbc_info = {
- MBEDTLS_CIPHER_AES_192_CBC,
- MBEDTLS_MODE_CBC,
- 192,
- "AES-192-CBC",
- 16,
- 0,
- 16,
- &aes_info
- };
- static const mbedtls_cipher_info_t aes_256_cbc_info = {
- MBEDTLS_CIPHER_AES_256_CBC,
- MBEDTLS_MODE_CBC,
- 256,
- "AES-256-CBC",
- 16,
- 0,
- 16,
- &aes_info
- };
- #endif /* MBEDTLS_CIPHER_MODE_CBC */
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- static const mbedtls_cipher_info_t aes_128_cfb128_info = {
- MBEDTLS_CIPHER_AES_128_CFB128,
- MBEDTLS_MODE_CFB,
- 128,
- "AES-128-CFB128",
- 16,
- 0,
- 16,
- &aes_info
- };
- static const mbedtls_cipher_info_t aes_192_cfb128_info = {
- MBEDTLS_CIPHER_AES_192_CFB128,
- MBEDTLS_MODE_CFB,
- 192,
- "AES-192-CFB128",
- 16,
- 0,
- 16,
- &aes_info
- };
- static const mbedtls_cipher_info_t aes_256_cfb128_info = {
- MBEDTLS_CIPHER_AES_256_CFB128,
- MBEDTLS_MODE_CFB,
- 256,
- "AES-256-CFB128",
- 16,
- 0,
- 16,
- &aes_info
- };
- #endif /* MBEDTLS_CIPHER_MODE_CFB */
- #if defined(MBEDTLS_CIPHER_MODE_OFB)
- static const mbedtls_cipher_info_t aes_128_ofb_info = {
- MBEDTLS_CIPHER_AES_128_OFB,
- MBEDTLS_MODE_OFB,
- 128,
- "AES-128-OFB",
- 16,
- 0,
- 16,
- &aes_info
- };
- static const mbedtls_cipher_info_t aes_192_ofb_info = {
- MBEDTLS_CIPHER_AES_192_OFB,
- MBEDTLS_MODE_OFB,
- 192,
- "AES-192-OFB",
- 16,
- 0,
- 16,
- &aes_info
- };
- static const mbedtls_cipher_info_t aes_256_ofb_info = {
- MBEDTLS_CIPHER_AES_256_OFB,
- MBEDTLS_MODE_OFB,
- 256,
- "AES-256-OFB",
- 16,
- 0,
- 16,
- &aes_info
- };
- #endif /* MBEDTLS_CIPHER_MODE_OFB */
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- static const mbedtls_cipher_info_t aes_128_ctr_info = {
- MBEDTLS_CIPHER_AES_128_CTR,
- MBEDTLS_MODE_CTR,
- 128,
- "AES-128-CTR",
- 16,
- 0,
- 16,
- &aes_info
- };
- static const mbedtls_cipher_info_t aes_192_ctr_info = {
- MBEDTLS_CIPHER_AES_192_CTR,
- MBEDTLS_MODE_CTR,
- 192,
- "AES-192-CTR",
- 16,
- 0,
- 16,
- &aes_info
- };
- static const mbedtls_cipher_info_t aes_256_ctr_info = {
- MBEDTLS_CIPHER_AES_256_CTR,
- MBEDTLS_MODE_CTR,
- 256,
- "AES-256-CTR",
- 16,
- 0,
- 16,
- &aes_info
- };
- #endif /* MBEDTLS_CIPHER_MODE_CTR */
- #if defined(MBEDTLS_CIPHER_MODE_XTS)
- static int xts_aes_setkey_enc_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- mbedtls_aes_xts_context *xts_ctx = ctx;
- return( mbedtls_aes_xts_setkey_enc( xts_ctx, key, key_bitlen ) );
- }
- static int xts_aes_setkey_dec_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- mbedtls_aes_xts_context *xts_ctx = ctx;
- return( mbedtls_aes_xts_setkey_dec( xts_ctx, key, key_bitlen ) );
- }
- static void *xts_aes_ctx_alloc( void )
- {
- mbedtls_aes_xts_context *xts_ctx = mbedtls_calloc( 1, sizeof( *xts_ctx ) );
- if( xts_ctx != NULL )
- mbedtls_aes_xts_init( xts_ctx );
- return( xts_ctx );
- }
- static void xts_aes_ctx_free( void *ctx )
- {
- mbedtls_aes_xts_context *xts_ctx = ctx;
- if( xts_ctx == NULL )
- return;
- mbedtls_aes_xts_free( xts_ctx );
- mbedtls_free( xts_ctx );
- }
- static const mbedtls_cipher_base_t xts_aes_info = {
- MBEDTLS_CIPHER_ID_AES,
- NULL,
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_OFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_XTS)
- aes_crypt_xts_wrap,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_STREAM)
- NULL,
- #endif
- xts_aes_setkey_enc_wrap,
- xts_aes_setkey_dec_wrap,
- xts_aes_ctx_alloc,
- xts_aes_ctx_free
- };
- static const mbedtls_cipher_info_t aes_128_xts_info = {
- MBEDTLS_CIPHER_AES_128_XTS,
- MBEDTLS_MODE_XTS,
- 256,
- "AES-128-XTS",
- 16,
- 0,
- 16,
- &xts_aes_info
- };
- static const mbedtls_cipher_info_t aes_256_xts_info = {
- MBEDTLS_CIPHER_AES_256_XTS,
- MBEDTLS_MODE_XTS,
- 512,
- "AES-256-XTS",
- 16,
- 0,
- 16,
- &xts_aes_info
- };
- #endif /* MBEDTLS_CIPHER_MODE_XTS */
- #if defined(MBEDTLS_GCM_C)
- static int gcm_aes_setkey_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- return mbedtls_gcm_setkey( (mbedtls_gcm_context *) ctx, MBEDTLS_CIPHER_ID_AES,
- key, key_bitlen );
- }
- static const mbedtls_cipher_base_t gcm_aes_info = {
- MBEDTLS_CIPHER_ID_AES,
- NULL,
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_OFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_XTS)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_STREAM)
- NULL,
- #endif
- gcm_aes_setkey_wrap,
- gcm_aes_setkey_wrap,
- gcm_ctx_alloc,
- gcm_ctx_free,
- };
- static const mbedtls_cipher_info_t aes_128_gcm_info = {
- MBEDTLS_CIPHER_AES_128_GCM,
- MBEDTLS_MODE_GCM,
- 128,
- "AES-128-GCM",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &gcm_aes_info
- };
- static const mbedtls_cipher_info_t aes_192_gcm_info = {
- MBEDTLS_CIPHER_AES_192_GCM,
- MBEDTLS_MODE_GCM,
- 192,
- "AES-192-GCM",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &gcm_aes_info
- };
- static const mbedtls_cipher_info_t aes_256_gcm_info = {
- MBEDTLS_CIPHER_AES_256_GCM,
- MBEDTLS_MODE_GCM,
- 256,
- "AES-256-GCM",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &gcm_aes_info
- };
- #endif /* MBEDTLS_GCM_C */
- #if defined(MBEDTLS_CCM_C)
- static int ccm_aes_setkey_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- return mbedtls_ccm_setkey( (mbedtls_ccm_context *) ctx, MBEDTLS_CIPHER_ID_AES,
- key, key_bitlen );
- }
- static const mbedtls_cipher_base_t ccm_aes_info = {
- MBEDTLS_CIPHER_ID_AES,
- NULL,
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_OFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_XTS)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_STREAM)
- NULL,
- #endif
- ccm_aes_setkey_wrap,
- ccm_aes_setkey_wrap,
- ccm_ctx_alloc,
- ccm_ctx_free,
- };
- static const mbedtls_cipher_info_t aes_128_ccm_info = {
- MBEDTLS_CIPHER_AES_128_CCM,
- MBEDTLS_MODE_CCM,
- 128,
- "AES-128-CCM",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &ccm_aes_info
- };
- static const mbedtls_cipher_info_t aes_192_ccm_info = {
- MBEDTLS_CIPHER_AES_192_CCM,
- MBEDTLS_MODE_CCM,
- 192,
- "AES-192-CCM",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &ccm_aes_info
- };
- static const mbedtls_cipher_info_t aes_256_ccm_info = {
- MBEDTLS_CIPHER_AES_256_CCM,
- MBEDTLS_MODE_CCM,
- 256,
- "AES-256-CCM",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &ccm_aes_info
- };
- static const mbedtls_cipher_info_t aes_128_ccm_star_no_tag_info = {
- MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG,
- MBEDTLS_MODE_CCM_STAR_NO_TAG,
- 128,
- "AES-128-CCM*-NO-TAG",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &ccm_aes_info
- };
- static const mbedtls_cipher_info_t aes_192_ccm_star_no_tag_info = {
- MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG,
- MBEDTLS_MODE_CCM_STAR_NO_TAG,
- 192,
- "AES-192-CCM*-NO-TAG",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &ccm_aes_info
- };
- static const mbedtls_cipher_info_t aes_256_ccm_star_no_tag_info = {
- MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG,
- MBEDTLS_MODE_CCM_STAR_NO_TAG,
- 256,
- "AES-256-CCM*-NO-TAG",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &ccm_aes_info
- };
- #endif /* MBEDTLS_CCM_C */
- #endif /* MBEDTLS_AES_C */
- #if defined(MBEDTLS_CAMELLIA_C)
- static int camellia_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
- const unsigned char *input, unsigned char *output )
- {
- return mbedtls_camellia_crypt_ecb( (mbedtls_camellia_context *) ctx, operation, input,
- output );
- }
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- static int camellia_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation,
- size_t length, unsigned char *iv,
- const unsigned char *input, unsigned char *output )
- {
- return mbedtls_camellia_crypt_cbc( (mbedtls_camellia_context *) ctx, operation, length, iv,
- input, output );
- }
- #endif /* MBEDTLS_CIPHER_MODE_CBC */
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- static int camellia_crypt_cfb128_wrap( void *ctx, mbedtls_operation_t operation,
- size_t length, size_t *iv_off, unsigned char *iv,
- const unsigned char *input, unsigned char *output )
- {
- return mbedtls_camellia_crypt_cfb128( (mbedtls_camellia_context *) ctx, operation, length,
- iv_off, iv, input, output );
- }
- #endif /* MBEDTLS_CIPHER_MODE_CFB */
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- static int camellia_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
- unsigned char *nonce_counter, unsigned char *stream_block,
- const unsigned char *input, unsigned char *output )
- {
- return mbedtls_camellia_crypt_ctr( (mbedtls_camellia_context *) ctx, length, nc_off,
- nonce_counter, stream_block, input, output );
- }
- #endif /* MBEDTLS_CIPHER_MODE_CTR */
- static int camellia_setkey_dec_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- return mbedtls_camellia_setkey_dec( (mbedtls_camellia_context *) ctx, key, key_bitlen );
- }
- static int camellia_setkey_enc_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- return mbedtls_camellia_setkey_enc( (mbedtls_camellia_context *) ctx, key, key_bitlen );
- }
- static void * camellia_ctx_alloc( void )
- {
- mbedtls_camellia_context *ctx;
- ctx = mbedtls_calloc( 1, sizeof( mbedtls_camellia_context ) );
- if( ctx == NULL )
- return( NULL );
- mbedtls_camellia_init( ctx );
- return( ctx );
- }
- static void camellia_ctx_free( void *ctx )
- {
- mbedtls_camellia_free( (mbedtls_camellia_context *) ctx );
- mbedtls_free( ctx );
- }
- static const mbedtls_cipher_base_t camellia_info = {
- MBEDTLS_CIPHER_ID_CAMELLIA,
- camellia_crypt_ecb_wrap,
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- camellia_crypt_cbc_wrap,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- camellia_crypt_cfb128_wrap,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_OFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- camellia_crypt_ctr_wrap,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_XTS)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_STREAM)
- NULL,
- #endif
- camellia_setkey_enc_wrap,
- camellia_setkey_dec_wrap,
- camellia_ctx_alloc,
- camellia_ctx_free
- };
- static const mbedtls_cipher_info_t camellia_128_ecb_info = {
- MBEDTLS_CIPHER_CAMELLIA_128_ECB,
- MBEDTLS_MODE_ECB,
- 128,
- "CAMELLIA-128-ECB",
- 0,
- 0,
- 16,
- &camellia_info
- };
- static const mbedtls_cipher_info_t camellia_192_ecb_info = {
- MBEDTLS_CIPHER_CAMELLIA_192_ECB,
- MBEDTLS_MODE_ECB,
- 192,
- "CAMELLIA-192-ECB",
- 0,
- 0,
- 16,
- &camellia_info
- };
- static const mbedtls_cipher_info_t camellia_256_ecb_info = {
- MBEDTLS_CIPHER_CAMELLIA_256_ECB,
- MBEDTLS_MODE_ECB,
- 256,
- "CAMELLIA-256-ECB",
- 0,
- 0,
- 16,
- &camellia_info
- };
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- static const mbedtls_cipher_info_t camellia_128_cbc_info = {
- MBEDTLS_CIPHER_CAMELLIA_128_CBC,
- MBEDTLS_MODE_CBC,
- 128,
- "CAMELLIA-128-CBC",
- 16,
- 0,
- 16,
- &camellia_info
- };
- static const mbedtls_cipher_info_t camellia_192_cbc_info = {
- MBEDTLS_CIPHER_CAMELLIA_192_CBC,
- MBEDTLS_MODE_CBC,
- 192,
- "CAMELLIA-192-CBC",
- 16,
- 0,
- 16,
- &camellia_info
- };
- static const mbedtls_cipher_info_t camellia_256_cbc_info = {
- MBEDTLS_CIPHER_CAMELLIA_256_CBC,
- MBEDTLS_MODE_CBC,
- 256,
- "CAMELLIA-256-CBC",
- 16,
- 0,
- 16,
- &camellia_info
- };
- #endif /* MBEDTLS_CIPHER_MODE_CBC */
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- static const mbedtls_cipher_info_t camellia_128_cfb128_info = {
- MBEDTLS_CIPHER_CAMELLIA_128_CFB128,
- MBEDTLS_MODE_CFB,
- 128,
- "CAMELLIA-128-CFB128",
- 16,
- 0,
- 16,
- &camellia_info
- };
- static const mbedtls_cipher_info_t camellia_192_cfb128_info = {
- MBEDTLS_CIPHER_CAMELLIA_192_CFB128,
- MBEDTLS_MODE_CFB,
- 192,
- "CAMELLIA-192-CFB128",
- 16,
- 0,
- 16,
- &camellia_info
- };
- static const mbedtls_cipher_info_t camellia_256_cfb128_info = {
- MBEDTLS_CIPHER_CAMELLIA_256_CFB128,
- MBEDTLS_MODE_CFB,
- 256,
- "CAMELLIA-256-CFB128",
- 16,
- 0,
- 16,
- &camellia_info
- };
- #endif /* MBEDTLS_CIPHER_MODE_CFB */
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- static const mbedtls_cipher_info_t camellia_128_ctr_info = {
- MBEDTLS_CIPHER_CAMELLIA_128_CTR,
- MBEDTLS_MODE_CTR,
- 128,
- "CAMELLIA-128-CTR",
- 16,
- 0,
- 16,
- &camellia_info
- };
- static const mbedtls_cipher_info_t camellia_192_ctr_info = {
- MBEDTLS_CIPHER_CAMELLIA_192_CTR,
- MBEDTLS_MODE_CTR,
- 192,
- "CAMELLIA-192-CTR",
- 16,
- 0,
- 16,
- &camellia_info
- };
- static const mbedtls_cipher_info_t camellia_256_ctr_info = {
- MBEDTLS_CIPHER_CAMELLIA_256_CTR,
- MBEDTLS_MODE_CTR,
- 256,
- "CAMELLIA-256-CTR",
- 16,
- 0,
- 16,
- &camellia_info
- };
- #endif /* MBEDTLS_CIPHER_MODE_CTR */
- #if defined(MBEDTLS_GCM_C)
- static int gcm_camellia_setkey_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- return mbedtls_gcm_setkey( (mbedtls_gcm_context *) ctx, MBEDTLS_CIPHER_ID_CAMELLIA,
- key, key_bitlen );
- }
- static const mbedtls_cipher_base_t gcm_camellia_info = {
- MBEDTLS_CIPHER_ID_CAMELLIA,
- NULL,
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_OFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_XTS)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_STREAM)
- NULL,
- #endif
- gcm_camellia_setkey_wrap,
- gcm_camellia_setkey_wrap,
- gcm_ctx_alloc,
- gcm_ctx_free,
- };
- static const mbedtls_cipher_info_t camellia_128_gcm_info = {
- MBEDTLS_CIPHER_CAMELLIA_128_GCM,
- MBEDTLS_MODE_GCM,
- 128,
- "CAMELLIA-128-GCM",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &gcm_camellia_info
- };
- static const mbedtls_cipher_info_t camellia_192_gcm_info = {
- MBEDTLS_CIPHER_CAMELLIA_192_GCM,
- MBEDTLS_MODE_GCM,
- 192,
- "CAMELLIA-192-GCM",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &gcm_camellia_info
- };
- static const mbedtls_cipher_info_t camellia_256_gcm_info = {
- MBEDTLS_CIPHER_CAMELLIA_256_GCM,
- MBEDTLS_MODE_GCM,
- 256,
- "CAMELLIA-256-GCM",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &gcm_camellia_info
- };
- #endif /* MBEDTLS_GCM_C */
- #if defined(MBEDTLS_CCM_C)
- static int ccm_camellia_setkey_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- return mbedtls_ccm_setkey( (mbedtls_ccm_context *) ctx, MBEDTLS_CIPHER_ID_CAMELLIA,
- key, key_bitlen );
- }
- static const mbedtls_cipher_base_t ccm_camellia_info = {
- MBEDTLS_CIPHER_ID_CAMELLIA,
- NULL,
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_OFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_XTS)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_STREAM)
- NULL,
- #endif
- ccm_camellia_setkey_wrap,
- ccm_camellia_setkey_wrap,
- ccm_ctx_alloc,
- ccm_ctx_free,
- };
- static const mbedtls_cipher_info_t camellia_128_ccm_info = {
- MBEDTLS_CIPHER_CAMELLIA_128_CCM,
- MBEDTLS_MODE_CCM,
- 128,
- "CAMELLIA-128-CCM",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &ccm_camellia_info
- };
- static const mbedtls_cipher_info_t camellia_192_ccm_info = {
- MBEDTLS_CIPHER_CAMELLIA_192_CCM,
- MBEDTLS_MODE_CCM,
- 192,
- "CAMELLIA-192-CCM",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &ccm_camellia_info
- };
- static const mbedtls_cipher_info_t camellia_256_ccm_info = {
- MBEDTLS_CIPHER_CAMELLIA_256_CCM,
- MBEDTLS_MODE_CCM,
- 256,
- "CAMELLIA-256-CCM",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &ccm_camellia_info
- };
- static const mbedtls_cipher_info_t camellia_128_ccm_star_no_tag_info = {
- MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG,
- MBEDTLS_MODE_CCM_STAR_NO_TAG,
- 128,
- "CAMELLIA-128-CCM*-NO-TAG",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &ccm_camellia_info
- };
- static const mbedtls_cipher_info_t camellia_192_ccm_star_no_tag_info = {
- MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG,
- MBEDTLS_MODE_CCM_STAR_NO_TAG,
- 192,
- "CAMELLIA-192-CCM*-NO-TAG",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &ccm_camellia_info
- };
- static const mbedtls_cipher_info_t camellia_256_ccm_star_no_tag_info = {
- MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG,
- MBEDTLS_MODE_CCM_STAR_NO_TAG,
- 256,
- "CAMELLIA-256-CCM*-NO-TAG",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &ccm_camellia_info
- };
- #endif /* MBEDTLS_CCM_C */
- #endif /* MBEDTLS_CAMELLIA_C */
- #if defined(MBEDTLS_ARIA_C)
- static int aria_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
- const unsigned char *input, unsigned char *output )
- {
- (void) operation;
- return mbedtls_aria_crypt_ecb( (mbedtls_aria_context *) ctx, input,
- output );
- }
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- static int aria_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation,
- size_t length, unsigned char *iv,
- const unsigned char *input, unsigned char *output )
- {
- return mbedtls_aria_crypt_cbc( (mbedtls_aria_context *) ctx, operation, length, iv,
- input, output );
- }
- #endif /* MBEDTLS_CIPHER_MODE_CBC */
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- static int aria_crypt_cfb128_wrap( void *ctx, mbedtls_operation_t operation,
- size_t length, size_t *iv_off, unsigned char *iv,
- const unsigned char *input, unsigned char *output )
- {
- return mbedtls_aria_crypt_cfb128( (mbedtls_aria_context *) ctx, operation, length,
- iv_off, iv, input, output );
- }
- #endif /* MBEDTLS_CIPHER_MODE_CFB */
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- static int aria_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
- unsigned char *nonce_counter, unsigned char *stream_block,
- const unsigned char *input, unsigned char *output )
- {
- return mbedtls_aria_crypt_ctr( (mbedtls_aria_context *) ctx, length, nc_off,
- nonce_counter, stream_block, input, output );
- }
- #endif /* MBEDTLS_CIPHER_MODE_CTR */
- static int aria_setkey_dec_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- return mbedtls_aria_setkey_dec( (mbedtls_aria_context *) ctx, key, key_bitlen );
- }
- static int aria_setkey_enc_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- return mbedtls_aria_setkey_enc( (mbedtls_aria_context *) ctx, key, key_bitlen );
- }
- static void * aria_ctx_alloc( void )
- {
- mbedtls_aria_context *ctx;
- ctx = mbedtls_calloc( 1, sizeof( mbedtls_aria_context ) );
- if( ctx == NULL )
- return( NULL );
- mbedtls_aria_init( ctx );
- return( ctx );
- }
- static void aria_ctx_free( void *ctx )
- {
- mbedtls_aria_free( (mbedtls_aria_context *) ctx );
- mbedtls_free( ctx );
- }
- static const mbedtls_cipher_base_t aria_info = {
- MBEDTLS_CIPHER_ID_ARIA,
- aria_crypt_ecb_wrap,
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- aria_crypt_cbc_wrap,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- aria_crypt_cfb128_wrap,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_OFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- aria_crypt_ctr_wrap,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_XTS)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_STREAM)
- NULL,
- #endif
- aria_setkey_enc_wrap,
- aria_setkey_dec_wrap,
- aria_ctx_alloc,
- aria_ctx_free
- };
- static const mbedtls_cipher_info_t aria_128_ecb_info = {
- MBEDTLS_CIPHER_ARIA_128_ECB,
- MBEDTLS_MODE_ECB,
- 128,
- "ARIA-128-ECB",
- 0,
- 0,
- 16,
- &aria_info
- };
- static const mbedtls_cipher_info_t aria_192_ecb_info = {
- MBEDTLS_CIPHER_ARIA_192_ECB,
- MBEDTLS_MODE_ECB,
- 192,
- "ARIA-192-ECB",
- 0,
- 0,
- 16,
- &aria_info
- };
- static const mbedtls_cipher_info_t aria_256_ecb_info = {
- MBEDTLS_CIPHER_ARIA_256_ECB,
- MBEDTLS_MODE_ECB,
- 256,
- "ARIA-256-ECB",
- 0,
- 0,
- 16,
- &aria_info
- };
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- static const mbedtls_cipher_info_t aria_128_cbc_info = {
- MBEDTLS_CIPHER_ARIA_128_CBC,
- MBEDTLS_MODE_CBC,
- 128,
- "ARIA-128-CBC",
- 16,
- 0,
- 16,
- &aria_info
- };
- static const mbedtls_cipher_info_t aria_192_cbc_info = {
- MBEDTLS_CIPHER_ARIA_192_CBC,
- MBEDTLS_MODE_CBC,
- 192,
- "ARIA-192-CBC",
- 16,
- 0,
- 16,
- &aria_info
- };
- static const mbedtls_cipher_info_t aria_256_cbc_info = {
- MBEDTLS_CIPHER_ARIA_256_CBC,
- MBEDTLS_MODE_CBC,
- 256,
- "ARIA-256-CBC",
- 16,
- 0,
- 16,
- &aria_info
- };
- #endif /* MBEDTLS_CIPHER_MODE_CBC */
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- static const mbedtls_cipher_info_t aria_128_cfb128_info = {
- MBEDTLS_CIPHER_ARIA_128_CFB128,
- MBEDTLS_MODE_CFB,
- 128,
- "ARIA-128-CFB128",
- 16,
- 0,
- 16,
- &aria_info
- };
- static const mbedtls_cipher_info_t aria_192_cfb128_info = {
- MBEDTLS_CIPHER_ARIA_192_CFB128,
- MBEDTLS_MODE_CFB,
- 192,
- "ARIA-192-CFB128",
- 16,
- 0,
- 16,
- &aria_info
- };
- static const mbedtls_cipher_info_t aria_256_cfb128_info = {
- MBEDTLS_CIPHER_ARIA_256_CFB128,
- MBEDTLS_MODE_CFB,
- 256,
- "ARIA-256-CFB128",
- 16,
- 0,
- 16,
- &aria_info
- };
- #endif /* MBEDTLS_CIPHER_MODE_CFB */
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- static const mbedtls_cipher_info_t aria_128_ctr_info = {
- MBEDTLS_CIPHER_ARIA_128_CTR,
- MBEDTLS_MODE_CTR,
- 128,
- "ARIA-128-CTR",
- 16,
- 0,
- 16,
- &aria_info
- };
- static const mbedtls_cipher_info_t aria_192_ctr_info = {
- MBEDTLS_CIPHER_ARIA_192_CTR,
- MBEDTLS_MODE_CTR,
- 192,
- "ARIA-192-CTR",
- 16,
- 0,
- 16,
- &aria_info
- };
- static const mbedtls_cipher_info_t aria_256_ctr_info = {
- MBEDTLS_CIPHER_ARIA_256_CTR,
- MBEDTLS_MODE_CTR,
- 256,
- "ARIA-256-CTR",
- 16,
- 0,
- 16,
- &aria_info
- };
- #endif /* MBEDTLS_CIPHER_MODE_CTR */
- #if defined(MBEDTLS_GCM_C)
- static int gcm_aria_setkey_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- return mbedtls_gcm_setkey( (mbedtls_gcm_context *) ctx, MBEDTLS_CIPHER_ID_ARIA,
- key, key_bitlen );
- }
- static const mbedtls_cipher_base_t gcm_aria_info = {
- MBEDTLS_CIPHER_ID_ARIA,
- NULL,
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_OFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_XTS)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_STREAM)
- NULL,
- #endif
- gcm_aria_setkey_wrap,
- gcm_aria_setkey_wrap,
- gcm_ctx_alloc,
- gcm_ctx_free,
- };
- static const mbedtls_cipher_info_t aria_128_gcm_info = {
- MBEDTLS_CIPHER_ARIA_128_GCM,
- MBEDTLS_MODE_GCM,
- 128,
- "ARIA-128-GCM",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &gcm_aria_info
- };
- static const mbedtls_cipher_info_t aria_192_gcm_info = {
- MBEDTLS_CIPHER_ARIA_192_GCM,
- MBEDTLS_MODE_GCM,
- 192,
- "ARIA-192-GCM",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &gcm_aria_info
- };
- static const mbedtls_cipher_info_t aria_256_gcm_info = {
- MBEDTLS_CIPHER_ARIA_256_GCM,
- MBEDTLS_MODE_GCM,
- 256,
- "ARIA-256-GCM",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &gcm_aria_info
- };
- #endif /* MBEDTLS_GCM_C */
- #if defined(MBEDTLS_CCM_C)
- static int ccm_aria_setkey_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- return mbedtls_ccm_setkey( (mbedtls_ccm_context *) ctx, MBEDTLS_CIPHER_ID_ARIA,
- key, key_bitlen );
- }
- static const mbedtls_cipher_base_t ccm_aria_info = {
- MBEDTLS_CIPHER_ID_ARIA,
- NULL,
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_OFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_XTS)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_STREAM)
- NULL,
- #endif
- ccm_aria_setkey_wrap,
- ccm_aria_setkey_wrap,
- ccm_ctx_alloc,
- ccm_ctx_free,
- };
- static const mbedtls_cipher_info_t aria_128_ccm_info = {
- MBEDTLS_CIPHER_ARIA_128_CCM,
- MBEDTLS_MODE_CCM,
- 128,
- "ARIA-128-CCM",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &ccm_aria_info
- };
- static const mbedtls_cipher_info_t aria_192_ccm_info = {
- MBEDTLS_CIPHER_ARIA_192_CCM,
- MBEDTLS_MODE_CCM,
- 192,
- "ARIA-192-CCM",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &ccm_aria_info
- };
- static const mbedtls_cipher_info_t aria_256_ccm_info = {
- MBEDTLS_CIPHER_ARIA_256_CCM,
- MBEDTLS_MODE_CCM,
- 256,
- "ARIA-256-CCM",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &ccm_aria_info
- };
- static const mbedtls_cipher_info_t aria_128_ccm_star_no_tag_info = {
- MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG,
- MBEDTLS_MODE_CCM_STAR_NO_TAG,
- 128,
- "ARIA-128-CCM*-NO-TAG",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &ccm_aria_info
- };
- static const mbedtls_cipher_info_t aria_192_ccm_star_no_tag_info = {
- MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG,
- MBEDTLS_MODE_CCM_STAR_NO_TAG,
- 192,
- "ARIA-192-CCM*-NO-TAG",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &ccm_aria_info
- };
- static const mbedtls_cipher_info_t aria_256_ccm_star_no_tag_info = {
- MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG,
- MBEDTLS_MODE_CCM_STAR_NO_TAG,
- 256,
- "ARIA-256-CCM*-NO-TAG",
- 12,
- MBEDTLS_CIPHER_VARIABLE_IV_LEN,
- 16,
- &ccm_aria_info
- };
- #endif /* MBEDTLS_CCM_C */
- #endif /* MBEDTLS_ARIA_C */
- #if defined(MBEDTLS_DES_C)
- static int des_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
- const unsigned char *input, unsigned char *output )
- {
- ((void) operation);
- return mbedtls_des_crypt_ecb( (mbedtls_des_context *) ctx, input, output );
- }
- static int des3_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
- const unsigned char *input, unsigned char *output )
- {
- ((void) operation);
- return mbedtls_des3_crypt_ecb( (mbedtls_des3_context *) ctx, input, output );
- }
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- static int des_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, size_t length,
- unsigned char *iv, const unsigned char *input, unsigned char *output )
- {
- return mbedtls_des_crypt_cbc( (mbedtls_des_context *) ctx, operation, length, iv, input,
- output );
- }
- #endif /* MBEDTLS_CIPHER_MODE_CBC */
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- static int des3_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, size_t length,
- unsigned char *iv, const unsigned char *input, unsigned char *output )
- {
- return mbedtls_des3_crypt_cbc( (mbedtls_des3_context *) ctx, operation, length, iv, input,
- output );
- }
- #endif /* MBEDTLS_CIPHER_MODE_CBC */
- static int des_setkey_dec_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- ((void) key_bitlen);
- return mbedtls_des_setkey_dec( (mbedtls_des_context *) ctx, key );
- }
- static int des_setkey_enc_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- ((void) key_bitlen);
- return mbedtls_des_setkey_enc( (mbedtls_des_context *) ctx, key );
- }
- static int des3_set2key_dec_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- ((void) key_bitlen);
- return mbedtls_des3_set2key_dec( (mbedtls_des3_context *) ctx, key );
- }
- static int des3_set2key_enc_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- ((void) key_bitlen);
- return mbedtls_des3_set2key_enc( (mbedtls_des3_context *) ctx, key );
- }
- static int des3_set3key_dec_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- ((void) key_bitlen);
- return mbedtls_des3_set3key_dec( (mbedtls_des3_context *) ctx, key );
- }
- static int des3_set3key_enc_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- ((void) key_bitlen);
- return mbedtls_des3_set3key_enc( (mbedtls_des3_context *) ctx, key );
- }
- static void * des_ctx_alloc( void )
- {
- mbedtls_des_context *des = mbedtls_calloc( 1, sizeof( mbedtls_des_context ) );
- if( des == NULL )
- return( NULL );
- mbedtls_des_init( des );
- return( des );
- }
- static void des_ctx_free( void *ctx )
- {
- mbedtls_des_free( (mbedtls_des_context *) ctx );
- mbedtls_free( ctx );
- }
- static void * des3_ctx_alloc( void )
- {
- mbedtls_des3_context *des3;
- des3 = mbedtls_calloc( 1, sizeof( mbedtls_des3_context ) );
- if( des3 == NULL )
- return( NULL );
- mbedtls_des3_init( des3 );
- return( des3 );
- }
- static void des3_ctx_free( void *ctx )
- {
- mbedtls_des3_free( (mbedtls_des3_context *) ctx );
- mbedtls_free( ctx );
- }
- static const mbedtls_cipher_base_t des_info = {
- MBEDTLS_CIPHER_ID_DES,
- des_crypt_ecb_wrap,
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- des_crypt_cbc_wrap,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_OFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_XTS)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_STREAM)
- NULL,
- #endif
- des_setkey_enc_wrap,
- des_setkey_dec_wrap,
- des_ctx_alloc,
- des_ctx_free
- };
- static const mbedtls_cipher_info_t des_ecb_info = {
- MBEDTLS_CIPHER_DES_ECB,
- MBEDTLS_MODE_ECB,
- MBEDTLS_KEY_LENGTH_DES,
- "DES-ECB",
- 0,
- 0,
- 8,
- &des_info
- };
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- static const mbedtls_cipher_info_t des_cbc_info = {
- MBEDTLS_CIPHER_DES_CBC,
- MBEDTLS_MODE_CBC,
- MBEDTLS_KEY_LENGTH_DES,
- "DES-CBC",
- 8,
- 0,
- 8,
- &des_info
- };
- #endif /* MBEDTLS_CIPHER_MODE_CBC */
- static const mbedtls_cipher_base_t des_ede_info = {
- MBEDTLS_CIPHER_ID_DES,
- des3_crypt_ecb_wrap,
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- des3_crypt_cbc_wrap,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_OFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_XTS)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_STREAM)
- NULL,
- #endif
- des3_set2key_enc_wrap,
- des3_set2key_dec_wrap,
- des3_ctx_alloc,
- des3_ctx_free
- };
- static const mbedtls_cipher_info_t des_ede_ecb_info = {
- MBEDTLS_CIPHER_DES_EDE_ECB,
- MBEDTLS_MODE_ECB,
- MBEDTLS_KEY_LENGTH_DES_EDE,
- "DES-EDE-ECB",
- 0,
- 0,
- 8,
- &des_ede_info
- };
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- static const mbedtls_cipher_info_t des_ede_cbc_info = {
- MBEDTLS_CIPHER_DES_EDE_CBC,
- MBEDTLS_MODE_CBC,
- MBEDTLS_KEY_LENGTH_DES_EDE,
- "DES-EDE-CBC",
- 8,
- 0,
- 8,
- &des_ede_info
- };
- #endif /* MBEDTLS_CIPHER_MODE_CBC */
- static const mbedtls_cipher_base_t des_ede3_info = {
- MBEDTLS_CIPHER_ID_3DES,
- des3_crypt_ecb_wrap,
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- des3_crypt_cbc_wrap,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_OFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_XTS)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_STREAM)
- NULL,
- #endif
- des3_set3key_enc_wrap,
- des3_set3key_dec_wrap,
- des3_ctx_alloc,
- des3_ctx_free
- };
- static const mbedtls_cipher_info_t des_ede3_ecb_info = {
- MBEDTLS_CIPHER_DES_EDE3_ECB,
- MBEDTLS_MODE_ECB,
- MBEDTLS_KEY_LENGTH_DES_EDE3,
- "DES-EDE3-ECB",
- 0,
- 0,
- 8,
- &des_ede3_info
- };
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- static const mbedtls_cipher_info_t des_ede3_cbc_info = {
- MBEDTLS_CIPHER_DES_EDE3_CBC,
- MBEDTLS_MODE_CBC,
- MBEDTLS_KEY_LENGTH_DES_EDE3,
- "DES-EDE3-CBC",
- 8,
- 0,
- 8,
- &des_ede3_info
- };
- #endif /* MBEDTLS_CIPHER_MODE_CBC */
- #endif /* MBEDTLS_DES_C */
- #if defined(MBEDTLS_CHACHA20_C)
- static int chacha20_setkey_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- if( key_bitlen != 256U )
- return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
- if ( 0 != mbedtls_chacha20_setkey( (mbedtls_chacha20_context*)ctx, key ) )
- return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
- return( 0 );
- }
- static int chacha20_stream_wrap( void *ctx, size_t length,
- const unsigned char *input,
- unsigned char *output )
- {
- int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
- ret = mbedtls_chacha20_update( ctx, length, input, output );
- if( ret == MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA )
- return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
- return( ret );
- }
- static void * chacha20_ctx_alloc( void )
- {
- mbedtls_chacha20_context *ctx;
- ctx = mbedtls_calloc( 1, sizeof( mbedtls_chacha20_context ) );
- if( ctx == NULL )
- return( NULL );
- mbedtls_chacha20_init( ctx );
- return( ctx );
- }
- static void chacha20_ctx_free( void *ctx )
- {
- mbedtls_chacha20_free( (mbedtls_chacha20_context *) ctx );
- mbedtls_free( ctx );
- }
- static const mbedtls_cipher_base_t chacha20_base_info = {
- MBEDTLS_CIPHER_ID_CHACHA20,
- NULL,
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_OFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_XTS)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_STREAM)
- chacha20_stream_wrap,
- #endif
- chacha20_setkey_wrap,
- chacha20_setkey_wrap,
- chacha20_ctx_alloc,
- chacha20_ctx_free
- };
- static const mbedtls_cipher_info_t chacha20_info = {
- MBEDTLS_CIPHER_CHACHA20,
- MBEDTLS_MODE_STREAM,
- 256,
- "CHACHA20",
- 12,
- 0,
- 1,
- &chacha20_base_info
- };
- #endif /* MBEDTLS_CHACHA20_C */
- #if defined(MBEDTLS_CHACHAPOLY_C)
- static int chachapoly_setkey_wrap( void *ctx,
- const unsigned char *key,
- unsigned int key_bitlen )
- {
- if( key_bitlen != 256U )
- return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
- if ( 0 != mbedtls_chachapoly_setkey( (mbedtls_chachapoly_context*)ctx, key ) )
- return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
- return( 0 );
- }
- static void * chachapoly_ctx_alloc( void )
- {
- mbedtls_chachapoly_context *ctx;
- ctx = mbedtls_calloc( 1, sizeof( mbedtls_chachapoly_context ) );
- if( ctx == NULL )
- return( NULL );
- mbedtls_chachapoly_init( ctx );
- return( ctx );
- }
- static void chachapoly_ctx_free( void *ctx )
- {
- mbedtls_chachapoly_free( (mbedtls_chachapoly_context *) ctx );
- mbedtls_free( ctx );
- }
- static const mbedtls_cipher_base_t chachapoly_base_info = {
- MBEDTLS_CIPHER_ID_CHACHA20,
- NULL,
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_OFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_XTS)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_STREAM)
- NULL,
- #endif
- chachapoly_setkey_wrap,
- chachapoly_setkey_wrap,
- chachapoly_ctx_alloc,
- chachapoly_ctx_free
- };
- static const mbedtls_cipher_info_t chachapoly_info = {
- MBEDTLS_CIPHER_CHACHA20_POLY1305,
- MBEDTLS_MODE_CHACHAPOLY,
- 256,
- "CHACHA20-POLY1305",
- 12,
- 0,
- 1,
- &chachapoly_base_info
- };
- #endif /* MBEDTLS_CHACHAPOLY_C */
- #if defined(MBEDTLS_CIPHER_NULL_CIPHER)
- static int null_crypt_stream( void *ctx, size_t length,
- const unsigned char *input,
- unsigned char *output )
- {
- ((void) ctx);
- memmove( output, input, length );
- return( 0 );
- }
- static int null_setkey( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- ((void) ctx);
- ((void) key);
- ((void) key_bitlen);
- return( 0 );
- }
- static void * null_ctx_alloc( void )
- {
- return( (void *) 1 );
- }
- static void null_ctx_free( void *ctx )
- {
- ((void) ctx);
- }
- static const mbedtls_cipher_base_t null_base_info = {
- MBEDTLS_CIPHER_ID_NULL,
- NULL,
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_OFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_XTS)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_STREAM)
- null_crypt_stream,
- #endif
- null_setkey,
- null_setkey,
- null_ctx_alloc,
- null_ctx_free
- };
- static const mbedtls_cipher_info_t null_cipher_info = {
- MBEDTLS_CIPHER_NULL,
- MBEDTLS_MODE_STREAM,
- 0,
- "NULL",
- 0,
- 0,
- 1,
- &null_base_info
- };
- #endif /* defined(MBEDTLS_CIPHER_NULL_CIPHER) */
- #if defined(MBEDTLS_NIST_KW_C)
- static void *kw_ctx_alloc( void )
- {
- void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_nist_kw_context ) );
- if( ctx != NULL )
- mbedtls_nist_kw_init( (mbedtls_nist_kw_context *) ctx );
- return( ctx );
- }
- static void kw_ctx_free( void *ctx )
- {
- mbedtls_nist_kw_free( ctx );
- mbedtls_free( ctx );
- }
- static int kw_aes_setkey_wrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- return mbedtls_nist_kw_setkey( (mbedtls_nist_kw_context *) ctx,
- MBEDTLS_CIPHER_ID_AES, key, key_bitlen, 1 );
- }
- static int kw_aes_setkey_unwrap( void *ctx, const unsigned char *key,
- unsigned int key_bitlen )
- {
- return mbedtls_nist_kw_setkey( (mbedtls_nist_kw_context *) ctx,
- MBEDTLS_CIPHER_ID_AES, key, key_bitlen, 0 );
- }
- static const mbedtls_cipher_base_t kw_aes_info = {
- MBEDTLS_CIPHER_ID_AES,
- NULL,
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_OFB)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_XTS)
- NULL,
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_STREAM)
- NULL,
- #endif
- kw_aes_setkey_wrap,
- kw_aes_setkey_unwrap,
- kw_ctx_alloc,
- kw_ctx_free,
- };
- static const mbedtls_cipher_info_t aes_128_nist_kw_info = {
- MBEDTLS_CIPHER_AES_128_KW,
- MBEDTLS_MODE_KW,
- 128,
- "AES-128-KW",
- 0,
- 0,
- 16,
- &kw_aes_info
- };
- static const mbedtls_cipher_info_t aes_192_nist_kw_info = {
- MBEDTLS_CIPHER_AES_192_KW,
- MBEDTLS_MODE_KW,
- 192,
- "AES-192-KW",
- 0,
- 0,
- 16,
- &kw_aes_info
- };
- static const mbedtls_cipher_info_t aes_256_nist_kw_info = {
- MBEDTLS_CIPHER_AES_256_KW,
- MBEDTLS_MODE_KW,
- 256,
- "AES-256-KW",
- 0,
- 0,
- 16,
- &kw_aes_info
- };
- static const mbedtls_cipher_info_t aes_128_nist_kwp_info = {
- MBEDTLS_CIPHER_AES_128_KWP,
- MBEDTLS_MODE_KWP,
- 128,
- "AES-128-KWP",
- 0,
- 0,
- 16,
- &kw_aes_info
- };
- static const mbedtls_cipher_info_t aes_192_nist_kwp_info = {
- MBEDTLS_CIPHER_AES_192_KWP,
- MBEDTLS_MODE_KWP,
- 192,
- "AES-192-KWP",
- 0,
- 0,
- 16,
- &kw_aes_info
- };
- static const mbedtls_cipher_info_t aes_256_nist_kwp_info = {
- MBEDTLS_CIPHER_AES_256_KWP,
- MBEDTLS_MODE_KWP,
- 256,
- "AES-256-KWP",
- 0,
- 0,
- 16,
- &kw_aes_info
- };
- #endif /* MBEDTLS_NIST_KW_C */
- const mbedtls_cipher_definition_t mbedtls_cipher_definitions[] =
- {
- #if defined(MBEDTLS_AES_C)
- { MBEDTLS_CIPHER_AES_128_ECB, &aes_128_ecb_info },
- { MBEDTLS_CIPHER_AES_192_ECB, &aes_192_ecb_info },
- { MBEDTLS_CIPHER_AES_256_ECB, &aes_256_ecb_info },
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- { MBEDTLS_CIPHER_AES_128_CBC, &aes_128_cbc_info },
- { MBEDTLS_CIPHER_AES_192_CBC, &aes_192_cbc_info },
- { MBEDTLS_CIPHER_AES_256_CBC, &aes_256_cbc_info },
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- { MBEDTLS_CIPHER_AES_128_CFB128, &aes_128_cfb128_info },
- { MBEDTLS_CIPHER_AES_192_CFB128, &aes_192_cfb128_info },
- { MBEDTLS_CIPHER_AES_256_CFB128, &aes_256_cfb128_info },
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_OFB)
- { MBEDTLS_CIPHER_AES_128_OFB, &aes_128_ofb_info },
- { MBEDTLS_CIPHER_AES_192_OFB, &aes_192_ofb_info },
- { MBEDTLS_CIPHER_AES_256_OFB, &aes_256_ofb_info },
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- { MBEDTLS_CIPHER_AES_128_CTR, &aes_128_ctr_info },
- { MBEDTLS_CIPHER_AES_192_CTR, &aes_192_ctr_info },
- { MBEDTLS_CIPHER_AES_256_CTR, &aes_256_ctr_info },
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_XTS)
- { MBEDTLS_CIPHER_AES_128_XTS, &aes_128_xts_info },
- { MBEDTLS_CIPHER_AES_256_XTS, &aes_256_xts_info },
- #endif
- #if defined(MBEDTLS_GCM_C)
- { MBEDTLS_CIPHER_AES_128_GCM, &aes_128_gcm_info },
- { MBEDTLS_CIPHER_AES_192_GCM, &aes_192_gcm_info },
- { MBEDTLS_CIPHER_AES_256_GCM, &aes_256_gcm_info },
- #endif
- #if defined(MBEDTLS_CCM_C)
- { MBEDTLS_CIPHER_AES_128_CCM, &aes_128_ccm_info },
- { MBEDTLS_CIPHER_AES_192_CCM, &aes_192_ccm_info },
- { MBEDTLS_CIPHER_AES_256_CCM, &aes_256_ccm_info },
- { MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG, &aes_128_ccm_star_no_tag_info },
- { MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG, &aes_192_ccm_star_no_tag_info },
- { MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG, &aes_256_ccm_star_no_tag_info },
- #endif
- #endif /* MBEDTLS_AES_C */
- #if defined(MBEDTLS_CAMELLIA_C)
- { MBEDTLS_CIPHER_CAMELLIA_128_ECB, &camellia_128_ecb_info },
- { MBEDTLS_CIPHER_CAMELLIA_192_ECB, &camellia_192_ecb_info },
- { MBEDTLS_CIPHER_CAMELLIA_256_ECB, &camellia_256_ecb_info },
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- { MBEDTLS_CIPHER_CAMELLIA_128_CBC, &camellia_128_cbc_info },
- { MBEDTLS_CIPHER_CAMELLIA_192_CBC, &camellia_192_cbc_info },
- { MBEDTLS_CIPHER_CAMELLIA_256_CBC, &camellia_256_cbc_info },
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- { MBEDTLS_CIPHER_CAMELLIA_128_CFB128, &camellia_128_cfb128_info },
- { MBEDTLS_CIPHER_CAMELLIA_192_CFB128, &camellia_192_cfb128_info },
- { MBEDTLS_CIPHER_CAMELLIA_256_CFB128, &camellia_256_cfb128_info },
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- { MBEDTLS_CIPHER_CAMELLIA_128_CTR, &camellia_128_ctr_info },
- { MBEDTLS_CIPHER_CAMELLIA_192_CTR, &camellia_192_ctr_info },
- { MBEDTLS_CIPHER_CAMELLIA_256_CTR, &camellia_256_ctr_info },
- #endif
- #if defined(MBEDTLS_GCM_C)
- { MBEDTLS_CIPHER_CAMELLIA_128_GCM, &camellia_128_gcm_info },
- { MBEDTLS_CIPHER_CAMELLIA_192_GCM, &camellia_192_gcm_info },
- { MBEDTLS_CIPHER_CAMELLIA_256_GCM, &camellia_256_gcm_info },
- #endif
- #if defined(MBEDTLS_CCM_C)
- { MBEDTLS_CIPHER_CAMELLIA_128_CCM, &camellia_128_ccm_info },
- { MBEDTLS_CIPHER_CAMELLIA_192_CCM, &camellia_192_ccm_info },
- { MBEDTLS_CIPHER_CAMELLIA_256_CCM, &camellia_256_ccm_info },
- { MBEDTLS_CIPHER_CAMELLIA_128_CCM_STAR_NO_TAG, &camellia_128_ccm_star_no_tag_info },
- { MBEDTLS_CIPHER_CAMELLIA_192_CCM_STAR_NO_TAG, &camellia_192_ccm_star_no_tag_info },
- { MBEDTLS_CIPHER_CAMELLIA_256_CCM_STAR_NO_TAG, &camellia_256_ccm_star_no_tag_info },
- #endif
- #endif /* MBEDTLS_CAMELLIA_C */
- #if defined(MBEDTLS_ARIA_C)
- { MBEDTLS_CIPHER_ARIA_128_ECB, &aria_128_ecb_info },
- { MBEDTLS_CIPHER_ARIA_192_ECB, &aria_192_ecb_info },
- { MBEDTLS_CIPHER_ARIA_256_ECB, &aria_256_ecb_info },
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- { MBEDTLS_CIPHER_ARIA_128_CBC, &aria_128_cbc_info },
- { MBEDTLS_CIPHER_ARIA_192_CBC, &aria_192_cbc_info },
- { MBEDTLS_CIPHER_ARIA_256_CBC, &aria_256_cbc_info },
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CFB)
- { MBEDTLS_CIPHER_ARIA_128_CFB128, &aria_128_cfb128_info },
- { MBEDTLS_CIPHER_ARIA_192_CFB128, &aria_192_cfb128_info },
- { MBEDTLS_CIPHER_ARIA_256_CFB128, &aria_256_cfb128_info },
- #endif
- #if defined(MBEDTLS_CIPHER_MODE_CTR)
- { MBEDTLS_CIPHER_ARIA_128_CTR, &aria_128_ctr_info },
- { MBEDTLS_CIPHER_ARIA_192_CTR, &aria_192_ctr_info },
- { MBEDTLS_CIPHER_ARIA_256_CTR, &aria_256_ctr_info },
- #endif
- #if defined(MBEDTLS_GCM_C)
- { MBEDTLS_CIPHER_ARIA_128_GCM, &aria_128_gcm_info },
- { MBEDTLS_CIPHER_ARIA_192_GCM, &aria_192_gcm_info },
- { MBEDTLS_CIPHER_ARIA_256_GCM, &aria_256_gcm_info },
- #endif
- #if defined(MBEDTLS_CCM_C)
- { MBEDTLS_CIPHER_ARIA_128_CCM, &aria_128_ccm_info },
- { MBEDTLS_CIPHER_ARIA_192_CCM, &aria_192_ccm_info },
- { MBEDTLS_CIPHER_ARIA_256_CCM, &aria_256_ccm_info },
- { MBEDTLS_CIPHER_ARIA_128_CCM_STAR_NO_TAG, &aria_128_ccm_star_no_tag_info },
- { MBEDTLS_CIPHER_ARIA_192_CCM_STAR_NO_TAG, &aria_192_ccm_star_no_tag_info },
- { MBEDTLS_CIPHER_ARIA_256_CCM_STAR_NO_TAG, &aria_256_ccm_star_no_tag_info },
- #endif
- #endif /* MBEDTLS_ARIA_C */
- #if defined(MBEDTLS_DES_C)
- { MBEDTLS_CIPHER_DES_ECB, &des_ecb_info },
- { MBEDTLS_CIPHER_DES_EDE_ECB, &des_ede_ecb_info },
- { MBEDTLS_CIPHER_DES_EDE3_ECB, &des_ede3_ecb_info },
- #if defined(MBEDTLS_CIPHER_MODE_CBC)
- { MBEDTLS_CIPHER_DES_CBC, &des_cbc_info },
- { MBEDTLS_CIPHER_DES_EDE_CBC, &des_ede_cbc_info },
- { MBEDTLS_CIPHER_DES_EDE3_CBC, &des_ede3_cbc_info },
- #endif
- #endif /* MBEDTLS_DES_C */
- #if defined(MBEDTLS_CHACHA20_C)
- { MBEDTLS_CIPHER_CHACHA20, &chacha20_info },
- #endif
- #if defined(MBEDTLS_CHACHAPOLY_C)
- { MBEDTLS_CIPHER_CHACHA20_POLY1305, &chachapoly_info },
- #endif
- #if defined(MBEDTLS_NIST_KW_C)
- { MBEDTLS_CIPHER_AES_128_KW, &aes_128_nist_kw_info },
- { MBEDTLS_CIPHER_AES_192_KW, &aes_192_nist_kw_info },
- { MBEDTLS_CIPHER_AES_256_KW, &aes_256_nist_kw_info },
- { MBEDTLS_CIPHER_AES_128_KWP, &aes_128_nist_kwp_info },
- { MBEDTLS_CIPHER_AES_192_KWP, &aes_192_nist_kwp_info },
- { MBEDTLS_CIPHER_AES_256_KWP, &aes_256_nist_kwp_info },
- #endif
- #if defined(MBEDTLS_CIPHER_NULL_CIPHER)
- { MBEDTLS_CIPHER_NULL, &null_cipher_info },
- #endif /* MBEDTLS_CIPHER_NULL_CIPHER */
- { MBEDTLS_CIPHER_NONE, NULL }
- };
- #define NUM_CIPHERS ( sizeof(mbedtls_cipher_definitions) / \
- sizeof(mbedtls_cipher_definitions[0]) )
- int mbedtls_cipher_supported[NUM_CIPHERS];
- #endif /* MBEDTLS_CIPHER_C */
|