Coverage Report

Created: 2023-09-25 06:45

/src/openssl30/providers/implementations/ciphers/cipher_aes_gcm.c
Line
Count
Source (jump to first uncovered line)
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
/* Dispatch functions for AES GCM mode */
18
19
#include "cipher_aes_gcm.h"
20
#include "prov/implementations.h"
21
#include "prov/providercommon.h"
22
23
static void *aes_gcm_newctx(void *provctx, size_t keybits)
24
1.96k
{
25
1.96k
    PROV_AES_GCM_CTX *ctx;
26
27
1.96k
    if (!ossl_prov_is_running())
28
0
        return NULL;
29
30
1.96k
    ctx = OPENSSL_zalloc(sizeof(*ctx));
31
1.96k
    if (ctx != NULL)
32
1.96k
        ossl_gcm_initctx(provctx, &ctx->base, keybits,
33
1.96k
                         ossl_prov_aes_hw_gcm(keybits));
34
1.96k
    return ctx;
35
1.96k
}
36
37
static OSSL_FUNC_cipher_freectx_fn aes_gcm_freectx;
38
static void aes_gcm_freectx(void *vctx)
39
1.96k
{
40
1.96k
    PROV_AES_GCM_CTX *ctx = (PROV_AES_GCM_CTX *)vctx;
41
42
1.96k
    OPENSSL_clear_free(ctx,  sizeof(*ctx));
43
1.96k
}
44
45
/* ossl_aes128gcm_functions */
46
IMPLEMENT_aead_cipher(aes, gcm, GCM, AEAD_FLAGS, 128, 8, 96);
47
/* ossl_aes192gcm_functions */
48
IMPLEMENT_aead_cipher(aes, gcm, GCM, AEAD_FLAGS, 192, 8, 96);
49
/* ossl_aes256gcm_functions */
50
IMPLEMENT_aead_cipher(aes, gcm, GCM, AEAD_FLAGS, 256, 8, 96);