003 File Manager
Current Path:
/usr/src/crypto/openssl/crypto/bn/asm
usr
/
src
/
crypto
/
openssl
/
crypto
/
bn
/
asm
/
📁
..
📄
armv4-gf2m.pl
(8.22 KB)
📄
armv4-mont.pl
(19.26 KB)
📄
armv8-mont.pl
(36.05 KB)
📄
bn-586.pl
(16.38 KB)
📄
bn-c64xplus.asm
(9.89 KB)
📄
c64xplus-gf2m.pl
(4.03 KB)
📄
co-586.pl
(5.9 KB)
📄
ia64-mont.pl
(25.77 KB)
📄
ia64.S
(44.58 KB)
📄
mips-mont.pl
(9.32 KB)
📄
mips.pl
(48.23 KB)
📄
parisc-mont.pl
(26.92 KB)
📄
ppc-mont.pl
(47.6 KB)
📄
ppc.pl
(44.43 KB)
📄
ppc64-mont.pl
(39.81 KB)
📄
rsaz-avx2.pl
(50.92 KB)
📄
rsaz-x86_64.pl
(45.89 KB)
📄
s390x-gf2m.pl
(5.37 KB)
📄
s390x-mont.pl
(6.85 KB)
📄
s390x.S
(13.04 KB)
📄
sparct4-mont.pl
(27.15 KB)
📄
sparcv8.S
(27.67 KB)
📄
sparcv8plus.S
(32.44 KB)
📄
sparcv9-gf2m.pl
(4.74 KB)
📄
sparcv9-mont.pl
(13.77 KB)
📄
sparcv9a-mont.pl
(20.5 KB)
📄
via-mont.pl
(9.1 KB)
📄
vis3-mont.pl
(9.07 KB)
📄
x86-gf2m.pl
(7.94 KB)
📄
x86-mont.pl
(17.29 KB)
📄
x86_64-gcc.c
(18.6 KB)
📄
x86_64-gf2m.pl
(9.3 KB)
📄
x86_64-mont.pl
(32.42 KB)
📄
x86_64-mont5.pl
(85.71 KB)
Editing: co-586.pl
#! /usr/bin/env perl # Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. # # Licensed under the OpenSSL license (the "License"). You may not use # this file except in compliance with the License. You can obtain a copy # in the file LICENSE in the source distribution or at # https://www.openssl.org/source/license.html $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; push(@INC,"${dir}","${dir}../../perlasm"); require "x86asm.pl"; $output = pop; open STDOUT,">$output"; &asm_init($ARGV[0]); &bn_mul_comba("bn_mul_comba8",8); &bn_mul_comba("bn_mul_comba4",4); &bn_sqr_comba("bn_sqr_comba8",8); &bn_sqr_comba("bn_sqr_comba4",4); &asm_finish(); close STDOUT or die "error closing STDOUT: $!"; sub mul_add_c { local($a,$ai,$b,$bi,$c0,$c1,$c2,$pos,$i,$na,$nb)=@_; # pos == -1 if eax and edx are pre-loaded, 0 to load from next # words, and 1 if load return value &comment("mul a[$ai]*b[$bi]"); # "eax" and "edx" will always be pre-loaded. # &mov("eax",&DWP($ai*4,$a,"",0)) ; # &mov("edx",&DWP($bi*4,$b,"",0)); &mul("edx"); &add($c0,"eax"); &mov("eax",&DWP(($na)*4,$a,"",0)) if $pos == 0; # load next a &mov("eax",&wparam(0)) if $pos > 0; # load r[] ### &adc($c1,"edx"); &mov("edx",&DWP(($nb)*4,$b,"",0)) if $pos == 0; # load next b &mov("edx",&DWP(($nb)*4,$b,"",0)) if $pos == 1; # load next b ### &adc($c2,0); # is pos > 1, it means it is the last loop &mov(&DWP($i*4,"eax","",0),$c0) if $pos > 0; # save r[]; &mov("eax",&DWP(($na)*4,$a,"",0)) if $pos == 1; # load next a } sub sqr_add_c { local($r,$a,$ai,$bi,$c0,$c1,$c2,$pos,$i,$na,$nb)=@_; # pos == -1 if eax and edx are pre-loaded, 0 to load from next # words, and 1 if load return value &comment("sqr a[$ai]*a[$bi]"); # "eax" and "edx" will always be pre-loaded. # &mov("eax",&DWP($ai*4,$a,"",0)) ; # &mov("edx",&DWP($bi*4,$b,"",0)); if ($ai == $bi) { &mul("eax");} else { &mul("edx");} &add($c0,"eax"); &mov("eax",&DWP(($na)*4,$a,"",0)) if $pos == 0; # load next a ### &adc($c1,"edx"); &mov("edx",&DWP(($nb)*4,$a,"",0)) if ($pos == 1) && ($na != $nb); ### &adc($c2,0); # is pos > 1, it means it is the last loop &mov(&DWP($i*4,$r,"",0),$c0) if $pos > 0; # save r[]; &mov("eax",&DWP(($na)*4,$a,"",0)) if $pos == 1; # load next b } sub sqr_add_c2 { local($r,$a,$ai,$bi,$c0,$c1,$c2,$pos,$i,$na,$nb)=@_; # pos == -1 if eax and edx are pre-loaded, 0 to load from next # words, and 1 if load return value &comment("sqr a[$ai]*a[$bi]"); # "eax" and "edx" will always be pre-loaded. # &mov("eax",&DWP($ai*4,$a,"",0)) ; # &mov("edx",&DWP($bi*4,$a,"",0)); if ($ai == $bi) { &mul("eax");} else { &mul("edx");} &add("eax","eax"); ### &adc("edx","edx"); ### &adc($c2,0); &add($c0,"eax"); &adc($c1,"edx"); &mov("eax",&DWP(($na)*4,$a,"",0)) if $pos == 0; # load next a &mov("eax",&DWP(($na)*4,$a,"",0)) if $pos == 1; # load next b &adc($c2,0); &mov(&DWP($i*4,$r,"",0),$c0) if $pos > 0; # save r[]; &mov("edx",&DWP(($nb)*4,$a,"",0)) if ($pos <= 1) && ($na != $nb); ### } sub bn_mul_comba { local($name,$num)=@_; local($a,$b,$c0,$c1,$c2); local($i,$as,$ae,$bs,$be,$ai,$bi); local($tot,$end); &function_begin_B($name,""); $c0="ebx"; $c1="ecx"; $c2="ebp"; $a="esi"; $b="edi"; $as=0; $ae=0; $bs=0; $be=0; $tot=$num+$num-1; &push("esi"); &mov($a,&wparam(1)); &push("edi"); &mov($b,&wparam(2)); &push("ebp"); &push("ebx"); &xor($c0,$c0); &mov("eax",&DWP(0,$a,"",0)); # load the first word &xor($c1,$c1); &mov("edx",&DWP(0,$b,"",0)); # load the first second for ($i=0; $i<$tot; $i++) { $ai=$as; $bi=$bs; $end=$be+1; &comment("################## Calculate word $i"); for ($j=$bs; $j<$end; $j++) { &xor($c2,$c2) if ($j == $bs); if (($j+1) == $end) { $v=1; $v=2 if (($i+1) == $tot); } else { $v=0; } if (($j+1) != $end) { $na=($ai-1); $nb=($bi+1); } else { $na=$as+($i < ($num-1)); $nb=$bs+($i >= ($num-1)); } #printf STDERR "[$ai,$bi] -> [$na,$nb]\n"; &mul_add_c($a,$ai,$b,$bi,$c0,$c1,$c2,$v,$i,$na,$nb); if ($v) { &comment("saved r[$i]"); # &mov("eax",&wparam(0)); # &mov(&DWP($i*4,"eax","",0),$c0); ($c0,$c1,$c2)=($c1,$c2,$c0); } $ai--; $bi++; } $as++ if ($i < ($num-1)); $ae++ if ($i >= ($num-1)); $bs++ if ($i >= ($num-1)); $be++ if ($i < ($num-1)); } &comment("save r[$i]"); # &mov("eax",&wparam(0)); &mov(&DWP($i*4,"eax","",0),$c0); &pop("ebx"); &pop("ebp"); &pop("edi"); &pop("esi"); &ret(); &function_end_B($name); } sub bn_sqr_comba { local($name,$num)=@_; local($r,$a,$c0,$c1,$c2)=@_; local($i,$as,$ae,$bs,$be,$ai,$bi); local($b,$tot,$end,$half); &function_begin_B($name,""); $c0="ebx"; $c1="ecx"; $c2="ebp"; $a="esi"; $r="edi"; &push("esi"); &push("edi"); &push("ebp"); &push("ebx"); &mov($r,&wparam(0)); &mov($a,&wparam(1)); &xor($c0,$c0); &xor($c1,$c1); &mov("eax",&DWP(0,$a,"",0)); # load the first word $as=0; $ae=0; $bs=0; $be=0; $tot=$num+$num-1; for ($i=0; $i<$tot; $i++) { $ai=$as; $bi=$bs; $end=$be+1; &comment("############### Calculate word $i"); for ($j=$bs; $j<$end; $j++) { &xor($c2,$c2) if ($j == $bs); if (($ai-1) < ($bi+1)) { $v=1; $v=2 if ($i+1) == $tot; } else { $v=0; } if (!$v) { $na=$ai-1; $nb=$bi+1; } else { $na=$as+($i < ($num-1)); $nb=$bs+($i >= ($num-1)); } if ($ai == $bi) { &sqr_add_c($r,$a,$ai,$bi, $c0,$c1,$c2,$v,$i,$na,$nb); } else { &sqr_add_c2($r,$a,$ai,$bi, $c0,$c1,$c2,$v,$i,$na,$nb); } if ($v) { &comment("saved r[$i]"); #&mov(&DWP($i*4,$r,"",0),$c0); ($c0,$c1,$c2)=($c1,$c2,$c0); last; } $ai--; $bi++; } $as++ if ($i < ($num-1)); $ae++ if ($i >= ($num-1)); $bs++ if ($i >= ($num-1)); $be++ if ($i < ($num-1)); } &mov(&DWP($i*4,$r,"",0),$c0); &pop("ebx"); &pop("ebp"); &pop("edi"); &pop("esi"); &ret(); &function_end_B($name); }
Upload File
Create Folder