blob: e80a3655a7c82bc1f9ba125f7eea0284046d771f [file] [log] [blame]
Paul Bakker8123e9d2011-01-06 15:37:30 +00001/**
Paul Bakkerfae35f02013-03-13 10:33:51 +01002 * \file cipher_wrap.c
Paul Bakker9af723c2014-05-01 13:03:14 +02003 *
Paul Bakker20281562011-11-11 10:34:04 +00004 * \brief Generic cipher wrapper for PolarSSL
Paul Bakker8123e9d2011-01-06 15:37:30 +00005 *
6 * \author Adriaan de Jong <dejong@fox-it.com>
7 *
Paul Bakker7dc4c442014-02-01 22:50:26 +01008 * Copyright (C) 2006-2014, Brainspark B.V.
Paul Bakker8123e9d2011-01-06 15:37:30 +00009 *
10 * This file is part of PolarSSL (http://www.polarssl.org)
11 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
12 *
13 * All rights reserved.
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License along
26 * with this program; if not, write to the Free Software Foundation, Inc.,
27 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 */
29
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020030#if !defined(POLARSSL_CONFIG_FILE)
Paul Bakker8123e9d2011-01-06 15:37:30 +000031#include "polarssl/config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020032#else
33#include POLARSSL_CONFIG_FILE
34#endif
Paul Bakker8123e9d2011-01-06 15:37:30 +000035
36#if defined(POLARSSL_CIPHER_C)
37
38#include "polarssl/cipher_wrap.h"
Paul Bakkerf6543712012-03-05 14:01:29 +000039
40#if defined(POLARSSL_AES_C)
Paul Bakker8123e9d2011-01-06 15:37:30 +000041#include "polarssl/aes.h"
Paul Bakkerf6543712012-03-05 14:01:29 +000042#endif
43
Manuel Pégourié-Gonnard37e230c2013-08-28 13:50:42 +020044#if defined(POLARSSL_ARC4_C)
45#include "polarssl/arc4.h"
46#endif
47
Paul Bakkerf6543712012-03-05 14:01:29 +000048#if defined(POLARSSL_CAMELLIA_C)
Paul Bakker8123e9d2011-01-06 15:37:30 +000049#include "polarssl/camellia.h"
Paul Bakkerf6543712012-03-05 14:01:29 +000050#endif
51
52#if defined(POLARSSL_DES_C)
Paul Bakker8123e9d2011-01-06 15:37:30 +000053#include "polarssl/des.h"
Paul Bakker02f61692012-03-15 10:54:25 +000054#endif
Paul Bakker8123e9d2011-01-06 15:37:30 +000055
Paul Bakker6132d0a2012-07-04 17:10:40 +000056#if defined(POLARSSL_BLOWFISH_C)
57#include "polarssl/blowfish.h"
58#endif
59
Manuel Pégourié-Gonnard07f8fa52013-08-30 18:34:08 +020060#if defined(POLARSSL_GCM_C)
61#include "polarssl/gcm.h"
62#endif
63
Manuel Pégourié-Gonnard41936952014-05-13 13:18:17 +020064#if defined(POLARSSL_CCM_C)
65#include "polarssl/ccm.h"
66#endif
67
Paul Bakker7dc4c442014-02-01 22:50:26 +010068#if defined(POLARSSL_PLATFORM_C)
69#include "polarssl/platform.h"
Paul Bakker6e339b52013-07-03 13:37:05 +020070#else
71#define polarssl_malloc malloc
72#define polarssl_free free
73#endif
74
Paul Bakker8123e9d2011-01-06 15:37:30 +000075#include <stdlib.h>
76
Manuel Pégourié-Gonnard87181d12013-10-24 14:02:40 +020077#if defined(POLARSSL_GCM_C)
78/* shared by all GCM ciphers */
79static void *gcm_ctx_alloc( void )
80{
81 return polarssl_malloc( sizeof( gcm_context ) );
82}
83
84static void gcm_ctx_free( void *ctx )
85{
86 gcm_free( ctx );
87 polarssl_free( ctx );
88}
Paul Bakker9af723c2014-05-01 13:03:14 +020089#endif /* POLARSSL_GCM_C */
Manuel Pégourié-Gonnard87181d12013-10-24 14:02:40 +020090
Manuel Pégourié-Gonnard41936952014-05-13 13:18:17 +020091#if defined(POLARSSL_CCM_C)
92/* shared by all CCM ciphers */
93static void *ccm_ctx_alloc( void )
94{
95 return polarssl_malloc( sizeof( ccm_context ) );
96}
97
98static void ccm_ctx_free( void *ctx )
99{
100 ccm_free( ctx );
101 polarssl_free( ctx );
102}
103#endif /* POLARSSL_CCM_C */
104
Paul Bakker8123e9d2011-01-06 15:37:30 +0000105#if defined(POLARSSL_AES_C)
106
Paul Bakker5e0efa72013-09-08 23:04:04 +0200107static int aes_crypt_ecb_wrap( void *ctx, operation_t operation,
108 const unsigned char *input, unsigned char *output )
109{
110 return aes_crypt_ecb( (aes_context *) ctx, operation, input, output );
111}
112
Paul Bakkerfae35f02013-03-13 10:33:51 +0100113static int aes_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length,
Paul Bakker8123e9d2011-01-06 15:37:30 +0000114 unsigned char *iv, const unsigned char *input, unsigned char *output )
115{
Manuel Pégourié-Gonnard92cb1d32013-09-13 16:24:20 +0200116#if defined(POLARSSL_CIPHER_MODE_CBC)
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200117 return aes_crypt_cbc( (aes_context *) ctx, operation, length, iv, input,
118 output );
Manuel Pégourié-Gonnard92cb1d32013-09-13 16:24:20 +0200119#else
120 ((void) ctx);
121 ((void) operation);
122 ((void) length);
123 ((void) iv);
124 ((void) input);
125 ((void) output);
126
127 return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
128#endif /* POLARSSL_CIPHER_MODE_CBC */
Paul Bakker8123e9d2011-01-06 15:37:30 +0000129}
130
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200131static int aes_crypt_cfb128_wrap( void *ctx, operation_t operation,
132 size_t length, size_t *iv_off, unsigned char *iv,
133 const unsigned char *input, unsigned char *output )
Paul Bakker343a8702011-06-09 14:27:58 +0000134{
135#if defined(POLARSSL_CIPHER_MODE_CFB)
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200136 return aes_crypt_cfb128( (aes_context *) ctx, operation, length, iv_off, iv,
137 input, output );
Paul Bakker343a8702011-06-09 14:27:58 +0000138#else
139 ((void) ctx);
140 ((void) operation);
141 ((void) length);
142 ((void) iv_off);
143 ((void) iv);
144 ((void) input);
145 ((void) output);
146
147 return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
Paul Bakker9af723c2014-05-01 13:03:14 +0200148#endif /* POLARSSL_CIPHER_MODE_CFB */
Paul Bakker343a8702011-06-09 14:27:58 +0000149}
150
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200151static int aes_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
152 unsigned char *nonce_counter, unsigned char *stream_block,
Paul Bakker343a8702011-06-09 14:27:58 +0000153 const unsigned char *input, unsigned char *output )
154{
155#if defined(POLARSSL_CIPHER_MODE_CTR)
156 return aes_crypt_ctr( (aes_context *) ctx, length, nc_off, nonce_counter,
157 stream_block, input, output );
158#else
159 ((void) ctx);
160 ((void) length);
161 ((void) nc_off);
162 ((void) nonce_counter);
163 ((void) stream_block);
164 ((void) input);
165 ((void) output);
166
167 return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
Paul Bakker9af723c2014-05-01 13:03:14 +0200168#endif /* POLARSSL_CIPHER_MODE_CTR */
Paul Bakker343a8702011-06-09 14:27:58 +0000169}
170
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200171static int aes_setkey_dec_wrap( void *ctx, const unsigned char *key,
172 unsigned int key_length )
Paul Bakker8123e9d2011-01-06 15:37:30 +0000173{
174 return aes_setkey_dec( (aes_context *) ctx, key, key_length );
175}
176
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200177static int aes_setkey_enc_wrap( void *ctx, const unsigned char *key,
178 unsigned int key_length )
Paul Bakker8123e9d2011-01-06 15:37:30 +0000179{
180 return aes_setkey_enc( (aes_context *) ctx, key, key_length );
181}
182
183static void * aes_ctx_alloc( void )
184{
Paul Bakker6e339b52013-07-03 13:37:05 +0200185 return polarssl_malloc( sizeof( aes_context ) );
Paul Bakker8123e9d2011-01-06 15:37:30 +0000186}
187
188static void aes_ctx_free( void *ctx )
189{
Paul Bakker6e339b52013-07-03 13:37:05 +0200190 polarssl_free( ctx );
Paul Bakker8123e9d2011-01-06 15:37:30 +0000191}
192
Paul Bakker343a8702011-06-09 14:27:58 +0000193const cipher_base_t aes_info = {
194 POLARSSL_CIPHER_ID_AES,
Paul Bakker5e0efa72013-09-08 23:04:04 +0200195 aes_crypt_ecb_wrap,
Paul Bakker343a8702011-06-09 14:27:58 +0000196 aes_crypt_cbc_wrap,
197 aes_crypt_cfb128_wrap,
198 aes_crypt_ctr_wrap,
Manuel Pégourié-Gonnard37e230c2013-08-28 13:50:42 +0200199 NULL,
Paul Bakker343a8702011-06-09 14:27:58 +0000200 aes_setkey_enc_wrap,
201 aes_setkey_dec_wrap,
202 aes_ctx_alloc,
203 aes_ctx_free
204};
205
Paul Bakker5e0efa72013-09-08 23:04:04 +0200206const cipher_info_t aes_128_ecb_info = {
207 POLARSSL_CIPHER_AES_128_ECB,
208 POLARSSL_MODE_ECB,
209 128,
210 "AES-128-ECB",
211 16,
212 0,
213 16,
214 &aes_info
215};
216
217const cipher_info_t aes_192_ecb_info = {
218 POLARSSL_CIPHER_AES_192_ECB,
219 POLARSSL_MODE_ECB,
220 192,
221 "AES-192-ECB",
222 16,
223 0,
224 16,
225 &aes_info
226};
227
228const cipher_info_t aes_256_ecb_info = {
229 POLARSSL_CIPHER_AES_256_ECB,
230 POLARSSL_MODE_ECB,
231 256,
232 "AES-256-ECB",
233 16,
234 0,
235 16,
236 &aes_info
237};
238
Manuel Pégourié-Gonnard989ed382013-09-13 14:41:45 +0200239#if defined(POLARSSL_CIPHER_MODE_CBC)
Paul Bakker8123e9d2011-01-06 15:37:30 +0000240const cipher_info_t aes_128_cbc_info = {
Paul Bakker23986e52011-04-24 08:57:21 +0000241 POLARSSL_CIPHER_AES_128_CBC,
Paul Bakker23986e52011-04-24 08:57:21 +0000242 POLARSSL_MODE_CBC,
243 128,
244 "AES-128-CBC",
245 16,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +0200246 0,
Paul Bakker23986e52011-04-24 08:57:21 +0000247 16,
Paul Bakker343a8702011-06-09 14:27:58 +0000248 &aes_info
Paul Bakker8123e9d2011-01-06 15:37:30 +0000249};
250
251const cipher_info_t aes_192_cbc_info = {
Paul Bakker23986e52011-04-24 08:57:21 +0000252 POLARSSL_CIPHER_AES_192_CBC,
Paul Bakker23986e52011-04-24 08:57:21 +0000253 POLARSSL_MODE_CBC,
254 192,
255 "AES-192-CBC",
256 16,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +0200257 0,
Paul Bakker23986e52011-04-24 08:57:21 +0000258 16,
Paul Bakker343a8702011-06-09 14:27:58 +0000259 &aes_info
Paul Bakker8123e9d2011-01-06 15:37:30 +0000260};
261
262const cipher_info_t aes_256_cbc_info = {
Paul Bakker23986e52011-04-24 08:57:21 +0000263 POLARSSL_CIPHER_AES_256_CBC,
Paul Bakker23986e52011-04-24 08:57:21 +0000264 POLARSSL_MODE_CBC,
265 256,
266 "AES-256-CBC",
267 16,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +0200268 0,
Paul Bakker23986e52011-04-24 08:57:21 +0000269 16,
Paul Bakker343a8702011-06-09 14:27:58 +0000270 &aes_info
Paul Bakker8123e9d2011-01-06 15:37:30 +0000271};
Manuel Pégourié-Gonnard989ed382013-09-13 14:41:45 +0200272#endif /* POLARSSL_CIPHER_MODE_CBC */
Paul Bakker343a8702011-06-09 14:27:58 +0000273
274#if defined(POLARSSL_CIPHER_MODE_CFB)
275const cipher_info_t aes_128_cfb128_info = {
276 POLARSSL_CIPHER_AES_128_CFB128,
Paul Bakker6132d0a2012-07-04 17:10:40 +0000277 POLARSSL_MODE_CFB,
Paul Bakker343a8702011-06-09 14:27:58 +0000278 128,
279 "AES-128-CFB128",
280 16,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +0200281 0,
Paul Bakker343a8702011-06-09 14:27:58 +0000282 16,
283 &aes_info
284};
285
286const cipher_info_t aes_192_cfb128_info = {
287 POLARSSL_CIPHER_AES_192_CFB128,
Paul Bakker6132d0a2012-07-04 17:10:40 +0000288 POLARSSL_MODE_CFB,
Paul Bakker343a8702011-06-09 14:27:58 +0000289 192,
290 "AES-192-CFB128",
291 16,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +0200292 0,
Paul Bakker343a8702011-06-09 14:27:58 +0000293 16,
294 &aes_info
295};
296
297const cipher_info_t aes_256_cfb128_info = {
298 POLARSSL_CIPHER_AES_256_CFB128,
Paul Bakker6132d0a2012-07-04 17:10:40 +0000299 POLARSSL_MODE_CFB,
Paul Bakker343a8702011-06-09 14:27:58 +0000300 256,
301 "AES-256-CFB128",
302 16,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +0200303 0,
Paul Bakker343a8702011-06-09 14:27:58 +0000304 16,
305 &aes_info
306};
307#endif /* POLARSSL_CIPHER_MODE_CFB */
308
309#if defined(POLARSSL_CIPHER_MODE_CTR)
310const cipher_info_t aes_128_ctr_info = {
311 POLARSSL_CIPHER_AES_128_CTR,
312 POLARSSL_MODE_CTR,
313 128,
314 "AES-128-CTR",
315 16,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +0200316 0,
Paul Bakker343a8702011-06-09 14:27:58 +0000317 16,
318 &aes_info
319};
320
321const cipher_info_t aes_192_ctr_info = {
322 POLARSSL_CIPHER_AES_192_CTR,
323 POLARSSL_MODE_CTR,
324 192,
325 "AES-192-CTR",
326 16,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +0200327 0,
Paul Bakker343a8702011-06-09 14:27:58 +0000328 16,
329 &aes_info
330};
331
332const cipher_info_t aes_256_ctr_info = {
333 POLARSSL_CIPHER_AES_256_CTR,
334 POLARSSL_MODE_CTR,
335 256,
336 "AES-256-CTR",
337 16,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +0200338 0,
Paul Bakker343a8702011-06-09 14:27:58 +0000339 16,
340 &aes_info
341};
342#endif /* POLARSSL_CIPHER_MODE_CTR */
343
Paul Bakker68884e32013-01-07 18:20:04 +0100344#if defined(POLARSSL_GCM_C)
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200345static int gcm_aes_setkey_wrap( void *ctx, const unsigned char *key,
346 unsigned int key_length )
Manuel Pégourié-Gonnard07f8fa52013-08-30 18:34:08 +0200347{
Paul Bakker43aff2a2013-09-09 00:10:27 +0200348 return gcm_init( (gcm_context *) ctx, POLARSSL_CIPHER_ID_AES,
349 key, key_length );
Manuel Pégourié-Gonnard07f8fa52013-08-30 18:34:08 +0200350}
351
352const cipher_base_t gcm_aes_info = {
353 POLARSSL_CIPHER_ID_AES,
354 NULL,
355 NULL,
356 NULL,
357 NULL,
Paul Bakker5e0efa72013-09-08 23:04:04 +0200358 NULL,
Paul Bakker43aff2a2013-09-09 00:10:27 +0200359 gcm_aes_setkey_wrap,
360 gcm_aes_setkey_wrap,
Manuel Pégourié-Gonnard07f8fa52013-08-30 18:34:08 +0200361 gcm_ctx_alloc,
362 gcm_ctx_free,
363};
364
Paul Bakker68884e32013-01-07 18:20:04 +0100365const cipher_info_t aes_128_gcm_info = {
366 POLARSSL_CIPHER_AES_128_GCM,
367 POLARSSL_MODE_GCM,
368 128,
369 "AES-128-GCM",
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +0200370 12,
371 1,
Paul Bakker68884e32013-01-07 18:20:04 +0100372 16,
Manuel Pégourié-Gonnard07f8fa52013-08-30 18:34:08 +0200373 &gcm_aes_info
Paul Bakker68884e32013-01-07 18:20:04 +0100374};
375
Manuel Pégourié-Gonnard83f3fc02013-09-04 12:07:24 +0200376const cipher_info_t aes_192_gcm_info = {
377 POLARSSL_CIPHER_AES_192_GCM,
378 POLARSSL_MODE_GCM,
379 192,
380 "AES-192-GCM",
381 12,
382 1,
383 16,
384 &gcm_aes_info
385};
386
Paul Bakker68884e32013-01-07 18:20:04 +0100387const cipher_info_t aes_256_gcm_info = {
388 POLARSSL_CIPHER_AES_256_GCM,
389 POLARSSL_MODE_GCM,
390 256,
391 "AES-256-GCM",
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +0200392 12,
393 1,
Paul Bakker68884e32013-01-07 18:20:04 +0100394 16,
Manuel Pégourié-Gonnard07f8fa52013-08-30 18:34:08 +0200395 &gcm_aes_info
Paul Bakker68884e32013-01-07 18:20:04 +0100396};
397#endif /* POLARSSL_GCM_C */
398
Manuel Pégourié-Gonnard41936952014-05-13 13:18:17 +0200399#if defined(POLARSSL_CCM_C)
400static int ccm_aes_setkey_wrap( void *ctx, const unsigned char *key,
401 unsigned int key_length )
402{
403 return ccm_init( (ccm_context *) ctx, POLARSSL_CIPHER_ID_AES,
404 key, key_length );
405}
406
407const cipher_base_t ccm_aes_info = {
408 POLARSSL_CIPHER_ID_AES,
409 NULL,
410 NULL,
411 NULL,
412 NULL,
413 NULL,
414 ccm_aes_setkey_wrap,
415 ccm_aes_setkey_wrap,
416 ccm_ctx_alloc,
417 ccm_ctx_free,
418};
419
420const cipher_info_t aes_128_ccm_info = {
421 POLARSSL_CIPHER_AES_128_CCM,
422 POLARSSL_MODE_CCM,
423 128,
424 "AES-128-CCM",
425 12,
426 1,
427 16,
428 &ccm_aes_info
429};
430
431const cipher_info_t aes_192_ccm_info = {
432 POLARSSL_CIPHER_AES_192_CCM,
433 POLARSSL_MODE_CCM,
434 192,
435 "AES-192-CCM",
436 12,
437 1,
438 16,
439 &ccm_aes_info
440};
441
442const cipher_info_t aes_256_ccm_info = {
443 POLARSSL_CIPHER_AES_256_CCM,
444 POLARSSL_MODE_CCM,
445 256,
446 "AES-256-CCM",
447 12,
448 1,
449 16,
450 &ccm_aes_info
451};
452#endif /* POLARSSL_CCM_C */
453
Paul Bakker9af723c2014-05-01 13:03:14 +0200454#endif /* POLARSSL_AES_C */
Paul Bakker8123e9d2011-01-06 15:37:30 +0000455
456#if defined(POLARSSL_CAMELLIA_C)
457
Paul Bakker5e0efa72013-09-08 23:04:04 +0200458static int camellia_crypt_ecb_wrap( void *ctx, operation_t operation,
459 const unsigned char *input, unsigned char *output )
460{
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200461 return camellia_crypt_ecb( (camellia_context *) ctx, operation, input,
462 output );
Paul Bakker5e0efa72013-09-08 23:04:04 +0200463}
464
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200465static int camellia_crypt_cbc_wrap( void *ctx, operation_t operation,
466 size_t length, unsigned char *iv,
467 const unsigned char *input, unsigned char *output )
Paul Bakker8123e9d2011-01-06 15:37:30 +0000468{
Manuel Pégourié-Gonnard92cb1d32013-09-13 16:24:20 +0200469#if defined(POLARSSL_CIPHER_MODE_CBC)
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200470 return camellia_crypt_cbc( (camellia_context *) ctx, operation, length, iv,
471 input, output );
Manuel Pégourié-Gonnard92cb1d32013-09-13 16:24:20 +0200472#else
473 ((void) ctx);
474 ((void) operation);
475 ((void) length);
476 ((void) iv);
477 ((void) input);
478 ((void) output);
479
480 return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
481#endif /* POLARSSL_CIPHER_MODE_CBC */
Paul Bakker8123e9d2011-01-06 15:37:30 +0000482}
483
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200484static int camellia_crypt_cfb128_wrap( void *ctx, operation_t operation,
485 size_t length, size_t *iv_off, unsigned char *iv,
486 const unsigned char *input, unsigned char *output )
Paul Bakker343a8702011-06-09 14:27:58 +0000487{
488#if defined(POLARSSL_CIPHER_MODE_CFB)
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200489 return camellia_crypt_cfb128( (camellia_context *) ctx, operation, length,
490 iv_off, iv, input, output );
Paul Bakker343a8702011-06-09 14:27:58 +0000491#else
492 ((void) ctx);
493 ((void) operation);
494 ((void) length);
495 ((void) iv_off);
496 ((void) iv);
497 ((void) input);
498 ((void) output);
499
500 return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
Paul Bakker9af723c2014-05-01 13:03:14 +0200501#endif /* POLARSSL_CIPHER_MODE_CFB */
Paul Bakker343a8702011-06-09 14:27:58 +0000502}
503
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200504static int camellia_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
505 unsigned char *nonce_counter, unsigned char *stream_block,
Paul Bakker343a8702011-06-09 14:27:58 +0000506 const unsigned char *input, unsigned char *output )
507{
508#if defined(POLARSSL_CIPHER_MODE_CTR)
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200509 return camellia_crypt_ctr( (camellia_context *) ctx, length, nc_off,
510 nonce_counter, stream_block, input, output );
Paul Bakker343a8702011-06-09 14:27:58 +0000511#else
512 ((void) ctx);
513 ((void) length);
514 ((void) nc_off);
515 ((void) nonce_counter);
516 ((void) stream_block);
517 ((void) input);
518 ((void) output);
519
520 return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
Paul Bakker9af723c2014-05-01 13:03:14 +0200521#endif /* POLARSSL_CIPHER_MODE_CTR */
Paul Bakker343a8702011-06-09 14:27:58 +0000522}
523
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200524static int camellia_setkey_dec_wrap( void *ctx, const unsigned char *key,
525 unsigned int key_length )
Paul Bakker8123e9d2011-01-06 15:37:30 +0000526{
527 return camellia_setkey_dec( (camellia_context *) ctx, key, key_length );
528}
529
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200530static int camellia_setkey_enc_wrap( void *ctx, const unsigned char *key,
531 unsigned int key_length )
Paul Bakker8123e9d2011-01-06 15:37:30 +0000532{
533 return camellia_setkey_enc( (camellia_context *) ctx, key, key_length );
534}
535
536static void * camellia_ctx_alloc( void )
537{
Paul Bakker6e339b52013-07-03 13:37:05 +0200538 return polarssl_malloc( sizeof( camellia_context ) );
Paul Bakker8123e9d2011-01-06 15:37:30 +0000539}
540
541static void camellia_ctx_free( void *ctx )
542{
Paul Bakker6e339b52013-07-03 13:37:05 +0200543 polarssl_free( ctx );
Paul Bakker8123e9d2011-01-06 15:37:30 +0000544}
545
Paul Bakker343a8702011-06-09 14:27:58 +0000546const cipher_base_t camellia_info = {
547 POLARSSL_CIPHER_ID_CAMELLIA,
Paul Bakker5e0efa72013-09-08 23:04:04 +0200548 camellia_crypt_ecb_wrap,
Paul Bakker343a8702011-06-09 14:27:58 +0000549 camellia_crypt_cbc_wrap,
550 camellia_crypt_cfb128_wrap,
551 camellia_crypt_ctr_wrap,
Manuel Pégourié-Gonnard37e230c2013-08-28 13:50:42 +0200552 NULL,
Paul Bakker343a8702011-06-09 14:27:58 +0000553 camellia_setkey_enc_wrap,
554 camellia_setkey_dec_wrap,
555 camellia_ctx_alloc,
556 camellia_ctx_free
557};
558
Paul Bakker5e0efa72013-09-08 23:04:04 +0200559const cipher_info_t camellia_128_ecb_info = {
560 POLARSSL_CIPHER_CAMELLIA_128_ECB,
561 POLARSSL_MODE_ECB,
562 128,
563 "CAMELLIA-128-ECB",
564 16,
565 0,
566 16,
567 &camellia_info
568};
569
570const cipher_info_t camellia_192_ecb_info = {
571 POLARSSL_CIPHER_CAMELLIA_192_ECB,
572 POLARSSL_MODE_ECB,
573 192,
574 "CAMELLIA-192-ECB",
575 16,
576 0,
577 16,
578 &camellia_info
579};
580
581const cipher_info_t camellia_256_ecb_info = {
582 POLARSSL_CIPHER_CAMELLIA_256_ECB,
583 POLARSSL_MODE_ECB,
584 256,
585 "CAMELLIA-256-ECB",
586 16,
587 0,
588 16,
589 &camellia_info
590};
591
Manuel Pégourié-Gonnard989ed382013-09-13 14:41:45 +0200592#if defined(POLARSSL_CIPHER_MODE_CBC)
Paul Bakker8123e9d2011-01-06 15:37:30 +0000593const cipher_info_t camellia_128_cbc_info = {
Paul Bakker23986e52011-04-24 08:57:21 +0000594 POLARSSL_CIPHER_CAMELLIA_128_CBC,
Paul Bakker23986e52011-04-24 08:57:21 +0000595 POLARSSL_MODE_CBC,
596 128,
597 "CAMELLIA-128-CBC",
598 16,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +0200599 0,
Paul Bakker23986e52011-04-24 08:57:21 +0000600 16,
Paul Bakker343a8702011-06-09 14:27:58 +0000601 &camellia_info
Paul Bakker8123e9d2011-01-06 15:37:30 +0000602};
603
604const cipher_info_t camellia_192_cbc_info = {
Paul Bakker23986e52011-04-24 08:57:21 +0000605 POLARSSL_CIPHER_CAMELLIA_192_CBC,
Paul Bakker23986e52011-04-24 08:57:21 +0000606 POLARSSL_MODE_CBC,
607 192,
608 "CAMELLIA-192-CBC",
609 16,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +0200610 0,
Paul Bakker23986e52011-04-24 08:57:21 +0000611 16,
Paul Bakker343a8702011-06-09 14:27:58 +0000612 &camellia_info
Paul Bakker8123e9d2011-01-06 15:37:30 +0000613};
614
615const cipher_info_t camellia_256_cbc_info = {
Paul Bakker23986e52011-04-24 08:57:21 +0000616 POLARSSL_CIPHER_CAMELLIA_256_CBC,
Paul Bakker23986e52011-04-24 08:57:21 +0000617 POLARSSL_MODE_CBC,
618 256,
619 "CAMELLIA-256-CBC",
620 16,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +0200621 0,
Paul Bakker23986e52011-04-24 08:57:21 +0000622 16,
Paul Bakker343a8702011-06-09 14:27:58 +0000623 &camellia_info
Paul Bakker8123e9d2011-01-06 15:37:30 +0000624};
Manuel Pégourié-Gonnard989ed382013-09-13 14:41:45 +0200625#endif /* POLARSSL_CIPHER_MODE_CBC */
Paul Bakker343a8702011-06-09 14:27:58 +0000626
627#if defined(POLARSSL_CIPHER_MODE_CFB)
628const cipher_info_t camellia_128_cfb128_info = {
629 POLARSSL_CIPHER_CAMELLIA_128_CFB128,
Paul Bakker6132d0a2012-07-04 17:10:40 +0000630 POLARSSL_MODE_CFB,
Paul Bakker343a8702011-06-09 14:27:58 +0000631 128,
632 "CAMELLIA-128-CFB128",
633 16,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +0200634 0,
Paul Bakker343a8702011-06-09 14:27:58 +0000635 16,
636 &camellia_info
637};
638
639const cipher_info_t camellia_192_cfb128_info = {
640 POLARSSL_CIPHER_CAMELLIA_192_CFB128,
Paul Bakker6132d0a2012-07-04 17:10:40 +0000641 POLARSSL_MODE_CFB,
Paul Bakker343a8702011-06-09 14:27:58 +0000642 192,
643 "CAMELLIA-192-CFB128",
644 16,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +0200645 0,
Paul Bakker343a8702011-06-09 14:27:58 +0000646 16,
647 &camellia_info
648};
649
650const cipher_info_t camellia_256_cfb128_info = {
651 POLARSSL_CIPHER_CAMELLIA_256_CFB128,
Paul Bakker6132d0a2012-07-04 17:10:40 +0000652 POLARSSL_MODE_CFB,
Paul Bakker343a8702011-06-09 14:27:58 +0000653 256,
654 "CAMELLIA-256-CFB128",
655 16,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +0200656 0,
Paul Bakker343a8702011-06-09 14:27:58 +0000657 16,
658 &camellia_info
659};
660#endif /* POLARSSL_CIPHER_MODE_CFB */
661
662#if defined(POLARSSL_CIPHER_MODE_CTR)
663const cipher_info_t camellia_128_ctr_info = {
664 POLARSSL_CIPHER_CAMELLIA_128_CTR,
665 POLARSSL_MODE_CTR,
666 128,
667 "CAMELLIA-128-CTR",
668 16,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +0200669 0,
Paul Bakker343a8702011-06-09 14:27:58 +0000670 16,
671 &camellia_info
672};
673
674const cipher_info_t camellia_192_ctr_info = {
675 POLARSSL_CIPHER_CAMELLIA_192_CTR,
676 POLARSSL_MODE_CTR,
677 192,
678 "CAMELLIA-192-CTR",
679 16,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +0200680 0,
Paul Bakker343a8702011-06-09 14:27:58 +0000681 16,
682 &camellia_info
683};
684
685const cipher_info_t camellia_256_ctr_info = {
686 POLARSSL_CIPHER_CAMELLIA_256_CTR,
687 POLARSSL_MODE_CTR,
688 256,
689 "CAMELLIA-256-CTR",
690 16,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +0200691 0,
Paul Bakker343a8702011-06-09 14:27:58 +0000692 16,
693 &camellia_info
694};
695#endif /* POLARSSL_CIPHER_MODE_CTR */
696
Manuel Pégourié-Gonnard87181d12013-10-24 14:02:40 +0200697#if defined(POLARSSL_GCM_C)
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200698static int gcm_camellia_setkey_wrap( void *ctx, const unsigned char *key,
699 unsigned int key_length )
Manuel Pégourié-Gonnard87181d12013-10-24 14:02:40 +0200700{
701 return gcm_init( (gcm_context *) ctx, POLARSSL_CIPHER_ID_CAMELLIA,
702 key, key_length );
703}
704
705const cipher_base_t gcm_camellia_info = {
706 POLARSSL_CIPHER_ID_CAMELLIA,
707 NULL,
708 NULL,
709 NULL,
710 NULL,
711 NULL,
712 gcm_camellia_setkey_wrap,
713 gcm_camellia_setkey_wrap,
714 gcm_ctx_alloc,
715 gcm_ctx_free,
716};
717
718const cipher_info_t camellia_128_gcm_info = {
719 POLARSSL_CIPHER_CAMELLIA_128_GCM,
720 POLARSSL_MODE_GCM,
721 128,
722 "CAMELLIA-128-GCM",
723 12,
724 1,
725 16,
726 &gcm_camellia_info
727};
728
729const cipher_info_t camellia_192_gcm_info = {
730 POLARSSL_CIPHER_CAMELLIA_192_GCM,
731 POLARSSL_MODE_GCM,
732 192,
733 "CAMELLIA-192-GCM",
734 12,
735 1,
736 16,
737 &gcm_camellia_info
738};
739
740const cipher_info_t camellia_256_gcm_info = {
741 POLARSSL_CIPHER_CAMELLIA_256_GCM,
742 POLARSSL_MODE_GCM,
743 256,
744 "CAMELLIA-256-GCM",
745 12,
746 1,
747 16,
748 &gcm_camellia_info
749};
750#endif /* POLARSSL_GCM_C */
751
Manuel Pégourié-Gonnard41936952014-05-13 13:18:17 +0200752#if defined(POLARSSL_CCM_C)
753static int ccm_camellia_setkey_wrap( void *ctx, const unsigned char *key,
754 unsigned int key_length )
755{
756 return ccm_init( (ccm_context *) ctx, POLARSSL_CIPHER_ID_CAMELLIA,
757 key, key_length );
758}
759
760const cipher_base_t ccm_camellia_info = {
761 POLARSSL_CIPHER_ID_CAMELLIA,
762 NULL,
763 NULL,
764 NULL,
765 NULL,
766 NULL,
767 ccm_camellia_setkey_wrap,
768 ccm_camellia_setkey_wrap,
769 ccm_ctx_alloc,
770 ccm_ctx_free,
771};
772
773const cipher_info_t camellia_128_ccm_info = {
774 POLARSSL_CIPHER_CAMELLIA_128_CCM,
775 POLARSSL_MODE_CCM,
776 128,
777 "CAMELLIA-128-CCM",
778 12,
779 1,
780 16,
781 &ccm_camellia_info
782};
783
784const cipher_info_t camellia_192_ccm_info = {
785 POLARSSL_CIPHER_CAMELLIA_192_CCM,
786 POLARSSL_MODE_CCM,
787 192,
788 "CAMELLIA-192-CCM",
789 12,
790 1,
791 16,
792 &ccm_camellia_info
793};
794
795const cipher_info_t camellia_256_ccm_info = {
796 POLARSSL_CIPHER_CAMELLIA_256_CCM,
797 POLARSSL_MODE_CCM,
798 256,
799 "CAMELLIA-256-CCM",
800 12,
801 1,
802 16,
803 &ccm_camellia_info
804};
805#endif /* POLARSSL_CCM_C */
806
Manuel Pégourié-Gonnard87181d12013-10-24 14:02:40 +0200807#endif /* POLARSSL_CAMELLIA_C */
Paul Bakker8123e9d2011-01-06 15:37:30 +0000808
809#if defined(POLARSSL_DES_C)
810
Paul Bakker5e0efa72013-09-08 23:04:04 +0200811static int des_crypt_ecb_wrap( void *ctx, operation_t operation,
812 const unsigned char *input, unsigned char *output )
813{
814 ((void) operation);
815 return des_crypt_ecb( (des_context *) ctx, input, output );
816}
817
818static int des3_crypt_ecb_wrap( void *ctx, operation_t operation,
819 const unsigned char *input, unsigned char *output )
820{
821 ((void) operation);
822 return des3_crypt_ecb( (des3_context *) ctx, input, output );
823}
824
Paul Bakkerfae35f02013-03-13 10:33:51 +0100825static int des_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length,
Paul Bakker8123e9d2011-01-06 15:37:30 +0000826 unsigned char *iv, const unsigned char *input, unsigned char *output )
827{
Manuel Pégourié-Gonnard92cb1d32013-09-13 16:24:20 +0200828#if defined(POLARSSL_CIPHER_MODE_CBC)
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200829 return des_crypt_cbc( (des_context *) ctx, operation, length, iv, input,
830 output );
Manuel Pégourié-Gonnard92cb1d32013-09-13 16:24:20 +0200831#else
832 ((void) ctx);
833 ((void) operation);
834 ((void) length);
835 ((void) iv);
836 ((void) input);
837 ((void) output);
838
839 return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
840#endif /* POLARSSL_CIPHER_MODE_CBC */
Paul Bakker8123e9d2011-01-06 15:37:30 +0000841}
842
Paul Bakkerfae35f02013-03-13 10:33:51 +0100843static int des3_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length,
Paul Bakker8123e9d2011-01-06 15:37:30 +0000844 unsigned char *iv, const unsigned char *input, unsigned char *output )
845{
Manuel Pégourié-Gonnard92cb1d32013-09-13 16:24:20 +0200846#if defined(POLARSSL_CIPHER_MODE_CBC)
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200847 return des3_crypt_cbc( (des3_context *) ctx, operation, length, iv, input,
848 output );
Manuel Pégourié-Gonnard92cb1d32013-09-13 16:24:20 +0200849#else
850 ((void) ctx);
851 ((void) operation);
852 ((void) length);
853 ((void) iv);
854 ((void) input);
855 ((void) output);
856
857 return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
858#endif /* POLARSSL_CIPHER_MODE_CBC */
Paul Bakker8123e9d2011-01-06 15:37:30 +0000859}
860
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200861static int des_crypt_cfb128_wrap( void *ctx, operation_t operation,
862 size_t length, size_t *iv_off, unsigned char *iv,
863 const unsigned char *input, unsigned char *output )
Paul Bakker343a8702011-06-09 14:27:58 +0000864{
865 ((void) ctx);
866 ((void) operation);
867 ((void) length);
868 ((void) iv_off);
869 ((void) iv);
870 ((void) input);
871 ((void) output);
872
873 return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
874}
875
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200876static int des_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
877 unsigned char *nonce_counter, unsigned char *stream_block,
Paul Bakker343a8702011-06-09 14:27:58 +0000878 const unsigned char *input, unsigned char *output )
879{
880 ((void) ctx);
881 ((void) length);
882 ((void) nc_off);
883 ((void) nonce_counter);
884 ((void) stream_block);
885 ((void) input);
886 ((void) output);
887
888 return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
889}
890
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200891static int des_setkey_dec_wrap( void *ctx, const unsigned char *key,
892 unsigned int key_length )
Paul Bakker8123e9d2011-01-06 15:37:30 +0000893{
Paul Bakkerd61e7d92011-01-18 16:17:47 +0000894 ((void) key_length);
895
Paul Bakker8123e9d2011-01-06 15:37:30 +0000896 return des_setkey_dec( (des_context *) ctx, key );
897}
898
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200899static int des_setkey_enc_wrap( void *ctx, const unsigned char *key,
900 unsigned int key_length )
Paul Bakker8123e9d2011-01-06 15:37:30 +0000901{
Paul Bakkerd61e7d92011-01-18 16:17:47 +0000902 ((void) key_length);
903
Paul Bakker8123e9d2011-01-06 15:37:30 +0000904 return des_setkey_enc( (des_context *) ctx, key );
905}
906
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200907static int des3_set2key_dec_wrap( void *ctx, const unsigned char *key,
908 unsigned int key_length )
Paul Bakker8123e9d2011-01-06 15:37:30 +0000909{
Paul Bakkerd61e7d92011-01-18 16:17:47 +0000910 ((void) key_length);
911
Paul Bakker8123e9d2011-01-06 15:37:30 +0000912 return des3_set2key_dec( (des3_context *) ctx, key );
913}
914
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200915static int des3_set2key_enc_wrap( void *ctx, const unsigned char *key,
916 unsigned int key_length )
Paul Bakker8123e9d2011-01-06 15:37:30 +0000917{
Paul Bakkerd61e7d92011-01-18 16:17:47 +0000918 ((void) key_length);
919
Paul Bakker8123e9d2011-01-06 15:37:30 +0000920 return des3_set2key_enc( (des3_context *) ctx, key );
921}
922
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200923static int des3_set3key_dec_wrap( void *ctx, const unsigned char *key,
924 unsigned int key_length )
Paul Bakker8123e9d2011-01-06 15:37:30 +0000925{
Paul Bakkerd61e7d92011-01-18 16:17:47 +0000926 ((void) key_length);
927
Paul Bakker8123e9d2011-01-06 15:37:30 +0000928 return des3_set3key_dec( (des3_context *) ctx, key );
929}
930
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +0200931static int des3_set3key_enc_wrap( void *ctx, const unsigned char *key,
932 unsigned int key_length )
Paul Bakker8123e9d2011-01-06 15:37:30 +0000933{
Paul Bakkerd61e7d92011-01-18 16:17:47 +0000934 ((void) key_length);
935
Paul Bakker8123e9d2011-01-06 15:37:30 +0000936 return des3_set3key_enc( (des3_context *) ctx, key );
937}
938
939static void * des_ctx_alloc( void )
940{
Paul Bakker6e339b52013-07-03 13:37:05 +0200941 return polarssl_malloc( sizeof( des_context ) );
Paul Bakker8123e9d2011-01-06 15:37:30 +0000942}
943
944static void * des3_ctx_alloc( void )
945{
Paul Bakker6e339b52013-07-03 13:37:05 +0200946 return polarssl_malloc( sizeof( des3_context ) );
Paul Bakker8123e9d2011-01-06 15:37:30 +0000947}
948
949static void des_ctx_free( void *ctx )
950{
Paul Bakker6e339b52013-07-03 13:37:05 +0200951 polarssl_free( ctx );
Paul Bakker8123e9d2011-01-06 15:37:30 +0000952}
953
Paul Bakker343a8702011-06-09 14:27:58 +0000954const cipher_base_t des_info = {
Paul Bakker23986e52011-04-24 08:57:21 +0000955 POLARSSL_CIPHER_ID_DES,
Paul Bakker5e0efa72013-09-08 23:04:04 +0200956 des_crypt_ecb_wrap,
Paul Bakker23986e52011-04-24 08:57:21 +0000957 des_crypt_cbc_wrap,
Paul Bakker343a8702011-06-09 14:27:58 +0000958 des_crypt_cfb128_wrap,
959 des_crypt_ctr_wrap,
Manuel Pégourié-Gonnard37e230c2013-08-28 13:50:42 +0200960 NULL,
Paul Bakker23986e52011-04-24 08:57:21 +0000961 des_setkey_enc_wrap,
962 des_setkey_dec_wrap,
963 des_ctx_alloc,
964 des_ctx_free
Paul Bakker8123e9d2011-01-06 15:37:30 +0000965};
966
Paul Bakker5e0efa72013-09-08 23:04:04 +0200967const cipher_info_t des_ecb_info = {
968 POLARSSL_CIPHER_DES_ECB,
969 POLARSSL_MODE_ECB,
970 POLARSSL_KEY_LENGTH_DES,
971 "DES-ECB",
972 8,
973 0,
974 8,
975 &des_info
976};
977
Manuel Pégourié-Gonnard989ed382013-09-13 14:41:45 +0200978#if defined(POLARSSL_CIPHER_MODE_CBC)
Paul Bakker343a8702011-06-09 14:27:58 +0000979const cipher_info_t des_cbc_info = {
980 POLARSSL_CIPHER_DES_CBC,
Paul Bakker23986e52011-04-24 08:57:21 +0000981 POLARSSL_MODE_CBC,
Paul Bakker343a8702011-06-09 14:27:58 +0000982 POLARSSL_KEY_LENGTH_DES,
983 "DES-CBC",
984 8,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +0200985 0,
Paul Bakker343a8702011-06-09 14:27:58 +0000986 8,
987 &des_info
988};
Manuel Pégourié-Gonnard989ed382013-09-13 14:41:45 +0200989#endif /* POLARSSL_CIPHER_MODE_CBC */
Paul Bakker343a8702011-06-09 14:27:58 +0000990
991const cipher_base_t des_ede_info = {
992 POLARSSL_CIPHER_ID_DES,
Paul Bakker5e0efa72013-09-08 23:04:04 +0200993 des3_crypt_ecb_wrap,
Paul Bakker23986e52011-04-24 08:57:21 +0000994 des3_crypt_cbc_wrap,
Paul Bakker343a8702011-06-09 14:27:58 +0000995 des_crypt_cfb128_wrap,
996 des_crypt_ctr_wrap,
Manuel Pégourié-Gonnard37e230c2013-08-28 13:50:42 +0200997 NULL,
Paul Bakker23986e52011-04-24 08:57:21 +0000998 des3_set2key_enc_wrap,
999 des3_set2key_dec_wrap,
1000 des3_ctx_alloc,
1001 des_ctx_free
Paul Bakker8123e9d2011-01-06 15:37:30 +00001002};
1003
Paul Bakker5e0efa72013-09-08 23:04:04 +02001004const cipher_info_t des_ede_ecb_info = {
1005 POLARSSL_CIPHER_DES_EDE_ECB,
1006 POLARSSL_MODE_ECB,
1007 POLARSSL_KEY_LENGTH_DES_EDE,
1008 "DES-EDE-ECB",
1009 8,
1010 0,
1011 8,
1012 &des_ede_info
1013};
1014
Manuel Pégourié-Gonnard989ed382013-09-13 14:41:45 +02001015#if defined(POLARSSL_CIPHER_MODE_CBC)
Paul Bakker343a8702011-06-09 14:27:58 +00001016const cipher_info_t des_ede_cbc_info = {
1017 POLARSSL_CIPHER_DES_EDE_CBC,
1018 POLARSSL_MODE_CBC,
1019 POLARSSL_KEY_LENGTH_DES_EDE,
1020 "DES-EDE-CBC",
Paul Bakker0e342352013-06-24 19:33:02 +02001021 8,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +02001022 0,
Paul Bakker0e342352013-06-24 19:33:02 +02001023 8,
Paul Bakker343a8702011-06-09 14:27:58 +00001024 &des_ede_info
1025};
Manuel Pégourié-Gonnard989ed382013-09-13 14:41:45 +02001026#endif /* POLARSSL_CIPHER_MODE_CBC */
Paul Bakker343a8702011-06-09 14:27:58 +00001027
1028const cipher_base_t des_ede3_info = {
1029 POLARSSL_CIPHER_ID_DES,
Paul Bakker5e0efa72013-09-08 23:04:04 +02001030 des3_crypt_ecb_wrap,
Paul Bakker343a8702011-06-09 14:27:58 +00001031 des3_crypt_cbc_wrap,
1032 des_crypt_cfb128_wrap,
1033 des_crypt_ctr_wrap,
Manuel Pégourié-Gonnard37e230c2013-08-28 13:50:42 +02001034 NULL,
Paul Bakker343a8702011-06-09 14:27:58 +00001035 des3_set3key_enc_wrap,
1036 des3_set3key_dec_wrap,
1037 des3_ctx_alloc,
1038 des_ctx_free
1039};
1040
Paul Bakker5e0efa72013-09-08 23:04:04 +02001041const cipher_info_t des_ede3_ecb_info = {
1042 POLARSSL_CIPHER_DES_EDE3_ECB,
1043 POLARSSL_MODE_ECB,
1044 POLARSSL_KEY_LENGTH_DES_EDE3,
1045 "DES-EDE3-ECB",
1046 8,
1047 0,
1048 8,
1049 &des_ede3_info
1050};
Manuel Pégourié-Gonnard989ed382013-09-13 14:41:45 +02001051#if defined(POLARSSL_CIPHER_MODE_CBC)
Paul Bakker8123e9d2011-01-06 15:37:30 +00001052const cipher_info_t des_ede3_cbc_info = {
Paul Bakker23986e52011-04-24 08:57:21 +00001053 POLARSSL_CIPHER_DES_EDE3_CBC,
Paul Bakker23986e52011-04-24 08:57:21 +00001054 POLARSSL_MODE_CBC,
1055 POLARSSL_KEY_LENGTH_DES_EDE3,
1056 "DES-EDE3-CBC",
1057 8,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +02001058 0,
Paul Bakker23986e52011-04-24 08:57:21 +00001059 8,
Paul Bakker343a8702011-06-09 14:27:58 +00001060 &des_ede3_info
Paul Bakker8123e9d2011-01-06 15:37:30 +00001061};
Manuel Pégourié-Gonnard989ed382013-09-13 14:41:45 +02001062#endif /* POLARSSL_CIPHER_MODE_CBC */
Paul Bakker9af723c2014-05-01 13:03:14 +02001063#endif /* POLARSSL_DES_C */
Paul Bakker8123e9d2011-01-06 15:37:30 +00001064
Paul Bakker6132d0a2012-07-04 17:10:40 +00001065#if defined(POLARSSL_BLOWFISH_C)
1066
Paul Bakker5e0efa72013-09-08 23:04:04 +02001067static int blowfish_crypt_ecb_wrap( void *ctx, operation_t operation,
1068 const unsigned char *input, unsigned char *output )
1069{
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +02001070 return blowfish_crypt_ecb( (blowfish_context *) ctx, operation, input,
1071 output );
Paul Bakker5e0efa72013-09-08 23:04:04 +02001072}
1073
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +02001074static int blowfish_crypt_cbc_wrap( void *ctx, operation_t operation,
1075 size_t length, unsigned char *iv, const unsigned char *input,
1076 unsigned char *output )
Paul Bakker6132d0a2012-07-04 17:10:40 +00001077{
Manuel Pégourié-Gonnard92cb1d32013-09-13 16:24:20 +02001078#if defined(POLARSSL_CIPHER_MODE_CBC)
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +02001079 return blowfish_crypt_cbc( (blowfish_context *) ctx, operation, length, iv,
1080 input, output );
Manuel Pégourié-Gonnard92cb1d32013-09-13 16:24:20 +02001081#else
1082 ((void) ctx);
1083 ((void) operation);
1084 ((void) length);
1085 ((void) iv);
1086 ((void) input);
1087 ((void) output);
1088
1089 return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
1090#endif /* POLARSSL_CIPHER_MODE_CBC */
Paul Bakker6132d0a2012-07-04 17:10:40 +00001091}
1092
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +02001093static int blowfish_crypt_cfb64_wrap( void *ctx, operation_t operation,
1094 size_t length, size_t *iv_off, unsigned char *iv,
1095 const unsigned char *input, unsigned char *output )
Paul Bakker6132d0a2012-07-04 17:10:40 +00001096{
1097#if defined(POLARSSL_CIPHER_MODE_CFB)
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +02001098 return blowfish_crypt_cfb64( (blowfish_context *) ctx, operation, length,
1099 iv_off, iv, input, output );
Paul Bakker6132d0a2012-07-04 17:10:40 +00001100#else
1101 ((void) ctx);
1102 ((void) operation);
1103 ((void) length);
1104 ((void) iv_off);
1105 ((void) iv);
1106 ((void) input);
1107 ((void) output);
1108
1109 return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
Paul Bakker9af723c2014-05-01 13:03:14 +02001110#endif /* POLARSSL_CIPHER_MODE_CFB */
Paul Bakker6132d0a2012-07-04 17:10:40 +00001111}
1112
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +02001113static int blowfish_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off,
1114 unsigned char *nonce_counter, unsigned char *stream_block,
Paul Bakker6132d0a2012-07-04 17:10:40 +00001115 const unsigned char *input, unsigned char *output )
1116{
1117#if defined(POLARSSL_CIPHER_MODE_CTR)
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +02001118 return blowfish_crypt_ctr( (blowfish_context *) ctx, length, nc_off,
1119 nonce_counter, stream_block, input, output );
Paul Bakker6132d0a2012-07-04 17:10:40 +00001120#else
1121 ((void) ctx);
1122 ((void) length);
1123 ((void) nc_off);
1124 ((void) nonce_counter);
1125 ((void) stream_block);
1126 ((void) input);
1127 ((void) output);
1128
1129 return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE;
Paul Bakker9af723c2014-05-01 13:03:14 +02001130#endif /* POLARSSL_CIPHER_MODE_CTR */
Paul Bakker6132d0a2012-07-04 17:10:40 +00001131}
1132
Paul Bakkerb9e4e2c2014-05-01 14:18:25 +02001133static int blowfish_setkey_wrap( void *ctx, const unsigned char *key,
1134 unsigned int key_length )
Paul Bakker6132d0a2012-07-04 17:10:40 +00001135{
1136 return blowfish_setkey( (blowfish_context *) ctx, key, key_length );
1137}
1138
1139static void * blowfish_ctx_alloc( void )
1140{
Paul Bakker6e339b52013-07-03 13:37:05 +02001141 return polarssl_malloc( sizeof( blowfish_context ) );
Paul Bakker6132d0a2012-07-04 17:10:40 +00001142}
1143
1144static void blowfish_ctx_free( void *ctx )
1145{
Paul Bakker6e339b52013-07-03 13:37:05 +02001146 polarssl_free( ctx );
Paul Bakker6132d0a2012-07-04 17:10:40 +00001147}
1148
1149const cipher_base_t blowfish_info = {
1150 POLARSSL_CIPHER_ID_BLOWFISH,
Paul Bakker5e0efa72013-09-08 23:04:04 +02001151 blowfish_crypt_ecb_wrap,
Paul Bakker6132d0a2012-07-04 17:10:40 +00001152 blowfish_crypt_cbc_wrap,
1153 blowfish_crypt_cfb64_wrap,
1154 blowfish_crypt_ctr_wrap,
Manuel Pégourié-Gonnard37e230c2013-08-28 13:50:42 +02001155 NULL,
Manuel Pégourié-Gonnardb5e85882013-08-28 16:36:14 +02001156 blowfish_setkey_wrap,
1157 blowfish_setkey_wrap,
Paul Bakker6132d0a2012-07-04 17:10:40 +00001158 blowfish_ctx_alloc,
1159 blowfish_ctx_free
1160};
1161
Paul Bakker5e0efa72013-09-08 23:04:04 +02001162const cipher_info_t blowfish_ecb_info = {
1163 POLARSSL_CIPHER_BLOWFISH_ECB,
1164 POLARSSL_MODE_ECB,
1165 128,
1166 "BLOWFISH-ECB",
1167 8,
1168 0,
1169 8,
1170 &blowfish_info
1171};
1172
Manuel Pégourié-Gonnard989ed382013-09-13 14:41:45 +02001173#if defined(POLARSSL_CIPHER_MODE_CBC)
Paul Bakker6132d0a2012-07-04 17:10:40 +00001174const cipher_info_t blowfish_cbc_info = {
1175 POLARSSL_CIPHER_BLOWFISH_CBC,
1176 POLARSSL_MODE_CBC,
Paul Bakkerbfe671f2013-04-07 22:35:44 +02001177 128,
Paul Bakker6132d0a2012-07-04 17:10:40 +00001178 "BLOWFISH-CBC",
1179 8,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +02001180 0,
Paul Bakker6132d0a2012-07-04 17:10:40 +00001181 8,
1182 &blowfish_info
1183};
Manuel Pégourié-Gonnard989ed382013-09-13 14:41:45 +02001184#endif /* POLARSSL_CIPHER_MODE_CBC */
Paul Bakker6132d0a2012-07-04 17:10:40 +00001185
1186#if defined(POLARSSL_CIPHER_MODE_CFB)
1187const cipher_info_t blowfish_cfb64_info = {
1188 POLARSSL_CIPHER_BLOWFISH_CFB64,
1189 POLARSSL_MODE_CFB,
Paul Bakkerbfe671f2013-04-07 22:35:44 +02001190 128,
Paul Bakker6132d0a2012-07-04 17:10:40 +00001191 "BLOWFISH-CFB64",
1192 8,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +02001193 0,
Paul Bakker6132d0a2012-07-04 17:10:40 +00001194 8,
1195 &blowfish_info
1196};
1197#endif /* POLARSSL_CIPHER_MODE_CFB */
1198
1199#if defined(POLARSSL_CIPHER_MODE_CTR)
1200const cipher_info_t blowfish_ctr_info = {
1201 POLARSSL_CIPHER_BLOWFISH_CTR,
1202 POLARSSL_MODE_CTR,
Paul Bakkerbfe671f2013-04-07 22:35:44 +02001203 128,
Paul Bakker6132d0a2012-07-04 17:10:40 +00001204 "BLOWFISH-CTR",
1205 8,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +02001206 0,
Paul Bakker6132d0a2012-07-04 17:10:40 +00001207 8,
1208 &blowfish_info
1209};
1210#endif /* POLARSSL_CIPHER_MODE_CTR */
1211#endif /* POLARSSL_BLOWFISH_C */
1212
Paul Bakker68884e32013-01-07 18:20:04 +01001213#if defined(POLARSSL_ARC4_C)
Manuel Pégourié-Gonnard37e230c2013-08-28 13:50:42 +02001214static int arc4_crypt_stream_wrap( void *ctx, size_t length,
1215 const unsigned char *input,
1216 unsigned char *output )
Paul Bakker68884e32013-01-07 18:20:04 +01001217{
Manuel Pégourié-Gonnard37e230c2013-08-28 13:50:42 +02001218 return( arc4_crypt( (arc4_context *) ctx, length, input, output ) );
Paul Bakker68884e32013-01-07 18:20:04 +01001219}
1220
Manuel Pégourié-Gonnard37e230c2013-08-28 13:50:42 +02001221static int arc4_setkey_wrap( void *ctx, const unsigned char *key,
1222 unsigned int key_length )
1223{
Manuel Pégourié-Gonnardce411252013-09-04 12:28:37 +02001224 /* we get key_length in bits, arc4 expects it in bytes */
1225 if( key_length % 8 != 0)
1226 return( POLARSSL_ERR_CIPHER_BAD_INPUT_DATA );
1227
1228 arc4_setup( (arc4_context *) ctx, key, key_length / 8 );
Manuel Pégourié-Gonnard37e230c2013-08-28 13:50:42 +02001229 return( 0 );
1230}
1231
1232static void * arc4_ctx_alloc( void )
1233{
1234 return polarssl_malloc( sizeof( arc4_context ) );
1235}
Paul Bakker68884e32013-01-07 18:20:04 +01001236
1237static void arc4_ctx_free( void *ctx )
1238{
Manuel Pégourié-Gonnard37e230c2013-08-28 13:50:42 +02001239 polarssl_free( ctx );
Paul Bakker68884e32013-01-07 18:20:04 +01001240}
1241
1242const cipher_base_t arc4_base_info = {
1243 POLARSSL_CIPHER_ID_ARC4,
1244 NULL,
1245 NULL,
1246 NULL,
Paul Bakker5e0efa72013-09-08 23:04:04 +02001247 NULL,
Manuel Pégourié-Gonnard37e230c2013-08-28 13:50:42 +02001248 arc4_crypt_stream_wrap,
1249 arc4_setkey_wrap,
1250 arc4_setkey_wrap,
Paul Bakker68884e32013-01-07 18:20:04 +01001251 arc4_ctx_alloc,
1252 arc4_ctx_free
1253};
1254
1255const cipher_info_t arc4_128_info = {
1256 POLARSSL_CIPHER_ARC4_128,
1257 POLARSSL_MODE_STREAM,
1258 128,
1259 "ARC4-128",
1260 0,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +02001261 0,
Paul Bakker68884e32013-01-07 18:20:04 +01001262 1,
1263 &arc4_base_info
1264};
1265#endif /* POLARSSL_ARC4_C */
1266
Paul Bakkerfab5c822012-02-06 16:45:10 +00001267#if defined(POLARSSL_CIPHER_NULL_CIPHER)
Manuel Pégourié-Gonnardb5e85882013-08-28 16:36:14 +02001268static int null_crypt_stream( void *ctx, size_t length,
1269 const unsigned char *input,
1270 unsigned char *output )
1271{
1272 ((void) ctx);
1273 memmove( output, input, length );
1274 return( 0 );
1275}
1276
1277static int null_setkey( void *ctx, const unsigned char *key,
1278 unsigned int key_length )
1279{
1280 ((void) ctx);
1281 ((void) key);
1282 ((void) key_length);
1283
1284 return( 0 );
1285}
1286
Paul Bakkerfab5c822012-02-06 16:45:10 +00001287static void * null_ctx_alloc( void )
1288{
1289 return (void *) 1;
1290}
1291
Paul Bakkerfab5c822012-02-06 16:45:10 +00001292static void null_ctx_free( void *ctx )
1293{
1294 ((void) ctx);
1295}
1296
1297const cipher_base_t null_base_info = {
1298 POLARSSL_CIPHER_ID_NULL,
1299 NULL,
1300 NULL,
1301 NULL,
Paul Bakker5e0efa72013-09-08 23:04:04 +02001302 NULL,
Manuel Pégourié-Gonnardb5e85882013-08-28 16:36:14 +02001303 null_crypt_stream,
1304 null_setkey,
1305 null_setkey,
Paul Bakkerfab5c822012-02-06 16:45:10 +00001306 null_ctx_alloc,
1307 null_ctx_free
1308};
1309
1310const cipher_info_t null_cipher_info = {
1311 POLARSSL_CIPHER_NULL,
Manuel Pégourié-Gonnardb5e85882013-08-28 16:36:14 +02001312 POLARSSL_MODE_STREAM,
Paul Bakkerfab5c822012-02-06 16:45:10 +00001313 0,
1314 "NULL",
Paul Bakker68884e32013-01-07 18:20:04 +01001315 0,
Manuel Pégourié-Gonnarda235b5b2013-09-03 13:25:52 +02001316 0,
Paul Bakkerfab5c822012-02-06 16:45:10 +00001317 1,
1318 &null_base_info
1319};
1320#endif /* defined(POLARSSL_CIPHER_NULL_CIPHER) */
1321
Manuel Pégourié-Gonnarddace82f2013-09-18 15:12:07 +02001322const cipher_definition_t cipher_definitions[] =
1323{
1324#if defined(POLARSSL_AES_C)
1325 { POLARSSL_CIPHER_AES_128_ECB, &aes_128_ecb_info },
1326 { POLARSSL_CIPHER_AES_192_ECB, &aes_192_ecb_info },
1327 { POLARSSL_CIPHER_AES_256_ECB, &aes_256_ecb_info },
1328#if defined(POLARSSL_CIPHER_MODE_CBC)
1329 { POLARSSL_CIPHER_AES_128_CBC, &aes_128_cbc_info },
1330 { POLARSSL_CIPHER_AES_192_CBC, &aes_192_cbc_info },
1331 { POLARSSL_CIPHER_AES_256_CBC, &aes_256_cbc_info },
1332#endif
1333#if defined(POLARSSL_CIPHER_MODE_CFB)
1334 { POLARSSL_CIPHER_AES_128_CFB128, &aes_128_cfb128_info },
1335 { POLARSSL_CIPHER_AES_192_CFB128, &aes_192_cfb128_info },
1336 { POLARSSL_CIPHER_AES_256_CFB128, &aes_256_cfb128_info },
1337#endif
1338#if defined(POLARSSL_CIPHER_MODE_CTR)
1339 { POLARSSL_CIPHER_AES_128_CTR, &aes_128_ctr_info },
1340 { POLARSSL_CIPHER_AES_192_CTR, &aes_192_ctr_info },
1341 { POLARSSL_CIPHER_AES_256_CTR, &aes_256_ctr_info },
1342#endif
1343#if defined(POLARSSL_GCM_C)
1344 { POLARSSL_CIPHER_AES_128_GCM, &aes_128_gcm_info },
1345 { POLARSSL_CIPHER_AES_192_GCM, &aes_192_gcm_info },
1346 { POLARSSL_CIPHER_AES_256_GCM, &aes_256_gcm_info },
1347#endif
Manuel Pégourié-Gonnard41936952014-05-13 13:18:17 +02001348#if defined(POLARSSL_CCM_C)
1349 { POLARSSL_CIPHER_AES_128_CCM, &aes_128_ccm_info },
1350 { POLARSSL_CIPHER_AES_192_CCM, &aes_192_ccm_info },
1351 { POLARSSL_CIPHER_AES_256_CCM, &aes_256_ccm_info },
1352#endif
Manuel Pégourié-Gonnarddace82f2013-09-18 15:12:07 +02001353#endif /* POLARSSL_AES_C */
1354
1355#if defined(POLARSSL_ARC4_C)
1356 { POLARSSL_CIPHER_ARC4_128, &arc4_128_info },
1357#endif
1358
1359#if defined(POLARSSL_BLOWFISH_C)
1360 { POLARSSL_CIPHER_BLOWFISH_ECB, &blowfish_ecb_info },
1361#if defined(POLARSSL_CIPHER_MODE_CBC)
1362 { POLARSSL_CIPHER_BLOWFISH_CBC, &blowfish_cbc_info },
1363#endif
1364#if defined(POLARSSL_CIPHER_MODE_CFB)
1365 { POLARSSL_CIPHER_BLOWFISH_CFB64, &blowfish_cfb64_info },
1366#endif
1367#if defined(POLARSSL_CIPHER_MODE_CTR)
1368 { POLARSSL_CIPHER_BLOWFISH_CTR, &blowfish_ctr_info },
1369#endif
1370#endif /* POLARSSL_BLOWFISH_C */
1371
1372#if defined(POLARSSL_CAMELLIA_C)
1373 { POLARSSL_CIPHER_CAMELLIA_128_ECB, &camellia_128_ecb_info },
1374 { POLARSSL_CIPHER_CAMELLIA_192_ECB, &camellia_192_ecb_info },
Manuel Pégourié-Gonnard13e0d442013-10-24 12:59:00 +02001375 { POLARSSL_CIPHER_CAMELLIA_256_ECB, &camellia_256_ecb_info },
Manuel Pégourié-Gonnarddace82f2013-09-18 15:12:07 +02001376#if defined(POLARSSL_CIPHER_MODE_CBC)
1377 { POLARSSL_CIPHER_CAMELLIA_128_CBC, &camellia_128_cbc_info },
1378 { POLARSSL_CIPHER_CAMELLIA_192_CBC, &camellia_192_cbc_info },
1379 { POLARSSL_CIPHER_CAMELLIA_256_CBC, &camellia_256_cbc_info },
1380#endif
1381#if defined(POLARSSL_CIPHER_MODE_CFB)
1382 { POLARSSL_CIPHER_CAMELLIA_128_CFB128, &camellia_128_cfb128_info },
1383 { POLARSSL_CIPHER_CAMELLIA_192_CFB128, &camellia_192_cfb128_info },
1384 { POLARSSL_CIPHER_CAMELLIA_256_CFB128, &camellia_256_cfb128_info },
1385#endif
1386#if defined(POLARSSL_CIPHER_MODE_CTR)
1387 { POLARSSL_CIPHER_CAMELLIA_128_CTR, &camellia_128_ctr_info },
1388 { POLARSSL_CIPHER_CAMELLIA_192_CTR, &camellia_192_ctr_info },
1389 { POLARSSL_CIPHER_CAMELLIA_256_CTR, &camellia_256_ctr_info },
1390#endif
Manuel Pégourié-Gonnard87181d12013-10-24 14:02:40 +02001391#if defined(POLARSSL_GCM_C)
1392 { POLARSSL_CIPHER_CAMELLIA_128_GCM, &camellia_128_gcm_info },
1393 { POLARSSL_CIPHER_CAMELLIA_192_GCM, &camellia_192_gcm_info },
1394 { POLARSSL_CIPHER_CAMELLIA_256_GCM, &camellia_256_gcm_info },
1395#endif
Manuel Pégourié-Gonnard41936952014-05-13 13:18:17 +02001396#if defined(POLARSSL_CCM_C)
1397 { POLARSSL_CIPHER_CAMELLIA_128_CCM, &camellia_128_ccm_info },
1398 { POLARSSL_CIPHER_CAMELLIA_192_CCM, &camellia_192_ccm_info },
1399 { POLARSSL_CIPHER_CAMELLIA_256_CCM, &camellia_256_ccm_info },
1400#endif
Manuel Pégourié-Gonnarddace82f2013-09-18 15:12:07 +02001401#endif /* POLARSSL_CAMELLIA_C */
1402
1403#if defined(POLARSSL_DES_C)
1404 { POLARSSL_CIPHER_DES_ECB, &des_ecb_info },
1405 { POLARSSL_CIPHER_DES_EDE_ECB, &des_ede_ecb_info },
1406 { POLARSSL_CIPHER_DES_EDE3_ECB, &des_ede3_ecb_info },
1407#if defined(POLARSSL_CIPHER_MODE_CBC)
1408 { POLARSSL_CIPHER_DES_CBC, &des_cbc_info },
1409 { POLARSSL_CIPHER_DES_EDE_CBC, &des_ede_cbc_info },
1410 { POLARSSL_CIPHER_DES_EDE3_CBC, &des_ede3_cbc_info },
1411#endif
1412#endif /* POLARSSL_DES_C */
1413
1414#if defined(POLARSSL_CIPHER_NULL_CIPHER)
Manuel Pégourié-Gonnard057e0cf2013-10-14 14:19:31 +02001415 { POLARSSL_CIPHER_NULL, &null_cipher_info },
Manuel Pégourié-Gonnarddace82f2013-09-18 15:12:07 +02001416#endif /* POLARSSL_CIPHER_NULL_CIPHER */
1417
1418 { 0, NULL }
1419};
1420
1421#define NUM_CIPHERS sizeof cipher_definitions / sizeof cipher_definitions[0]
1422int supported_ciphers[NUM_CIPHERS];
1423
Paul Bakker9af723c2014-05-01 13:03:14 +02001424#endif /* POLARSSL_CIPHER_C */