/src/openssl30/providers/implementations/ciphers/cipher_aria_gcm.c
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | /*  | 
2  |  |  * Copyright 2019-2024 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  |  | /* Dispatch functions for ARIA GCM mode */  | 
11  |  |  | 
12  |  | #include "cipher_aria_gcm.h"  | 
13  |  | #include "prov/implementations.h"  | 
14  |  | #include "prov/providercommon.h"  | 
15  |  |  | 
16  |  | static void *aria_gcm_newctx(void *provctx, size_t keybits)  | 
17  | 865  | { | 
18  | 865  |     PROV_ARIA_GCM_CTX *ctx;  | 
19  |  |  | 
20  | 865  |     if (!ossl_prov_is_running())  | 
21  | 0  |         return NULL;  | 
22  |  |  | 
23  | 865  |     ctx = OPENSSL_zalloc(sizeof(*ctx));  | 
24  | 865  |     if (ctx != NULL)  | 
25  | 865  |         ossl_gcm_initctx(provctx, &ctx->base, keybits,  | 
26  | 865  |                          ossl_prov_aria_hw_gcm(keybits));  | 
27  | 865  |     return ctx;  | 
28  | 865  | }  | 
29  |  |  | 
30  |  | static void *aria_gcm_dupctx(void *provctx)  | 
31  | 0  | { | 
32  | 0  |     PROV_ARIA_GCM_CTX *ctx = provctx;  | 
33  | 0  |     PROV_ARIA_GCM_CTX *dctx = NULL;  | 
34  |  | 
  | 
35  | 0  |     if (ctx == NULL)  | 
36  | 0  |         return NULL;  | 
37  |  |  | 
38  | 0  |     dctx =  OPENSSL_memdup(ctx, sizeof(*ctx));  | 
39  | 0  |     if (dctx != NULL && dctx->base.gcm.key != NULL)  | 
40  | 0  |         dctx->base.gcm.key = &dctx->ks.ks;  | 
41  |  | 
  | 
42  | 0  |     return dctx;  | 
43  | 0  | }  | 
44  |  |  | 
45  |  | static OSSL_FUNC_cipher_freectx_fn aria_gcm_freectx;  | 
46  |  | static void aria_gcm_freectx(void *vctx)  | 
47  | 865  | { | 
48  | 865  |     PROV_ARIA_GCM_CTX *ctx = (PROV_ARIA_GCM_CTX *)vctx;  | 
49  |  |  | 
50  | 865  |     OPENSSL_clear_free(ctx,  sizeof(*ctx));  | 
51  | 865  | }  | 
52  |  |  | 
53  |  | /* ossl_aria128gcm_functions */  | 
54  |  | IMPLEMENT_aead_cipher(aria, gcm, GCM, AEAD_FLAGS, 128, 8, 96);  | 
55  |  | /* ossl_aria192gcm_functions */  | 
56  |  | IMPLEMENT_aead_cipher(aria, gcm, GCM, AEAD_FLAGS, 192, 8, 96);  | 
57  |  | /* ossl_aria256gcm_functions */  | 
58  |  | IMPLEMENT_aead_cipher(aria, gcm, GCM, AEAD_FLAGS, 256, 8, 96);  | 
59  |  |  |