Magellan Linux

Annotation of /trunk/openssl/patches/openssl-0.9.8k-binutils-32bit-asm.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 997 - (hide annotations) (download)
Thu Mar 4 08:44:21 2010 UTC (14 years, 3 months ago) by niro
File size: 2968 byte(s)
fix 32bit issues in md4-x86_64 asm code with newer binutils

1 niro 997 And the fix from md5-x86_64 implementation author - Marc Bevand with explanation
2    
3     "Well my assembler code doesn't really care whether the
4     displacement are interpreted as 32-bit signed or unsigned values
5     because in the end the result is truncated to 32-bit. So in order to
6     fix it replace each hex value with a 32-bit signed value (eg.
7     0xd76aa478 with -680876936)."
8    
9     http://rt.openssl.org/Ticket/Display.html?id=2094
10    
11     Index: crypto/md5/asm/md5-x86_64.pl
12     ===================================================================
13     RCS file: /usr/local/src/openssl/CVSROOT/openssl/crypto/md5/asm/md5-x86_64.pl,v
14     retrieving revision 1.2.2.1
15     retrieving revision 1.2.2.2
16     diff -u -p -r1.2.2.1 -r1.2.2.2
17     --- openssl/crypto/md5/asm/md5-x86_64.pl 11 Nov 2007 13:34:06 -0000 1.2.2.1
18     +++ openssl/crypto/md5/asm/md5-x86_64.pl 13 Nov 2009 14:14:46 -0000 1.2.2.2
19     @@ -19,6 +19,7 @@ my $code;
20     sub round1_step
21     {
22     my ($pos, $dst, $x, $y, $z, $k_next, $T_i, $s) = @_;
23     + $T_i = unpack("l",pack("l", hex($T_i))); # convert to 32-bit signed decimal
24     $code .= " mov 0*4(%rsi), %r10d /* (NEXT STEP) X[0] */\n" if ($pos == -1);
25     $code .= " mov %edx, %r11d /* (NEXT STEP) z' = %edx */\n" if ($pos == -1);
26     $code .= <<EOF;
27     @@ -42,6 +43,7 @@ EOF
28     sub round2_step
29     {
30     my ($pos, $dst, $x, $y, $z, $k_next, $T_i, $s) = @_;
31     + $T_i = unpack("l",pack("l", hex($T_i))); # convert to 32-bit signed decimal
32     $code .= " mov 1*4(%rsi), %r10d /* (NEXT STEP) X[1] */\n" if ($pos == -1);
33     $code .= " mov %ecx, %r11d /* (NEXT STEP) y' = %ecx */\n" if ($pos == -1);
34     $code .= <<EOF;
35     @@ -65,6 +67,7 @@ EOF
36     sub round3_step
37     {
38     my ($pos, $dst, $x, $y, $z, $k_next, $T_i, $s) = @_;
39     + $T_i = unpack("l",pack("l", hex($T_i))); # convert to 32-bit signed decimal
40     $code .= " mov 5*4(%rsi), %r10d /* (NEXT STEP) X[5] */\n" if ($pos == -1);
41     $code .= " mov %ecx, %r11d /* (NEXT STEP) y' = %ecx */\n" if ($pos == -1);
42     $code .= <<EOF;
43     @@ -87,6 +90,7 @@ EOF
44     sub round4_step
45     {
46     my ($pos, $dst, $x, $y, $z, $k_next, $T_i, $s) = @_;
47     + $T_i = unpack("l",pack("l", hex($T_i))); # convert to 32-bit signed decimal
48     $code .= " mov 0*4(%rsi), %r10d /* (NEXT STEP) X[0] */\n" if ($pos == -1);
49     $code .= " mov \$0xffffffff, %r11d\n" if ($pos == -1);
50     $code .= " xor %edx, %r11d /* (NEXT STEP) not z' = not %edx*/\n"
51    
52     --- openssl-1.0.0-beta4/crypto/sha/asm/sha1-x86_64.pl.binutils 2009-11-12 15:17:29.000000000 +0100
53     +++ openssl-1.0.0-beta4/crypto/sha/asm/sha1-x86_64.pl 2009-11-12 17:24:18.000000000 +0100
54     @@ -150,7 +150,7 @@ ___
55     sub BODY_20_39 {
56     my ($i,$a,$b,$c,$d,$e,$f)=@_;
57     my $j=$i+1;
58     -my $K=($i<40)?0x6ed9eba1:0xca62c1d6;
59     +my $K=($i<40)?0x6ed9eba1:-0x359d3e2a;
60     $code.=<<___ if ($i<79);
61     lea $K($xi,$e),$f
62     mov `4*($j%16)`(%rsp),$xi
63     @@ -187,7 +187,7 @@ sub BODY_40_59 {
64     my ($i,$a,$b,$c,$d,$e,$f)=@_;
65     my $j=$i+1;
66     $code.=<<___;
67     - lea 0x8f1bbcdc($xi,$e),$f
68     + lea -0x70e44324($xi,$e),$f
69     mov `4*($j%16)`(%rsp),$xi
70     mov $b,$t0
71     mov $b,$t1