clmul.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Carry-less multiply operations.
  3. * SPDX-License-Identifier: GPL-2.0-or-later
  4. *
  5. * Copyright (C) 2023 Linaro, Ltd.
  6. */
  7. #ifndef CRYPTO_CLMUL_H
  8. #define CRYPTO_CLMUL_H
  9. #include "qemu/int128.h"
  10. #include "host/crypto/clmul.h"
  11. /**
  12. * clmul_8x8_low:
  13. *
  14. * Perform eight 8x8->8 carry-less multiplies.
  15. */
  16. uint64_t clmul_8x8_low(uint64_t, uint64_t);
  17. /**
  18. * clmul_8x4_even:
  19. *
  20. * Perform four 8x8->16 carry-less multiplies.
  21. * The odd bytes of the inputs are ignored.
  22. */
  23. uint64_t clmul_8x4_even(uint64_t, uint64_t);
  24. /**
  25. * clmul_8x4_odd:
  26. *
  27. * Perform four 8x8->16 carry-less multiplies.
  28. * The even bytes of the inputs are ignored.
  29. */
  30. uint64_t clmul_8x4_odd(uint64_t, uint64_t);
  31. /**
  32. * clmul_8x4_packed:
  33. *
  34. * Perform four 8x8->16 carry-less multiplies.
  35. */
  36. uint64_t clmul_8x4_packed(uint32_t, uint32_t);
  37. /**
  38. * clmul_16x2_even:
  39. *
  40. * Perform two 16x16->32 carry-less multiplies.
  41. * The odd words of the inputs are ignored.
  42. */
  43. uint64_t clmul_16x2_even(uint64_t, uint64_t);
  44. /**
  45. * clmul_16x2_odd:
  46. *
  47. * Perform two 16x16->32 carry-less multiplies.
  48. * The even words of the inputs are ignored.
  49. */
  50. uint64_t clmul_16x2_odd(uint64_t, uint64_t);
  51. /**
  52. * clmul_32:
  53. *
  54. * Perform a 32x32->64 carry-less multiply.
  55. */
  56. uint64_t clmul_32(uint32_t, uint32_t);
  57. /**
  58. * clmul_64:
  59. *
  60. * Perform a 64x64->128 carry-less multiply.
  61. */
  62. Int128 clmul_64_gen(uint64_t, uint64_t);
  63. static inline Int128 clmul_64(uint64_t a, uint64_t b)
  64. {
  65. if (HAVE_CLMUL_ACCEL) {
  66. return clmul_64_accel(a, b);
  67. } else {
  68. return clmul_64_gen(a, b);
  69. }
  70. }
  71. #endif /* CRYPTO_CLMUL_H */