1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * sha1-ce-core.S - SHA-1 secure hash using ARMv8 Crypto Extensions
5 * Copyright (C) 2015 Linaro Ltd.
6 * Author: Ard Biesheuvel <ard.biesheuvel@linaro.org>
9 #include <linux/linkage.h>
10 #include <asm/assembler.h>
14 .fpu crypto-neon-fp-armv8
36 .macro add_only, op, ev, rc, s0, dg1
38 vadd.u32 tb\ev, q\s0, \rc
42 sha1\op\().32 dg0, dg1a\ev, ta\ev
44 sha1\op\().32 dg0, \dg1, ta\ev
48 .macro add_update, op, ev, rc, s0, s1, s2, s3, dg1
49 sha1su0.32 q\s0, q\s1, q\s2
50 add_only \op, \ev, \rc, \s1, \dg1
56 .word 0x5a827999, 0x5a827999, 0x5a827999, 0x5a827999
57 .word 0x6ed9eba1, 0x6ed9eba1, 0x6ed9eba1, 0x6ed9eba1
58 .word 0x8f1bbcdc, 0x8f1bbcdc, 0x8f1bbcdc, 0x8f1bbcdc
59 .word 0xca62c1d6, 0xca62c1d6, 0xca62c1d6, 0xca62c1d6
62 * void sha1_ce_transform(struct sha1_state *sst, u8 const *src,
65 ENTRY(sha1_ce_transform)
66 /* load round constants */
68 vld1.32 {k0-k1}, [ip, :128]!
69 vld1.32 {k2-k3}, [ip, :128]
76 0: vld1.32 {q8-q9}, [r1]!
77 vld1.32 {q10-q11}, [r1]!
80 #ifndef CONFIG_CPU_BIG_ENDIAN
90 add_update c, 0, k0, 8, 9, 10, 11, dgb
91 add_update c, 1, k0, 9, 10, 11, 8
92 add_update c, 0, k0, 10, 11, 8, 9
93 add_update c, 1, k0, 11, 8, 9, 10
94 add_update c, 0, k1, 8, 9, 10, 11
96 add_update p, 1, k1, 9, 10, 11, 8
97 add_update p, 0, k1, 10, 11, 8, 9
98 add_update p, 1, k1, 11, 8, 9, 10
99 add_update p, 0, k1, 8, 9, 10, 11
100 add_update p, 1, k2, 9, 10, 11, 8
102 add_update m, 0, k2, 10, 11, 8, 9
103 add_update m, 1, k2, 11, 8, 9, 10
104 add_update m, 0, k2, 8, 9, 10, 11
105 add_update m, 1, k2, 9, 10, 11, 8
106 add_update m, 0, k3, 10, 11, 8, 9
108 add_update p, 1, k3, 11, 8, 9, 10
110 add_only p, 1, k3, 10
111 add_only p, 0, k3, 11
115 vadd.u32 dga, dga, dg0
116 vadd.u32 dgb, dgb, dg1a0
119 /* store new state */
123 ENDPROC(sha1_ce_transform)