e4cfc6cd8fb6a1a0a717c1cff434626f75544a83
[openssl.git] / providers / implementations / ciphers / cipher_aria_ccm.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 CCM mode */
11
12 #include "cipher_aria_ccm.h"
13 #include "prov/implementations.h"
14
15 static OSSL_OP_cipher_freectx_fn aria_ccm_freectx;
16
17 static void *aria_ccm_newctx(void *provctx, size_t keybits)
18 {
19     PROV_ARIA_CCM_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
20
21     if (ctx != NULL)
22         ccm_initctx(&ctx->base, keybits, PROV_ARIA_HW_ccm(keybits));
23     return ctx;
24 }
25
26 static void aria_ccm_freectx(void *vctx)
27 {
28     PROV_ARIA_CCM_CTX *ctx = (PROV_ARIA_CCM_CTX *)vctx;
29
30     OPENSSL_clear_free(ctx,  sizeof(*ctx));
31 }
32
33 /* aria128ccm functions */
34 IMPLEMENT_aead_cipher(aria, ccm, CCM, AEAD_FLAGS, 128, 8, 96);
35 /* aria192ccm functions */
36 IMPLEMENT_aead_cipher(aria, ccm, CCM, AEAD_FLAGS, 192, 8, 96);
37 /* aria256ccm functions */
38 IMPLEMENT_aead_cipher(aria, ccm, CCM, AEAD_FLAGS, 256, 8, 96);
39