diff options
Diffstat (limited to 'src/lib/libcrypto/sha')
| -rw-r--r-- | src/lib/libcrypto/sha/asm/sha1-s390x.pl | 246 | ||||
| -rw-r--r-- | src/lib/libcrypto/sha/asm/sha512-s390x.pl | 322 |
2 files changed, 0 insertions, 568 deletions
diff --git a/src/lib/libcrypto/sha/asm/sha1-s390x.pl b/src/lib/libcrypto/sha/asm/sha1-s390x.pl deleted file mode 100644 index 9193dda45e..0000000000 --- a/src/lib/libcrypto/sha/asm/sha1-s390x.pl +++ /dev/null | |||
| @@ -1,246 +0,0 @@ | |||
| 1 | #!/usr/bin/env perl | ||
| 2 | |||
| 3 | # ==================================================================== | ||
| 4 | # Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL | ||
| 5 | # project. The module is, however, dual licensed under OpenSSL and | ||
| 6 | # CRYPTOGAMS licenses depending on where you obtain it. For further | ||
| 7 | # details see http://www.openssl.org/~appro/cryptogams/. | ||
| 8 | # ==================================================================== | ||
| 9 | |||
| 10 | # SHA1 block procedure for s390x. | ||
| 11 | |||
| 12 | # April 2007. | ||
| 13 | # | ||
| 14 | # Performance is >30% better than gcc 3.3 generated code. But the real | ||
| 15 | # twist is that SHA1 hardware support is detected and utilized. In | ||
| 16 | # which case performance can reach further >4.5x for larger chunks. | ||
| 17 | |||
| 18 | # January 2009. | ||
| 19 | # | ||
| 20 | # Optimize Xupdate for amount of memory references and reschedule | ||
| 21 | # instructions to favour dual-issue z10 pipeline. On z10 hardware is | ||
| 22 | # "only" ~2.3x faster than software. | ||
| 23 | |||
| 24 | # November 2010. | ||
| 25 | # | ||
| 26 | # Adapt for -m31 build. If kernel supports what's called "highgprs" | ||
| 27 | # feature on Linux [see /proc/cpuinfo], it's possible to use 64-bit | ||
| 28 | # instructions and achieve "64-bit" performance even in 31-bit legacy | ||
| 29 | # application context. The feature is not specific to any particular | ||
| 30 | # processor, as long as it's "z-CPU". Latter implies that the code | ||
| 31 | # remains z/Architecture specific. | ||
| 32 | |||
| 33 | $kimdfunc=1; # magic function code for kimd instruction | ||
| 34 | |||
| 35 | $flavour = shift; | ||
| 36 | |||
| 37 | if ($flavour =~ /3[12]/) { | ||
| 38 | $SIZE_T=4; | ||
| 39 | $g=""; | ||
| 40 | } else { | ||
| 41 | $SIZE_T=8; | ||
| 42 | $g="g"; | ||
| 43 | } | ||
| 44 | |||
| 45 | while (($output=shift) && ($output!~/^\w[\w\-]*\.\w+$/)) {} | ||
| 46 | open STDOUT,">$output"; | ||
| 47 | |||
| 48 | $K_00_39="%r0"; $K=$K_00_39; | ||
| 49 | $K_40_79="%r1"; | ||
| 50 | $ctx="%r2"; $prefetch="%r2"; | ||
| 51 | $inp="%r3"; | ||
| 52 | $len="%r4"; | ||
| 53 | |||
| 54 | $A="%r5"; | ||
| 55 | $B="%r6"; | ||
| 56 | $C="%r7"; | ||
| 57 | $D="%r8"; | ||
| 58 | $E="%r9"; @V=($A,$B,$C,$D,$E); | ||
| 59 | $t0="%r10"; | ||
| 60 | $t1="%r11"; | ||
| 61 | @X=("%r12","%r13","%r14"); | ||
| 62 | $sp="%r15"; | ||
| 63 | |||
| 64 | $stdframe=16*$SIZE_T+4*8; | ||
| 65 | $frame=$stdframe+16*4; | ||
| 66 | |||
| 67 | sub Xupdate { | ||
| 68 | my $i=shift; | ||
| 69 | |||
| 70 | $code.=<<___ if ($i==15); | ||
| 71 | lg $prefetch,$stdframe($sp) ### Xupdate(16) warm-up | ||
| 72 | lr $X[0],$X[2] | ||
| 73 | ___ | ||
| 74 | return if ($i&1); # Xupdate is vectorized and executed every 2nd cycle | ||
| 75 | $code.=<<___ if ($i<16); | ||
| 76 | lg $X[0],`$i*4`($inp) ### Xload($i) | ||
| 77 | rllg $X[1],$X[0],32 | ||
| 78 | ___ | ||
| 79 | $code.=<<___ if ($i>=16); | ||
| 80 | xgr $X[0],$prefetch ### Xupdate($i) | ||
| 81 | lg $prefetch,`$stdframe+4*(($i+2)%16)`($sp) | ||
| 82 | xg $X[0],`$stdframe+4*(($i+8)%16)`($sp) | ||
| 83 | xgr $X[0],$prefetch | ||
| 84 | rll $X[0],$X[0],1 | ||
| 85 | rllg $X[1],$X[0],32 | ||
| 86 | rll $X[1],$X[1],1 | ||
| 87 | rllg $X[0],$X[1],32 | ||
| 88 | lr $X[2],$X[1] # feedback | ||
| 89 | ___ | ||
| 90 | $code.=<<___ if ($i<=70); | ||
| 91 | stg $X[0],`$stdframe+4*($i%16)`($sp) | ||
| 92 | ___ | ||
| 93 | unshift(@X,pop(@X)); | ||
| 94 | } | ||
| 95 | |||
| 96 | sub BODY_00_19 { | ||
| 97 | my ($i,$a,$b,$c,$d,$e)=@_; | ||
| 98 | my $xi=$X[1]; | ||
| 99 | |||
| 100 | &Xupdate($i); | ||
| 101 | $code.=<<___; | ||
| 102 | alr $e,$K ### $i | ||
| 103 | rll $t1,$a,5 | ||
| 104 | lr $t0,$d | ||
| 105 | xr $t0,$c | ||
| 106 | alr $e,$t1 | ||
| 107 | nr $t0,$b | ||
| 108 | alr $e,$xi | ||
| 109 | xr $t0,$d | ||
| 110 | rll $b,$b,30 | ||
| 111 | alr $e,$t0 | ||
| 112 | ___ | ||
| 113 | } | ||
| 114 | |||
| 115 | sub BODY_20_39 { | ||
| 116 | my ($i,$a,$b,$c,$d,$e)=@_; | ||
| 117 | my $xi=$X[1]; | ||
| 118 | |||
| 119 | &Xupdate($i); | ||
| 120 | $code.=<<___; | ||
| 121 | alr $e,$K ### $i | ||
| 122 | rll $t1,$a,5 | ||
| 123 | lr $t0,$b | ||
| 124 | alr $e,$t1 | ||
| 125 | xr $t0,$c | ||
| 126 | alr $e,$xi | ||
| 127 | xr $t0,$d | ||
| 128 | rll $b,$b,30 | ||
| 129 | alr $e,$t0 | ||
| 130 | ___ | ||
| 131 | } | ||
| 132 | |||
| 133 | sub BODY_40_59 { | ||
| 134 | my ($i,$a,$b,$c,$d,$e)=@_; | ||
| 135 | my $xi=$X[1]; | ||
| 136 | |||
| 137 | &Xupdate($i); | ||
| 138 | $code.=<<___; | ||
| 139 | alr $e,$K ### $i | ||
| 140 | rll $t1,$a,5 | ||
| 141 | lr $t0,$b | ||
| 142 | alr $e,$t1 | ||
| 143 | or $t0,$c | ||
| 144 | lr $t1,$b | ||
| 145 | nr $t0,$d | ||
| 146 | nr $t1,$c | ||
| 147 | alr $e,$xi | ||
| 148 | or $t0,$t1 | ||
| 149 | rll $b,$b,30 | ||
| 150 | alr $e,$t0 | ||
| 151 | ___ | ||
| 152 | } | ||
| 153 | |||
| 154 | $code.=<<___; | ||
| 155 | .text | ||
| 156 | .align 64 | ||
| 157 | .type Ktable,\@object | ||
| 158 | Ktable: .long 0x5a827999,0x6ed9eba1,0x8f1bbcdc,0xca62c1d6 | ||
| 159 | .skip 48 #.long 0,0,0,0,0,0,0,0,0,0,0,0 | ||
| 160 | .size Ktable,.-Ktable | ||
| 161 | .globl sha1_block_data_order | ||
| 162 | .type sha1_block_data_order,\@function | ||
| 163 | sha1_block_data_order: | ||
| 164 | ___ | ||
| 165 | $code.=<<___ if ($kimdfunc); | ||
| 166 | larl %r1,OPENSSL_s390xcap_P | ||
| 167 | lg %r0,0(%r1) | ||
| 168 | tmhl %r0,0x4000 # check for message-security assist | ||
| 169 | jz .Lsoftware | ||
| 170 | lghi %r0,0 | ||
| 171 | la %r1,`2*$SIZE_T`($sp) | ||
| 172 | .long 0xb93e0002 # kimd %r0,%r2 | ||
| 173 | lg %r0,`2*$SIZE_T`($sp) | ||
| 174 | tmhh %r0,`0x8000>>$kimdfunc` | ||
| 175 | jz .Lsoftware | ||
| 176 | lghi %r0,$kimdfunc | ||
| 177 | lgr %r1,$ctx | ||
| 178 | lgr %r2,$inp | ||
| 179 | sllg %r3,$len,6 | ||
| 180 | .long 0xb93e0002 # kimd %r0,%r2 | ||
| 181 | brc 1,.-4 # pay attention to "partial completion" | ||
| 182 | br %r14 | ||
| 183 | .align 16 | ||
| 184 | .Lsoftware: | ||
| 185 | ___ | ||
| 186 | $code.=<<___; | ||
| 187 | lghi %r1,-$frame | ||
| 188 | st${g} $ctx,`2*$SIZE_T`($sp) | ||
| 189 | stm${g} %r6,%r15,`6*$SIZE_T`($sp) | ||
| 190 | lgr %r0,$sp | ||
| 191 | la $sp,0(%r1,$sp) | ||
| 192 | st${g} %r0,0($sp) | ||
| 193 | |||
| 194 | larl $t0,Ktable | ||
| 195 | llgf $A,0($ctx) | ||
| 196 | llgf $B,4($ctx) | ||
| 197 | llgf $C,8($ctx) | ||
| 198 | llgf $D,12($ctx) | ||
| 199 | llgf $E,16($ctx) | ||
| 200 | |||
| 201 | lg $K_00_39,0($t0) | ||
| 202 | lg $K_40_79,8($t0) | ||
| 203 | |||
| 204 | .Lloop: | ||
| 205 | rllg $K_00_39,$K_00_39,32 | ||
| 206 | ___ | ||
| 207 | for ($i=0;$i<20;$i++) { &BODY_00_19($i,@V); unshift(@V,pop(@V)); } | ||
| 208 | $code.=<<___; | ||
| 209 | rllg $K_00_39,$K_00_39,32 | ||
| 210 | ___ | ||
| 211 | for (;$i<40;$i++) { &BODY_20_39($i,@V); unshift(@V,pop(@V)); } | ||
| 212 | $code.=<<___; $K=$K_40_79; | ||
| 213 | rllg $K_40_79,$K_40_79,32 | ||
| 214 | ___ | ||
| 215 | for (;$i<60;$i++) { &BODY_40_59($i,@V); unshift(@V,pop(@V)); } | ||
| 216 | $code.=<<___; | ||
| 217 | rllg $K_40_79,$K_40_79,32 | ||
| 218 | ___ | ||
| 219 | for (;$i<80;$i++) { &BODY_20_39($i,@V); unshift(@V,pop(@V)); } | ||
| 220 | $code.=<<___; | ||
| 221 | |||
| 222 | l${g} $ctx,`$frame+2*$SIZE_T`($sp) | ||
| 223 | la $inp,64($inp) | ||
| 224 | al $A,0($ctx) | ||
| 225 | al $B,4($ctx) | ||
| 226 | al $C,8($ctx) | ||
| 227 | al $D,12($ctx) | ||
| 228 | al $E,16($ctx) | ||
| 229 | st $A,0($ctx) | ||
| 230 | st $B,4($ctx) | ||
| 231 | st $C,8($ctx) | ||
| 232 | st $D,12($ctx) | ||
| 233 | st $E,16($ctx) | ||
| 234 | brct${g} $len,.Lloop | ||
| 235 | |||
| 236 | lm${g} %r6,%r15,`$frame+6*$SIZE_T`($sp) | ||
| 237 | br %r14 | ||
| 238 | .size sha1_block_data_order,.-sha1_block_data_order | ||
| 239 | .string "SHA1 block transform for s390x, CRYPTOGAMS by <appro\@openssl.org>" | ||
| 240 | .comm OPENSSL_s390xcap_P,16,8 | ||
| 241 | ___ | ||
| 242 | |||
| 243 | $code =~ s/\`([^\`]*)\`/eval $1/gem; | ||
| 244 | |||
| 245 | print $code; | ||
| 246 | close STDOUT; | ||
diff --git a/src/lib/libcrypto/sha/asm/sha512-s390x.pl b/src/lib/libcrypto/sha/asm/sha512-s390x.pl deleted file mode 100644 index 079a3fc78a..0000000000 --- a/src/lib/libcrypto/sha/asm/sha512-s390x.pl +++ /dev/null | |||
| @@ -1,322 +0,0 @@ | |||
| 1 | #!/usr/bin/env perl | ||
| 2 | |||
| 3 | # ==================================================================== | ||
| 4 | # Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL | ||
| 5 | # project. The module is, however, dual licensed under OpenSSL and | ||
| 6 | # CRYPTOGAMS licenses depending on where you obtain it. For further | ||
| 7 | # details see http://www.openssl.org/~appro/cryptogams/. | ||
| 8 | # ==================================================================== | ||
| 9 | |||
| 10 | # SHA256/512 block procedures for s390x. | ||
| 11 | |||
| 12 | # April 2007. | ||
| 13 | # | ||
| 14 | # sha256_block_data_order is reportedly >3 times faster than gcc 3.3 | ||
| 15 | # generated code (must be a bug in compiler, as improvement is | ||
| 16 | # "pathologically" high, in particular in comparison to other SHA | ||
| 17 | # modules). But the real twist is that it detects if hardware support | ||
| 18 | # for SHA256 is available and in such case utilizes it. Then the | ||
| 19 | # performance can reach >6.5x of assembler one for larger chunks. | ||
| 20 | # | ||
| 21 | # sha512_block_data_order is ~70% faster than gcc 3.3 generated code. | ||
| 22 | |||
| 23 | # January 2009. | ||
| 24 | # | ||
| 25 | # Add support for hardware SHA512 and reschedule instructions to | ||
| 26 | # favour dual-issue z10 pipeline. Hardware SHA256/512 is ~4.7x faster | ||
| 27 | # than software. | ||
| 28 | |||
| 29 | # November 2010. | ||
| 30 | # | ||
| 31 | # Adapt for -m31 build. If kernel supports what's called "highgprs" | ||
| 32 | # feature on Linux [see /proc/cpuinfo], it's possible to use 64-bit | ||
| 33 | # instructions and achieve "64-bit" performance even in 31-bit legacy | ||
| 34 | # application context. The feature is not specific to any particular | ||
| 35 | # processor, as long as it's "z-CPU". Latter implies that the code | ||
| 36 | # remains z/Architecture specific. On z900 SHA256 was measured to | ||
| 37 | # perform 2.4x and SHA512 - 13x better than code generated by gcc 4.3. | ||
| 38 | |||
| 39 | $flavour = shift; | ||
| 40 | |||
| 41 | if ($flavour =~ /3[12]/) { | ||
| 42 | $SIZE_T=4; | ||
| 43 | $g=""; | ||
| 44 | } else { | ||
| 45 | $SIZE_T=8; | ||
| 46 | $g="g"; | ||
| 47 | } | ||
| 48 | |||
| 49 | $t0="%r0"; | ||
| 50 | $t1="%r1"; | ||
| 51 | $ctx="%r2"; $t2="%r2"; | ||
| 52 | $inp="%r3"; | ||
| 53 | $len="%r4"; # used as index in inner loop | ||
| 54 | |||
| 55 | $A="%r5"; | ||
| 56 | $B="%r6"; | ||
| 57 | $C="%r7"; | ||
| 58 | $D="%r8"; | ||
| 59 | $E="%r9"; | ||
| 60 | $F="%r10"; | ||
| 61 | $G="%r11"; | ||
| 62 | $H="%r12"; @V=($A,$B,$C,$D,$E,$F,$G,$H); | ||
| 63 | $tbl="%r13"; | ||
| 64 | $T1="%r14"; | ||
| 65 | $sp="%r15"; | ||
| 66 | |||
| 67 | while (($output=shift) && ($output!~/^\w[\w\-]*\.\w+$/)) {} | ||
| 68 | open STDOUT,">$output"; | ||
| 69 | |||
| 70 | if ($output =~ /512/) { | ||
| 71 | $label="512"; | ||
| 72 | $SZ=8; | ||
| 73 | $LD="lg"; # load from memory | ||
| 74 | $ST="stg"; # store to memory | ||
| 75 | $ADD="alg"; # add with memory operand | ||
| 76 | $ROT="rllg"; # rotate left | ||
| 77 | $SHR="srlg"; # logical right shift [see even at the end] | ||
| 78 | @Sigma0=(25,30,36); | ||
| 79 | @Sigma1=(23,46,50); | ||
| 80 | @sigma0=(56,63, 7); | ||
| 81 | @sigma1=( 3,45, 6); | ||
| 82 | $rounds=80; | ||
| 83 | $kimdfunc=3; # 0 means unknown/unsupported/unimplemented/disabled | ||
| 84 | } else { | ||
| 85 | $label="256"; | ||
| 86 | $SZ=4; | ||
| 87 | $LD="llgf"; # load from memory | ||
| 88 | $ST="st"; # store to memory | ||
| 89 | $ADD="al"; # add with memory operand | ||
| 90 | $ROT="rll"; # rotate left | ||
| 91 | $SHR="srl"; # logical right shift | ||
| 92 | @Sigma0=(10,19,30); | ||
| 93 | @Sigma1=( 7,21,26); | ||
| 94 | @sigma0=(14,25, 3); | ||
| 95 | @sigma1=(13,15,10); | ||
| 96 | $rounds=64; | ||
| 97 | $kimdfunc=2; # magic function code for kimd instruction | ||
| 98 | } | ||
| 99 | $Func="sha${label}_block_data_order"; | ||
| 100 | $Table="K${label}"; | ||
| 101 | $stdframe=16*$SIZE_T+4*8; | ||
| 102 | $frame=$stdframe+16*$SZ; | ||
| 103 | |||
| 104 | sub BODY_00_15 { | ||
| 105 | my ($i,$a,$b,$c,$d,$e,$f,$g,$h) = @_; | ||
| 106 | |||
| 107 | $code.=<<___ if ($i<16); | ||
| 108 | $LD $T1,`$i*$SZ`($inp) ### $i | ||
| 109 | ___ | ||
| 110 | $code.=<<___; | ||
| 111 | $ROT $t0,$e,$Sigma1[0] | ||
| 112 | $ROT $t1,$e,$Sigma1[1] | ||
| 113 | lgr $t2,$f | ||
| 114 | xgr $t0,$t1 | ||
| 115 | $ROT $t1,$t1,`$Sigma1[2]-$Sigma1[1]` | ||
| 116 | xgr $t2,$g | ||
| 117 | $ST $T1,`$stdframe+$SZ*($i%16)`($sp) | ||
| 118 | xgr $t0,$t1 # Sigma1(e) | ||
| 119 | algr $T1,$h # T1+=h | ||
| 120 | ngr $t2,$e | ||
| 121 | lgr $t1,$a | ||
| 122 | algr $T1,$t0 # T1+=Sigma1(e) | ||
| 123 | $ROT $h,$a,$Sigma0[0] | ||
| 124 | xgr $t2,$g # Ch(e,f,g) | ||
| 125 | $ADD $T1,`$i*$SZ`($len,$tbl) # T1+=K[i] | ||
| 126 | $ROT $t0,$a,$Sigma0[1] | ||
| 127 | algr $T1,$t2 # T1+=Ch(e,f,g) | ||
| 128 | ogr $t1,$b | ||
| 129 | xgr $h,$t0 | ||
| 130 | lgr $t2,$a | ||
| 131 | ngr $t1,$c | ||
| 132 | $ROT $t0,$t0,`$Sigma0[2]-$Sigma0[1]` | ||
| 133 | xgr $h,$t0 # h=Sigma0(a) | ||
| 134 | ngr $t2,$b | ||
| 135 | algr $h,$T1 # h+=T1 | ||
| 136 | ogr $t2,$t1 # Maj(a,b,c) | ||
| 137 | algr $d,$T1 # d+=T1 | ||
| 138 | algr $h,$t2 # h+=Maj(a,b,c) | ||
| 139 | ___ | ||
| 140 | } | ||
| 141 | |||
| 142 | sub BODY_16_XX { | ||
| 143 | my ($i,$a,$b,$c,$d,$e,$f,$g,$h) = @_; | ||
| 144 | |||
| 145 | $code.=<<___; | ||
| 146 | $LD $T1,`$stdframe+$SZ*(($i+1)%16)`($sp) ### $i | ||
| 147 | $LD $t1,`$stdframe+$SZ*(($i+14)%16)`($sp) | ||
| 148 | $ROT $t0,$T1,$sigma0[0] | ||
| 149 | $SHR $T1,$sigma0[2] | ||
| 150 | $ROT $t2,$t0,`$sigma0[1]-$sigma0[0]` | ||
| 151 | xgr $T1,$t0 | ||
| 152 | $ROT $t0,$t1,$sigma1[0] | ||
| 153 | xgr $T1,$t2 # sigma0(X[i+1]) | ||
| 154 | $SHR $t1,$sigma1[2] | ||
| 155 | $ADD $T1,`$stdframe+$SZ*($i%16)`($sp) # +=X[i] | ||
| 156 | xgr $t1,$t0 | ||
| 157 | $ROT $t0,$t0,`$sigma1[1]-$sigma1[0]` | ||
| 158 | $ADD $T1,`$stdframe+$SZ*(($i+9)%16)`($sp) # +=X[i+9] | ||
| 159 | xgr $t1,$t0 # sigma1(X[i+14]) | ||
| 160 | algr $T1,$t1 # +=sigma1(X[i+14]) | ||
| 161 | ___ | ||
| 162 | &BODY_00_15(@_); | ||
| 163 | } | ||
| 164 | |||
| 165 | $code.=<<___; | ||
| 166 | .text | ||
| 167 | .align 64 | ||
| 168 | .type $Table,\@object | ||
| 169 | $Table: | ||
| 170 | ___ | ||
| 171 | $code.=<<___ if ($SZ==4); | ||
| 172 | .long 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5 | ||
| 173 | .long 0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5 | ||
| 174 | .long 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3 | ||
| 175 | .long 0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174 | ||
| 176 | .long 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc | ||
| 177 | .long 0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da | ||
| 178 | .long 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7 | ||
| 179 | .long 0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967 | ||
| 180 | .long 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13 | ||
| 181 | .long 0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85 | ||
| 182 | .long 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3 | ||
| 183 | .long 0xd192e819,0xd6990624,0xf40e3585,0x106aa070 | ||
| 184 | .long 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5 | ||
| 185 | .long 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3 | ||
| 186 | .long 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208 | ||
| 187 | .long 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 | ||
| 188 | ___ | ||
| 189 | $code.=<<___ if ($SZ==8); | ||
| 190 | .quad 0x428a2f98d728ae22,0x7137449123ef65cd | ||
| 191 | .quad 0xb5c0fbcfec4d3b2f,0xe9b5dba58189dbbc | ||
| 192 | .quad 0x3956c25bf348b538,0x59f111f1b605d019 | ||
| 193 | .quad 0x923f82a4af194f9b,0xab1c5ed5da6d8118 | ||
| 194 | .quad 0xd807aa98a3030242,0x12835b0145706fbe | ||
| 195 | .quad 0x243185be4ee4b28c,0x550c7dc3d5ffb4e2 | ||
| 196 | .quad 0x72be5d74f27b896f,0x80deb1fe3b1696b1 | ||
| 197 | .quad 0x9bdc06a725c71235,0xc19bf174cf692694 | ||
| 198 | .quad 0xe49b69c19ef14ad2,0xefbe4786384f25e3 | ||
| 199 | .quad 0x0fc19dc68b8cd5b5,0x240ca1cc77ac9c65 | ||
| 200 | .quad 0x2de92c6f592b0275,0x4a7484aa6ea6e483 | ||
| 201 | .quad 0x5cb0a9dcbd41fbd4,0x76f988da831153b5 | ||
| 202 | .quad 0x983e5152ee66dfab,0xa831c66d2db43210 | ||
| 203 | .quad 0xb00327c898fb213f,0xbf597fc7beef0ee4 | ||
| 204 | .quad 0xc6e00bf33da88fc2,0xd5a79147930aa725 | ||
| 205 | .quad 0x06ca6351e003826f,0x142929670a0e6e70 | ||
| 206 | .quad 0x27b70a8546d22ffc,0x2e1b21385c26c926 | ||
| 207 | .quad 0x4d2c6dfc5ac42aed,0x53380d139d95b3df | ||
| 208 | .quad 0x650a73548baf63de,0x766a0abb3c77b2a8 | ||
| 209 | .quad 0x81c2c92e47edaee6,0x92722c851482353b | ||
| 210 | .quad 0xa2bfe8a14cf10364,0xa81a664bbc423001 | ||
| 211 | .quad 0xc24b8b70d0f89791,0xc76c51a30654be30 | ||
| 212 | .quad 0xd192e819d6ef5218,0xd69906245565a910 | ||
| 213 | .quad 0xf40e35855771202a,0x106aa07032bbd1b8 | ||
| 214 | .quad 0x19a4c116b8d2d0c8,0x1e376c085141ab53 | ||
| 215 | .quad 0x2748774cdf8eeb99,0x34b0bcb5e19b48a8 | ||
| 216 | .quad 0x391c0cb3c5c95a63,0x4ed8aa4ae3418acb | ||
| 217 | .quad 0x5b9cca4f7763e373,0x682e6ff3d6b2b8a3 | ||
| 218 | .quad 0x748f82ee5defb2fc,0x78a5636f43172f60 | ||
| 219 | .quad 0x84c87814a1f0ab72,0x8cc702081a6439ec | ||
| 220 | .quad 0x90befffa23631e28,0xa4506cebde82bde9 | ||
| 221 | .quad 0xbef9a3f7b2c67915,0xc67178f2e372532b | ||
| 222 | .quad 0xca273eceea26619c,0xd186b8c721c0c207 | ||
| 223 | .quad 0xeada7dd6cde0eb1e,0xf57d4f7fee6ed178 | ||
| 224 | .quad 0x06f067aa72176fba,0x0a637dc5a2c898a6 | ||
| 225 | .quad 0x113f9804bef90dae,0x1b710b35131c471b | ||
| 226 | .quad 0x28db77f523047d84,0x32caab7b40c72493 | ||
| 227 | .quad 0x3c9ebe0a15c9bebc,0x431d67c49c100d4c | ||
| 228 | .quad 0x4cc5d4becb3e42b6,0x597f299cfc657e2a | ||
| 229 | .quad 0x5fcb6fab3ad6faec,0x6c44198c4a475817 | ||
| 230 | ___ | ||
| 231 | $code.=<<___; | ||
| 232 | .size $Table,.-$Table | ||
| 233 | .globl $Func | ||
| 234 | .type $Func,\@function | ||
| 235 | $Func: | ||
| 236 | sllg $len,$len,`log(16*$SZ)/log(2)` | ||
| 237 | ___ | ||
| 238 | $code.=<<___ if ($kimdfunc); | ||
| 239 | larl %r1,OPENSSL_s390xcap_P | ||
| 240 | lg %r0,0(%r1) | ||
| 241 | tmhl %r0,0x4000 # check for message-security assist | ||
| 242 | jz .Lsoftware | ||
| 243 | lghi %r0,0 | ||
| 244 | la %r1,`2*$SIZE_T`($sp) | ||
| 245 | .long 0xb93e0002 # kimd %r0,%r2 | ||
| 246 | lg %r0,`2*$SIZE_T`($sp) | ||
| 247 | tmhh %r0,`0x8000>>$kimdfunc` | ||
| 248 | jz .Lsoftware | ||
| 249 | lghi %r0,$kimdfunc | ||
| 250 | lgr %r1,$ctx | ||
| 251 | lgr %r2,$inp | ||
| 252 | lgr %r3,$len | ||
| 253 | .long 0xb93e0002 # kimd %r0,%r2 | ||
| 254 | brc 1,.-4 # pay attention to "partial completion" | ||
| 255 | br %r14 | ||
| 256 | .align 16 | ||
| 257 | .Lsoftware: | ||
| 258 | ___ | ||
| 259 | $code.=<<___; | ||
| 260 | lghi %r1,-$frame | ||
| 261 | la $len,0($len,$inp) | ||
| 262 | stm${g} $ctx,%r15,`2*$SIZE_T`($sp) | ||
| 263 | lgr %r0,$sp | ||
| 264 | la $sp,0(%r1,$sp) | ||
| 265 | st${g} %r0,0($sp) | ||
| 266 | |||
| 267 | larl $tbl,$Table | ||
| 268 | $LD $A,`0*$SZ`($ctx) | ||
| 269 | $LD $B,`1*$SZ`($ctx) | ||
| 270 | $LD $C,`2*$SZ`($ctx) | ||
| 271 | $LD $D,`3*$SZ`($ctx) | ||
| 272 | $LD $E,`4*$SZ`($ctx) | ||
| 273 | $LD $F,`5*$SZ`($ctx) | ||
| 274 | $LD $G,`6*$SZ`($ctx) | ||
| 275 | $LD $H,`7*$SZ`($ctx) | ||
| 276 | |||
| 277 | .Lloop: | ||
| 278 | lghi $len,0 | ||
| 279 | ___ | ||
| 280 | for ($i=0;$i<16;$i++) { &BODY_00_15($i,@V); unshift(@V,pop(@V)); } | ||
| 281 | $code.=".Lrounds_16_xx:\n"; | ||
| 282 | for (;$i<32;$i++) { &BODY_16_XX($i,@V); unshift(@V,pop(@V)); } | ||
| 283 | $code.=<<___; | ||
| 284 | aghi $len,`16*$SZ` | ||
| 285 | lghi $t0,`($rounds-16)*$SZ` | ||
| 286 | clgr $len,$t0 | ||
| 287 | jne .Lrounds_16_xx | ||
| 288 | |||
| 289 | l${g} $ctx,`$frame+2*$SIZE_T`($sp) | ||
| 290 | la $inp,`16*$SZ`($inp) | ||
| 291 | $ADD $A,`0*$SZ`($ctx) | ||
| 292 | $ADD $B,`1*$SZ`($ctx) | ||
| 293 | $ADD $C,`2*$SZ`($ctx) | ||
| 294 | $ADD $D,`3*$SZ`($ctx) | ||
| 295 | $ADD $E,`4*$SZ`($ctx) | ||
| 296 | $ADD $F,`5*$SZ`($ctx) | ||
| 297 | $ADD $G,`6*$SZ`($ctx) | ||
| 298 | $ADD $H,`7*$SZ`($ctx) | ||
| 299 | $ST $A,`0*$SZ`($ctx) | ||
| 300 | $ST $B,`1*$SZ`($ctx) | ||
| 301 | $ST $C,`2*$SZ`($ctx) | ||
| 302 | $ST $D,`3*$SZ`($ctx) | ||
| 303 | $ST $E,`4*$SZ`($ctx) | ||
| 304 | $ST $F,`5*$SZ`($ctx) | ||
| 305 | $ST $G,`6*$SZ`($ctx) | ||
| 306 | $ST $H,`7*$SZ`($ctx) | ||
| 307 | cl${g} $inp,`$frame+4*$SIZE_T`($sp) | ||
| 308 | jne .Lloop | ||
| 309 | |||
| 310 | lm${g} %r6,%r15,`$frame+6*$SIZE_T`($sp) | ||
| 311 | br %r14 | ||
| 312 | .size $Func,.-$Func | ||
| 313 | .string "SHA${label} block transform for s390x, CRYPTOGAMS by <appro\@openssl.org>" | ||
| 314 | .comm OPENSSL_s390xcap_P,16,8 | ||
| 315 | ___ | ||
| 316 | |||
| 317 | $code =~ s/\`([^\`]*)\`/eval $1/gem; | ||
| 318 | # unlike 32-bit shift 64-bit one takes three arguments | ||
| 319 | $code =~ s/(srlg\s+)(%r[0-9]+),/$1$2,$2,/gm; | ||
| 320 | |||
| 321 | print $code; | ||
| 322 | close STDOUT; | ||
