69ee9f2cc55055e20a1c6145947df0037cb1fff9
[openssl.git] / providers / implementations / ciphers / cipher_aes_ocb.c
1 /*
2  * Copyright 2019-2021 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 <openssl/proverr.h>
18 #include "cipher_aes_ocb.h"
19 #include "prov/providercommon.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 = ossl_cipher_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         if (out != NULL)
181             out += AES_BLOCK_SIZE;
182     }
183     if (nextblocks > 0) {
184         outlint += nextblocks;
185         if (outsize < outlint) {
186             ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
187             return 0;
188         }
189         if (!ciph(ctx, in, out, nextblocks)) {
190             ERR_raise(ERR_LIB_PROV, PROV_R_CIPHER_OPERATION_FAILED);
191             return 0;
192         }
193         in += nextblocks;
194         inl -= nextblocks;
195     }
196     if (inl != 0
197         && !ossl_cipher_trailingdata(buf, bufsz, AES_BLOCK_SIZE, &in, &inl)) {
198         /* PROVerr already called */
199         return 0;
200     }
201
202     *outl = outlint;
203     return inl == 0;
204 }
205
206 /* A wrapper function that has the same signature as cipher */
207 static int cipher_updateaad(PROV_AES_OCB_CTX *ctx, const unsigned char *in,
208                             unsigned char *out, size_t len)
209 {
210     return aes_generic_ocb_setaad(ctx, in, len);
211 }
212
213 static int update_iv(PROV_AES_OCB_CTX *ctx)
214 {
215     if (ctx->iv_state == IV_STATE_FINISHED
216         || ctx->iv_state == IV_STATE_UNINITIALISED)
217         return 0;
218     if (ctx->iv_state == IV_STATE_BUFFERED) {
219         if (!aes_generic_ocb_setiv(ctx, ctx->base.iv, ctx->base.ivlen,
220                                    ctx->taglen))
221             return 0;
222         ctx->iv_state = IV_STATE_COPIED;
223     }
224     return 1;
225 }
226
227 static int aes_ocb_block_update(void *vctx, unsigned char *out, size_t *outl,
228                                 size_t outsize, const unsigned char *in,
229                                 size_t inl)
230 {
231     PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx;
232     unsigned char *buf;
233     size_t *buflen;
234     OSSL_ocb_cipher_fn fn;
235
236     if (!ctx->key_set || !update_iv(ctx))
237         return 0;
238
239     if (inl == 0) {
240         *outl = 0;
241         return 1;
242     }
243
244     /* Are we dealing with AAD or normal data here? */
245     if (out == NULL) {
246         buf = ctx->aad_buf;
247         buflen = &ctx->aad_buf_len;
248         fn = cipher_updateaad;
249     } else {
250         buf = ctx->data_buf;
251         buflen = &ctx->data_buf_len;
252         fn = aes_generic_ocb_cipher;
253     }
254     return aes_ocb_block_update_internal(ctx, buf, buflen, out, outl, outsize,
255                                          in, inl, fn);
256 }
257
258 static int aes_ocb_block_final(void *vctx, unsigned char *out, size_t *outl,
259                                size_t outsize)
260 {
261     PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx;
262
263     if (!ossl_prov_is_running())
264         return 0;
265
266     /* If no block_update has run then the iv still needs to be set */
267     if (!ctx->key_set || !update_iv(ctx))
268         return 0;
269
270     /*
271      * Empty the buffer of any partial block that we might have been provided,
272      * both for data and AAD
273      */
274     *outl = 0;
275     if (ctx->data_buf_len > 0) {
276         if (!aes_generic_ocb_cipher(ctx, ctx->data_buf, out, ctx->data_buf_len))
277             return 0;
278         *outl = ctx->data_buf_len;
279         ctx->data_buf_len = 0;
280     }
281     if (ctx->aad_buf_len > 0) {
282         if (!aes_generic_ocb_setaad(ctx, ctx->aad_buf, ctx->aad_buf_len))
283             return 0;
284         ctx->aad_buf_len = 0;
285     }
286     if (ctx->base.enc) {
287         /* If encrypting then just get the tag */
288         if (!aes_generic_ocb_gettag(ctx, ctx->tag, ctx->taglen))
289             return 0;
290     } else {
291         /* If decrypting then verify */
292         if (ctx->taglen == 0)
293             return 0;
294         if (!aes_generic_ocb_final(ctx))
295             return 0;
296     }
297     /* Don't reuse the IV */
298     ctx->iv_state = IV_STATE_FINISHED;
299     return 1;
300 }
301
302 static void *aes_ocb_newctx(void *provctx, size_t kbits, size_t blkbits,
303                             size_t ivbits, unsigned int mode, uint64_t flags)
304 {
305     PROV_AES_OCB_CTX *ctx;
306
307     if (!ossl_prov_is_running())
308         return NULL;
309
310     ctx = OPENSSL_zalloc(sizeof(*ctx));
311     if (ctx != NULL) {
312         ossl_cipher_generic_initkey(ctx, kbits, blkbits, ivbits, mode, flags,
313                                     ossl_prov_cipher_hw_aes_ocb(kbits), NULL);
314         ctx->taglen = OCB_DEFAULT_TAG_LEN;
315     }
316     return ctx;
317 }
318
319 static void aes_ocb_freectx(void *vctx)
320 {
321     PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx;
322
323     if (ctx != NULL) {
324         aes_generic_ocb_cleanup(ctx);
325         ossl_cipher_generic_reset_ctx((PROV_CIPHER_CTX *)vctx);
326         OPENSSL_clear_free(ctx,  sizeof(*ctx));
327     }
328 }
329
330 static void *aes_ocb_dupctx(void *vctx)
331 {
332     PROV_AES_OCB_CTX *in = (PROV_AES_OCB_CTX *)vctx;
333     PROV_AES_OCB_CTX *ret;
334
335     if (!ossl_prov_is_running())
336         return NULL;
337
338     ret = OPENSSL_malloc(sizeof(*ret));
339     if (ret == NULL) {
340         ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
341         return NULL;
342     }
343     *ret = *in;
344     if (!aes_generic_ocb_copy_ctx(ret, in)) {
345         OPENSSL_free(ret);
346         ret = NULL;
347     }
348     return ret;
349 }
350
351 static int aes_ocb_set_ctx_params(void *vctx, const OSSL_PARAM params[])
352 {
353     PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx;
354     const OSSL_PARAM *p;
355     size_t sz;
356
357     p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_AEAD_TAG);
358     if (p != NULL) {
359         if (p->data_type != OSSL_PARAM_OCTET_STRING) {
360             ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);
361             return 0;
362         }
363         if (p->data == NULL) {
364             /* Tag len must be 0 to 16 */
365             if (p->data_size > OCB_MAX_TAG_LEN)
366                 return 0;
367             ctx->taglen = p->data_size;
368         } else {
369             if (p->data_size != ctx->taglen || ctx->base.enc)
370                 return 0;
371             memcpy(ctx->tag, p->data, p->data_size);
372         }
373      }
374     p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_AEAD_IVLEN);
375     if (p != NULL) {
376         if (!OSSL_PARAM_get_size_t(p, &sz)) {
377             ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);
378             return 0;
379         }
380         /* IV len must be 1 to 15 */
381         if (sz < OCB_MIN_IV_LEN || sz > OCB_MAX_IV_LEN)
382             return 0;
383         ctx->base.ivlen = sz;
384     }
385     p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_KEYLEN);
386     if (p != NULL) {
387         size_t keylen;
388
389         if (!OSSL_PARAM_get_size_t(p, &keylen)) {
390             ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);
391             return 0;
392         }
393         if (ctx->base.keylen != keylen) {
394             ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
395             return 0;
396         }
397     }
398     return 1;
399 }
400
401 static int aes_ocb_get_ctx_params(void *vctx, OSSL_PARAM params[])
402 {
403     PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx;
404     OSSL_PARAM *p;
405
406     p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_IVLEN);
407     if (p != NULL && !OSSL_PARAM_set_size_t(p, ctx->base.ivlen)) {
408         ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
409         return 0;
410     }
411     p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_KEYLEN);
412     if (p != NULL && !OSSL_PARAM_set_size_t(p, ctx->base.keylen)) {
413         ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
414         return 0;
415     }
416     p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_AEAD_TAGLEN);
417     if (p != NULL) {
418         if (!OSSL_PARAM_set_size_t(p, ctx->taglen)) {
419             ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
420             return 0;
421         }
422     }
423
424     p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_IV);
425     if (p != NULL) {
426         if (ctx->base.ivlen > p->data_size) {
427             ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_IV_LENGTH);
428             return 0;
429         }
430         if (!OSSL_PARAM_set_octet_string(p, ctx->base.oiv, ctx->base.ivlen)
431             && !OSSL_PARAM_set_octet_ptr(p, &ctx->base.oiv, ctx->base.ivlen)) {
432             ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
433             return 0;
434         }
435     }
436     p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_UPDATED_IV);
437     if (p != NULL) {
438         if (ctx->base.ivlen > p->data_size) {
439             ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_IV_LENGTH);
440             return 0;
441         }
442         if (!OSSL_PARAM_set_octet_string(p, ctx->base.iv, ctx->base.ivlen)
443             && !OSSL_PARAM_set_octet_ptr(p, &ctx->base.iv, ctx->base.ivlen)) {
444             ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
445             return 0;
446         }
447     }
448     p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_AEAD_TAG);
449     if (p != NULL) {
450         if (p->data_type != OSSL_PARAM_OCTET_STRING) {
451             ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);
452             return 0;
453         }
454         if (!ctx->base.enc || p->data_size != ctx->taglen) {
455             ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_TAG_LENGTH);
456             return 0;
457         }
458         memcpy(p->data, ctx->tag, ctx->taglen);
459     }
460     return 1;
461 }
462
463 static const OSSL_PARAM cipher_ocb_known_gettable_ctx_params[] = {
464     OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_KEYLEN, NULL),
465     OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_IVLEN, NULL),
466     OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_AEAD_TAGLEN, NULL),
467     OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_IV, NULL, 0),
468     OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_UPDATED_IV, NULL, 0),
469     OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_AEAD_TAG, NULL, 0),
470     OSSL_PARAM_END
471 };
472 static const OSSL_PARAM *cipher_ocb_gettable_ctx_params(ossl_unused void *p_ctx)
473 {
474     return cipher_ocb_known_gettable_ctx_params;
475 }
476
477 static const OSSL_PARAM cipher_ocb_known_settable_ctx_params[] = {
478     OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_KEYLEN, NULL),
479     OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_AEAD_IVLEN, NULL),
480     OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_AEAD_TAG, NULL, 0),
481     OSSL_PARAM_END
482 };
483 static const OSSL_PARAM *cipher_ocb_settable_ctx_params(ossl_unused void *p_ctx)
484 {
485     return cipher_ocb_known_settable_ctx_params;
486 }
487
488 static int aes_ocb_cipher(void *vctx, unsigned char *out, size_t *outl,
489                           size_t outsize, const unsigned char *in, size_t inl)
490 {
491     PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx;
492
493     if (!ossl_prov_is_running())
494         return 0;
495
496     if (outsize < inl) {
497         ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
498         return 0;
499     }
500
501     if (!aes_generic_ocb_cipher(ctx, in, out, inl)) {
502         ERR_raise(ERR_LIB_PROV, PROV_R_CIPHER_OPERATION_FAILED);
503         return 0;
504     }
505
506     *outl = inl;
507     return 1;
508 }
509
510 #define IMPLEMENT_cipher(mode, UCMODE, flags, kbits, blkbits, ivbits)          \
511 static OSSL_FUNC_cipher_get_params_fn aes_##kbits##_##mode##_get_params;       \
512 static int aes_##kbits##_##mode##_get_params(OSSL_PARAM params[])              \
513 {                                                                              \
514     return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE,    \
515                                           flags, kbits, blkbits, ivbits);      \
516 }                                                                              \
517 static OSSL_FUNC_cipher_newctx_fn aes_##kbits##_##mode##_newctx;               \
518 static void *aes_##kbits##_##mode##_newctx(void *provctx)                      \
519 {                                                                              \
520     return aes_##mode##_newctx(provctx, kbits, blkbits, ivbits,                \
521                                EVP_CIPH_##UCMODE##_MODE, flags);               \
522 }                                                                              \
523 const OSSL_DISPATCH ossl_##aes##kbits##mode##_functions[] = {                  \
524     { OSSL_FUNC_CIPHER_NEWCTX,                                                 \
525         (void (*)(void))aes_##kbits##_##mode##_newctx },                       \
526     { OSSL_FUNC_CIPHER_ENCRYPT_INIT, (void (*)(void))aes_##mode##_einit },     \
527     { OSSL_FUNC_CIPHER_DECRYPT_INIT, (void (*)(void))aes_##mode##_dinit },     \
528     { OSSL_FUNC_CIPHER_UPDATE, (void (*)(void))aes_##mode##_block_update },    \
529     { OSSL_FUNC_CIPHER_FINAL, (void (*)(void))aes_##mode##_block_final },      \
530     { OSSL_FUNC_CIPHER_CIPHER, (void (*)(void))aes_ocb_cipher },               \
531     { OSSL_FUNC_CIPHER_FREECTX, (void (*)(void))aes_##mode##_freectx },        \
532     { OSSL_FUNC_CIPHER_DUPCTX, (void (*)(void))aes_##mode##_dupctx },          \
533     { OSSL_FUNC_CIPHER_GET_PARAMS,                                             \
534         (void (*)(void))aes_##kbits##_##mode##_get_params },                   \
535     { OSSL_FUNC_CIPHER_GET_CTX_PARAMS,                                         \
536         (void (*)(void))aes_##mode##_get_ctx_params },                         \
537     { OSSL_FUNC_CIPHER_SET_CTX_PARAMS,                                         \
538         (void (*)(void))aes_##mode##_set_ctx_params },                         \
539     { OSSL_FUNC_CIPHER_GETTABLE_PARAMS,                                        \
540         (void (*)(void))ossl_cipher_generic_gettable_params },                 \
541     { OSSL_FUNC_CIPHER_GETTABLE_CTX_PARAMS,                                    \
542         (void (*)(void))cipher_ocb_gettable_ctx_params },                      \
543     { OSSL_FUNC_CIPHER_SETTABLE_CTX_PARAMS,                                    \
544         (void (*)(void))cipher_ocb_settable_ctx_params },                      \
545     { 0, NULL }                                                                \
546 }
547
548 IMPLEMENT_cipher(ocb, OCB, AES_OCB_FLAGS, 256, 128, OCB_DEFAULT_IV_LEN * 8);
549 IMPLEMENT_cipher(ocb, OCB, AES_OCB_FLAGS, 192, 128, OCB_DEFAULT_IV_LEN * 8);
550 IMPLEMENT_cipher(ocb, OCB, AES_OCB_FLAGS, 128, 128, OCB_DEFAULT_IV_LEN * 8);