summaryrefslogtreecommitdiffstats
path: root/providers/implementations/ciphers/cipher_sm4_xts.h
diff options
context:
space:
mode:
Diffstat (limited to 'providers/implementations/ciphers/cipher_sm4_xts.h')
-rw-r--r--providers/implementations/ciphers/cipher_sm4_xts.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/providers/implementations/ciphers/cipher_sm4_xts.h b/providers/implementations/ciphers/cipher_sm4_xts.h
new file mode 100644
index 0000000000..4c369183e2
--- /dev/null
+++ b/providers/implementations/ciphers/cipher_sm4_xts.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include <crypto/sm4.h>
+#include "prov/ciphercommon.h"
+#include "crypto/sm4_platform.h"
+
+PROV_CIPHER_FUNC(void, xts_stream,
+ (const unsigned char *in, unsigned char *out, size_t len,
+ const SM4_KEY *key1, const SM4_KEY *key2,
+ const unsigned char iv[16]));
+
+typedef struct prov_sm4_xts_ctx_st {
+ /* Must be first */
+ PROV_CIPHER_CTX base;
+
+ /* SM4 key schedules to use */
+ union {
+ OSSL_UNION_ALIGN;
+ SM4_KEY ks;
+ } ks1, ks2;
+
+ /*-
+ * XTS standard to use with SM4-XTS algorithm
+ *
+ * Must be 0 or 1,
+ * 0 for XTS mode specified by GB/T 17964-2021
+ * 1 for XTS mode specified by IEEE Std 1619-2007
+ */
+ int xts_standard;
+
+ XTS128_CONTEXT xts;
+
+ /* Stream function for XTS mode specified by GB/T 17964-2021 */
+ OSSL_xts_stream_fn stream_gb;
+ /* Stream function for XTS mode specified by IEEE Std 1619-2007 */
+ OSSL_xts_stream_fn stream;
+} PROV_SM4_XTS_CTX;
+
+const PROV_CIPHER_HW *ossl_prov_cipher_hw_sm4_xts(size_t keybits);