Coverage Report

Created: 2025-12-10 06:24

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
    if (!ossl_prov_is_running())
311
0
        return NULL;
312
313
0
    ctx = OPENSSL_zalloc(sizeof(*ctx));
314
0
    if (ctx != NULL) {
315
0
        ossl_cipher_generic_initkey(ctx, kbits, blkbits, ivbits, mode, flags,
316
0
            ossl_prov_cipher_hw_aes_ocb(kbits), NULL);
317
0
        ctx->taglen = OCB_DEFAULT_TAG_LEN;
318
0
    }
319
0
    return ctx;
320
0
}
321
322
static void aes_ocb_freectx(void *vctx)
323
0
{
324
0
    PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx;
325
326
0
    if (ctx != NULL) {
327
0
        aes_generic_ocb_cleanup(ctx);
328
0
        ossl_cipher_generic_reset_ctx((PROV_CIPHER_CTX *)vctx);
329
0
        OPENSSL_clear_free(ctx, sizeof(*ctx));
330
0
    }
331
0
}
332
333
static void *aes_ocb_dupctx(void *vctx)
334
0
{
335
0
    PROV_AES_OCB_CTX *in = (PROV_AES_OCB_CTX *)vctx;
336
0
    PROV_AES_OCB_CTX *ret;
337
338
0
    if (!ossl_prov_is_running())
339
0
        return NULL;
340
341
0
    ret = OPENSSL_malloc(sizeof(*ret));
342
0
    if (ret == NULL)
343
0
        return NULL;
344
0
    *ret = *in;
345
0
    if (!aes_generic_ocb_copy_ctx(ret, in)) {
346
0
        OPENSSL_free(ret);
347
0
        ret = NULL;
348
0
    }
349
0
    return ret;
350
0
}
351
352
static const OSSL_PARAM *cipher_ocb_settable_ctx_params(ossl_unused void *cctx,
353
    ossl_unused void *p_ctx)
354
0
{
355
0
    return aes_ocb_set_ctx_params_list;
356
0
}
357
358
static int aes_ocb_set_ctx_params(void *vctx, const OSSL_PARAM params[])
359
0
{
360
0
    PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx;
361
0
    struct aes_ocb_set_ctx_params_st p;
362
0
    size_t sz;
363
364
0
    if (ctx == NULL || !aes_ocb_set_ctx_params_decoder(params, &p))
365
0
        return 0;
366
367
0
    if (p.tag != NULL) {
368
0
        if (p.tag->data_type != OSSL_PARAM_OCTET_STRING) {
369
0
            ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);
370
0
            return 0;
371
0
        }
372
0
        if (p.tag->data == NULL) {
373
            /* Tag len must be 0 to 16 */
374
0
            if (p.tag->data_size > OCB_MAX_TAG_LEN) {
375
0
                ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_TAG_LENGTH);
376
0
                return 0;
377
0
            }
378
0
            ctx->taglen = p.tag->data_size;
379
0
        } else {
380
0
            if (ctx->base.enc) {
381
0
                ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);
382
0
                return 0;
383
0
            }
384
0
            if (p.tag->data_size != ctx->taglen) {
385
0
                ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_TAG_LENGTH);
386
0
                return 0;
387
0
            }
388
0
            memcpy(ctx->tag, p.tag->data, p.tag->data_size);
389
0
        }
390
0
    }
391
392
0
    if (p.ivlen != NULL) {
393
0
        if (!OSSL_PARAM_get_size_t(p.ivlen, &sz)) {
394
0
            ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);
395
0
            return 0;
396
0
        }
397
        /* IV len must be 1 to 15 */
398
0
        if (sz < OCB_MIN_IV_LEN || sz > OCB_MAX_IV_LEN)
399
0
            return 0;
400
0
        if (ctx->base.ivlen != sz) {
401
0
            ctx->base.ivlen = sz;
402
0
            ctx->iv_state = IV_STATE_UNINITIALISED;
403
0
        }
404
0
    }
405
406
0
    if (p.keylen != NULL) {
407
0
        size_t keylen;
408
409
0
        if (!OSSL_PARAM_get_size_t(p.keylen, &keylen)) {
410
0
            ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);
411
0
            return 0;
412
0
        }
