diff options
Diffstat (limited to '')
-rwxr-xr-x | src/lib/libcrypto/sha/asm/sha512-ppc.pl | 114 |
1 files changed, 56 insertions, 58 deletions
diff --git a/src/lib/libcrypto/sha/asm/sha512-ppc.pl b/src/lib/libcrypto/sha/asm/sha512-ppc.pl index 768a6a6fad..6b44a68e59 100755 --- a/src/lib/libcrypto/sha/asm/sha512-ppc.pl +++ b/src/lib/libcrypto/sha/asm/sha512-ppc.pl | |||
@@ -40,6 +40,7 @@ $output =shift; | |||
40 | 40 | ||
41 | if ($flavour =~ /64/) { | 41 | if ($flavour =~ /64/) { |
42 | $SIZE_T=8; | 42 | $SIZE_T=8; |
43 | $LRSAVE=2*$SIZE_T; | ||
43 | $STU="stdu"; | 44 | $STU="stdu"; |
44 | $UCMP="cmpld"; | 45 | $UCMP="cmpld"; |
45 | $SHL="sldi"; | 46 | $SHL="sldi"; |
@@ -47,6 +48,7 @@ if ($flavour =~ /64/) { | |||
47 | $PUSH="std"; | 48 | $PUSH="std"; |
48 | } elsif ($flavour =~ /32/) { | 49 | } elsif ($flavour =~ /32/) { |
49 | $SIZE_T=4; | 50 | $SIZE_T=4; |
51 | $LRSAVE=$SIZE_T; | ||
50 | $STU="stwu"; | 52 | $STU="stwu"; |
51 | $UCMP="cmplw"; | 53 | $UCMP="cmplw"; |
52 | $SHL="slwi"; | 54 | $SHL="slwi"; |
@@ -87,7 +89,8 @@ if ($output =~ /512/) { | |||
87 | $SHR="srwi"; | 89 | $SHR="srwi"; |
88 | } | 90 | } |
89 | 91 | ||
90 | $FRAME=32*$SIZE_T; | 92 | $FRAME=32*$SIZE_T+16*$SZ; |
93 | $LOCALS=6*$SIZE_T; | ||
91 | 94 | ||
92 | $sp ="r1"; | 95 | $sp ="r1"; |
93 | $toc="r2"; | 96 | $toc="r2"; |
@@ -179,13 +182,12 @@ $code=<<___; | |||
179 | .globl $func | 182 | .globl $func |
180 | .align 6 | 183 | .align 6 |
181 | $func: | 184 | $func: |
185 | $STU $sp,-$FRAME($sp) | ||
182 | mflr r0 | 186 | mflr r0 |
183 | $STU $sp,`-($FRAME+16*$SZ)`($sp) | ||
184 | $SHL $num,$num,`log(16*$SZ)/log(2)` | 187 | $SHL $num,$num,`log(16*$SZ)/log(2)` |
185 | 188 | ||
186 | $PUSH $ctx,`$FRAME-$SIZE_T*22`($sp) | 189 | $PUSH $ctx,`$FRAME-$SIZE_T*22`($sp) |
187 | 190 | ||
188 | $PUSH r0,`$FRAME-$SIZE_T*21`($sp) | ||
189 | $PUSH $toc,`$FRAME-$SIZE_T*20`($sp) | 191 | $PUSH $toc,`$FRAME-$SIZE_T*20`($sp) |
190 | $PUSH r13,`$FRAME-$SIZE_T*19`($sp) | 192 | $PUSH r13,`$FRAME-$SIZE_T*19`($sp) |
191 | $PUSH r14,`$FRAME-$SIZE_T*18`($sp) | 193 | $PUSH r14,`$FRAME-$SIZE_T*18`($sp) |
@@ -206,6 +208,7 @@ $func: | |||
206 | $PUSH r29,`$FRAME-$SIZE_T*3`($sp) | 208 | $PUSH r29,`$FRAME-$SIZE_T*3`($sp) |
207 | $PUSH r30,`$FRAME-$SIZE_T*2`($sp) | 209 | $PUSH r30,`$FRAME-$SIZE_T*2`($sp) |
208 | $PUSH r31,`$FRAME-$SIZE_T*1`($sp) | 210 | $PUSH r31,`$FRAME-$SIZE_T*1`($sp) |
211 | $PUSH r0,`$FRAME+$LRSAVE`($sp) | ||
209 | 212 | ||
210 | $LD $A,`0*$SZ`($ctx) | 213 | $LD $A,`0*$SZ`($ctx) |
211 | mr $inp,r4 ; incarnate $inp | 214 | mr $inp,r4 ; incarnate $inp |
@@ -217,7 +220,7 @@ $func: | |||
217 | $LD $G,`6*$SZ`($ctx) | 220 | $LD $G,`6*$SZ`($ctx) |
218 | $LD $H,`7*$SZ`($ctx) | 221 | $LD $H,`7*$SZ`($ctx) |
219 | 222 | ||
220 | b LPICmeup | 223 | bl LPICmeup |
221 | LPICedup: | 224 | LPICedup: |
222 | andi. r0,$inp,3 | 225 | andi. r0,$inp,3 |
223 | bne Lunaligned | 226 | bne Lunaligned |
@@ -226,40 +229,14 @@ Laligned: | |||
226 | $PUSH $num,`$FRAME-$SIZE_T*24`($sp) ; end pointer | 229 | $PUSH $num,`$FRAME-$SIZE_T*24`($sp) ; end pointer |
227 | $PUSH $inp,`$FRAME-$SIZE_T*23`($sp) ; inp pointer | 230 | $PUSH $inp,`$FRAME-$SIZE_T*23`($sp) ; inp pointer |
228 | bl Lsha2_block_private | 231 | bl Lsha2_block_private |
229 | Ldone: | 232 | b Ldone |
230 | $POP r0,`$FRAME-$SIZE_T*21`($sp) | ||
231 | $POP $toc,`$FRAME-$SIZE_T*20`($sp) | ||
232 | $POP r13,`$FRAME-$SIZE_T*19`($sp) | ||
233 | $POP r14,`$FRAME-$SIZE_T*18`($sp) | ||
234 | $POP r15,`$FRAME-$SIZE_T*17`($sp) | ||
235 | $POP r16,`$FRAME-$SIZE_T*16`($sp) | ||
236 | $POP r17,`$FRAME-$SIZE_T*15`($sp) | ||
237 | $POP r18,`$FRAME-$SIZE_T*14`($sp) | ||
238 | $POP r19,`$FRAME-$SIZE_T*13`($sp) | ||
239 | $POP r20,`$FRAME-$SIZE_T*12`($sp) | ||
240 | $POP r21,`$FRAME-$SIZE_T*11`($sp) | ||
241 | $POP r22,`$FRAME-$SIZE_T*10`($sp) | ||
242 | $POP r23,`$FRAME-$SIZE_T*9`($sp) | ||
243 | $POP r24,`$FRAME-$SIZE_T*8`($sp) | ||
244 | $POP r25,`$FRAME-$SIZE_T*7`($sp) | ||
245 | $POP r26,`$FRAME-$SIZE_T*6`($sp) | ||
246 | $POP r27,`$FRAME-$SIZE_T*5`($sp) | ||
247 | $POP r28,`$FRAME-$SIZE_T*4`($sp) | ||
248 | $POP r29,`$FRAME-$SIZE_T*3`($sp) | ||
249 | $POP r30,`$FRAME-$SIZE_T*2`($sp) | ||
250 | $POP r31,`$FRAME-$SIZE_T*1`($sp) | ||
251 | mtlr r0 | ||
252 | addi $sp,$sp,`$FRAME+16*$SZ` | ||
253 | blr | ||
254 | ___ | ||
255 | 233 | ||
256 | # PowerPC specification allows an implementation to be ill-behaved | 234 | ; PowerPC specification allows an implementation to be ill-behaved |
257 | # upon unaligned access which crosses page boundary. "Better safe | 235 | ; upon unaligned access which crosses page boundary. "Better safe |
258 | # than sorry" principle makes me treat it specially. But I don't | 236 | ; than sorry" principle makes me treat it specially. But I don't |
259 | # look for particular offending word, but rather for the input | 237 | ; look for particular offending word, but rather for the input |
260 | # block which crosses the boundary. Once found that block is aligned | 238 | ; block which crosses the boundary. Once found that block is aligned |
261 | # and hashed separately... | 239 | ; and hashed separately... |
262 | $code.=<<___; | ||
263 | .align 4 | 240 | .align 4 |
264 | Lunaligned: | 241 | Lunaligned: |
265 | subfic $t1,$inp,4096 | 242 | subfic $t1,$inp,4096 |
@@ -278,7 +255,7 @@ Lunaligned: | |||
278 | Lcross_page: | 255 | Lcross_page: |
279 | li $t1,`16*$SZ/4` | 256 | li $t1,`16*$SZ/4` |
280 | mtctr $t1 | 257 | mtctr $t1 |
281 | addi r20,$sp,$FRAME ; aligned spot below the frame | 258 | addi r20,$sp,$LOCALS ; aligned spot below the frame |
282 | Lmemcpy: | 259 | Lmemcpy: |
283 | lbz r16,0($inp) | 260 | lbz r16,0($inp) |
284 | lbz r17,1($inp) | 261 | lbz r17,1($inp) |
@@ -293,8 +270,8 @@ Lmemcpy: | |||
293 | bdnz Lmemcpy | 270 | bdnz Lmemcpy |
294 | 271 | ||
295 | $PUSH $inp,`$FRAME-$SIZE_T*26`($sp) ; save real inp | 272 | $PUSH $inp,`$FRAME-$SIZE_T*26`($sp) ; save real inp |
296 | addi $t1,$sp,`$FRAME+16*$SZ` ; fictitious end pointer | 273 | addi $t1,$sp,`$LOCALS+16*$SZ` ; fictitious end pointer |
297 | addi $inp,$sp,$FRAME ; fictitious inp pointer | 274 | addi $inp,$sp,$LOCALS ; fictitious inp pointer |
298 | $PUSH $num,`$FRAME-$SIZE_T*25`($sp) ; save real num | 275 | $PUSH $num,`$FRAME-$SIZE_T*25`($sp) ; save real num |
299 | $PUSH $t1,`$FRAME-$SIZE_T*24`($sp) ; end pointer | 276 | $PUSH $t1,`$FRAME-$SIZE_T*24`($sp) ; end pointer |
300 | $PUSH $inp,`$FRAME-$SIZE_T*23`($sp) ; inp pointer | 277 | $PUSH $inp,`$FRAME-$SIZE_T*23`($sp) ; inp pointer |
@@ -303,10 +280,36 @@ Lmemcpy: | |||
303 | $POP $num,`$FRAME-$SIZE_T*25`($sp) ; restore real num | 280 | $POP $num,`$FRAME-$SIZE_T*25`($sp) ; restore real num |
304 | addic. $num,$num,`-16*$SZ` ; num-- | 281 | addic. $num,$num,`-16*$SZ` ; num-- |
305 | bne- Lunaligned | 282 | bne- Lunaligned |
306 | b Ldone | ||
307 | ___ | ||
308 | 283 | ||
309 | $code.=<<___; | 284 | Ldone: |
285 | $POP r0,`$FRAME+$LRSAVE`($sp) | ||
286 | $POP $toc,`$FRAME-$SIZE_T*20`($sp) | ||
287 | $POP r13,`$FRAME-$SIZE_T*19`($sp) | ||
288 | $POP r14,`$FRAME-$SIZE_T*18`($sp) | ||
289 | $POP r15,`$FRAME-$SIZE_T*17`($sp) | ||
290 | $POP r16,`$FRAME-$SIZE_T*16`($sp) | ||
291 | $POP r17,`$FRAME-$SIZE_T*15`($sp) | ||
292 | $POP r18,`$FRAME-$SIZE_T*14`($sp) | ||
293 | $POP r19,`$FRAME-$SIZE_T*13`($sp) | ||
294 | $POP r20,`$FRAME-$SIZE_T*12`($sp) | ||
295 | $POP r21,`$FRAME-$SIZE_T*11`($sp) | ||
296 | $POP r22,`$FRAME-$SIZE_T*10`($sp) | ||
297 | $POP r23,`$FRAME-$SIZE_T*9`($sp) | ||
298 | $POP r24,`$FRAME-$SIZE_T*8`($sp) | ||
299 | $POP r25,`$FRAME-$SIZE_T*7`($sp) | ||
300 | $POP r26,`$FRAME-$SIZE_T*6`($sp) | ||
301 | $POP r27,`$FRAME-$SIZE_T*5`($sp) | ||
302 | $POP r28,`$FRAME-$SIZE_T*4`($sp) | ||
303 | $POP r29,`$FRAME-$SIZE_T*3`($sp) | ||
304 | $POP r30,`$FRAME-$SIZE_T*2`($sp) | ||
305 | $POP r31,`$FRAME-$SIZE_T*1`($sp) | ||
306 | mtlr r0 | ||
307 | addi $sp,$sp,$FRAME | ||
308 | blr | ||
309 | .long 0 | ||
310 | .byte 0,12,4,1,0x80,18,3,0 | ||
311 | .long 0 | ||
312 | |||
310 | .align 4 | 313 | .align 4 |
311 | Lsha2_block_private: | 314 | Lsha2_block_private: |
312 | ___ | 315 | ___ |
@@ -372,6 +375,8 @@ $code.=<<___; | |||
372 | $ST $H,`7*$SZ`($ctx) | 375 | $ST $H,`7*$SZ`($ctx) |
373 | bne Lsha2_block_private | 376 | bne Lsha2_block_private |
374 | blr | 377 | blr |
378 | .long 0 | ||
379 | .byte 0,12,0x14,0,0,0,0,0 | ||
375 | ___ | 380 | ___ |
376 | 381 | ||
377 | # Ugly hack here, because PPC assembler syntax seem to vary too | 382 | # Ugly hack here, because PPC assembler syntax seem to vary too |
@@ -379,22 +384,15 @@ ___ | |||
379 | $code.=<<___; | 384 | $code.=<<___; |
380 | .align 6 | 385 | .align 6 |
381 | LPICmeup: | 386 | LPICmeup: |
382 | bl LPIC | 387 | mflr r0 |
383 | addi $Tbl,$Tbl,`64-4` ; "distance" between . and last nop | 388 | bcl 20,31,\$+4 |
384 | b LPICedup | 389 | mflr $Tbl ; vvvvvv "distance" between . and 1st data entry |
385 | nop | 390 | addi $Tbl,$Tbl,`64-8` |
386 | nop | 391 | mtlr r0 |
387 | nop | ||
388 | nop | ||
389 | nop | ||
390 | LPIC: mflr $Tbl | ||
391 | blr | 392 | blr |
392 | nop | 393 | .long 0 |
393 | nop | 394 | .byte 0,12,0x14,0,0,0,0,0 |
394 | nop | 395 | .space `64-9*4` |
395 | nop | ||
396 | nop | ||
397 | nop | ||
398 | ___ | 396 | ___ |
399 | $code.=<<___ if ($SZ==8); | 397 | $code.=<<___ if ($SZ==8); |
400 | .long 0x428a2f98,0xd728ae22,0x71374491,0x23ef65cd | 398 | .long 0x428a2f98,0xd728ae22,0x71374491,0x23ef65cd |