openssl/providers/implementations/ciphers/cipher_sm4_xts.h
Xu Yizhou 2788b56f0c providers: Add SM4 XTS implementation
Signed-off-by: Xu Yizhou <xuyizhou1@huawei.com>

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19619)
2022-11-29 16:17:30 +01:00

47 lines
1.3 KiB
C

/*
* 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);