]> git.ipfire.org Git - thirdparty/openssl.git/blob - providers/implementations/ciphers/cipher_sm4_xts.h
Copyright year updates
[thirdparty/openssl.git] / providers / implementations / ciphers / cipher_sm4_xts.h
1 /*
2 * Copyright 2022-2023 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 #include <crypto/sm4.h>
11 #include "prov/ciphercommon.h"
12 #include "crypto/sm4_platform.h"
13
14 PROV_CIPHER_FUNC(void, xts_stream,
15 (const unsigned char *in, unsigned char *out, size_t len,
16 const SM4_KEY *key1, const SM4_KEY *key2,
17 const unsigned char iv[16], const int enc));
18
19 typedef struct prov_sm4_xts_ctx_st {
20 /* Must be first */
21 PROV_CIPHER_CTX base;
22
23 /* SM4 key schedules to use */
24 union {
25 OSSL_UNION_ALIGN;
26 SM4_KEY ks;
27 } ks1, ks2;
28
29 /*-
30 * XTS standard to use with SM4-XTS algorithm
31 *
32 * Must be 0 or 1,
33 * 0 for XTS mode specified by GB/T 17964-2021
34 * 1 for XTS mode specified by IEEE Std 1619-2007
35 */
36 int xts_standard;
37
38 XTS128_CONTEXT xts;
39
40 /* Stream function for XTS mode specified by GB/T 17964-2021 */
41 OSSL_xts_stream_fn stream_gb;
42 /* Stream function for XTS mode specified by IEEE Std 1619-2007 */
43 OSSL_xts_stream_fn stream;
44 } PROV_SM4_XTS_CTX;
45
46 const PROV_CIPHER_HW *ossl_prov_cipher_hw_sm4_xts(size_t keybits);