Fix Issue OSS-Fuzz: Branch on uninitialized memory (in ccm code).
[openssl.git] / providers / default / ciphers / cipher_aria_gcm.c
1 /*
2  * Copyright 2019 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 "internal/provider_algs.h"
14
15 static void *aria_gcm_newctx(void *provctx, size_t keybits)
16 {
17     PROV_ARIA_GCM_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
18
19     if (ctx != NULL)
20         gcm_initctx(provctx, &ctx->base, keybits, PROV_ARIA_HW_gcm(keybits), 4);
21     return ctx;
22 }
23
24 static OSSL_OP_cipher_freectx_fn aria_gcm_freectx;
25 static void aria_gcm_freectx(void *vctx)
26 {
27     PROV_ARIA_GCM_CTX *ctx = (PROV_ARIA_GCM_CTX *)vctx;
28
29     gcm_deinitctx((PROV_GCM_CTX *)ctx);
30     OPENSSL_clear_free(ctx,  sizeof(*ctx));
31 }
32
33 /* aria128gcm_functions */
34 IMPLEMENT_aead_cipher(aria, gcm, GCM, AEAD_FLAGS, 128, 8, 96);
35 /* aria192gcm_functions */
36 IMPLEMENT_aead_cipher(aria, gcm, GCM, AEAD_FLAGS, 192, 8, 96);
37 /* aria256gcm_functions */
38 IMPLEMENT_aead_cipher(aria, gcm, GCM, AEAD_FLAGS, 256, 8, 96);
39