1e1051a39Sopenharmony_ci/*
2e1051a39Sopenharmony_ci * Copyright 2019-2021 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_ci/*
15e1051a39Sopenharmony_ci * Available in cipher_fips.c, and compiled with different values depending
16e1051a39Sopenharmony_ci * on we're in the FIPS module or not.
17e1051a39Sopenharmony_ci */
18e1051a39Sopenharmony_ciextern const int ossl_aes_xts_allow_insecure_decrypt;
19e1051a39Sopenharmony_ci
20e1051a39Sopenharmony_ciPROV_CIPHER_FUNC(void, xts_stream,
21e1051a39Sopenharmony_ci                 (const unsigned char *in, unsigned char *out, size_t len,
22e1051a39Sopenharmony_ci                  const AES_KEY *key1, const AES_KEY *key2,
23e1051a39Sopenharmony_ci                  const unsigned char iv[16]));
24e1051a39Sopenharmony_ci
25e1051a39Sopenharmony_citypedef struct prov_aes_xts_ctx_st {
26e1051a39Sopenharmony_ci    PROV_CIPHER_CTX base;      /* Must be first */
27e1051a39Sopenharmony_ci    union {
28e1051a39Sopenharmony_ci        OSSL_UNION_ALIGN;
29e1051a39Sopenharmony_ci        AES_KEY ks;
30e1051a39Sopenharmony_ci    } ks1, ks2;                /* AES key schedules to use */
31e1051a39Sopenharmony_ci    XTS128_CONTEXT xts;
32e1051a39Sopenharmony_ci    OSSL_xts_stream_fn stream;
33e1051a39Sopenharmony_ci} PROV_AES_XTS_CTX;
34e1051a39Sopenharmony_ci
35e1051a39Sopenharmony_ciconst PROV_CIPHER_HW *ossl_prov_cipher_hw_aes_xts(size_t keybits);
36