sm4.h 983 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved.
  3. * Copyright 2017 Ribose Inc. All Rights Reserved.
  4. *
  5. * Licensed under the Apache License 2.0 (the "License"). You may not use
  6. * this file except in compliance with the License. You can obtain a copy
  7. * in the file LICENSE in the source distribution or at
  8. * https://www.openssl.org/source/license.html
  9. */
  10. #ifndef OSSL_CRYPTO_SM4_H
  11. # define OSSL_CRYPTO_SM4_H
  12. # pragma once
  13. # include <openssl/opensslconf.h>
  14. # include <openssl/e_os2.h>
  15. # ifdef OPENSSL_NO_SM4
  16. # error SM4 is disabled.
  17. # endif
  18. # define SM4_ENCRYPT 1
  19. # define SM4_DECRYPT 0
  20. # define SM4_BLOCK_SIZE 16
  21. # define SM4_KEY_SCHEDULE 32
  22. typedef struct SM4_KEY_st {
  23. uint32_t rk[SM4_KEY_SCHEDULE];
  24. } SM4_KEY;
  25. int ossl_sm4_set_key(const uint8_t *key, SM4_KEY *ks);
  26. void ossl_sm4_encrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *ks);
  27. void ossl_sm4_decrypt(const uint8_t *in, uint8_t *out, const SM4_KEY *ks);
  28. #endif