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