speck.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Common values for the Speck algorithm
  4. */
  5. #ifndef _CRYPTO_SPECK_H
  6. #define _CRYPTO_SPECK_H
  7. #include <linux/types.h>
  8. /* Speck128 */
  9. #define SPECK128_BLOCK_SIZE 16
  10. #define SPECK128_128_KEY_SIZE 16
  11. #define SPECK128_128_NROUNDS 32
  12. #define SPECK128_192_KEY_SIZE 24
  13. #define SPECK128_192_NROUNDS 33
  14. #define SPECK128_256_KEY_SIZE 32
  15. #define SPECK128_256_NROUNDS 34
  16. struct speck128_tfm_ctx {
  17. u64 round_keys[SPECK128_256_NROUNDS];
  18. int nrounds;
  19. };
  20. void crypto_speck128_encrypt(const struct speck128_tfm_ctx *ctx,
  21. u8 *out, const u8 *in);
  22. void crypto_speck128_decrypt(const struct speck128_tfm_ctx *ctx,
  23. u8 *out, const u8 *in);
  24. int crypto_speck128_setkey(struct speck128_tfm_ctx *ctx, const u8 *key,
  25. unsigned int keysize);
  26. /* Speck64 */
  27. #define SPECK64_BLOCK_SIZE 8
  28. #define SPECK64_96_KEY_SIZE 12
  29. #define SPECK64_96_NROUNDS 26
  30. #define SPECK64_128_KEY_SIZE 16
  31. #define SPECK64_128_NROUNDS 27
  32. struct speck64_tfm_ctx {
  33. u32 round_keys[SPECK64_128_NROUNDS];
  34. int nrounds;
  35. };
  36. void crypto_speck64_encrypt(const struct speck64_tfm_ctx *ctx,
  37. u8 *out, const u8 *in);
  38. void crypto_speck64_decrypt(const struct speck64_tfm_ctx *ctx,
  39. u8 *out, const u8 *in);
  40. int crypto_speck64_setkey(struct speck64_tfm_ctx *ctx, const u8 *key,
  41. unsigned int keysize);
  42. #endif /* _CRYPTO_SPECK_H */