diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/evp/e_camellia.c | 507 |
1 files changed, 486 insertions, 21 deletions
diff --git a/src/lib/libcrypto/evp/e_camellia.c b/src/lib/libcrypto/evp/e_camellia.c index 70dad7ead6..46b918c163 100644 --- a/src/lib/libcrypto/evp/e_camellia.c +++ b/src/lib/libcrypto/evp/e_camellia.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: e_camellia.c,v 1.9 2021/12/12 21:30:13 tb Exp $ */ | 1 | /* $OpenBSD: e_camellia.c,v 1.10 2022/09/03 20:06:43 jsing Exp $ */ |
| 2 | /* ==================================================================== | 2 | /* ==================================================================== |
| 3 | * Copyright (c) 2006 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 2006 The OpenSSL Project. All rights reserved. |
| 4 | * | 4 | * |
| @@ -73,26 +73,491 @@ typedef struct { | |||
| 73 | } EVP_CAMELLIA_KEY; | 73 | } EVP_CAMELLIA_KEY; |
| 74 | 74 | ||
| 75 | /* Attribute operation for Camellia */ | 75 | /* Attribute operation for Camellia */ |
| 76 | #define data(ctx) EVP_C_DATA(EVP_CAMELLIA_KEY,ctx) | 76 | #define data(ctx) ((EVP_CAMELLIA_KEY *)(ctx)->cipher_data) |
| 77 | 77 | ||
| 78 | IMPLEMENT_BLOCK_CIPHER(camellia_128, ks, Camellia, EVP_CAMELLIA_KEY, | 78 | static int |
| 79 | NID_camellia_128, 16, 16, 16, 128, | 79 | camellia_128_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) |
| 80 | 0, camellia_init_key, NULL, | 80 | { |
| 81 | EVP_CIPHER_set_asn1_iv, | 81 | while (inl >= EVP_MAXCHUNK) { |
| 82 | EVP_CIPHER_get_asn1_iv, | 82 | Camellia_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); |
| 83 | NULL) | 83 | inl -= EVP_MAXCHUNK; |
| 84 | IMPLEMENT_BLOCK_CIPHER(camellia_192, ks, Camellia, EVP_CAMELLIA_KEY, | 84 | in += EVP_MAXCHUNK; |
| 85 | NID_camellia_192, 16, 24, 16, 128, | 85 | out += EVP_MAXCHUNK; |
| 86 | 0, camellia_init_key, NULL, | 86 | } |
| 87 | EVP_CIPHER_set_asn1_iv, | 87 | |
| 88 | EVP_CIPHER_get_asn1_iv, | 88 | if (inl) |
| 89 | NULL) | 89 | Camellia_cbc_encrypt(in, out, (long)inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); |
| 90 | IMPLEMENT_BLOCK_CIPHER(camellia_256, ks, Camellia, EVP_CAMELLIA_KEY, | 90 | |
| 91 | NID_camellia_256, 16, 32, 16, 128, | 91 | return 1; |
| 92 | 0, camellia_init_key, NULL, | 92 | } |
| 93 | EVP_CIPHER_set_asn1_iv, | 93 | |
| 94 | EVP_CIPHER_get_asn1_iv, | 94 | static int |
| 95 | NULL) | 95 | camellia_128_cfb128_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) |
| 96 | { | ||
| 97 | size_t chunk = EVP_MAXCHUNK; | ||
| 98 | |||
| 99 | if (128 == 1) | ||
| 100 | chunk >>= 3; | ||
| 101 | |||
| 102 | if (inl < chunk) | ||
| 103 | chunk = inl; | ||
| 104 | |||
| 105 | while (inl && inl >= chunk) { | ||
| 106 | Camellia_cfb128_encrypt(in, out, (long)((128 == 1) && !(ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS) ? inl * 8 : inl), &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); | ||
| 107 | inl -= chunk; | ||
| 108 | in += chunk; | ||
| 109 | out += chunk; | ||
| 110 | if (inl < chunk) | ||
| 111 | chunk = inl; | ||
| 112 | } | ||
| 113 | |||
| 114 | return 1; | ||
| 115 | } | ||
| 116 | |||
| 117 | static int | ||
| 118 | camellia_128_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) | ||
| 119 | { | ||
| 120 | size_t i, bl; | ||
| 121 | |||
| 122 | bl = ctx->cipher->block_size; | ||
| 123 | |||
| 124 | if (inl < bl) | ||
| 125 | return 1; | ||
| 126 | |||
| 127 | inl -= bl; | ||
| 128 | |||
| 129 | for (i = 0; i <= inl; i += bl) | ||
| 130 | Camellia_ecb_encrypt(in + i, out + i, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->encrypt); | ||
| 131 | |||
| 132 | return 1; | ||
| 133 | } | ||
| 134 | |||
| 135 | static int | ||
| 136 | camellia_128_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) | ||
| 137 | { | ||
| 138 | while (inl >= EVP_MAXCHUNK) { | ||
| 139 | Camellia_ofb128_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); | ||
| 140 | inl -= EVP_MAXCHUNK; | ||
| 141 | in += EVP_MAXCHUNK; | ||
| 142 | out += EVP_MAXCHUNK; | ||
| 143 | } | ||
| 144 | |||
| 145 | if (inl) | ||
| 146 | Camellia_ofb128_encrypt(in, out, (long)inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); | ||
| 147 | |||
| 148 | return 1; | ||
| 149 | } | ||
| 150 | |||
| 151 | static const EVP_CIPHER camellia_128_cbc = { | ||
| 152 | .nid = NID_camellia_128_cbc, | ||
| 153 | .block_size = 16, | ||
| 154 | .key_len = 16, | ||
| 155 | .iv_len = 16, | ||
| 156 | .flags = 0 | EVP_CIPH_CBC_MODE, | ||
| 157 | .init = camellia_init_key, | ||
| 158 | .do_cipher = camellia_128_cbc_cipher, | ||
| 159 | .cleanup = NULL, | ||
| 160 | .ctx_size = sizeof(EVP_CAMELLIA_KEY), | ||
| 161 | .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, | ||
| 162 | .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, | ||
| 163 | .ctrl = NULL, | ||
| 164 | .app_data = NULL, | ||
| 165 | }; | ||
| 166 | |||
| 167 | const EVP_CIPHER * | ||
| 168 | EVP_camellia_128_cbc(void) | ||
| 169 | { | ||
| 170 | return &camellia_128_cbc; | ||
| 171 | } | ||
| 172 | |||
| 173 | static const EVP_CIPHER camellia_128_cfb128 = { | ||
| 174 | .nid = NID_camellia_128_cfb128, | ||
| 175 | .block_size = 1, | ||
| 176 | .key_len = 16, | ||
| 177 | .iv_len = 16, | ||
| 178 | .flags = 0 | EVP_CIPH_CFB_MODE, | ||
| 179 | .init = camellia_init_key, | ||
| 180 | .do_cipher = camellia_128_cfb128_cipher, | ||
| 181 | .cleanup = NULL, | ||
| 182 | .ctx_size = sizeof(EVP_CAMELLIA_KEY), | ||
| 183 | .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, | ||
| 184 | .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, | ||
| 185 | .ctrl = NULL, | ||
| 186 | .app_data = NULL, | ||
| 187 | }; | ||
| 188 | |||
| 189 | const EVP_CIPHER * | ||
| 190 | EVP_camellia_128_cfb128(void) | ||
| 191 | { | ||
| 192 | return &camellia_128_cfb128; | ||
| 193 | } | ||
| 194 | |||
| 195 | static const EVP_CIPHER camellia_128_ofb = { | ||
| 196 | .nid = NID_camellia_128_ofb128, | ||
| 197 | .block_size = 1, | ||
| 198 | .key_len = 16, | ||
| 199 | .iv_len = 16, | ||
| 200 | .flags = 0 | EVP_CIPH_OFB_MODE, | ||
| 201 | .init = camellia_init_key, | ||
| 202 | .do_cipher = camellia_128_ofb_cipher, | ||
| 203 | .cleanup = NULL, | ||
| 204 | .ctx_size = sizeof(EVP_CAMELLIA_KEY), | ||
| 205 | .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, | ||
| 206 | .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, | ||
| 207 | .ctrl = NULL, | ||
| 208 | .app_data = NULL, | ||
| 209 | }; | ||
| 210 | |||
| 211 | const EVP_CIPHER * | ||
| 212 | EVP_camellia_128_ofb(void) | ||
| 213 | { | ||
| 214 | return &camellia_128_ofb; | ||
| 215 | } | ||
| 216 | |||
| 217 | static const EVP_CIPHER camellia_128_ecb = { | ||
| 218 | .nid = NID_camellia_128_ecb, | ||
| 219 | .block_size = 16, | ||
| 220 | .key_len = 16, | ||
| 221 | .iv_len = 0, | ||
| 222 | .flags = 0 | EVP_CIPH_ECB_MODE, | ||
| 223 | .init = camellia_init_key, | ||
| 224 | .do_cipher = camellia_128_ecb_cipher, | ||
| 225 | .cleanup = NULL, | ||
| 226 | .ctx_size = sizeof(EVP_CAMELLIA_KEY), | ||
| 227 | .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, | ||
| 228 | .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, | ||
| 229 | .ctrl = NULL, | ||
| 230 | .app_data = NULL, | ||
| 231 | }; | ||
| 232 | |||
| 233 | const EVP_CIPHER * | ||
| 234 | EVP_camellia_128_ecb(void) | ||
| 235 | { | ||
| 236 | return &camellia_128_ecb; | ||
| 237 | } | ||
| 238 | |||
| 239 | static int | ||
| 240 | camellia_192_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) | ||
| 241 | { | ||
| 242 | while (inl >= EVP_MAXCHUNK) { | ||
| 243 | Camellia_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); | ||
| 244 | inl -= EVP_MAXCHUNK; | ||
| 245 | in += EVP_MAXCHUNK; | ||
| 246 | out += EVP_MAXCHUNK; | ||
| 247 | } | ||
| 248 | |||
| 249 | if (inl) | ||
| 250 | Camellia_cbc_encrypt(in, out, (long)inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); | ||
| 251 | |||
| 252 | return 1; | ||
| 253 | } | ||
| 254 | |||
| 255 | static int | ||
| 256 | camellia_192_cfb128_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) | ||
| 257 | { | ||
| 258 | size_t chunk = EVP_MAXCHUNK; | ||
| 259 | |||
| 260 | if (128 == 1) | ||
| 261 | chunk >>= 3; | ||
| 262 | |||
| 263 | if (inl < chunk) | ||
| 264 | chunk = inl; | ||
| 265 | |||
| 266 | while (inl && inl >= chunk) { | ||
| 267 | Camellia_cfb128_encrypt(in, out, (long)((128 == 1) && !(ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS) ? inl * 8 : inl), &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); | ||
| 268 | inl -= chunk; | ||
| 269 | in += chunk; | ||
| 270 | out += chunk; | ||
| 271 | if (inl < chunk) | ||
| 272 | chunk = inl; | ||
| 273 | } | ||
| 274 | |||
| 275 | return 1; | ||
| 276 | } | ||
| 277 | |||
| 278 | static int | ||
| 279 | camellia_192_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) | ||
| 280 | { | ||
| 281 | size_t i, bl; | ||
| 282 | |||
| 283 | bl = ctx->cipher->block_size; | ||
| 284 | |||
| 285 | if (inl < bl) | ||
| 286 | return 1; | ||
| 287 | |||
| 288 | inl -= bl; | ||
| 289 | |||
| 290 | for (i = 0; i <= inl; i += bl) | ||
| 291 | Camellia_ecb_encrypt(in + i, out + i, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->encrypt); | ||
| 292 | |||
| 293 | return 1; | ||
| 294 | } | ||
| 295 | |||
| 296 | static int | ||
| 297 | camellia_192_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) | ||
| 298 | { | ||
| 299 | while (inl >= EVP_MAXCHUNK) { | ||
| 300 | Camellia_ofb128_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); | ||
| 301 | inl -= EVP_MAXCHUNK; | ||
| 302 | in += EVP_MAXCHUNK; | ||
| 303 | out += EVP_MAXCHUNK; | ||
| 304 | } | ||
| 305 | |||
| 306 | if (inl) | ||
| 307 | Camellia_ofb128_encrypt(in, out, (long)inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); | ||
| 308 | |||
| 309 | return 1; | ||
| 310 | } | ||
| 311 | |||
| 312 | static const EVP_CIPHER camellia_192_cbc = { | ||
| 313 | .nid = NID_camellia_192_cbc, | ||
| 314 | .block_size = 16, | ||
| 315 | .key_len = 24, | ||
| 316 | .iv_len = 16, | ||
| 317 | .flags = 0 | EVP_CIPH_CBC_MODE, | ||
| 318 | .init = camellia_init_key, | ||
| 319 | .do_cipher = camellia_192_cbc_cipher, | ||
| 320 | .cleanup = NULL, | ||
| 321 | .ctx_size = sizeof(EVP_CAMELLIA_KEY), | ||
| 322 | .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, | ||
| 323 | .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, | ||
| 324 | .ctrl = NULL, | ||
| 325 | .app_data = NULL, | ||
| 326 | }; | ||
| 327 | |||
| 328 | const EVP_CIPHER * | ||
| 329 | EVP_camellia_192_cbc(void) | ||
| 330 | { | ||
| 331 | return &camellia_192_cbc; | ||
| 332 | } | ||
| 333 | |||
| 334 | static const EVP_CIPHER camellia_192_cfb128 = { | ||
| 335 | .nid = NID_camellia_192_cfb128, | ||
| 336 | .block_size = 1, | ||
| 337 | .key_len = 24, | ||
| 338 | .iv_len = 16, | ||
| 339 | .flags = 0 | EVP_CIPH_CFB_MODE, | ||
| 340 | .init = camellia_init_key, | ||
| 341 | .do_cipher = camellia_192_cfb128_cipher, | ||
| 342 | .cleanup = NULL, | ||
| 343 | .ctx_size = sizeof(EVP_CAMELLIA_KEY), | ||
| 344 | .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, | ||
| 345 | .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, | ||
| 346 | .ctrl = NULL, | ||
| 347 | .app_data = NULL, | ||
| 348 | }; | ||
| 349 | |||
| 350 | const EVP_CIPHER * | ||
| 351 | EVP_camellia_192_cfb128(void) | ||
| 352 | { | ||
| 353 | return &camellia_192_cfb128; | ||
| 354 | } | ||
| 355 | |||
| 356 | static const EVP_CIPHER camellia_192_ofb = { | ||
| 357 | .nid = NID_camellia_192_ofb128, | ||
| 358 | .block_size = 1, | ||
| 359 | .key_len = 24, | ||
| 360 | .iv_len = 16, | ||
| 361 | .flags = 0 | EVP_CIPH_OFB_MODE, | ||
| 362 | .init = camellia_init_key, | ||
| 363 | .do_cipher = camellia_192_ofb_cipher, | ||
| 364 | .cleanup = NULL, | ||
| 365 | .ctx_size = sizeof(EVP_CAMELLIA_KEY), | ||
| 366 | .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, | ||
| 367 | .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, | ||
| 368 | .ctrl = NULL, | ||
| 369 | .app_data = NULL, | ||
| 370 | }; | ||
| 371 | |||
| 372 | const EVP_CIPHER * | ||
| 373 | EVP_camellia_192_ofb(void) | ||
| 374 | { | ||
| 375 | return &camellia_192_ofb; | ||
| 376 | } | ||
| 377 | |||
| 378 | static const EVP_CIPHER camellia_192_ecb = { | ||
| 379 | .nid = NID_camellia_192_ecb, | ||
| 380 | .block_size = 16, | ||
| 381 | .key_len = 24, | ||
| 382 | .iv_len = 0, | ||
| 383 | .flags = 0 | EVP_CIPH_ECB_MODE, | ||
| 384 | .init = camellia_init_key, | ||
| 385 | .do_cipher = camellia_192_ecb_cipher, | ||
| 386 | .cleanup = NULL, | ||
| 387 | .ctx_size = sizeof(EVP_CAMELLIA_KEY), | ||
| 388 | .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, | ||
| 389 | .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, | ||
| 390 | .ctrl = NULL, | ||
| 391 | .app_data = NULL, | ||
| 392 | }; | ||
| 393 | |||
| 394 | const EVP_CIPHER * | ||
| 395 | EVP_camellia_192_ecb(void) | ||
| 396 | { | ||
| 397 | return &camellia_192_ecb; | ||
| 398 | } | ||
| 399 | |||
| 400 | static int | ||
| 401 | camellia_256_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) | ||
| 402 | { | ||
| 403 | while (inl >= EVP_MAXCHUNK) { | ||
| 404 | Camellia_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); | ||
| 405 | inl -= EVP_MAXCHUNK; | ||
| 406 | in += EVP_MAXCHUNK; | ||
| 407 | out += EVP_MAXCHUNK; | ||
| 408 | } | ||
| 409 | |||
| 410 | if (inl) | ||
| 411 | Camellia_cbc_encrypt(in, out, (long)inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, ctx->encrypt); | ||
| 412 | |||
| 413 | return 1; | ||
| 414 | } | ||
| 415 | |||
| 416 | static int | ||
| 417 | camellia_256_cfb128_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) | ||
| 418 | { | ||
| 419 | size_t chunk = EVP_MAXCHUNK; | ||
| 420 | |||
| 421 | if (128 == 1) | ||
| 422 | chunk >>= 3; | ||
| 423 | |||
| 424 | if (inl < chunk) | ||
| 425 | chunk = inl; | ||
| 426 | |||
| 427 | while (inl && inl >= chunk) { | ||
| 428 | Camellia_cfb128_encrypt(in, out, (long)((128 == 1) && !(ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS) ? inl * 8 : inl), &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num, ctx->encrypt); | ||
| 429 | inl -= chunk; | ||
| 430 | in += chunk; | ||
| 431 | out += chunk; | ||
| 432 | if (inl < chunk) | ||
| 433 | chunk = inl; | ||
| 434 | } | ||
| 435 | |||
| 436 | return 1; | ||
| 437 | } | ||
| 438 | |||
| 439 | static int | ||
| 440 | camellia_256_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) | ||
| 441 | { | ||
| 442 | size_t i, bl; | ||
| 443 | |||
| 444 | bl = ctx->cipher->block_size; | ||
| 445 | |||
| 446 | if (inl < bl) | ||
| 447 | return 1; | ||
| 448 | |||
| 449 | inl -= bl; | ||
| 450 | |||
| 451 | for (i = 0; i <= inl; i += bl) | ||
| 452 | Camellia_ecb_encrypt(in + i, out + i, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->encrypt); | ||
| 453 | |||
| 454 | return 1; | ||
| 455 | } | ||
| 456 | |||
| 457 | static int | ||
| 458 | camellia_256_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) | ||
| 459 | { | ||
| 460 | while (inl >= EVP_MAXCHUNK) { | ||
| 461 | Camellia_ofb128_encrypt(in, out, (long)EVP_MAXCHUNK, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); | ||
| 462 | inl -= EVP_MAXCHUNK; | ||
| 463 | in += EVP_MAXCHUNK; | ||
| 464 | out += EVP_MAXCHUNK; | ||
| 465 | } | ||
| 466 | |||
| 467 | if (inl) | ||
| 468 | Camellia_ofb128_encrypt(in, out, (long)inl, &((EVP_CAMELLIA_KEY *)ctx->cipher_data)->ks, ctx->iv, &ctx->num); | ||
| 469 | |||
| 470 | return 1; | ||
| 471 | } | ||
| 472 | |||
| 473 | static const EVP_CIPHER camellia_256_cbc = { | ||
| 474 | .nid = NID_camellia_256_cbc, | ||
| 475 | .block_size = 16, | ||
| 476 | .key_len = 32, | ||
| 477 | .iv_len = 16, | ||
| 478 | .flags = 0 | EVP_CIPH_CBC_MODE, | ||
| 479 | .init = camellia_init_key, | ||
| 480 | .do_cipher = camellia_256_cbc_cipher, | ||
| 481 | .cleanup = NULL, | ||
| 482 | .ctx_size = sizeof(EVP_CAMELLIA_KEY), | ||
| 483 | .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, | ||
| 484 | .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, | ||
| 485 | .ctrl = NULL, | ||
| 486 | .app_data = NULL, | ||
| 487 | }; | ||
| 488 | |||
| 489 | const EVP_CIPHER * | ||
| 490 | EVP_camellia_256_cbc(void) | ||
| 491 | { | ||
| 492 | return &camellia_256_cbc; | ||
| 493 | } | ||
| 494 | |||
| 495 | static const EVP_CIPHER camellia_256_cfb128 = { | ||
| 496 | .nid = NID_camellia_256_cfb128, | ||
| 497 | .block_size = 1, | ||
| 498 | .key_len = 32, | ||
| 499 | .iv_len = 16, | ||
| 500 | .flags = 0 | EVP_CIPH_CFB_MODE, | ||
| 501 | .init = camellia_init_key, | ||
| 502 | .do_cipher = camellia_256_cfb128_cipher, | ||
| 503 | .cleanup = NULL, | ||
| 504 | .ctx_size = sizeof(EVP_CAMELLIA_KEY), | ||
| 505 | .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, | ||
| 506 | .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, | ||
| 507 | .ctrl = NULL, | ||
| 508 | .app_data = NULL, | ||
| 509 | }; | ||
| 510 | |||
| 511 | const EVP_CIPHER * | ||
| 512 | EVP_camellia_256_cfb128(void) | ||
| 513 | { | ||
| 514 | return &camellia_256_cfb128; | ||
| 515 | } | ||
| 516 | |||
| 517 | static const EVP_CIPHER camellia_256_ofb = { | ||
| 518 | .nid = NID_camellia_256_ofb128, | ||
| 519 | .block_size = 1, | ||
| 520 | .key_len = 32, | ||
| 521 | .iv_len = 16, | ||
| 522 | .flags = 0 | EVP_CIPH_OFB_MODE, | ||
| 523 | .init = camellia_init_key, | ||
| 524 | .do_cipher = camellia_256_ofb_cipher, | ||
| 525 | .cleanup = NULL, | ||
| 526 | .ctx_size = sizeof(EVP_CAMELLIA_KEY), | ||
| 527 | .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, | ||
| 528 | .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, | ||
| 529 | .ctrl = NULL, | ||
| 530 | .app_data = NULL, | ||
| 531 | }; | ||
| 532 | |||
| 533 | const EVP_CIPHER * | ||
| 534 | EVP_camellia_256_ofb(void) | ||
| 535 | { | ||
| 536 | return &camellia_256_ofb; | ||
| 537 | } | ||
| 538 | |||
| 539 | static const EVP_CIPHER camellia_256_ecb = { | ||
| 540 | .nid = NID_camellia_256_ecb, | ||
| 541 | .block_size = 16, | ||
| 542 | .key_len = 32, | ||
| 543 | .iv_len = 0, | ||
| 544 | .flags = 0 | EVP_CIPH_ECB_MODE, | ||
| 545 | .init = camellia_init_key, | ||
| 546 | .do_cipher = camellia_256_ecb_cipher, | ||
| 547 | .cleanup = NULL, | ||
| 548 | .ctx_size = sizeof(EVP_CAMELLIA_KEY), | ||
| 549 | .set_asn1_parameters = EVP_CIPHER_set_asn1_iv, | ||
| 550 | .get_asn1_parameters = EVP_CIPHER_get_asn1_iv, | ||
| 551 | .ctrl = NULL, | ||
| 552 | .app_data = NULL, | ||
| 553 | }; | ||
| 554 | |||
| 555 | const EVP_CIPHER * | ||
| 556 | EVP_camellia_256_ecb(void) | ||
| 557 | { | ||
| 558 | return &camellia_256_ecb; | ||
| 559 | } | ||
| 560 | |||
| 96 | 561 | ||
| 97 | #define IMPLEMENT_CAMELLIA_CFBR(ksize,cbits) IMPLEMENT_CFBR(camellia,Camellia,EVP_CAMELLIA_KEY,ks,ksize,cbits,16) | 562 | #define IMPLEMENT_CAMELLIA_CFBR(ksize,cbits) IMPLEMENT_CFBR(camellia,Camellia,EVP_CAMELLIA_KEY,ks,ksize,cbits,16) |
| 98 | 563 | ||
