]>
Commit | Line | Data |
---|---|---|
3837c202 SL |
1 | /* |
2 | * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. | |
3 | * | |
4 | * Licensed under the Apache License 2.0 (the "License"). You may not use | |
5 | * this file except in compliance with the License. You can obtain a copy | |
6 | * in the file LICENSE in the source distribution or at | |
7 | * https://www.openssl.org/source/license.html | |
8 | */ | |
9 | ||
10 | #include "cipher_aes_ocb.h" | |
11 | #include "internal/providercommonerr.h" | |
12 | #include "internal/ciphers/cipher_aead.h" | |
13 | #include "internal/provider_algs.h" | |
14 | ||
15 | #define AES_OCB_FLAGS AEAD_FLAGS | |
16 | ||
17 | #define OCB_DEFAULT_TAG_LEN 16 | |
18 | #define OCB_DEFAULT_IV_LEN 12 | |
19 | #define OCB_MIN_IV_LEN 1 | |
20 | #define OCB_MAX_IV_LEN 15 | |
21 | ||
22 | PROV_CIPHER_FUNC(int, ocb_cipher, (PROV_AES_OCB_CTX *ctx, | |
23 | const unsigned char *in, unsigned char *out, | |
24 | size_t nextblock)); | |
25 | /* forward declarations */ | |
26 | static OSSL_OP_cipher_encrypt_init_fn aes_ocb_einit; | |
27 | static OSSL_OP_cipher_decrypt_init_fn aes_ocb_dinit; | |
28 | static OSSL_OP_cipher_update_fn aes_ocb_block_update; | |
29 | static OSSL_OP_cipher_final_fn aes_ocb_block_final; | |
30 | static OSSL_OP_cipher_cipher_fn aes_ocb_cipher; | |
31 | static OSSL_OP_cipher_freectx_fn aes_ocb_freectx; | |
32 | static OSSL_OP_cipher_dupctx_fn aes_ocb_dupctx; | |
33 | static OSSL_OP_cipher_get_ctx_params_fn aes_ocb_get_ctx_params; | |
34 | static OSSL_OP_cipher_set_ctx_params_fn aes_ocb_set_ctx_params; | |
35 | ||
36 | /* | |
37 | * The following methods could be moved into PROV_AES_OCB_HW if | |
38 | * multiple hardware implementations are ever needed. | |
39 | */ | |
40 | static ossl_inline int aes_generic_ocb_setiv(PROV_AES_OCB_CTX *ctx, | |
41 | const unsigned char *iv, | |
42 | size_t ivlen, size_t taglen) | |
43 | { | |
44 | return (CRYPTO_ocb128_setiv(&ctx->ocb, iv, ivlen, taglen) == 1); | |
45 | } | |
46 | ||
47 | static ossl_inline int aes_generic_ocb_setaad(PROV_AES_OCB_CTX *ctx, | |
48 | const unsigned char *aad, | |
49 | size_t alen) | |
50 | { | |
51 | return CRYPTO_ocb128_aad(&ctx->ocb, aad, alen) == 1; | |
52 | } | |
53 | ||
54 | static ossl_inline int aes_generic_ocb_gettag(PROV_AES_OCB_CTX *ctx, | |
55 | unsigned char *tag, size_t tlen) | |
56 | { | |
57 | return CRYPTO_ocb128_tag(&ctx->ocb, tag, tlen) > 0; | |
58 | } | |
59 | ||
60 | static ossl_inline int aes_generic_ocb_final(PROV_AES_OCB_CTX *ctx) | |
61 | { | |
62 | return (CRYPTO_ocb128_finish(&ctx->ocb, ctx->tag, ctx->taglen) == 0); | |
63 | } | |
64 | ||
65 | static ossl_inline void aes_generic_ocb_cleanup(PROV_AES_OCB_CTX *ctx) | |
66 | { | |
67 | CRYPTO_ocb128_cleanup(&ctx->ocb); | |
68 | } | |
69 | ||
70 | static ossl_inline int aes_generic_ocb_cipher(PROV_AES_OCB_CTX *ctx, | |
71 | const unsigned char *in, | |
72 | unsigned char *out, size_t len) | |
73 | { | |
74 | if (ctx->base.enc) { | |
75 | if (!CRYPTO_ocb128_encrypt(&ctx->ocb, in, out, len)) | |
76 | return 0; | |
77 | } else { | |
78 | if (!CRYPTO_ocb128_decrypt(&ctx->ocb, in, out, len)) | |
79 | return 0; | |
80 | } | |
81 | return 1; | |
82 | } | |
83 | ||
84 | static ossl_inline int aes_generic_ocb_copy_ctx(PROV_AES_OCB_CTX *dst, | |
85 | PROV_AES_OCB_CTX *src) | |
86 | { | |
87 | return (!CRYPTO_ocb128_copy_ctx(&dst->ocb, &src->ocb, | |
88 | &src->ksenc.ks, &src->ksdec.ks)); | |
89 | } | |
90 | ||
91 | /*- | |
92 | * Provider dispatch functions | |
93 | */ | |
94 | static int aes_ocb_init(void *vctx, const unsigned char *key, size_t keylen, | |
95 | const unsigned char *iv, size_t ivlen, int enc) | |
96 | { | |
97 | PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx; | |
98 | ||
99 | ctx->base.enc = enc; | |
100 | ||
101 | if (iv != NULL) { | |
102 | if (ivlen != ctx->base.ivlen) { | |
103 | /* IV len must be 1 to 15 */ | |
104 | if (ivlen < OCB_MIN_IV_LEN || ivlen > OCB_MAX_IV_LEN) { | |
105 | ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_IV_LENGTH); | |
106 | return 0; | |
107 | } | |
108 | ctx->base.ivlen = ivlen; | |
109 | } | |
110 | memcpy(ctx->base.iv, iv, ivlen); | |
111 | ctx->iv_state = IV_STATE_BUFFERED; | |
112 | } | |
113 | if (key != NULL) { | |
114 | if (keylen != ctx->base.keylen) { | |
115 | ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH); | |
116 | return 0; | |
117 | } | |
118 | return ctx->base.hw->init(&ctx->base, key, keylen); | |
119 | } | |
120 | return 1; | |
121 | } | |
122 | ||
123 | static int aes_ocb_einit(void *vctx, const unsigned char *key, size_t keylen, | |
124 | const unsigned char *iv, size_t ivlen) | |
125 | { | |
126 | return aes_ocb_init(vctx, key, keylen, iv, ivlen, 1); | |
127 | } | |
128 | ||
129 | static int aes_ocb_dinit(void *vctx, const unsigned char *key, size_t keylen, | |
130 | const unsigned char *iv, size_t ivlen) | |
131 | { | |
132 | return aes_ocb_init(vctx, key, keylen, iv, ivlen, 0); | |
133 | } | |
134 | ||
135 | /* | |
136 | * Because of the way OCB works, both the AAD and data are buffered in the | |
137 | * same way. Only the last block can be a partial block. | |
138 | */ | |
139 | static int aes_ocb_block_update_internal(PROV_AES_OCB_CTX *ctx, | |
140 | unsigned char *buf, size_t *bufsz, | |
141 | unsigned char *out, size_t *outl, | |
142 | size_t outsize, const unsigned char *in, | |
143 | size_t inl, OSSL_ocb_cipher_fn ciph) | |
144 | { | |
145 | size_t nextblocks = fillblock(buf, bufsz, AES_BLOCK_SIZE, &in, &inl); | |
146 | size_t outlint = 0; | |
147 | ||
148 | if (*bufsz == AES_BLOCK_SIZE) { | |
149 | if (outsize < AES_BLOCK_SIZE) { | |
150 | ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL); | |
151 | return 0; | |
152 | } | |
153 | if (!ciph(ctx, buf, out, AES_BLOCK_SIZE)) { | |
154 | ERR_raise(ERR_LIB_PROV, PROV_R_CIPHER_OPERATION_FAILED); | |
155 | return 0; | |
156 | } | |
157 | *bufsz = 0; | |
158 | outlint = AES_BLOCK_SIZE; | |
159 | out += AES_BLOCK_SIZE; | |
160 | } | |
161 | if (nextblocks > 0) { | |
162 | outlint += nextblocks; | |
163 | if (outsize < outlint) { | |
164 | ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL); | |
165 | return 0; | |
166 | } | |
167 | if (!ciph(ctx, in, out, nextblocks)) { | |
168 | ERR_raise(ERR_LIB_PROV, PROV_R_CIPHER_OPERATION_FAILED); | |
169 | return 0; | |
170 | } | |
171 | in += nextblocks; | |
172 | inl -= nextblocks; | |
173 | } | |
174 | if (!trailingdata(buf, bufsz, AES_BLOCK_SIZE, &in, &inl)) { | |
175 | /* PROVerr already called */ | |
176 | return 0; | |
177 | } | |
178 | ||
179 | *outl = outlint; | |
180 | return inl == 0; | |
181 | } | |
182 | ||
183 | /* A wrapper function that has the same signature as cipher */ | |
184 | static int cipher_updateaad(PROV_AES_OCB_CTX *ctx, const unsigned char *in, | |
185 | unsigned char *out, size_t len) | |
186 | { | |
187 | return aes_generic_ocb_setaad(ctx, in, len); | |
188 | } | |
189 | ||
190 | static int update_iv(PROV_AES_OCB_CTX *ctx) | |
191 | { | |
192 | if (ctx->iv_state == IV_STATE_FINISHED | |
193 | || ctx->iv_state == IV_STATE_UNINITIALISED) | |
194 | return 0; | |
195 | if (ctx->iv_state == IV_STATE_BUFFERED) { | |
196 | if (!aes_generic_ocb_setiv(ctx, ctx->base.iv, ctx->base.ivlen, | |
197 | ctx->taglen)) | |
198 | return 0; | |
199 | ctx->iv_state = IV_STATE_COPIED; | |
200 | } | |
201 | return 1; | |
202 | } | |
203 | ||
204 | static int aes_ocb_block_update(void *vctx, unsigned char *out, size_t *outl, | |
205 | size_t outsize, const unsigned char *in, | |
206 | size_t inl) | |
207 | { | |
208 | PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx; | |
209 | unsigned char *buf; | |
210 | size_t *buflen; | |
211 | OSSL_ocb_cipher_fn fn; | |
212 | ||
213 | if (!ctx->key_set || !update_iv(ctx)) | |
214 | return 0; | |
215 | ||
216 | /* Are we dealing with AAD or normal data here? */ | |
217 | if (out == NULL) { | |
218 | buf = ctx->aad_buf; | |
219 | buflen = &ctx->aad_buf_len; | |
220 | fn = cipher_updateaad; | |
221 | } else { | |
222 | buf = ctx->data_buf; | |
223 | buflen = &ctx->data_buf_len; | |
224 | fn = aes_generic_ocb_cipher; | |
225 | } | |
226 | return aes_ocb_block_update_internal(ctx, buf, buflen, out, outl, outsize, | |
227 | in, inl, fn); | |
228 | } | |
229 | ||
230 | static int aes_ocb_block_final(void *vctx, unsigned char *out, size_t *outl, | |
231 | size_t outsize) | |
232 | { | |
233 | PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx; | |
234 | ||
235 | /* If no block_update has run then the iv still needs to be set */ | |
236 | if (!ctx->key_set || !update_iv(ctx)) | |
237 | return 0; | |
238 | ||
239 | /* | |
240 | * Empty the buffer of any partial block that we might have been provided, | |
241 | * both for data and AAD | |
242 | */ | |
243 | *outl = 0; | |
244 | if (ctx->data_buf_len > 0) { | |
245 | if (!aes_generic_ocb_cipher(ctx, ctx->data_buf, out, ctx->data_buf_len)) | |
246 | return 0; | |
247 | *outl = ctx->data_buf_len; | |
248 | ctx->data_buf_len = 0; | |
249 | } | |
250 | if (ctx->aad_buf_len > 0) { | |
251 | if (!aes_generic_ocb_setaad(ctx, ctx->aad_buf, ctx->aad_buf_len)) | |
252 | return 0; | |
253 | ctx->aad_buf_len = 0; | |
254 | } | |
255 | if (ctx->base.enc) { | |
256 | /* If encrypting then just get the tag */ | |
257 | if (!aes_generic_ocb_gettag(ctx, ctx->tag, ctx->taglen)) | |
258 | return 0; | |
259 | } else { | |
260 | /* If decrypting then verify */ | |
261 | if (ctx->taglen == 0) | |
262 | return 0; | |
263 | if (!aes_generic_ocb_final(ctx)) | |
264 | return 0; | |
265 | } | |
266 | /* Don't reuse the IV */ | |
267 | ctx->iv_state = IV_STATE_FINISHED; | |
268 | return 1; | |
269 | } | |
270 | ||
271 | static void *aes_ocb_newctx(void *provctx, size_t kbits, size_t blkbits, | |
272 | size_t ivbits, unsigned int mode, uint64_t flags) | |
273 | { | |
274 | PROV_AES_OCB_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx)); | |
275 | ||
276 | if (ctx != NULL) { | |
277 | cipher_generic_initkey(ctx, kbits, blkbits, ivbits, mode, flags, | |
278 | PROV_CIPHER_HW_aes_ocb(kbits), NULL); | |
279 | ctx->taglen = OCB_DEFAULT_TAG_LEN; | |
280 | } | |
281 | return ctx; | |
282 | } | |
283 | ||
284 | static void aes_ocb_freectx(void *vctx) | |
285 | { | |
286 | PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx; | |
287 | ||
288 | aes_generic_ocb_cleanup(ctx); | |
289 | OPENSSL_cleanse(ctx->base.iv, sizeof(ctx->base.iv)); | |
290 | OPENSSL_clear_free(ctx, sizeof(*ctx)); | |
291 | } | |
292 | ||
293 | static void *aes_ocb_dupctx(void *vctx) | |
294 | { | |
295 | PROV_AES_OCB_CTX *in = (PROV_AES_OCB_CTX *)vctx; | |
296 | PROV_AES_OCB_CTX *ret = OPENSSL_malloc(sizeof(*ret)); | |
297 | ||
298 | if (ret == NULL) { | |
299 | ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE); | |
300 | return NULL; | |
301 | } | |
302 | *ret = *in; | |
303 | if (!aes_generic_ocb_copy_ctx(ret, in)) | |
304 | OPENSSL_free(ret); | |
305 | return ret; | |
306 | } | |
307 | ||
308 | static int aes_ocb_set_ctx_params(void *vctx, const OSSL_PARAM params[]) | |
309 | { | |
310 | PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx; | |
311 | const OSSL_PARAM *p; | |
312 | size_t sz; | |
313 | ||
314 | p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_AEAD_TAG); | |
315 | if (p != NULL) { | |
316 | if (p->data_type != OSSL_PARAM_OCTET_STRING) { | |
317 | ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER); | |
318 | return 0; | |
319 | } | |
320 | if (p->data == NULL) { | |
321 | /* Tag len must be 0 to 16 */ | |
322 | if (p->data_size > OCB_MAX_TAG_LEN) | |
323 | return 0; | |
324 | ctx->taglen = p->data_size; | |
325 | } else { | |
326 | if (p->data_size != ctx->taglen || ctx->base.enc) | |
327 | return 0; | |
328 | memcpy(ctx->tag, p->data, p->data_size); | |
329 | } | |
330 | } | |
331 | p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_AEAD_IVLEN); | |
332 | if (p != NULL) { | |
333 | if (!OSSL_PARAM_get_size_t(p, &sz)) { | |
334 | ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER); | |
335 | return 0; | |
336 | } | |
337 | /* IV len must be 1 to 15 */ | |
338 | if (sz < OCB_MIN_IV_LEN || sz > OCB_MAX_IV_LEN) | |
339 | return 0; | |
340 | ctx->base.ivlen = sz; | |
341 | } | |
342 | p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_KEYLEN); | |
343 | if (p != NULL) { | |
344 | size_t keylen; | |
345 | ||
346 | if (!OSSL_PARAM_get_size_t(p, &keylen)) { | |
347 | ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER); | |
348 | return 0; | |
349 | } | |
350 | if (ctx->base.keylen != keylen) { | |
351 | ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH); | |
352 | return 0; | |
353 | } | |
354 | } | |
355 | return 1; | |
356 | } | |
357 | ||
358 | static int aes_ocb_get_ctx_params(void *vctx, OSSL_PARAM params[]) | |
359 | { | |
360 | PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx; | |
361 | OSSL_PARAM *p; | |
362 | ||
363 | p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_IVLEN); | |
364 | if (p != NULL && !OSSL_PARAM_set_size_t(p, ctx->base.ivlen)) { | |
365 | ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER); | |
366 | return 0; | |
367 | } | |
368 | p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_KEYLEN); | |
369 | if (p != NULL && !OSSL_PARAM_set_size_t(p, ctx->base.keylen)) { | |
370 | ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER); | |
371 | return 0; | |
372 | } | |
373 | p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_AEAD_TAGLEN); | |
374 | if (p != NULL) { | |
375 | if (!OSSL_PARAM_set_size_t(p, ctx->taglen)) { | |
376 | ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER); | |
377 | return 0; | |
378 | } | |
379 | } | |
380 | ||
381 | p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_IV); | |
382 | if (p != NULL) { | |
383 | if (ctx->base.ivlen != p->data_size) { | |
384 | ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_IV_LENGTH); | |
385 | return 0; | |
386 | } | |
387 | if (!OSSL_PARAM_set_octet_string(p, ctx->base.iv, ctx->base.ivlen)) { | |
388 | ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER); | |
389 | return 0; | |
390 | } | |
391 | } | |
392 | p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_AEAD_TAG); | |
393 | if (p != NULL) { | |
394 | if (p->data_type != OSSL_PARAM_OCTET_STRING) { | |
395 | ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER); | |
396 | return 0; | |
397 | } | |
398 | if (!ctx->base.enc || p->data_size != ctx->taglen) { | |
399 | ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_TAGLEN); | |
400 | return 0; | |
401 | } | |
402 | memcpy(p->data, ctx->tag, ctx->taglen); | |
403 | } | |
404 | return 1; | |
405 | } | |
406 | ||
407 | static const OSSL_PARAM cipher_ocb_known_gettable_ctx_params[] = { | |
408 | OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_KEYLEN, NULL), | |
409 | OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_IVLEN, NULL), | |
410 | OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_AEAD_TAGLEN, NULL), | |
411 | OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_IV, NULL, 0), | |
412 | OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_AEAD_TAG, NULL, 0), | |
413 | OSSL_PARAM_END | |
414 | }; | |
415 | static const OSSL_PARAM *cipher_ocb_gettable_ctx_params(void) | |
416 | { | |
417 | return cipher_ocb_known_gettable_ctx_params; | |
418 | } | |
419 | ||
420 | static const OSSL_PARAM cipher_ocb_known_settable_ctx_params[] = { | |
421 | OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_KEYLEN, NULL), | |
422 | OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_AEAD_IVLEN, NULL), | |
423 | OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_AEAD_TAG, NULL, 0), | |
424 | OSSL_PARAM_END | |
425 | }; | |
426 | static const OSSL_PARAM *cipher_ocb_settable_ctx_params(void) | |
427 | { | |
428 | return cipher_ocb_known_settable_ctx_params; | |
429 | } | |
430 | ||
431 | static int aes_ocb_cipher(void *vctx, unsigned char *out, size_t *outl, | |
432 | size_t outsize, const unsigned char *in, size_t inl) | |
433 | { | |
434 | PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx; | |
435 | ||
436 | if (outsize < inl) { | |
437 | ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL); | |
438 | return 0; | |
439 | } | |
440 | ||
441 | if (!aes_generic_ocb_cipher(ctx, in, out, inl)) { | |
442 | ERR_raise(ERR_LIB_PROV, PROV_R_CIPHER_OPERATION_FAILED); | |
443 | return 0; | |
444 | } | |
445 | ||
446 | *outl = inl; | |
447 | return 1; | |
448 | } | |
449 | ||
450 | #define IMPLEMENT_cipher(mode, UCMODE, flags, kbits, blkbits, ivbits) \ | |
451 | static OSSL_OP_cipher_get_params_fn aes_##kbits##_##mode##_get_params; \ | |
452 | static int aes_##kbits##_##mode##_get_params(OSSL_PARAM params[]) \ | |
453 | { \ | |
454 | return cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE, \ | |
455 | flags, kbits, blkbits, ivbits); \ | |
456 | } \ | |
457 | static OSSL_OP_cipher_newctx_fn aes_##kbits##_##mode##_newctx; \ | |
458 | static void *aes_##kbits##_##mode##_newctx(void *provctx) \ | |
459 | { \ | |
460 | return aes_##mode##_newctx(provctx, kbits, blkbits, ivbits, \ | |
461 | EVP_CIPH_##UCMODE##_MODE, flags); \ | |
462 | } \ | |
463 | const OSSL_DISPATCH aes##kbits##mode##_functions[] = { \ | |
464 | { OSSL_FUNC_CIPHER_NEWCTX, \ | |
465 | (void (*)(void))aes_##kbits##_##mode##_newctx }, \ | |
466 | { OSSL_FUNC_CIPHER_ENCRYPT_INIT, (void (*)(void))aes_##mode##_einit }, \ | |
467 | { OSSL_FUNC_CIPHER_DECRYPT_INIT, (void (*)(void))aes_##mode##_dinit }, \ | |
468 | { OSSL_FUNC_CIPHER_UPDATE, (void (*)(void))aes_##mode##_block_update }, \ | |
469 | { OSSL_FUNC_CIPHER_FINAL, (void (*)(void))aes_##mode##_block_final }, \ | |
470 | { OSSL_FUNC_CIPHER_CIPHER, (void (*)(void))aes_ocb_cipher }, \ | |
471 | { OSSL_FUNC_CIPHER_FREECTX, (void (*)(void))aes_##mode##_freectx }, \ | |
472 | { OSSL_FUNC_CIPHER_DUPCTX, (void (*)(void))aes_##mode##_dupctx }, \ | |
473 | { OSSL_FUNC_CIPHER_GET_PARAMS, \ | |
474 | (void (*)(void))aes_##kbits##_##mode##_get_params }, \ | |
475 | { OSSL_FUNC_CIPHER_GET_CTX_PARAMS, \ | |
476 | (void (*)(void))aes_##mode##_get_ctx_params }, \ | |
477 | { OSSL_FUNC_CIPHER_SET_CTX_PARAMS, \ | |
478 | (void (*)(void))aes_##mode##_set_ctx_params }, \ | |
479 | { OSSL_FUNC_CIPHER_GETTABLE_PARAMS, \ | |
480 | (void (*)(void))cipher_generic_gettable_params }, \ | |
481 | { OSSL_FUNC_CIPHER_GETTABLE_CTX_PARAMS, \ | |
482 | (void (*)(void))cipher_ocb_gettable_ctx_params }, \ | |
483 | { OSSL_FUNC_CIPHER_SETTABLE_CTX_PARAMS, \ | |
484 | (void (*)(void))cipher_ocb_settable_ctx_params }, \ | |
485 | { 0, NULL } \ | |
486 | } | |
487 | ||
488 | IMPLEMENT_cipher(ocb, OCB, AES_OCB_FLAGS, 256, 128, OCB_DEFAULT_IV_LEN * 8); | |
489 | IMPLEMENT_cipher(ocb, OCB, AES_OCB_FLAGS, 192, 128, OCB_DEFAULT_IV_LEN * 8); | |
490 | IMPLEMENT_cipher(ocb, OCB, AES_OCB_FLAGS, 128, 128, OCB_DEFAULT_IV_LEN * 8); | |
491 |