1e1051a39Sopenharmony_ci/*
2e1051a39Sopenharmony_ci * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
3e1051a39Sopenharmony_ci *
4e1051a39Sopenharmony_ci * Licensed under the Apache License 2.0 (the "License").  You may not use
5e1051a39Sopenharmony_ci * this file except in compliance with the License.  You can obtain a copy
6e1051a39Sopenharmony_ci * in the file LICENSE in the source distribution or at
7e1051a39Sopenharmony_ci * https://www.openssl.org/source/license.html
8e1051a39Sopenharmony_ci */
9e1051a39Sopenharmony_ci
10e1051a39Sopenharmony_ci/* Dispatch functions for ARIA cipher modes ecb, cbc, ofb, cfb, ctr */
11e1051a39Sopenharmony_ci
12e1051a39Sopenharmony_ci#include "cipher_aria.h"
13e1051a39Sopenharmony_ci#include "prov/implementations.h"
14e1051a39Sopenharmony_ci#include "prov/providercommon.h"
15e1051a39Sopenharmony_ci
16e1051a39Sopenharmony_cistatic OSSL_FUNC_cipher_freectx_fn aria_freectx;
17e1051a39Sopenharmony_cistatic OSSL_FUNC_cipher_dupctx_fn aria_dupctx;
18e1051a39Sopenharmony_ci
19e1051a39Sopenharmony_cistatic void aria_freectx(void *vctx)
20e1051a39Sopenharmony_ci{
21e1051a39Sopenharmony_ci    PROV_ARIA_CTX *ctx = (PROV_ARIA_CTX *)vctx;
22e1051a39Sopenharmony_ci
23e1051a39Sopenharmony_ci    ossl_cipher_generic_reset_ctx((PROV_CIPHER_CTX *)vctx);
24e1051a39Sopenharmony_ci    OPENSSL_clear_free(ctx,  sizeof(*ctx));
25e1051a39Sopenharmony_ci}
26e1051a39Sopenharmony_ci
27e1051a39Sopenharmony_cistatic void *aria_dupctx(void *ctx)
28e1051a39Sopenharmony_ci{
29e1051a39Sopenharmony_ci    PROV_ARIA_CTX *in = (PROV_ARIA_CTX *)ctx;
30e1051a39Sopenharmony_ci    PROV_ARIA_CTX *ret;
31e1051a39Sopenharmony_ci
32e1051a39Sopenharmony_ci    if (!ossl_prov_is_running())
33e1051a39Sopenharmony_ci        return NULL;
34e1051a39Sopenharmony_ci
35e1051a39Sopenharmony_ci    ret = OPENSSL_malloc(sizeof(*ret));
36e1051a39Sopenharmony_ci    if (ret == NULL) {
37e1051a39Sopenharmony_ci        ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
38e1051a39Sopenharmony_ci        return NULL;
39e1051a39Sopenharmony_ci    }
40e1051a39Sopenharmony_ci    in->base.hw->copyctx(&ret->base, &in->base);
41e1051a39Sopenharmony_ci
42e1051a39Sopenharmony_ci    return ret;
43e1051a39Sopenharmony_ci}
44e1051a39Sopenharmony_ci
45e1051a39Sopenharmony_ci/* ossl_aria256ecb_functions */
46e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(aria, ARIA, ecb, ECB, 0, 256, 128, 0, block)
47e1051a39Sopenharmony_ci/* ossl_aria192ecb_functions */
48e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(aria, ARIA, ecb, ECB, 0, 192, 128, 0, block)
49e1051a39Sopenharmony_ci/* ossl_aria128ecb_functions */
50e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(aria, ARIA, ecb, ECB, 0, 128, 128, 0, block)
51e1051a39Sopenharmony_ci/* ossl_aria256cbc_functions */
52e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(aria, ARIA, cbc, CBC, 0, 256, 128, 128, block)
53e1051a39Sopenharmony_ci/* ossl_aria192cbc_functions */
54e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(aria, ARIA, cbc, CBC, 0, 192, 128, 128, block)
55e1051a39Sopenharmony_ci/* ossl_aria128cbc_functions */
56e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(aria, ARIA, cbc, CBC, 0, 128, 128, 128, block)
57e1051a39Sopenharmony_ci/* ossl_aria256ofb_functions */
58e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(aria, ARIA, ofb, OFB, 0, 256, 8, 128, stream)
59e1051a39Sopenharmony_ci/* ossl_aria192ofb_functions */
60e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(aria, ARIA, ofb, OFB, 0, 192, 8, 128, stream)
61e1051a39Sopenharmony_ci/* ossl_aria128ofb_functions */
62e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(aria, ARIA, ofb, OFB, 0, 128, 8, 128, stream)
63e1051a39Sopenharmony_ci/* ossl_aria256cfb_functions */
64e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(aria, ARIA, cfb,  CFB, 0, 256, 8, 128, stream)
65e1051a39Sopenharmony_ci/* ossl_aria192cfb_functions */
66e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(aria, ARIA, cfb,  CFB, 0, 192, 8, 128, stream)
67e1051a39Sopenharmony_ci/* ossl_aria128cfb_functions */
68e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(aria, ARIA, cfb,  CFB, 0, 128, 8, 128, stream)
69e1051a39Sopenharmony_ci/* ossl_aria256cfb1_functions */
70e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(aria, ARIA, cfb1, CFB, 0, 256, 8, 128, stream)
71e1051a39Sopenharmony_ci/* ossl_aria192cfb1_functions */
72e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(aria, ARIA, cfb1, CFB, 0, 192, 8, 128, stream)
73e1051a39Sopenharmony_ci/* ossl_aria128cfb1_functions */
74e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(aria, ARIA, cfb1, CFB, 0, 128, 8, 128, stream)
75e1051a39Sopenharmony_ci/* ossl_aria256cfb8_functions */
76e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(aria, ARIA, cfb8, CFB, 0, 256, 8, 128, stream)
77e1051a39Sopenharmony_ci/* ossl_aria192cfb8_functions */
78e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(aria, ARIA, cfb8, CFB, 0, 192, 8, 128, stream)
79e1051a39Sopenharmony_ci/* ossl_aria128cfb8_functions */
80e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(aria, ARIA, cfb8, CFB, 0, 128, 8, 128, stream)
81e1051a39Sopenharmony_ci/* ossl_aria256ctr_functions */
82e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(aria, ARIA, ctr, CTR, 0, 256, 8, 128, stream)
83e1051a39Sopenharmony_ci/* ossl_aria192ctr_functions */
84e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(aria, ARIA, ctr, CTR, 0, 192, 8, 128, stream)
85e1051a39Sopenharmony_ci/* ossl_aria128ctr_functions */
86e1051a39Sopenharmony_ciIMPLEMENT_generic_cipher(aria, ARIA, ctr, CTR, 0, 128, 8, 128, stream)
87