2 * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
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
11 * AES low level APIs are deprecated for public use, but still ok for internal
12 * use where we're using them to implement the higher level EVP interface, as is
15 #include "internal/deprecated.h"
17 /* Dispatch functions for AES cipher modes ecb, cbc, ofb, cfb, ctr */
19 #include "cipher_aes.h"
20 #include "prov/implementations.h"
22 static OSSL_FUNC_cipher_freectx_fn aes_freectx;
23 static OSSL_FUNC_cipher_dupctx_fn aes_dupctx;
25 static void aes_freectx(void *vctx)
27 PROV_AES_CTX *ctx = (PROV_AES_CTX *)vctx;
29 OPENSSL_clear_free(ctx, sizeof(*ctx));
32 static void *aes_dupctx(void *ctx)
34 PROV_AES_CTX *in = (PROV_AES_CTX *)ctx;
35 PROV_AES_CTX *ret = OPENSSL_malloc(sizeof(*ret));
38 ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
41 in->base.hw->copyctx(&ret->base, &in->base);
46 /* aes256ecb_functions */
47 IMPLEMENT_generic_cipher(aes, AES, ecb, ECB, 0, 256, 128, 0, block)
48 /* aes192ecb_functions */
49 IMPLEMENT_generic_cipher(aes, AES, ecb, ECB, 0, 192, 128, 0, block)
50 /* aes128ecb_functions */
51 IMPLEMENT_generic_cipher(aes, AES, ecb, ECB, 0, 128, 128, 0, block)
52 /* aes256cbc_functions */
53 IMPLEMENT_generic_cipher(aes, AES, cbc, CBC, 0, 256, 128, 128, block)
54 /* aes192cbc_functions */
55 IMPLEMENT_generic_cipher(aes, AES, cbc, CBC, 0, 192, 128, 128, block)
56 /* aes128cbc_functions */
57 IMPLEMENT_generic_cipher(aes, AES, cbc, CBC, 0, 128, 128, 128, block)
58 /* aes256ofb_functions */
59 IMPLEMENT_generic_cipher(aes, AES, ofb, OFB, 0, 256, 8, 128, stream)
60 /* aes192ofb_functions */
61 IMPLEMENT_generic_cipher(aes, AES, ofb, OFB, 0, 192, 8, 128, stream)
62 /* aes128ofb_functions */
63 IMPLEMENT_generic_cipher(aes, AES, ofb, OFB, 0, 128, 8, 128, stream)
64 /* aes256cfb_functions */
65 IMPLEMENT_generic_cipher(aes, AES, cfb, CFB, 0, 256, 8, 128, stream)
66 /* aes192cfb_functions */
67 IMPLEMENT_generic_cipher(aes, AES, cfb, CFB, 0, 192, 8, 128, stream)
68 /* aes128cfb_functions */
69 IMPLEMENT_generic_cipher(aes, AES, cfb, CFB, 0, 128, 8, 128, stream)
70 /* aes256cfb1_functions */
71 IMPLEMENT_generic_cipher(aes, AES, cfb1, CFB, 0, 256, 8, 128, stream)
72 /* aes192cfb1_functions */
73 IMPLEMENT_generic_cipher(aes, AES, cfb1, CFB, 0, 192, 8, 128, stream)
74 /* aes128cfb1_functions */
75 IMPLEMENT_generic_cipher(aes, AES, cfb1, CFB, 0, 128, 8, 128, stream)
76 /* aes256cfb8_functions */
77 IMPLEMENT_generic_cipher(aes, AES, cfb8, CFB, 0, 256, 8, 128, stream)
78 /* aes192cfb8_functions */
79 IMPLEMENT_generic_cipher(aes, AES, cfb8, CFB, 0, 192, 8, 128, stream)
80 /* aes128cfb8_functions */
81 IMPLEMENT_generic_cipher(aes, AES, cfb8, CFB, 0, 128, 8, 128, stream)
82 /* aes256ctr_functions */
83 IMPLEMENT_generic_cipher(aes, AES, ctr, CTR, 0, 256, 8, 128, stream)
84 /* aes192ctr_functions */
85 IMPLEMENT_generic_cipher(aes, AES, ctr, CTR, 0, 192, 8, 128, stream)
86 /* aes128ctr_functions */
87 IMPLEMENT_generic_cipher(aes, AES, ctr, CTR, 0, 128, 8, 128, stream)