2 * SHA-1 implementation for PowerPC.
4 * Copyright (C) 2005 Paul Mackerras <paulus@samba.org>
9 * We roll the registers for T, A, B, C, D, E around on each
10 * iteration; T on iteration t is A on iteration t+1, and so on.
11 * We use registers 7 - 12 for this.
13 #define RT(t) ((((t)+5)%6)+7)
14 #define RA(t) ((((t)+4)%6)+7)
15 #define RB(t) ((((t)+3)%6)+7)
16 #define RC(t) ((((t)+2)%6)+7)
17 #define RD(t) ((((t)+1)%6)+7)
18 #define RE(t) ((((t)+0)%6)+7)
20 /* We use registers 16 - 31 for the W values */
21 #define W(t) (((t)%16)+16)
24 and %r6,RB(t),RC(t); \
25 andc %r0,RD(t),RB(t); \
26 rotlwi RT(t),RA(t),5; \
27 rotlwi RB(t),RB(t),30; \
30 add RT(t),RT(t),%r6; \
35 xor %r6,RB(t),RC(t); \
36 rotlwi RT(t),RA(t),5; \
37 rotlwi RB(t),RB(t),30; \
40 add RT(t),RT(t),%r6; \
45 and %r6,RB(t),RC(t); \
46 and %r0,RB(t),RD(t); \
47 rotlwi RT(t),RA(t),5; \
48 rotlwi RB(t),RB(t),30; \
50 and %r0,RC(t),RD(t); \
53 add RT(t),RT(t),%r6; \
61 xor %r0,W((t)-3),W((t)-8); \
62 xor W(t),W((t)-16),W((t)-14); \
67 STEPD0(t); LOADW((t)+4); \
68 STEPD0((t)+1); LOADW((t)+5); \
69 STEPD0((t)+2); LOADW((t)+6); \
70 STEPD0((t)+3); LOADW((t)+7)
72 #define STEPUP4(t, fn) \
73 STEP##fn(t); UPDATEW((t)+4); \
74 STEP##fn((t)+1); UPDATEW((t)+5); \
75 STEP##fn((t)+2); UPDATEW((t)+6); \
76 STEP##fn((t)+3); UPDATEW((t)+7)
78 #define STEPUP20(t, fn) \
82 STEPUP4((t)+12, fn); \
107 lwz RA(0),0(%r3) /* A */
108 lwz RB(0),4(%r3) /* B */
109 lwz RC(0),8(%r3) /* C */
110 lwz RD(0),12(%r3) /* D */
111 lwz RE(0),16(%r3) /* E */
120 lis %r15,0x5a82 /* K0-19 */
128 lis %r15,0x6ed9 /* K20-39 */
132 lis %r15,0x8f1b /* K40-59 */
136 lis %r15,0xca62 /* K60-79 */
153 add RD(0),RD(80),%r19
154 add RC(0),RC(80),%r18
155 add RB(0),RB(80),%r17
156 add RA(0),RA(80),%r16