diff options
author | miod <> | 2023-02-01 20:45:04 +0000 |
---|---|---|
committer | miod <> | 2023-02-01 20:45:04 +0000 |
commit | dc4b2cf3e0979364f14ff89a07ffafc47435e2e7 (patch) | |
tree | 58219f5c6538172b9d00f33bf48c9a61419ec7a0 /src/lib/libcrypto/camellia | |
parent | 86f42338b2994b620482c37e3d0d9fc3ba1f523b (diff) | |
download | openbsd-dc4b2cf3e0979364f14ff89a07ffafc47435e2e7.tar.gz openbsd-dc4b2cf3e0979364f14ff89a07ffafc47435e2e7.tar.bz2 openbsd-dc4b2cf3e0979364f14ff89a07ffafc47435e2e7.zip |
Move all data blocks from .text to .rodata and cleanup up and homogeneize code
responsible from getting the proper address of those blocks.
ok tb@ jsing@
Diffstat (limited to 'src/lib/libcrypto/camellia')
-rw-r--r-- | src/lib/libcrypto/camellia/asm/cmll-x86.pl | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/src/lib/libcrypto/camellia/asm/cmll-x86.pl b/src/lib/libcrypto/camellia/asm/cmll-x86.pl index 027302ac86..a4ab11e54d 100644 --- a/src/lib/libcrypto/camellia/asm/cmll-x86.pl +++ b/src/lib/libcrypto/camellia/asm/cmll-x86.pl | |||
@@ -141,10 +141,8 @@ my $t0=@T[($j)%4],$t1=@T[($j+1)%4],$t2=@T[($j+2)%4],$t3=@T[($j+3)%4]; | |||
141 | &mov ($_esp,"ebx"); # save %esp | 141 | &mov ($_esp,"ebx"); # save %esp |
142 | &mov ($_end,"eax"); # save keyEnd | 142 | &mov ($_end,"eax"); # save keyEnd |
143 | 143 | ||
144 | &call (&label("pic_point")); | 144 | &picsetup($Tbl); |
145 | &set_label("pic_point"); | 145 | &picsymbol($Tbl, &label("Camellia_SBOX"), $Tbl); |
146 | &blindpop($Tbl); | ||
147 | &lea ($Tbl,&DWP(&label("Camellia_SBOX")."-".&label("pic_point"),$Tbl)); | ||
148 | 146 | ||
149 | &mov (@T[0],&DWP(0,$idx)); # load plaintext | 147 | &mov (@T[0],&DWP(0,$idx)); # load plaintext |
150 | &mov (@T[1],&DWP(4,$idx)); | 148 | &mov (@T[1],&DWP(4,$idx)); |
@@ -206,10 +204,8 @@ if ($OPENSSL) { | |||
206 | &mov ($_esp,"ebx"); # save %esp | 204 | &mov ($_esp,"ebx"); # save %esp |
207 | &mov ($_end,"eax"); # save keyEnd | 205 | &mov ($_end,"eax"); # save keyEnd |
208 | 206 | ||
209 | &call (&label("pic_point")); | 207 | &picsetup($Tbl); |
210 | &set_label("pic_point"); | 208 | &picsymbol($Tbl, &label("Camellia_SBOX"), $Tbl); |
211 | &blindpop($Tbl); | ||
212 | &lea ($Tbl,&DWP(&label("Camellia_SBOX")."-".&label("pic_point"),$Tbl)); | ||
213 | 209 | ||
214 | &mov (@T[0],&DWP(0,$idx)); # load plaintext | 210 | &mov (@T[0],&DWP(0,$idx)); # load plaintext |
215 | &mov (@T[1],&DWP(4,$idx)); | 211 | &mov (@T[1],&DWP(4,$idx)); |
@@ -316,10 +312,8 @@ if ($OPENSSL) { | |||
316 | &lea ($key,&DWP(0,$key,"eax")); | 312 | &lea ($key,&DWP(0,$key,"eax")); |
317 | &mov (&DWP(5*4,"esp"),"ebx");# save %esp | 313 | &mov (&DWP(5*4,"esp"),"ebx");# save %esp |
318 | 314 | ||
319 | &call (&label("pic_point")); | 315 | &picsetup($Tbl); |
320 | &set_label("pic_point"); | 316 | &picsymbol($Tbl, &label("Camellia_SBOX"), $Tbl); |
321 | &blindpop($Tbl); | ||
322 | &lea ($Tbl,&DWP(&label("Camellia_SBOX")."-".&label("pic_point"),$Tbl)); | ||
323 | 317 | ||
324 | &mov (@T[0],&DWP(0,$idx)); # load ciphertext | 318 | &mov (@T[0],&DWP(0,$idx)); # load ciphertext |
325 | &mov (@T[1],&DWP(4,$idx)); | 319 | &mov (@T[1],&DWP(4,$idx)); |
@@ -381,10 +375,8 @@ if ($OPENSSL) { | |||
381 | &lea ($key,&DWP(0,$key,"eax")); | 375 | &lea ($key,&DWP(0,$key,"eax")); |
382 | &mov (&DWP(5*4,"esp"),"ebx");# save %esp | 376 | &mov (&DWP(5*4,"esp"),"ebx");# save %esp |
383 | 377 | ||
384 | &call (&label("pic_point")); | 378 | &picsetup($Tbl); |
385 | &set_label("pic_point"); | 379 | &picsymbol($Tbl, &label("Camellia_SBOX"), $Tbl); |
386 | &blindpop($Tbl); | ||
387 | &lea ($Tbl,&DWP(&label("Camellia_SBOX")."-".&label("pic_point"),$Tbl)); | ||
388 | 380 | ||
389 | &mov (@T[0],&DWP(0,$idx)); # load ciphertext | 381 | &mov (@T[0],&DWP(0,$idx)); # load ciphertext |
390 | &mov (@T[1],&DWP(4,$idx)); | 382 | &mov (@T[1],&DWP(4,$idx)); |
@@ -594,10 +586,8 @@ my $bias=int(@T[0])?shift(@T):0; | |||
594 | &xor (@T[3],&DWP(1*8+4,$key)); | 586 | &xor (@T[3],&DWP(1*8+4,$key)); |
595 | 587 | ||
596 | &set_label("1st128",4); | 588 | &set_label("1st128",4); |
597 | &call (&label("pic_point")); | 589 | &picsetup($Tbl); |
598 | &set_label("pic_point"); | 590 | &picsymbol($Tbl, &label("Camellia_SBOX"), $Tbl); |
599 | &blindpop($Tbl); | ||
600 | &lea ($Tbl,&DWP(&label("Camellia_SBOX")."-".&label("pic_point"),$Tbl)); | ||
601 | &lea ($key,&DWP(&label("Camellia_SIGMA")."-".&label("Camellia_SBOX"),$Tbl)); | 591 | &lea ($key,&DWP(&label("Camellia_SIGMA")."-".&label("Camellia_SBOX"),$Tbl)); |
602 | 592 | ||
603 | &mov ($idx,&DWP($step*8,$key)); # prefetch SIGMA[0] | 593 | &mov ($idx,&DWP($step*8,$key)); # prefetch SIGMA[0] |
@@ -786,6 +776,7 @@ sub S4404 { my $i=shift; $i=($i<<1|$i>>7)&0xff; $i=@SBOX[$i]; return $i<<24|$i<< | |||
786 | sub S0222 { my $i=shift; $i=@SBOX[$i]; $i=($i<<1|$i>>7)&0xff; return $i<<16|$i<<8|$i; } | 776 | sub S0222 { my $i=shift; $i=@SBOX[$i]; $i=($i<<1|$i>>7)&0xff; return $i<<16|$i<<8|$i; } |
787 | sub S3033 { my $i=shift; $i=@SBOX[$i]; $i=($i>>1|$i<<7)&0xff; return $i<<24|$i<<8|$i; } | 777 | sub S3033 { my $i=shift; $i=@SBOX[$i]; $i=($i>>1|$i<<7)&0xff; return $i<<24|$i<<8|$i; } |
788 | 778 | ||
779 | &rodataseg(); | ||
789 | &set_label("Camellia_SIGMA",64); | 780 | &set_label("Camellia_SIGMA",64); |
790 | &data_word( | 781 | &data_word( |
791 | 0xa09e667f, 0x3bcc908b, 0xb67ae858, 0x4caa73b2, | 782 | 0xa09e667f, 0x3bcc908b, 0xb67ae858, 0x4caa73b2, |
@@ -796,6 +787,7 @@ sub S3033 { my $i=shift; $i=@SBOX[$i]; $i=($i>>1|$i<<7)&0xff; return $i<<24|$i<< | |||
796 | # tables are interleaved, remember? | 787 | # tables are interleaved, remember? |
797 | for ($i=0;$i<256;$i++) { &data_word(&S1110($i),&S4404($i)); } | 788 | for ($i=0;$i<256;$i++) { &data_word(&S1110($i),&S4404($i)); } |
798 | for ($i=0;$i<256;$i++) { &data_word(&S0222($i),&S3033($i)); } | 789 | for ($i=0;$i<256;$i++) { &data_word(&S0222($i),&S3033($i)); } |
790 | &previous(); | ||
799 | 791 | ||
800 | # void Camellia_cbc_encrypt (const void char *inp, unsigned char *out, | 792 | # void Camellia_cbc_encrypt (const void char *inp, unsigned char *out, |
801 | # size_t length, const CAMELLIA_KEY *key, | 793 | # size_t length, const CAMELLIA_KEY *key, |
@@ -856,10 +848,8 @@ my ($s0,$s1,$s2,$s3) = @T; | |||
856 | &mov ($_key,$s3); # save copy of key | 848 | &mov ($_key,$s3); # save copy of key |
857 | &mov ($_ivp,$Tbl); # save copy of ivp | 849 | &mov ($_ivp,$Tbl); # save copy of ivp |
858 | 850 | ||
859 | &call (&label("pic_point")); # make it PIC! | 851 | &picsetup($Tbl); |
860 | &set_label("pic_point"); | 852 | &picsymbol($Tbl, &label("Camellia_SBOX"), $Tbl); |
861 | &blindpop($Tbl); | ||
862 | &lea ($Tbl,&DWP(&label("Camellia_SBOX")."-".&label("pic_point"),$Tbl)); | ||
863 | 853 | ||
864 | &mov ($idx,32); | 854 | &mov ($idx,32); |
865 | &set_label("prefetch_sbox",4); | 855 | &set_label("prefetch_sbox",4); |
@@ -1133,6 +1123,4 @@ my ($s0,$s1,$s2,$s3) = @T; | |||
1133 | &function_end("Camellia_cbc_encrypt"); | 1123 | &function_end("Camellia_cbc_encrypt"); |
1134 | } | 1124 | } |
1135 | 1125 | ||
1136 | &asciz("Camellia for x86 by <appro\@openssl.org>"); | ||
1137 | |||
1138 | &asm_finish(); | 1126 | &asm_finish(); |