413
0
        if (ctx->base.keylen != keylen) {
414
0
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
415
0
            return 0;
416
0
        }
417
0
    }
418
0
    return 1;
419
0
}
420
421
static const OSSL_PARAM *cipher_ocb_gettable_ctx_params(ossl_unused void *cctx,
422
    ossl_unused void *p_ctx)
423
3
{
424
3
    return aes_ocb_get_ctx_params_list;
425
3
}
426
427
static int aes_ocb_get_ctx_params(void *vctx, OSSL_PARAM params[])
428
0
{
429
0
    PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx;
430
0
    struct aes_ocb_get_ctx_params_st p;
431
432
0
    if (ctx == NULL || !aes_ocb_get_ctx_params_decoder(params, &p))
433
0
        return 0;
434
435
0
    if (p.ivlen != NULL && !OSSL_PARAM_set_size_t(p.ivlen, ctx->base.ivlen)) {
436
0
        ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
437
0
        return 0;
438
0
    }
439
440
0
    if (p.keylen != NULL && !OSSL_PARAM_set_size_t(p.keylen, ctx->base.keylen)) {
441
0
        ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
442
0
        return 0;
443
0
    }
444
445
0
    if (p.taglen != NULL) {
446
0
        if (!OSSL_PARAM_set_size_t(p.taglen, ctx->taglen)) {
447
0
            ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
448
0
            return 0;
449
0
        }
450
0
    }
451
452
0
    if (p.iv != NULL) {
453
0
        if (ctx->base.ivlen > p.iv->data_size) {
454
0
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_IV_LENGTH);
455
0
            return 0;
456
0
        }
457
0
        if (!OSSL_PARAM_set_octet_string_or_ptr(p.iv, ctx->base.oiv,
458
0
                ctx->base.ivlen)) {
459
0
            ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
460
0
            return 0;
461
0
        }
462
0
    }
463
464
0
    if (p.upd_iv != NULL) {
465
0
        if (ctx->base.ivlen > p.upd_iv->data_size) {
466
0
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_IV_LENGTH);
467
0
            return 0;
468
0
        }
469
0
        if (!OSSL_PARAM_set_octet_string_or_ptr(p.upd_iv, ctx->base.iv,
470
0
                ctx->base.ivlen)) {
471
0
            ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
472
0
            return 0;
473
0
        }
474
0
    }
475
476
0
    if (p.tag != NULL) {
477
0
        if (p.tag->data_type != OSSL_PARAM_OCTET_STRING) {
478
0
            ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER);
479
0
            return 0;
480
0
        }
481
0
        if (!ctx->base.enc || p.tag->data_size != ctx->taglen) {
482
0
            ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_TAG_LENGTH);
483
0
            return 0;
484
0
        }
485
0
        memcpy(p.tag->data, ctx->tag, ctx->taglen);
486
0
    }
487
0
    return 1;
488
0
}
489
490
static int aes_ocb_cipher(void *vctx, unsigned char *out, size_t *outl,
491
    size_t outsize, const unsigned char *in, size_t inl)
492
0
{
493
0
    PROV_AES_OCB_CTX *ctx = (PROV_AES_OCB_CTX *)vctx;
494
495
0
    if (!ossl_prov_is_running())
496
0
        return 0;
497
498
0
    if (outsize < inl) {
499
0
        ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
500
0
        return 0;
501
0
    }
502
503
0
    if (!aes_generic_ocb_cipher(ctx, in, out, inl)) {
504
0
        ERR_raise(ERR_LIB_PROV, PROV_R_CIPHER_OPERATION_FAILED);
505
0
        return 0;
506
0
    }
507
508
0
    *outl = inl;
509
0
    return 1;
510
0
}
511
512
#define IMPLEMENT_cipher(mode, UCMODE, flags, kbits, blkbits, ivbits)           \
513
    static OSSL_FUNC_cipher_get_params_fn aes_##kbits##_##mode##_get_params;    \
514
    static int aes_##kbits##_##mode##_get_params(OSSL_PARAM params[])           \
