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#include <openssl/aes.h>
11e1051a39Sopenharmony_ci#include "prov/ciphercommon.h"
12e1051a39Sopenharmony_ci#include "crypto/aes_platform.h"
13e1051a39Sopenharmony_ci
14e1051a39Sopenharmony_citypedef struct prov_aes_ctx_st {
15e1051a39Sopenharmony_ci    PROV_CIPHER_CTX base;      /* Must be first */
16e1051a39Sopenharmony_ci    union {
17e1051a39Sopenharmony_ci        OSSL_UNION_ALIGN;
18e1051a39Sopenharmony_ci        AES_KEY ks;
19e1051a39Sopenharmony_ci    } ks;
20e1051a39Sopenharmony_ci
21e1051a39Sopenharmony_ci    /* Platform specific data */
22e1051a39Sopenharmony_ci    union {
23e1051a39Sopenharmony_ci        int dummy;
24e1051a39Sopenharmony_ci#if defined(OPENSSL_CPUID_OBJ) && defined(__s390__)
25e1051a39Sopenharmony_ci        struct {
26e1051a39Sopenharmony_ci            union {
27e1051a39Sopenharmony_ci                OSSL_UNION_ALIGN;
28e1051a39Sopenharmony_ci                /*-
29e1051a39Sopenharmony_ci                 * KM-AES parameter block - begin
30e1051a39Sopenharmony_ci                 * (see z/Architecture Principles of Operation >= SA22-7832-06)
31e1051a39Sopenharmony_ci                 */
32e1051a39Sopenharmony_ci                struct {
33e1051a39Sopenharmony_ci                    unsigned char k[32];
34e1051a39Sopenharmony_ci                } km;
35e1051a39Sopenharmony_ci                /* KM-AES parameter block - end */
36e1051a39Sopenharmony_ci                /*-
37e1051a39Sopenharmony_ci                 * KMO-AES/KMF-AES parameter block - begin
38e1051a39Sopenharmony_ci                 * (see z/Architecture Principles of Operation >= SA22-7832-08)
39e1051a39Sopenharmony_ci                 */
40e1051a39Sopenharmony_ci                struct {
41e1051a39Sopenharmony_ci                    unsigned char cv[16];
42e1051a39Sopenharmony_ci                    unsigned char k[32];
43e1051a39Sopenharmony_ci                } kmo_kmf;
44e1051a39Sopenharmony_ci                /* KMO-AES/KMF-AES parameter block - end */
45e1051a39Sopenharmony_ci            } param;
46e1051a39Sopenharmony_ci            unsigned int fc;
47e1051a39Sopenharmony_ci            int res;
48e1051a39Sopenharmony_ci        } s390x;
49e1051a39Sopenharmony_ci#endif /* defined(OPENSSL_CPUID_OBJ) && defined(__s390__) */
50e1051a39Sopenharmony_ci    } plat;
51e1051a39Sopenharmony_ci
52e1051a39Sopenharmony_ci} PROV_AES_CTX;
53e1051a39Sopenharmony_ci
54e1051a39Sopenharmony_ci#define ossl_prov_cipher_hw_aes_ofb ossl_prov_cipher_hw_aes_ofb128
55e1051a39Sopenharmony_ci#define ossl_prov_cipher_hw_aes_cfb ossl_prov_cipher_hw_aes_cfb128
56e1051a39Sopenharmony_ciconst PROV_CIPHER_HW *ossl_prov_cipher_hw_aes_ecb(size_t keybits);
57e1051a39Sopenharmony_ciconst PROV_CIPHER_HW *ossl_prov_cipher_hw_aes_cbc(size_t keybits);
58e1051a39Sopenharmony_ciconst PROV_CIPHER_HW *ossl_prov_cipher_hw_aes_ofb128(size_t keybits);
59e1051a39Sopenharmony_ciconst PROV_CIPHER_HW *ossl_prov_cipher_hw_aes_cfb128(size_t keybits);
60e1051a39Sopenharmony_ciconst PROV_CIPHER_HW *ossl_prov_cipher_hw_aes_cfb1(size_t keybits);
61e1051a39Sopenharmony_ciconst PROV_CIPHER_HW *ossl_prov_cipher_hw_aes_cfb8(size_t keybits);
62e1051a39Sopenharmony_ciconst PROV_CIPHER_HW *ossl_prov_cipher_hw_aes_ctr(size_t keybits);
63