1*b077aed3SPierre Pronchery /*
2*b077aed3SPierre Pronchery * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
3*b077aed3SPierre Pronchery *
4*b077aed3SPierre Pronchery * Licensed under the Apache License 2.0 (the "License"). You may not use
5*b077aed3SPierre Pronchery * this file except in compliance with the License. You can obtain a copy
6*b077aed3SPierre Pronchery * in the file LICENSE in the source distribution or at
7*b077aed3SPierre Pronchery * https://www.openssl.org/source/license.html
8*b077aed3SPierre Pronchery */
9*b077aed3SPierre Pronchery
10*b077aed3SPierre Pronchery /*-
11*b077aed3SPierre Pronchery * Generic support for ARIA CCM.
12*b077aed3SPierre Pronchery */
13*b077aed3SPierre Pronchery
14*b077aed3SPierre Pronchery #include "cipher_aria_ccm.h"
15*b077aed3SPierre Pronchery
ccm_aria_initkey(PROV_CCM_CTX * ctx,const unsigned char * key,size_t keylen)16*b077aed3SPierre Pronchery static int ccm_aria_initkey(PROV_CCM_CTX *ctx,
17*b077aed3SPierre Pronchery const unsigned char *key, size_t keylen)
18*b077aed3SPierre Pronchery {
19*b077aed3SPierre Pronchery PROV_ARIA_CCM_CTX *actx = (PROV_ARIA_CCM_CTX *)ctx;
20*b077aed3SPierre Pronchery
21*b077aed3SPierre Pronchery ossl_aria_set_encrypt_key(key, keylen * 8, &actx->ks.ks);
22*b077aed3SPierre Pronchery CRYPTO_ccm128_init(&ctx->ccm_ctx, ctx->m, ctx->l, &actx->ks.ks,
23*b077aed3SPierre Pronchery (block128_f)ossl_aria_encrypt);
24*b077aed3SPierre Pronchery ctx->str = NULL;
25*b077aed3SPierre Pronchery ctx->key_set = 1;
26*b077aed3SPierre Pronchery return 1;
27*b077aed3SPierre Pronchery }
28*b077aed3SPierre Pronchery
29*b077aed3SPierre Pronchery static const PROV_CCM_HW ccm_aria = {
30*b077aed3SPierre Pronchery ccm_aria_initkey,
31*b077aed3SPierre Pronchery ossl_ccm_generic_setiv,
32*b077aed3SPierre Pronchery ossl_ccm_generic_setaad,
33*b077aed3SPierre Pronchery ossl_ccm_generic_auth_encrypt,
34*b077aed3SPierre Pronchery ossl_ccm_generic_auth_decrypt,
35*b077aed3SPierre Pronchery ossl_ccm_generic_gettag
36*b077aed3SPierre Pronchery };
ossl_prov_aria_hw_ccm(size_t keybits)37*b077aed3SPierre Pronchery const PROV_CCM_HW *ossl_prov_aria_hw_ccm(size_t keybits)
38*b077aed3SPierre Pronchery {
39*b077aed3SPierre Pronchery return &ccm_aria;
40*b077aed3SPierre Pronchery }
41