1
C nettle, low-level cryptographics library
3
C Copyright (C) 2013 Niels Möller
5
C The nettle library is free software; you can redistribute it and/or modify
6
C it under the terms of the GNU Lesser General Public License as published by
7
C the Free Software Foundation; either version 2.1 of the License, or (at your
8
C option) any later version.
10
C The nettle library is distributed in the hope that it will be useful, but
11
C WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12
C or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13
C License for more details.
15
C You should have received a copy of the GNU Lesser General Public License
16
C along with the nettle library; see the file COPYING.LIB. If not, write to
17
C the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
.file "sha256-compress.asm"
21
define(<STATE>, <%rdi>)
22
define(<INPUT>, <%rsi>)
33
define(<T1>, <%edi>) C Overlap STATE
34
define(<COUNT>, <%r14>)
38
movl OFFSET($1)(%rsp), W
39
movl OFFSET(eval(($1 + 14) % 16))(%rsp), T0
47
movl OFFSET(eval(($1 + 1) % 16))(%rsp), T0
55
addl OFFSET(eval(($1 + 9) % 16))(%rsp), W
56
movl W, OFFSET($1)(%rsp)
59
C ROUND(A,B,C,D,E,F,G,H,K)
61
C H += S1(E) + Choice(E,F,G) + K + W
63
C H += S0(A) + Majority(A,B,C)
67
C S1(E) = E<<<26 ^ E<<<21 ^ E<<<7
68
C S0(A) = A<<<30 ^ A<<<19 ^ A<<<10
69
C Choice (E, F, G) = G^(E&(F^G))
70
C Majority (A,B,C) = (A&B) + (C&(A^B))
86
addl OFFSET($9)(K,COUNT,4), $8
108
movl OFFSET($1)(INPUT, COUNT, 4), W
110
movl W, OFFSET($1)(%rsp, COUNT, 4)
114
C _nettle_sha256_compress(uint32_t *state, const uint8_t *input, const uint32_t *k)
119
PROLOGUE(_nettle_sha256_compress)
124
mov STATE, 72(%rsp) C Save state, to free a register
143
NOEXPN(0) ROUND(SA,SB,SC,SD,SE,SF,SG,SH,0)
144
NOEXPN(1) ROUND(SH,SA,SB,SC,SD,SE,SF,SG,1)
145
NOEXPN(2) ROUND(SG,SH,SA,SB,SC,SD,SE,SF,2)
146
NOEXPN(3) ROUND(SF,SG,SH,SA,SB,SC,SD,SE,3)
147
NOEXPN(4) ROUND(SE,SF,SG,SH,SA,SB,SC,SD,4)
148
NOEXPN(5) ROUND(SD,SE,SF,SG,SH,SA,SB,SC,5)
149
NOEXPN(6) ROUND(SC,SD,SE,SF,SG,SH,SA,SB,6)
150
NOEXPN(7) ROUND(SB,SC,SD,SE,SF,SG,SH,SA,7)
156
EXPN( 0) ROUND(SA,SB,SC,SD,SE,SF,SG,SH,0)
157
EXPN( 1) ROUND(SH,SA,SB,SC,SD,SE,SF,SG,1)
158
EXPN( 2) ROUND(SG,SH,SA,SB,SC,SD,SE,SF,2)
159
EXPN( 3) ROUND(SF,SG,SH,SA,SB,SC,SD,SE,3)
160
EXPN( 4) ROUND(SE,SF,SG,SH,SA,SB,SC,SD,4)
161
EXPN( 5) ROUND(SD,SE,SF,SG,SH,SA,SB,SC,5)
162
EXPN( 6) ROUND(SC,SD,SE,SF,SG,SH,SA,SB,6)
163
EXPN( 7) ROUND(SB,SC,SD,SE,SF,SG,SH,SA,7)
164
EXPN( 8) ROUND(SA,SB,SC,SD,SE,SF,SG,SH,8)
165
EXPN( 9) ROUND(SH,SA,SB,SC,SD,SE,SF,SG,9)
166
EXPN(10) ROUND(SG,SH,SA,SB,SC,SD,SE,SF,10)
167
EXPN(11) ROUND(SF,SG,SH,SA,SB,SC,SD,SE,11)
168
EXPN(12) ROUND(SE,SF,SG,SH,SA,SB,SC,SD,12)
169
EXPN(13) ROUND(SD,SE,SF,SG,SH,SA,SB,SC,13)
170
EXPN(14) ROUND(SC,SD,SE,SF,SG,SH,SA,SB,14)
171
EXPN(15) ROUND(SB,SC,SD,SE,SF,SG,SH,SA,15)
197
EPILOGUE(_nettle_sha256_compress)