diff options
author | djm <> | 2012-10-13 21:23:50 +0000 |
---|---|---|
committer | djm <> | 2012-10-13 21:23:50 +0000 |
commit | 228cae30b117c2493f69ad3c195341cd6ec8d430 (patch) | |
tree | 29ff00b10d52c0978077c4fd83c33b065bade73e /src/lib/libcrypto/sha/asm/sha1-ppc.pl | |
parent | 731838c66b52c0ae5888333005b74115a620aa96 (diff) | |
download | openbsd-228cae30b117c2493f69ad3c195341cd6ec8d430.tar.gz openbsd-228cae30b117c2493f69ad3c195341cd6ec8d430.tar.bz2 openbsd-228cae30b117c2493f69ad3c195341cd6ec8d430.zip |
import OpenSSL-1.0.1c
Diffstat (limited to 'src/lib/libcrypto/sha/asm/sha1-ppc.pl')
-rwxr-xr-x | src/lib/libcrypto/sha/asm/sha1-ppc.pl | 83 |
1 files changed, 45 insertions, 38 deletions
diff --git a/src/lib/libcrypto/sha/asm/sha1-ppc.pl b/src/lib/libcrypto/sha/asm/sha1-ppc.pl index dcd0fcdfcf..2140dd2f8d 100755 --- a/src/lib/libcrypto/sha/asm/sha1-ppc.pl +++ b/src/lib/libcrypto/sha/asm/sha1-ppc.pl | |||
@@ -24,12 +24,14 @@ $flavour = shift; | |||
24 | 24 | ||
25 | if ($flavour =~ /64/) { | 25 | if ($flavour =~ /64/) { |
26 | $SIZE_T =8; | 26 | $SIZE_T =8; |
27 | $LRSAVE =2*$SIZE_T; | ||
27 | $UCMP ="cmpld"; | 28 | $UCMP ="cmpld"; |
28 | $STU ="stdu"; | 29 | $STU ="stdu"; |
29 | $POP ="ld"; | 30 | $POP ="ld"; |
30 | $PUSH ="std"; | 31 | $PUSH ="std"; |
31 | } elsif ($flavour =~ /32/) { | 32 | } elsif ($flavour =~ /32/) { |
32 | $SIZE_T =4; | 33 | $SIZE_T =4; |
34 | $LRSAVE =$SIZE_T; | ||
33 | $UCMP ="cmplw"; | 35 | $UCMP ="cmplw"; |
34 | $STU ="stwu"; | 36 | $STU ="stwu"; |
35 | $POP ="lwz"; | 37 | $POP ="lwz"; |
@@ -43,7 +45,8 @@ die "can't locate ppc-xlate.pl"; | |||
43 | 45 | ||
44 | open STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!"; | 46 | open STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!"; |
45 | 47 | ||
46 | $FRAME=24*$SIZE_T; | 48 | $FRAME=24*$SIZE_T+64; |
49 | $LOCALS=6*$SIZE_T; | ||
47 | 50 | ||
48 | $K ="r0"; | 51 | $K ="r0"; |
49 | $sp ="r1"; | 52 | $sp ="r1"; |
@@ -162,9 +165,8 @@ $code=<<___; | |||
162 | .globl .sha1_block_data_order | 165 | .globl .sha1_block_data_order |
163 | .align 4 | 166 | .align 4 |
164 | .sha1_block_data_order: | 167 | .sha1_block_data_order: |
168 | $STU $sp,-$FRAME($sp) | ||
165 | mflr r0 | 169 | mflr r0 |
166 | $STU $sp,`-($FRAME+64)`($sp) | ||
167 | $PUSH r0,`$FRAME-$SIZE_T*18`($sp) | ||
168 | $PUSH r15,`$FRAME-$SIZE_T*17`($sp) | 170 | $PUSH r15,`$FRAME-$SIZE_T*17`($sp) |
169 | $PUSH r16,`$FRAME-$SIZE_T*16`($sp) | 171 | $PUSH r16,`$FRAME-$SIZE_T*16`($sp) |
170 | $PUSH r17,`$FRAME-$SIZE_T*15`($sp) | 172 | $PUSH r17,`$FRAME-$SIZE_T*15`($sp) |
@@ -182,6 +184,7 @@ $code=<<___; | |||
182 | $PUSH r29,`$FRAME-$SIZE_T*3`($sp) | 184 | $PUSH r29,`$FRAME-$SIZE_T*3`($sp) |
183 | $PUSH r30,`$FRAME-$SIZE_T*2`($sp) | 185 | $PUSH r30,`$FRAME-$SIZE_T*2`($sp) |
184 | $PUSH r31,`$FRAME-$SIZE_T*1`($sp) | 186 | $PUSH r31,`$FRAME-$SIZE_T*1`($sp) |
187 | $PUSH r0,`$FRAME+$LRSAVE`($sp) | ||
185 | lwz $A,0($ctx) | 188 | lwz $A,0($ctx) |
186 | lwz $B,4($ctx) | 189 | lwz $B,4($ctx) |
187 | lwz $C,8($ctx) | 190 | lwz $C,8($ctx) |
@@ -192,37 +195,14 @@ $code=<<___; | |||
192 | Laligned: | 195 | Laligned: |
193 | mtctr $num | 196 | mtctr $num |
194 | bl Lsha1_block_private | 197 | bl Lsha1_block_private |
195 | Ldone: | 198 | b Ldone |
196 | $POP r0,`$FRAME-$SIZE_T*18`($sp) | ||
197 | $POP r15,`$FRAME-$SIZE_T*17`($sp) | ||
198 | $POP r16,`$FRAME-$SIZE_T*16`($sp) | ||
199 | $POP r17,`$FRAME-$SIZE_T*15`($sp) | ||
200 | $POP r18,`$FRAME-$SIZE_T*14`($sp) | ||
201 | $POP r19,`$FRAME-$SIZE_T*13`($sp) | ||
202 | $POP r20,`$FRAME-$SIZE_T*12`($sp) | ||
203 | $POP r21,`$FRAME-$SIZE_T*11`($sp) | ||
204 | $POP r22,`$FRAME-$SIZE_T*10`($sp) | ||
205 | $POP r23,`$FRAME-$SIZE_T*9`($sp) | ||
206 | $POP r24,`$FRAME-$SIZE_T*8`($sp) | ||
207 | $POP r25,`$FRAME-$SIZE_T*7`($sp) | ||
208 | $POP r26,`$FRAME-$SIZE_T*6`($sp) | ||
209 | $POP r27,`$FRAME-$SIZE_T*5`($sp) | ||
210 | $POP r28,`$FRAME-$SIZE_T*4`($sp) | ||
211 | $POP r29,`$FRAME-$SIZE_T*3`($sp) | ||
212 | $POP r30,`$FRAME-$SIZE_T*2`($sp) | ||
213 | $POP r31,`$FRAME-$SIZE_T*1`($sp) | ||
214 | mtlr r0 | ||
215 | addi $sp,$sp,`$FRAME+64` | ||
216 | blr | ||
217 | ___ | ||
218 | 199 | ||
219 | # PowerPC specification allows an implementation to be ill-behaved | 200 | ; PowerPC specification allows an implementation to be ill-behaved |
220 | # upon unaligned access which crosses page boundary. "Better safe | 201 | ; upon unaligned access which crosses page boundary. "Better safe |
221 | # than sorry" principle makes me treat it specially. But I don't | 202 | ; than sorry" principle makes me treat it specially. But I don't |
222 | # look for particular offending word, but rather for 64-byte input | 203 | ; look for particular offending word, but rather for 64-byte input |
223 | # block which crosses the boundary. Once found that block is aligned | 204 | ; block which crosses the boundary. Once found that block is aligned |
224 | # and hashed separately... | 205 | ; and hashed separately... |
225 | $code.=<<___; | ||
226 | .align 4 | 206 | .align 4 |
227 | Lunaligned: | 207 | Lunaligned: |
228 | subfic $t1,$inp,4096 | 208 | subfic $t1,$inp,4096 |
@@ -237,7 +217,7 @@ Lunaligned: | |||
237 | Lcross_page: | 217 | Lcross_page: |
238 | li $t1,16 | 218 | li $t1,16 |
239 | mtctr $t1 | 219 | mtctr $t1 |
240 | addi r20,$sp,$FRAME ; spot below the frame | 220 | addi r20,$sp,$LOCALS ; spot within the frame |
241 | Lmemcpy: | 221 | Lmemcpy: |
242 | lbz r16,0($inp) | 222 | lbz r16,0($inp) |
243 | lbz r17,1($inp) | 223 | lbz r17,1($inp) |
@@ -251,15 +231,40 @@ Lmemcpy: | |||
251 | addi r20,r20,4 | 231 | addi r20,r20,4 |
252 | bdnz Lmemcpy | 232 | bdnz Lmemcpy |
253 | 233 | ||
254 | $PUSH $inp,`$FRAME-$SIZE_T*19`($sp) | 234 | $PUSH $inp,`$FRAME-$SIZE_T*18`($sp) |
255 | li $t1,1 | 235 | li $t1,1 |
256 | addi $inp,$sp,$FRAME | 236 | addi $inp,$sp,$LOCALS |
257 | mtctr $t1 | 237 | mtctr $t1 |
258 | bl Lsha1_block_private | 238 | bl Lsha1_block_private |
259 | $POP $inp,`$FRAME-$SIZE_T*19`($sp) | 239 | $POP $inp,`$FRAME-$SIZE_T*18`($sp) |
260 | addic. $num,$num,-1 | 240 | addic. $num,$num,-1 |
261 | bne- Lunaligned | 241 | bne- Lunaligned |
262 | b Ldone | 242 | |
243 | Ldone: | ||
244 | $POP r0,`$FRAME+$LRSAVE`($sp) | ||
245 | $POP r15,`$FRAME-$SIZE_T*17`($sp) | ||
246 | $POP r16,`$FRAME-$SIZE_T*16`($sp) | ||
247 | $POP r17,`$FRAME-$SIZE_T*15`($sp) | ||
248 | $POP r18,`$FRAME-$SIZE_T*14`($sp) | ||
249 | $POP r19,`$FRAME-$SIZE_T*13`($sp) | ||
250 | $POP r20,`$FRAME-$SIZE_T*12`($sp) | ||
251 | $POP r21,`$FRAME-$SIZE_T*11`($sp) | ||
252 | $POP r22,`$FRAME-$SIZE_T*10`($sp) | ||
253 | $POP r23,`$FRAME-$SIZE_T*9`($sp) | ||
254 | $POP r24,`$FRAME-$SIZE_T*8`($sp) | ||
255 | $POP r25,`$FRAME-$SIZE_T*7`($sp) | ||
256 | $POP r26,`$FRAME-$SIZE_T*6`($sp) | ||
257 | $POP r27,`$FRAME-$SIZE_T*5`($sp) | ||
258 | $POP r28,`$FRAME-$SIZE_T*4`($sp) | ||
259 | $POP r29,`$FRAME-$SIZE_T*3`($sp) | ||
260 | $POP r30,`$FRAME-$SIZE_T*2`($sp) | ||
261 | $POP r31,`$FRAME-$SIZE_T*1`($sp) | ||
262 | mtlr r0 | ||
263 | addi $sp,$sp,$FRAME | ||
264 | blr | ||
265 | .long 0 | ||
266 | .byte 0,12,4,1,0x80,18,3,0 | ||
267 | .long 0 | ||
263 | ___ | 268 | ___ |
264 | 269 | ||
265 | # This is private block function, which uses tailored calling | 270 | # This is private block function, which uses tailored calling |
@@ -309,6 +314,8 @@ $code.=<<___; | |||
309 | addi $inp,$inp,`16*4` | 314 | addi $inp,$inp,`16*4` |
310 | bdnz- Lsha1_block_private | 315 | bdnz- Lsha1_block_private |
311 | blr | 316 | blr |
317 | .long 0 | ||
318 | .byte 0,12,0x14,0,0,0,0,0 | ||
312 | ___ | 319 | ___ |
313 | $code.=<<___; | 320 | $code.=<<___; |
314 | .asciz "SHA1 block transform for PPC, CRYPTOGAMS by <appro\@fy.chalmers.se>" | 321 | .asciz "SHA1 block transform for PPC, CRYPTOGAMS by <appro\@fy.chalmers.se>" |