sm4-ce-core.S 743 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/linkage.h>
  3. #include <asm/assembler.h>
  4. .irp b, 0, 1, 2, 3, 4, 5, 6, 7, 8
  5. .set .Lv\b\().4s, \b
  6. .endr
  7. .macro sm4e, rd, rn
  8. .inst 0xcec08400 | .L\rd | (.L\rn << 5)
  9. .endm
  10. /*
  11. * void sm4_ce_do_crypt(const u32 *rk, u32 *out, const u32 *in);
  12. */
  13. .text
  14. ENTRY(sm4_ce_do_crypt)
  15. ld1 {v8.4s}, [x2]
  16. ld1 {v0.4s-v3.4s}, [x0], #64
  17. CPU_LE( rev32 v8.16b, v8.16b )
  18. ld1 {v4.4s-v7.4s}, [x0]
  19. sm4e v8.4s, v0.4s
  20. sm4e v8.4s, v1.4s
  21. sm4e v8.4s, v2.4s
  22. sm4e v8.4s, v3.4s
  23. sm4e v8.4s, v4.4s
  24. sm4e v8.4s, v5.4s
  25. sm4e v8.4s, v6.4s
  26. sm4e v8.4s, v7.4s
  27. rev64 v8.4s, v8.4s
  28. ext v8.16b, v8.16b, v8.16b, #8
  29. CPU_LE( rev32 v8.16b, v8.16b )
  30. st1 {v8.4s}, [x1]
  31. ret
  32. ENDPROC(sm4_ce_do_crypt)