Add basic aria and camellia ciphers modes to default provider
[openssl.git] / providers / common / ciphers / cipher_aes.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 AES cipher modes ecb, cbc, ofb, cfb, ctr */
11
12 #include "cipher_locl.h"
13
14 static OSSL_OP_cipher_freectx_fn aes_freectx;
15 static OSSL_OP_cipher_dupctx_fn aes_dupctx;
16
17 static void aes_freectx(void *vctx)
18 {
19     PROV_AES_CTX *ctx = (PROV_AES_CTX *)vctx;
20
21     OPENSSL_clear_free(ctx,  sizeof(*ctx));
22 }
23
24 static void *aes_dupctx(void *ctx)
25 {
26     PROV_AES_CTX *in = (PROV_AES_CTX *)ctx;
27     PROV_AES_CTX *ret = OPENSSL_malloc(sizeof(*ret));
28
29     if (ret == NULL) {
30         ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
31         return NULL;
32     }
33     *ret = *in;
34
35     return ret;
36 }
37
38 /* aes256ecb_functions */
39 IMPLEMENT_generic_cipher(aes, AES, ecb, ECB, 0, 256, 128, 0, block)
40 /* aes192ecb_functions */
41 IMPLEMENT_generic_cipher(aes, AES, ecb, ECB, 0, 192, 128, 0, block)
42 /* aes128ecb_functions */
43 IMPLEMENT_generic_cipher(aes, AES, ecb, ECB, 0, 128, 128, 0, block)
44 /* aes256cbc_functions */
45 IMPLEMENT_generic_cipher(aes, AES, cbc, CBC, 0, 256, 128, 128, block)
46 /* aes192cbc_functions */
47 IMPLEMENT_generic_cipher(aes, AES, cbc, CBC, 0, 192, 128, 128, block)
48 /* aes128cbc_functions */
49 IMPLEMENT_generic_cipher(aes, AES, cbc, CBC, 0, 128, 128, 128, block)
50 /* aes256ofb_functions */
51 IMPLEMENT_generic_cipher(aes, AES, ofb, OFB, 0, 256, 8, 128, stream)
52 /* aes192ofb_functions */
53 IMPLEMENT_generic_cipher(aes, AES, ofb, OFB, 0, 192, 8, 128, stream)
54 /* aes128ofb_functions */
55 IMPLEMENT_generic_cipher(aes, AES, ofb, OFB, 0, 128, 8, 128, stream)
56 /* aes256cfb_functions */
57 IMPLEMENT_generic_cipher(aes, AES, cfb,  CFB, 0, 256, 8, 128, stream)
58 /* aes192cfb_functions */
59 IMPLEMENT_generic_cipher(aes, AES, cfb,  CFB, 0, 192, 8, 128, stream)
60 /* aes128cfb_functions */
61 IMPLEMENT_generic_cipher(aes, AES, cfb,  CFB, 0, 128, 8, 128, stream)
62 /* aes256cfb1_functions */
63 IMPLEMENT_generic_cipher(aes, AES, cfb1, CFB, 0, 256, 8, 128, stream)
64 /* aes192cfb1_functions */
65 IMPLEMENT_generic_cipher(aes, AES, cfb1, CFB, 0, 192, 8, 128, stream)
66 /* aes128cfb1_functions */
67 IMPLEMENT_generic_cipher(aes, AES, cfb1, CFB, 0, 128, 8, 128, stream)
68 /* aes256cfb8_functions */
69 IMPLEMENT_generic_cipher(aes, AES, cfb8, CFB, 0, 256, 8, 128, stream)
70 /* aes192cfb8_functions */
71 IMPLEMENT_generic_cipher(aes, AES, cfb8, CFB, 0, 192, 8, 128, stream)
72 /* aes128cfb8_functions */
73 IMPLEMENT_generic_cipher(aes, AES, cfb8, CFB, 0, 128, 8, 128, stream)
74 /* aes256ctr_functions */
75 IMPLEMENT_generic_cipher(aes, AES, ctr, CTR, 0, 256, 8, 128, stream)
76 /* aes192ctr_functions */
77 IMPLEMENT_generic_cipher(aes, AES, ctr, CTR, 0, 192, 8, 128, stream)
78 /* aes128ctr_functions */
79 IMPLEMENT_generic_cipher(aes, AES, ctr, CTR, 0, 128, 8, 128, stream)