515
3
    {                                                                           \
516
3
        return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE, \
517
3
            flags, kbits, blkbits, ivbits);                                     \
518
3
    }                                                                           \
cipher_aes_ocb.c:aes_256_ocb_get_params
Line
Count
Source
515
1
    {                                                                           \
516
1
        return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE, \
517
1
            flags, kbits, blkbits, ivbits);                                     \
518
1
    }                                                                           \
cipher_aes_ocb.c:aes_192_ocb_get_params
Line
Count
Source
515
1
    {                                                                           \
516
1
        return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE, \
517
1
            flags, kbits, blkbits, ivbits);                                     \
518
1
    }                                                                           \
cipher_aes_ocb.c:aes_128_ocb_get_params
Line
Count
Source
515
1
    {                                                                           \
516
1
        return ossl_cipher_generic_get_params(params, EVP_CIPH_##UCMODE##_MODE, \
517
1
            flags, kbits, blkbits, ivbits);                                     \
518
1
    }                                                                           \
519
    static OSSL_FUNC_cipher_newctx_fn aes_##kbits##_##mode##_newctx;            \
520
    static void *aes_##kbits##_##mode##_newctx(void *provctx)                   \
521
0
    {                                                                           \
522
0
        return aes_##mode##_newctx(provctx, kbits, blkbits, ivbits,             \
523
0
            EVP_CIPH_##UCMODE##_MODE, flags);                                   \
524
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
525
    const OSSL_DISPATCH ossl_##aes##kbits##mode##_functions[] = {               \
526
        { OSSL_FUNC_CIPHER_NEWCTX,                                              \
527
            (void (*)(void))aes_##kbits##_##mode##_newctx },                    \
528
        { OSSL_FUNC_CIPHER_ENCRYPT_INIT, (void (*)(void))aes_##mode##_einit },  \
529
        { OSSL_FUNC_CIPHER_DECRYPT_INIT, (void (*)(void))aes_##mode##_dinit },  \
530
        { OSSL_FUNC_CIPHER_UPDATE, (void (*)(void))aes_##mode##_block_update }, \
531
        { OSSL_FUNC_CIPHER_FINAL, (void (*)(void))aes_##mode##_block_final },   \
532
        { OSSL_FUNC_CIPHER_CIPHER, (void (*)(void))aes_ocb_cipher },            \
533
        { OSSL_FUNC_CIPHER_FREECTX, (void (*)(void))aes_##mode##_freectx },     \
534
        { OSSL_FUNC_CIPHER_DUPCTX, (void (*)(void))aes_##mode##_dupctx },       \
535
        { OSSL_FUNC_CIPHER_GET_PARAMS,                                          \
536
            (void (*)(void))aes_##kbits##_##mode##_get_params },                \
537
        { OSSL_FUNC_CIPHER_GET_CTX_PARAMS,                                      \
538
            (void (*)(void))aes_##mode##_get_ctx_params },                      \
539
        { OSSL_FUNC_CIPHER_SET_CTX_PARAMS,                                      \
540
            (void (*)(void))aes_##mode##_set_ctx_params },                      \
541
        { OSSL_FUNC_CIPHER_GETTABLE_PARAMS,                                     \
542
            (void (*)(void))ossl_cipher_generic_gettable_params },              \
543
        { OSSL_FUNC_CIPHER_GETTABLE_CTX_PARAMS,                                 \
544
            (void (*)(void))cipher_ocb_gettable_ctx_params },                   \
545
        { OSSL_FUNC_CIPHER_SETTABLE_CTX_PARAMS,                                 \
546
            (void (*)(void))cipher_ocb_settable_ctx_params },                   \
547
        OSSL_DISPATCH_END                                                       \
548
    }
549
550
IMPLEMENT_cipher(ocb, OCB, AES_OCB_FLAGS, 256, 128, OCB_DEFAULT_IV_LEN * 8);
551
IMPLEMENT_cipher(ocb, OCB, AES_OCB_FLAGS, 192, 128, OCB_DEFAULT_IV_LEN * 8);
552
IMPLEMENT_cipher(ocb, OCB, AES_OCB_FLAGS, 128, 128, OCB_DEFAULT_IV_LEN * 8);