Add AES_CBC_CTS ciphers to providers
[openssl.git] / providers / implementations / ciphers / cipher_aria.c
1 /*
2  * Copyright 2019-2020 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 cipher modes ecb, cbc, ofb, cfb, ctr */
11
12 #include "cipher_aria.h"
13 #include "prov/implementations.h"
14
15 static OSSL_FUNC_cipher_freectx_fn aria_freectx;
16 static OSSL_FUNC_cipher_dupctx_fn aria_dupctx;
17
18 static void aria_freectx(void *vctx)
19 {
20     PROV_ARIA_CTX *ctx = (PROV_ARIA_CTX *)vctx;
21
22     cipher_generic_reset_ctx((PROV_CIPHER_CTX *)vctx);
23     OPENSSL_clear_free(ctx,  sizeof(*ctx));
24 }
25
26 static void *aria_dupctx(void *ctx)
27 {
28     PROV_ARIA_CTX *in = (PROV_ARIA_CTX *)ctx;
29     PROV_ARIA_CTX *ret = OPENSSL_malloc(sizeof(*ret));
30
31     if (ret == NULL) {
32         ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
33         return NULL;
34     }
35     in->base.hw->copyctx(&ret->base, &in->base);
36
37     return ret;
38 }
39
40 /* aria256ecb_functions */
41 IMPLEMENT_generic_cipher(aria, ARIA, ecb, ECB, 0, 256, 128, 0, block)
42 /* aria192ecb_functions */
43 IMPLEMENT_generic_cipher(aria, ARIA, ecb, ECB, 0, 192, 128, 0, block)
44 /* aria128ecb_functions */
45 IMPLEMENT_generic_cipher(aria, ARIA, ecb, ECB, 0, 128, 128, 0, block)
46 /* aria256cbc_functions */
47 IMPLEMENT_generic_cipher(aria, ARIA, cbc, CBC, 0, 256, 128, 128, block)
48 /* aria192cbc_functions */
49 IMPLEMENT_generic_cipher(aria, ARIA, cbc, CBC, 0, 192, 128, 128, block)
50 /* aria128cbc_functions */
51 IMPLEMENT_generic_cipher(aria, ARIA, cbc, CBC, 0, 128, 128, 128, block)
52 /* aria256ofb_functions */
53 IMPLEMENT_generic_cipher(aria, ARIA, ofb, OFB, 0, 256, 8, 128, stream)
54 /* aria192ofb_functions */
55 IMPLEMENT_generic_cipher(aria, ARIA, ofb, OFB, 0, 192, 8, 128, stream)
56 /* aria128ofb_functions */
57 IMPLEMENT_generic_cipher(aria, ARIA, ofb, OFB, 0, 128, 8, 128, stream)
58 /* aria256cfb_functions */
59 IMPLEMENT_generic_cipher(aria, ARIA, cfb,  CFB, 0, 256, 8, 128, stream)
60 /* aria192cfb_functions */
61 IMPLEMENT_generic_cipher(aria, ARIA, cfb,  CFB, 0, 192, 8, 128, stream)
62 /* aria128cfb_functions */
63 IMPLEMENT_generic_cipher(aria, ARIA, cfb,  CFB, 0, 128, 8, 128, stream)
64 /* aria256cfb1_functions */
65 IMPLEMENT_generic_cipher(aria, ARIA, cfb1, CFB, 0, 256, 8, 128, stream)
66 /* aria192cfb1_functions */
67 IMPLEMENT_generic_cipher(aria, ARIA, cfb1, CFB, 0, 192, 8, 128, stream)
68 /* aria128cfb1_functions */
69 IMPLEMENT_generic_cipher(aria, ARIA, cfb1, CFB, 0, 128, 8, 128, stream)
70 /* aria256cfb8_functions */
71 IMPLEMENT_generic_cipher(aria, ARIA, cfb8, CFB, 0, 256, 8, 128, stream)
72 /* aria192cfb8_functions */
73 IMPLEMENT_generic_cipher(aria, ARIA, cfb8, CFB, 0, 192, 8, 128, stream)
74 /* aria128cfb8_functions */
75 IMPLEMENT_generic_cipher(aria, ARIA, cfb8, CFB, 0, 128, 8, 128, stream)
76 /* aria256ctr_functions */
77 IMPLEMENT_generic_cipher(aria, ARIA, ctr, CTR, 0, 256, 8, 128, stream)
78 /* aria192ctr_functions */
79 IMPLEMENT_generic_cipher(aria, ARIA, ctr, CTR, 0, 192, 8, 128, stream)
80 /* aria128ctr_functions */
81 IMPLEMENT_generic_cipher(aria, ARIA, ctr, CTR, 0, 128, 8, 128, stream)