sm4.h 754 B

1234567891011121314151617181920212223242526272829303132
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Common values for the SM4 algorithm
  4. * Copyright (C) 2018 ARM Limited or its affiliates.
  5. */
  6. #ifndef _CRYPTO_SM4_H
  7. #define _CRYPTO_SM4_H
  8. #include <linux/types.h>
  9. #include <linux/crypto.h>
  10. #define SM4_KEY_SIZE 16
  11. #define SM4_BLOCK_SIZE 16
  12. #define SM4_RKEY_WORDS 32
  13. struct crypto_sm4_ctx {
  14. u32 rkey_enc[SM4_RKEY_WORDS];
  15. u32 rkey_dec[SM4_RKEY_WORDS];
  16. };
  17. int crypto_sm4_set_key(struct crypto_tfm *tfm, const u8 *in_key,
  18. unsigned int key_len);
  19. int crypto_sm4_expand_key(struct crypto_sm4_ctx *ctx, const u8 *in_key,
  20. unsigned int key_len);
  21. void crypto_sm4_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in);
  22. void crypto_sm4_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in);
  23. #endif