2
0

cipher_sm4_xts.h 1.4 KB

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