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