diff options
author | Ralf S. Engelschall <rse@openssl.org> | 1998-12-21 10:56:39 +0000 |
---|---|---|
committer | Ralf S. Engelschall <rse@openssl.org> | 1998-12-21 10:56:39 +0000 |
commit | 58964a492275ca9a59a0cd9c8155cb2491b4b909 (patch) | |
tree | c7b16876a5789463bbbb468ef4829c8129b3d718 /perl/mul.pl | |
parent | d02b48c63a58ea4367a0e905979f140b7d090f86 (diff) | |
download | openssl-58964a492275ca9a59a0cd9c8155cb2491b4b909.tar.gz |
Import of old SSLeay release: SSLeay 0.9.0b
Diffstat (limited to 'perl/mul.pl')
-rw-r--r-- | perl/mul.pl | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/perl/mul.pl b/perl/mul.pl new file mode 100644 index 0000000000..611a760625 --- /dev/null +++ b/perl/mul.pl @@ -0,0 +1,56 @@ +#!/usr/bin/perl + +use ExtUtils::testlib; + +use SSLeay; + + +sub mul + { + my($ab,$cd,$num)=@_; + + if ($num <= 4096) + { + return($ab*$cd); + } + else + { + my($a,$b,$c,$d,$n,$ac,$bd,$m,$t1,$t2); + + $n=$num/2; + + $a=$ab->mask_bits($n); + $b=$ab->rshift($n); + $c=$cd->mask_bits($n); + $d=$cd->rshift($n); + + $t1=($b-$a); + $t2=($c-$d); + $m= &mul($t1,$t2,$n); + $ac=&mul($a,$c,$n); + $bd=&mul($b,$d,$n); + $m=$m+$ac+$bd; + $m=$m->lshift($n); + $bd=$bd->lshift($num); + + $r=$ac+$m+$bd; + return($r); + } + } + +$num=4096*32; +$a=SSLeay::BN::rand($num); +$b=SSLeay::BN::rand($num); + +#for (1 .. 10) + { + $r=&mul($a,$b,$num); + } + +#for (1 .. 10) + { + $rr=$a*$b; + } + +$res=$rr-$r; +print $res->bn2hex()."\n"; |