Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 1 | /** |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 2 | * \file cipher_wrap.c |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 3 | * |
Paul Bakker | 2028156 | 2011-11-11 10:34:04 +0000 | [diff] [blame] | 4 | * \brief Generic cipher wrapper for PolarSSL |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 5 | * |
| 6 | * \author Adriaan de Jong <dejong@fox-it.com> |
| 7 | * |
Paul Bakker | 68884e3 | 2013-01-07 18:20:04 +0100 | [diff] [blame] | 8 | * Copyright (C) 2006-2013, Brainspark B.V. |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 9 | * |
| 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 | |
| 30 | #include "polarssl/config.h" |
| 31 | |
| 32 | #if defined(POLARSSL_CIPHER_C) |
| 33 | |
| 34 | #include "polarssl/cipher_wrap.h" |
Paul Bakker | f654371 | 2012-03-05 14:01:29 +0000 | [diff] [blame] | 35 | |
| 36 | #if defined(POLARSSL_AES_C) |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 37 | #include "polarssl/aes.h" |
Paul Bakker | f654371 | 2012-03-05 14:01:29 +0000 | [diff] [blame] | 38 | #endif |
| 39 | |
| 40 | #if defined(POLARSSL_CAMELLIA_C) |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 41 | #include "polarssl/camellia.h" |
Paul Bakker | f654371 | 2012-03-05 14:01:29 +0000 | [diff] [blame] | 42 | #endif |
| 43 | |
| 44 | #if defined(POLARSSL_DES_C) |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 45 | #include "polarssl/des.h" |
Paul Bakker | 02f6169 | 2012-03-15 10:54:25 +0000 | [diff] [blame] | 46 | #endif |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 47 | |
Paul Bakker | 6132d0a | 2012-07-04 17:10:40 +0000 | [diff] [blame] | 48 | #if defined(POLARSSL_BLOWFISH_C) |
| 49 | #include "polarssl/blowfish.h" |
| 50 | #endif |
| 51 | |
Paul Bakker | 6e339b5 | 2013-07-03 13:37:05 +0200 | [diff] [blame] | 52 | #if defined(POLARSSL_MEMORY_C) |
| 53 | #include "polarssl/memory.h" |
| 54 | #else |
| 55 | #define polarssl_malloc malloc |
| 56 | #define polarssl_free free |
| 57 | #endif |
| 58 | |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 59 | #include <stdlib.h> |
| 60 | |
| 61 | #if defined(POLARSSL_AES_C) |
| 62 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 63 | static int aes_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length, |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 64 | unsigned char *iv, const unsigned char *input, unsigned char *output ) |
| 65 | { |
| 66 | return aes_crypt_cbc( (aes_context *) ctx, operation, length, iv, input, output ); |
| 67 | } |
| 68 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 69 | static int aes_crypt_cfb128_wrap( void *ctx, operation_t operation, size_t length, |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 70 | size_t *iv_off, unsigned char *iv, const unsigned char *input, unsigned char *output ) |
| 71 | { |
| 72 | #if defined(POLARSSL_CIPHER_MODE_CFB) |
| 73 | return aes_crypt_cfb128( (aes_context *) ctx, operation, length, iv_off, iv, input, output ); |
| 74 | #else |
| 75 | ((void) ctx); |
| 76 | ((void) operation); |
| 77 | ((void) length); |
| 78 | ((void) iv_off); |
| 79 | ((void) iv); |
| 80 | ((void) input); |
| 81 | ((void) output); |
| 82 | |
| 83 | return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE; |
| 84 | #endif |
| 85 | } |
| 86 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 87 | static int aes_crypt_ctr_wrap( void *ctx, size_t length, |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 88 | size_t *nc_off, unsigned char *nonce_counter, unsigned char *stream_block, |
| 89 | const unsigned char *input, unsigned char *output ) |
| 90 | { |
| 91 | #if defined(POLARSSL_CIPHER_MODE_CTR) |
| 92 | return aes_crypt_ctr( (aes_context *) ctx, length, nc_off, nonce_counter, |
| 93 | stream_block, input, output ); |
| 94 | #else |
| 95 | ((void) ctx); |
| 96 | ((void) length); |
| 97 | ((void) nc_off); |
| 98 | ((void) nonce_counter); |
| 99 | ((void) stream_block); |
| 100 | ((void) input); |
| 101 | ((void) output); |
| 102 | |
| 103 | return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE; |
| 104 | #endif |
| 105 | } |
| 106 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 107 | static int aes_setkey_dec_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 108 | { |
| 109 | return aes_setkey_dec( (aes_context *) ctx, key, key_length ); |
| 110 | } |
| 111 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 112 | static int aes_setkey_enc_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 113 | { |
| 114 | return aes_setkey_enc( (aes_context *) ctx, key, key_length ); |
| 115 | } |
| 116 | |
| 117 | static void * aes_ctx_alloc( void ) |
| 118 | { |
Paul Bakker | 6e339b5 | 2013-07-03 13:37:05 +0200 | [diff] [blame] | 119 | return polarssl_malloc( sizeof( aes_context ) ); |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | static void aes_ctx_free( void *ctx ) |
| 123 | { |
Paul Bakker | 6e339b5 | 2013-07-03 13:37:05 +0200 | [diff] [blame] | 124 | polarssl_free( ctx ); |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 125 | } |
| 126 | |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 127 | const cipher_base_t aes_info = { |
| 128 | POLARSSL_CIPHER_ID_AES, |
| 129 | aes_crypt_cbc_wrap, |
| 130 | aes_crypt_cfb128_wrap, |
| 131 | aes_crypt_ctr_wrap, |
| 132 | aes_setkey_enc_wrap, |
| 133 | aes_setkey_dec_wrap, |
| 134 | aes_ctx_alloc, |
| 135 | aes_ctx_free |
| 136 | }; |
| 137 | |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 138 | const cipher_info_t aes_128_cbc_info = { |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 139 | POLARSSL_CIPHER_AES_128_CBC, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 140 | POLARSSL_MODE_CBC, |
| 141 | 128, |
| 142 | "AES-128-CBC", |
| 143 | 16, |
| 144 | 16, |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 145 | &aes_info |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 146 | }; |
| 147 | |
| 148 | const cipher_info_t aes_192_cbc_info = { |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 149 | POLARSSL_CIPHER_AES_192_CBC, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 150 | POLARSSL_MODE_CBC, |
| 151 | 192, |
| 152 | "AES-192-CBC", |
| 153 | 16, |
| 154 | 16, |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 155 | &aes_info |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 156 | }; |
| 157 | |
| 158 | const cipher_info_t aes_256_cbc_info = { |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 159 | POLARSSL_CIPHER_AES_256_CBC, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 160 | POLARSSL_MODE_CBC, |
| 161 | 256, |
| 162 | "AES-256-CBC", |
| 163 | 16, |
| 164 | 16, |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 165 | &aes_info |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 166 | }; |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 167 | |
| 168 | #if defined(POLARSSL_CIPHER_MODE_CFB) |
| 169 | const cipher_info_t aes_128_cfb128_info = { |
| 170 | POLARSSL_CIPHER_AES_128_CFB128, |
Paul Bakker | 6132d0a | 2012-07-04 17:10:40 +0000 | [diff] [blame] | 171 | POLARSSL_MODE_CFB, |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 172 | 128, |
| 173 | "AES-128-CFB128", |
| 174 | 16, |
| 175 | 16, |
| 176 | &aes_info |
| 177 | }; |
| 178 | |
| 179 | const cipher_info_t aes_192_cfb128_info = { |
| 180 | POLARSSL_CIPHER_AES_192_CFB128, |
Paul Bakker | 6132d0a | 2012-07-04 17:10:40 +0000 | [diff] [blame] | 181 | POLARSSL_MODE_CFB, |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 182 | 192, |
| 183 | "AES-192-CFB128", |
| 184 | 16, |
| 185 | 16, |
| 186 | &aes_info |
| 187 | }; |
| 188 | |
| 189 | const cipher_info_t aes_256_cfb128_info = { |
| 190 | POLARSSL_CIPHER_AES_256_CFB128, |
Paul Bakker | 6132d0a | 2012-07-04 17:10:40 +0000 | [diff] [blame] | 191 | POLARSSL_MODE_CFB, |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 192 | 256, |
| 193 | "AES-256-CFB128", |
| 194 | 16, |
| 195 | 16, |
| 196 | &aes_info |
| 197 | }; |
| 198 | #endif /* POLARSSL_CIPHER_MODE_CFB */ |
| 199 | |
| 200 | #if defined(POLARSSL_CIPHER_MODE_CTR) |
| 201 | const cipher_info_t aes_128_ctr_info = { |
| 202 | POLARSSL_CIPHER_AES_128_CTR, |
| 203 | POLARSSL_MODE_CTR, |
| 204 | 128, |
| 205 | "AES-128-CTR", |
| 206 | 16, |
| 207 | 16, |
| 208 | &aes_info |
| 209 | }; |
| 210 | |
| 211 | const cipher_info_t aes_192_ctr_info = { |
| 212 | POLARSSL_CIPHER_AES_192_CTR, |
| 213 | POLARSSL_MODE_CTR, |
| 214 | 192, |
| 215 | "AES-192-CTR", |
| 216 | 16, |
| 217 | 16, |
| 218 | &aes_info |
| 219 | }; |
| 220 | |
| 221 | const cipher_info_t aes_256_ctr_info = { |
| 222 | POLARSSL_CIPHER_AES_256_CTR, |
| 223 | POLARSSL_MODE_CTR, |
| 224 | 256, |
| 225 | "AES-256-CTR", |
| 226 | 16, |
| 227 | 16, |
| 228 | &aes_info |
| 229 | }; |
| 230 | #endif /* POLARSSL_CIPHER_MODE_CTR */ |
| 231 | |
Paul Bakker | 68884e3 | 2013-01-07 18:20:04 +0100 | [diff] [blame] | 232 | #if defined(POLARSSL_GCM_C) |
| 233 | const cipher_info_t aes_128_gcm_info = { |
| 234 | POLARSSL_CIPHER_AES_128_GCM, |
| 235 | POLARSSL_MODE_GCM, |
| 236 | 128, |
| 237 | "AES-128-GCM", |
| 238 | 16, |
| 239 | 16, |
| 240 | &aes_info |
| 241 | }; |
| 242 | |
| 243 | const cipher_info_t aes_256_gcm_info = { |
| 244 | POLARSSL_CIPHER_AES_256_GCM, |
| 245 | POLARSSL_MODE_GCM, |
| 246 | 256, |
| 247 | "AES-256-GCM", |
| 248 | 16, |
| 249 | 16, |
| 250 | &aes_info |
| 251 | }; |
| 252 | #endif /* POLARSSL_GCM_C */ |
| 253 | |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 254 | #endif |
| 255 | |
| 256 | #if defined(POLARSSL_CAMELLIA_C) |
| 257 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 258 | static int camellia_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length, |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 259 | unsigned char *iv, const unsigned char *input, unsigned char *output ) |
| 260 | { |
| 261 | return camellia_crypt_cbc( (camellia_context *) ctx, operation, length, iv, input, output ); |
| 262 | } |
| 263 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 264 | static int camellia_crypt_cfb128_wrap( void *ctx, operation_t operation, size_t length, |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 265 | size_t *iv_off, unsigned char *iv, const unsigned char *input, unsigned char *output ) |
| 266 | { |
| 267 | #if defined(POLARSSL_CIPHER_MODE_CFB) |
| 268 | return camellia_crypt_cfb128( (camellia_context *) ctx, operation, length, iv_off, iv, input, output ); |
| 269 | #else |
| 270 | ((void) ctx); |
| 271 | ((void) operation); |
| 272 | ((void) length); |
| 273 | ((void) iv_off); |
| 274 | ((void) iv); |
| 275 | ((void) input); |
| 276 | ((void) output); |
| 277 | |
| 278 | return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE; |
| 279 | #endif |
| 280 | } |
| 281 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 282 | static int camellia_crypt_ctr_wrap( void *ctx, size_t length, |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 283 | size_t *nc_off, unsigned char *nonce_counter, unsigned char *stream_block, |
| 284 | const unsigned char *input, unsigned char *output ) |
| 285 | { |
| 286 | #if defined(POLARSSL_CIPHER_MODE_CTR) |
| 287 | return camellia_crypt_ctr( (camellia_context *) ctx, length, nc_off, nonce_counter, |
| 288 | stream_block, input, output ); |
| 289 | #else |
| 290 | ((void) ctx); |
| 291 | ((void) length); |
| 292 | ((void) nc_off); |
| 293 | ((void) nonce_counter); |
| 294 | ((void) stream_block); |
| 295 | ((void) input); |
| 296 | ((void) output); |
| 297 | |
| 298 | return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE; |
| 299 | #endif |
| 300 | } |
| 301 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 302 | static int camellia_setkey_dec_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 303 | { |
| 304 | return camellia_setkey_dec( (camellia_context *) ctx, key, key_length ); |
| 305 | } |
| 306 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 307 | static int camellia_setkey_enc_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 308 | { |
| 309 | return camellia_setkey_enc( (camellia_context *) ctx, key, key_length ); |
| 310 | } |
| 311 | |
| 312 | static void * camellia_ctx_alloc( void ) |
| 313 | { |
Paul Bakker | 6e339b5 | 2013-07-03 13:37:05 +0200 | [diff] [blame] | 314 | return polarssl_malloc( sizeof( camellia_context ) ); |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | static void camellia_ctx_free( void *ctx ) |
| 318 | { |
Paul Bakker | 6e339b5 | 2013-07-03 13:37:05 +0200 | [diff] [blame] | 319 | polarssl_free( ctx ); |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 320 | } |
| 321 | |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 322 | const cipher_base_t camellia_info = { |
| 323 | POLARSSL_CIPHER_ID_CAMELLIA, |
| 324 | camellia_crypt_cbc_wrap, |
| 325 | camellia_crypt_cfb128_wrap, |
| 326 | camellia_crypt_ctr_wrap, |
| 327 | camellia_setkey_enc_wrap, |
| 328 | camellia_setkey_dec_wrap, |
| 329 | camellia_ctx_alloc, |
| 330 | camellia_ctx_free |
| 331 | }; |
| 332 | |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 333 | const cipher_info_t camellia_128_cbc_info = { |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 334 | POLARSSL_CIPHER_CAMELLIA_128_CBC, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 335 | POLARSSL_MODE_CBC, |
| 336 | 128, |
| 337 | "CAMELLIA-128-CBC", |
| 338 | 16, |
| 339 | 16, |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 340 | &camellia_info |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 341 | }; |
| 342 | |
| 343 | const cipher_info_t camellia_192_cbc_info = { |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 344 | POLARSSL_CIPHER_CAMELLIA_192_CBC, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 345 | POLARSSL_MODE_CBC, |
| 346 | 192, |
| 347 | "CAMELLIA-192-CBC", |
| 348 | 16, |
| 349 | 16, |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 350 | &camellia_info |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 351 | }; |
| 352 | |
| 353 | const cipher_info_t camellia_256_cbc_info = { |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 354 | POLARSSL_CIPHER_CAMELLIA_256_CBC, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 355 | POLARSSL_MODE_CBC, |
| 356 | 256, |
| 357 | "CAMELLIA-256-CBC", |
| 358 | 16, |
| 359 | 16, |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 360 | &camellia_info |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 361 | }; |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 362 | |
| 363 | #if defined(POLARSSL_CIPHER_MODE_CFB) |
| 364 | const cipher_info_t camellia_128_cfb128_info = { |
| 365 | POLARSSL_CIPHER_CAMELLIA_128_CFB128, |
Paul Bakker | 6132d0a | 2012-07-04 17:10:40 +0000 | [diff] [blame] | 366 | POLARSSL_MODE_CFB, |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 367 | 128, |
| 368 | "CAMELLIA-128-CFB128", |
| 369 | 16, |
| 370 | 16, |
| 371 | &camellia_info |
| 372 | }; |
| 373 | |
| 374 | const cipher_info_t camellia_192_cfb128_info = { |
| 375 | POLARSSL_CIPHER_CAMELLIA_192_CFB128, |
Paul Bakker | 6132d0a | 2012-07-04 17:10:40 +0000 | [diff] [blame] | 376 | POLARSSL_MODE_CFB, |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 377 | 192, |
| 378 | "CAMELLIA-192-CFB128", |
| 379 | 16, |
| 380 | 16, |
| 381 | &camellia_info |
| 382 | }; |
| 383 | |
| 384 | const cipher_info_t camellia_256_cfb128_info = { |
| 385 | POLARSSL_CIPHER_CAMELLIA_256_CFB128, |
Paul Bakker | 6132d0a | 2012-07-04 17:10:40 +0000 | [diff] [blame] | 386 | POLARSSL_MODE_CFB, |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 387 | 256, |
| 388 | "CAMELLIA-256-CFB128", |
| 389 | 16, |
| 390 | 16, |
| 391 | &camellia_info |
| 392 | }; |
| 393 | #endif /* POLARSSL_CIPHER_MODE_CFB */ |
| 394 | |
| 395 | #if defined(POLARSSL_CIPHER_MODE_CTR) |
| 396 | const cipher_info_t camellia_128_ctr_info = { |
| 397 | POLARSSL_CIPHER_CAMELLIA_128_CTR, |
| 398 | POLARSSL_MODE_CTR, |
| 399 | 128, |
| 400 | "CAMELLIA-128-CTR", |
| 401 | 16, |
| 402 | 16, |
| 403 | &camellia_info |
| 404 | }; |
| 405 | |
| 406 | const cipher_info_t camellia_192_ctr_info = { |
| 407 | POLARSSL_CIPHER_CAMELLIA_192_CTR, |
| 408 | POLARSSL_MODE_CTR, |
| 409 | 192, |
| 410 | "CAMELLIA-192-CTR", |
| 411 | 16, |
| 412 | 16, |
| 413 | &camellia_info |
| 414 | }; |
| 415 | |
| 416 | const cipher_info_t camellia_256_ctr_info = { |
| 417 | POLARSSL_CIPHER_CAMELLIA_256_CTR, |
| 418 | POLARSSL_MODE_CTR, |
| 419 | 256, |
| 420 | "CAMELLIA-256-CTR", |
| 421 | 16, |
| 422 | 16, |
| 423 | &camellia_info |
| 424 | }; |
| 425 | #endif /* POLARSSL_CIPHER_MODE_CTR */ |
| 426 | |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 427 | #endif |
| 428 | |
| 429 | #if defined(POLARSSL_DES_C) |
| 430 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 431 | static int des_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length, |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 432 | unsigned char *iv, const unsigned char *input, unsigned char *output ) |
| 433 | { |
| 434 | return des_crypt_cbc( (des_context *) ctx, operation, length, iv, input, output ); |
| 435 | } |
| 436 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 437 | static int des3_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length, |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 438 | unsigned char *iv, const unsigned char *input, unsigned char *output ) |
| 439 | { |
| 440 | return des3_crypt_cbc( (des3_context *) ctx, operation, length, iv, input, output ); |
| 441 | } |
| 442 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 443 | static int des_crypt_cfb128_wrap( void *ctx, operation_t operation, size_t length, |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 444 | size_t *iv_off, unsigned char *iv, const unsigned char *input, unsigned char *output ) |
| 445 | { |
| 446 | ((void) ctx); |
| 447 | ((void) operation); |
| 448 | ((void) length); |
| 449 | ((void) iv_off); |
| 450 | ((void) iv); |
| 451 | ((void) input); |
| 452 | ((void) output); |
| 453 | |
| 454 | return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE; |
| 455 | } |
| 456 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 457 | static int des_crypt_ctr_wrap( void *ctx, size_t length, |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 458 | size_t *nc_off, unsigned char *nonce_counter, unsigned char *stream_block, |
| 459 | const unsigned char *input, unsigned char *output ) |
| 460 | { |
| 461 | ((void) ctx); |
| 462 | ((void) length); |
| 463 | ((void) nc_off); |
| 464 | ((void) nonce_counter); |
| 465 | ((void) stream_block); |
| 466 | ((void) input); |
| 467 | ((void) output); |
| 468 | |
| 469 | return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE; |
| 470 | } |
| 471 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 472 | static int des_setkey_dec_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 473 | { |
Paul Bakker | d61e7d9 | 2011-01-18 16:17:47 +0000 | [diff] [blame] | 474 | ((void) key_length); |
| 475 | |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 476 | return des_setkey_dec( (des_context *) ctx, key ); |
| 477 | } |
| 478 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 479 | static int des_setkey_enc_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 480 | { |
Paul Bakker | d61e7d9 | 2011-01-18 16:17:47 +0000 | [diff] [blame] | 481 | ((void) key_length); |
| 482 | |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 483 | return des_setkey_enc( (des_context *) ctx, key ); |
| 484 | } |
| 485 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 486 | static int des3_set2key_dec_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 487 | { |
Paul Bakker | d61e7d9 | 2011-01-18 16:17:47 +0000 | [diff] [blame] | 488 | ((void) key_length); |
| 489 | |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 490 | return des3_set2key_dec( (des3_context *) ctx, key ); |
| 491 | } |
| 492 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 493 | static int des3_set2key_enc_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 494 | { |
Paul Bakker | d61e7d9 | 2011-01-18 16:17:47 +0000 | [diff] [blame] | 495 | ((void) key_length); |
| 496 | |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 497 | return des3_set2key_enc( (des3_context *) ctx, key ); |
| 498 | } |
| 499 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 500 | static int des3_set3key_dec_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 501 | { |
Paul Bakker | d61e7d9 | 2011-01-18 16:17:47 +0000 | [diff] [blame] | 502 | ((void) key_length); |
| 503 | |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 504 | return des3_set3key_dec( (des3_context *) ctx, key ); |
| 505 | } |
| 506 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 507 | static int des3_set3key_enc_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 508 | { |
Paul Bakker | d61e7d9 | 2011-01-18 16:17:47 +0000 | [diff] [blame] | 509 | ((void) key_length); |
| 510 | |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 511 | return des3_set3key_enc( (des3_context *) ctx, key ); |
| 512 | } |
| 513 | |
| 514 | static void * des_ctx_alloc( void ) |
| 515 | { |
Paul Bakker | 6e339b5 | 2013-07-03 13:37:05 +0200 | [diff] [blame] | 516 | return polarssl_malloc( sizeof( des_context ) ); |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | static void * des3_ctx_alloc( void ) |
| 520 | { |
Paul Bakker | 6e339b5 | 2013-07-03 13:37:05 +0200 | [diff] [blame] | 521 | return polarssl_malloc( sizeof( des3_context ) ); |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | static void des_ctx_free( void *ctx ) |
| 525 | { |
Paul Bakker | 6e339b5 | 2013-07-03 13:37:05 +0200 | [diff] [blame] | 526 | polarssl_free( ctx ); |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 527 | } |
| 528 | |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 529 | const cipher_base_t des_info = { |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 530 | POLARSSL_CIPHER_ID_DES, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 531 | des_crypt_cbc_wrap, |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 532 | des_crypt_cfb128_wrap, |
| 533 | des_crypt_ctr_wrap, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 534 | des_setkey_enc_wrap, |
| 535 | des_setkey_dec_wrap, |
| 536 | des_ctx_alloc, |
| 537 | des_ctx_free |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 538 | }; |
| 539 | |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 540 | const cipher_info_t des_cbc_info = { |
| 541 | POLARSSL_CIPHER_DES_CBC, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 542 | POLARSSL_MODE_CBC, |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 543 | POLARSSL_KEY_LENGTH_DES, |
| 544 | "DES-CBC", |
| 545 | 8, |
| 546 | 8, |
| 547 | &des_info |
| 548 | }; |
| 549 | |
| 550 | const cipher_base_t des_ede_info = { |
| 551 | POLARSSL_CIPHER_ID_DES, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 552 | des3_crypt_cbc_wrap, |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 553 | des_crypt_cfb128_wrap, |
| 554 | des_crypt_ctr_wrap, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 555 | des3_set2key_enc_wrap, |
| 556 | des3_set2key_dec_wrap, |
| 557 | des3_ctx_alloc, |
| 558 | des_ctx_free |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 559 | }; |
| 560 | |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 561 | const cipher_info_t des_ede_cbc_info = { |
| 562 | POLARSSL_CIPHER_DES_EDE_CBC, |
| 563 | POLARSSL_MODE_CBC, |
| 564 | POLARSSL_KEY_LENGTH_DES_EDE, |
| 565 | "DES-EDE-CBC", |
Paul Bakker | 0e34235 | 2013-06-24 19:33:02 +0200 | [diff] [blame] | 566 | 8, |
| 567 | 8, |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 568 | &des_ede_info |
| 569 | }; |
| 570 | |
| 571 | const cipher_base_t des_ede3_info = { |
| 572 | POLARSSL_CIPHER_ID_DES, |
| 573 | des3_crypt_cbc_wrap, |
| 574 | des_crypt_cfb128_wrap, |
| 575 | des_crypt_ctr_wrap, |
| 576 | des3_set3key_enc_wrap, |
| 577 | des3_set3key_dec_wrap, |
| 578 | des3_ctx_alloc, |
| 579 | des_ctx_free |
| 580 | }; |
| 581 | |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 582 | const cipher_info_t des_ede3_cbc_info = { |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 583 | POLARSSL_CIPHER_DES_EDE3_CBC, |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 584 | POLARSSL_MODE_CBC, |
| 585 | POLARSSL_KEY_LENGTH_DES_EDE3, |
| 586 | "DES-EDE3-CBC", |
| 587 | 8, |
| 588 | 8, |
Paul Bakker | 343a870 | 2011-06-09 14:27:58 +0000 | [diff] [blame] | 589 | &des_ede3_info |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 590 | }; |
| 591 | #endif |
| 592 | |
Paul Bakker | 6132d0a | 2012-07-04 17:10:40 +0000 | [diff] [blame] | 593 | #if defined(POLARSSL_BLOWFISH_C) |
| 594 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 595 | static int blowfish_crypt_cbc_wrap( void *ctx, operation_t operation, size_t length, |
Paul Bakker | 6132d0a | 2012-07-04 17:10:40 +0000 | [diff] [blame] | 596 | unsigned char *iv, const unsigned char *input, unsigned char *output ) |
| 597 | { |
| 598 | return blowfish_crypt_cbc( (blowfish_context *) ctx, operation, length, iv, input, output ); |
| 599 | } |
| 600 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 601 | static int blowfish_crypt_cfb64_wrap( void *ctx, operation_t operation, size_t length, |
Paul Bakker | 6132d0a | 2012-07-04 17:10:40 +0000 | [diff] [blame] | 602 | size_t *iv_off, unsigned char *iv, const unsigned char *input, unsigned char *output ) |
| 603 | { |
| 604 | #if defined(POLARSSL_CIPHER_MODE_CFB) |
| 605 | return blowfish_crypt_cfb64( (blowfish_context *) ctx, operation, length, iv_off, iv, input, output ); |
| 606 | #else |
| 607 | ((void) ctx); |
| 608 | ((void) operation); |
| 609 | ((void) length); |
| 610 | ((void) iv_off); |
| 611 | ((void) iv); |
| 612 | ((void) input); |
| 613 | ((void) output); |
| 614 | |
| 615 | return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE; |
| 616 | #endif |
| 617 | } |
| 618 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 619 | static int blowfish_crypt_ctr_wrap( void *ctx, size_t length, |
Paul Bakker | 6132d0a | 2012-07-04 17:10:40 +0000 | [diff] [blame] | 620 | size_t *nc_off, unsigned char *nonce_counter, unsigned char *stream_block, |
| 621 | const unsigned char *input, unsigned char *output ) |
| 622 | { |
| 623 | #if defined(POLARSSL_CIPHER_MODE_CTR) |
| 624 | return blowfish_crypt_ctr( (blowfish_context *) ctx, length, nc_off, nonce_counter, |
| 625 | stream_block, input, output ); |
| 626 | #else |
| 627 | ((void) ctx); |
| 628 | ((void) length); |
| 629 | ((void) nc_off); |
| 630 | ((void) nonce_counter); |
| 631 | ((void) stream_block); |
| 632 | ((void) input); |
| 633 | ((void) output); |
| 634 | |
| 635 | return POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE; |
| 636 | #endif |
| 637 | } |
| 638 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 639 | static int blowfish_setkey_dec_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) |
Paul Bakker | 6132d0a | 2012-07-04 17:10:40 +0000 | [diff] [blame] | 640 | { |
| 641 | return blowfish_setkey( (blowfish_context *) ctx, key, key_length ); |
| 642 | } |
| 643 | |
Paul Bakker | fae35f0 | 2013-03-13 10:33:51 +0100 | [diff] [blame] | 644 | static int blowfish_setkey_enc_wrap( void *ctx, const unsigned char *key, unsigned int key_length ) |
Paul Bakker | 6132d0a | 2012-07-04 17:10:40 +0000 | [diff] [blame] | 645 | { |
| 646 | return blowfish_setkey( (blowfish_context *) ctx, key, key_length ); |
| 647 | } |
| 648 | |
| 649 | static void * blowfish_ctx_alloc( void ) |
| 650 | { |
Paul Bakker | 6e339b5 | 2013-07-03 13:37:05 +0200 | [diff] [blame] | 651 | return polarssl_malloc( sizeof( blowfish_context ) ); |
Paul Bakker | 6132d0a | 2012-07-04 17:10:40 +0000 | [diff] [blame] | 652 | } |
| 653 | |
| 654 | static void blowfish_ctx_free( void *ctx ) |
| 655 | { |
Paul Bakker | 6e339b5 | 2013-07-03 13:37:05 +0200 | [diff] [blame] | 656 | polarssl_free( ctx ); |
Paul Bakker | 6132d0a | 2012-07-04 17:10:40 +0000 | [diff] [blame] | 657 | } |
| 658 | |
| 659 | const cipher_base_t blowfish_info = { |
| 660 | POLARSSL_CIPHER_ID_BLOWFISH, |
| 661 | blowfish_crypt_cbc_wrap, |
| 662 | blowfish_crypt_cfb64_wrap, |
| 663 | blowfish_crypt_ctr_wrap, |
| 664 | blowfish_setkey_enc_wrap, |
| 665 | blowfish_setkey_dec_wrap, |
| 666 | blowfish_ctx_alloc, |
| 667 | blowfish_ctx_free |
| 668 | }; |
| 669 | |
| 670 | const cipher_info_t blowfish_cbc_info = { |
| 671 | POLARSSL_CIPHER_BLOWFISH_CBC, |
| 672 | POLARSSL_MODE_CBC, |
Paul Bakker | bfe671f | 2013-04-07 22:35:44 +0200 | [diff] [blame] | 673 | 128, |
Paul Bakker | 6132d0a | 2012-07-04 17:10:40 +0000 | [diff] [blame] | 674 | "BLOWFISH-CBC", |
| 675 | 8, |
| 676 | 8, |
| 677 | &blowfish_info |
| 678 | }; |
| 679 | |
| 680 | #if defined(POLARSSL_CIPHER_MODE_CFB) |
| 681 | const cipher_info_t blowfish_cfb64_info = { |
| 682 | POLARSSL_CIPHER_BLOWFISH_CFB64, |
| 683 | POLARSSL_MODE_CFB, |
Paul Bakker | bfe671f | 2013-04-07 22:35:44 +0200 | [diff] [blame] | 684 | 128, |
Paul Bakker | 6132d0a | 2012-07-04 17:10:40 +0000 | [diff] [blame] | 685 | "BLOWFISH-CFB64", |
| 686 | 8, |
| 687 | 8, |
| 688 | &blowfish_info |
| 689 | }; |
| 690 | #endif /* POLARSSL_CIPHER_MODE_CFB */ |
| 691 | |
| 692 | #if defined(POLARSSL_CIPHER_MODE_CTR) |
| 693 | const cipher_info_t blowfish_ctr_info = { |
| 694 | POLARSSL_CIPHER_BLOWFISH_CTR, |
| 695 | POLARSSL_MODE_CTR, |
Paul Bakker | bfe671f | 2013-04-07 22:35:44 +0200 | [diff] [blame] | 696 | 128, |
Paul Bakker | 6132d0a | 2012-07-04 17:10:40 +0000 | [diff] [blame] | 697 | "BLOWFISH-CTR", |
| 698 | 8, |
| 699 | 8, |
| 700 | &blowfish_info |
| 701 | }; |
| 702 | #endif /* POLARSSL_CIPHER_MODE_CTR */ |
| 703 | #endif /* POLARSSL_BLOWFISH_C */ |
| 704 | |
Paul Bakker | 68884e3 | 2013-01-07 18:20:04 +0100 | [diff] [blame] | 705 | #if defined(POLARSSL_ARC4_C) |
| 706 | static void * arc4_ctx_alloc( void ) |
| 707 | { |
| 708 | return (void *) 1; |
| 709 | } |
| 710 | |
| 711 | |
| 712 | static void arc4_ctx_free( void *ctx ) |
| 713 | { |
| 714 | ((void) ctx); |
| 715 | } |
| 716 | |
| 717 | const cipher_base_t arc4_base_info = { |
| 718 | POLARSSL_CIPHER_ID_ARC4, |
| 719 | NULL, |
| 720 | NULL, |
| 721 | NULL, |
| 722 | NULL, |
| 723 | NULL, |
| 724 | arc4_ctx_alloc, |
| 725 | arc4_ctx_free |
| 726 | }; |
| 727 | |
| 728 | const cipher_info_t arc4_128_info = { |
| 729 | POLARSSL_CIPHER_ARC4_128, |
| 730 | POLARSSL_MODE_STREAM, |
| 731 | 128, |
| 732 | "ARC4-128", |
| 733 | 0, |
| 734 | 1, |
| 735 | &arc4_base_info |
| 736 | }; |
| 737 | #endif /* POLARSSL_ARC4_C */ |
| 738 | |
Paul Bakker | fab5c82 | 2012-02-06 16:45:10 +0000 | [diff] [blame] | 739 | #if defined(POLARSSL_CIPHER_NULL_CIPHER) |
| 740 | static void * null_ctx_alloc( void ) |
| 741 | { |
| 742 | return (void *) 1; |
| 743 | } |
| 744 | |
| 745 | |
| 746 | static void null_ctx_free( void *ctx ) |
| 747 | { |
| 748 | ((void) ctx); |
| 749 | } |
| 750 | |
| 751 | const cipher_base_t null_base_info = { |
| 752 | POLARSSL_CIPHER_ID_NULL, |
| 753 | NULL, |
| 754 | NULL, |
| 755 | NULL, |
| 756 | NULL, |
| 757 | NULL, |
| 758 | null_ctx_alloc, |
| 759 | null_ctx_free |
| 760 | }; |
| 761 | |
| 762 | const cipher_info_t null_cipher_info = { |
| 763 | POLARSSL_CIPHER_NULL, |
| 764 | POLARSSL_MODE_NULL, |
| 765 | 0, |
| 766 | "NULL", |
Paul Bakker | 68884e3 | 2013-01-07 18:20:04 +0100 | [diff] [blame] | 767 | 0, |
Paul Bakker | fab5c82 | 2012-02-06 16:45:10 +0000 | [diff] [blame] | 768 | 1, |
| 769 | &null_base_info |
| 770 | }; |
| 771 | #endif /* defined(POLARSSL_CIPHER_NULL_CIPHER) */ |
| 772 | |
Paul Bakker | 8123e9d | 2011-01-06 15:37:30 +0000 | [diff] [blame] | 773 | #endif |