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  * Generic support for ARIA CCM.
12  */
13 
14 #include "cipher_aria_ccm.h"
15 
ccm_aria_initkey(PROV_CCM_CTX * ctx,const unsigned char * key,size_t keylen)16 static int ccm_aria_initkey(PROV_CCM_CTX *ctx,
17                             const unsigned char *key, size_t keylen)
18 {
19     PROV_ARIA_CCM_CTX *actx = (PROV_ARIA_CCM_CTX *)ctx;
20 
21     ossl_aria_set_encrypt_key(key, (int)(keylen * 8), &actx->ks.ks);
22     CRYPTO_ccm128_init(&ctx->ccm_ctx, (unsigned int)ctx->m,
23                        (unsigned int)ctx->l, &actx->ks.ks,
24                        (block128_f)ossl_aria_encrypt);
25     ctx->str = NULL;
26     ctx->key_set = 1;
27     return 1;
28 }
29 
30 static const PROV_CCM_HW ccm_aria = {
31     ccm_aria_initkey,
32     ossl_ccm_generic_setiv,
33     ossl_ccm_generic_setaad,
34     ossl_ccm_generic_auth_encrypt,
35     ossl_ccm_generic_auth_decrypt,
36     ossl_ccm_generic_gettag
37 };
ossl_prov_aria_hw_ccm(size_t keybits)38 const PROV_CCM_HW *ossl_prov_aria_hw_ccm(size_t keybits)
39 {
40     return &ccm_aria;
41 }
42