Coverage Report

Created: 2026-02-22 06:11

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