diff options
author | markus <> | 2003-11-18 12:39:05 +0000 |
---|---|---|
committer | markus <> | 2003-11-18 12:39:05 +0000 |
commit | 3cf6590e9b2b978b44c38897634f84fbf167db4f (patch) | |
tree | 7f604b9764cd13753c7602979f5424b7dc97e04b /src | |
parent | 56f777457f24d2899caf9b29a79285b5753e3e9b (diff) | |
download | openbsd-3cf6590e9b2b978b44c38897634f84fbf167db4f.tar.gz openbsd-3cf6590e9b2b978b44c38897634f84fbf167db4f.tar.bz2 openbsd-3cf6590e9b2b978b44c38897634f84fbf167db4f.zip |
use bn_asm_vax.S (from netbsd); test + ok by miod
use asm code for i386, except for the CBC code, because
it is not clean PIC code.
add <machime/asm.h> support to x86unix.pl
tested by: nick (on 30386), henning, djm, tedu, jmc and more;
no shlib minor crank necessary, only internal symbols changed.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/bf/asm/bf-586.pl | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/asm/bn-586.pl | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/cast/asm/cast-586.pl | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/cast/c_enc.c | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/des/asm/des-586.pl | 12 | ||||
-rw-r--r-- | src/lib/libcrypto/des/des_enc.c | 2 | ||||
-rw-r--r-- | src/lib/libcrypto/perlasm/x86asm.pl | 8 | ||||
-rw-r--r-- | src/lib/libcrypto/perlasm/x86unix.pl | 35 | ||||
-rw-r--r-- | src/lib/libssl/crypto/Makefile | 47 | ||||
-rw-r--r-- | src/lib/libssl/crypto/arch/vax/bn_asm_vax.S | 436 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/bf/asm/bf-586.pl | 2 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/bn/asm/bn-586.pl | 2 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/cast/asm/cast-586.pl | 2 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/cast/c_enc.c | 2 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/des/asm/des-586.pl | 12 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/des/des_enc.c | 2 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/perlasm/x86asm.pl | 8 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/perlasm/x86unix.pl | 35 |
18 files changed, 588 insertions, 25 deletions
diff --git a/src/lib/libcrypto/bf/asm/bf-586.pl b/src/lib/libcrypto/bf/asm/bf-586.pl index b556642c94..b5a4760d09 100644 --- a/src/lib/libcrypto/bf/asm/bf-586.pl +++ b/src/lib/libcrypto/bf/asm/bf-586.pl | |||
@@ -18,7 +18,7 @@ $tmp4="edx"; | |||
18 | 18 | ||
19 | &BF_encrypt("BF_encrypt",1); | 19 | &BF_encrypt("BF_encrypt",1); |
20 | &BF_encrypt("BF_decrypt",0); | 20 | &BF_encrypt("BF_decrypt",0); |
21 | &cbc("BF_cbc_encrypt","BF_encrypt","BF_decrypt",1,4,5,3,-1,-1); | 21 | &cbc("BF_cbc_encrypt","BF_encrypt","BF_decrypt",1,4,5,3,-1,-1) unless $main'openbsd; |
22 | &asm_finish(); | 22 | &asm_finish(); |
23 | 23 | ||
24 | sub BF_encrypt | 24 | sub BF_encrypt |
diff --git a/src/lib/libcrypto/bn/asm/bn-586.pl b/src/lib/libcrypto/bn/asm/bn-586.pl index 33f6125920..9a78f63be1 100644 --- a/src/lib/libcrypto/bn/asm/bn-586.pl +++ b/src/lib/libcrypto/bn/asm/bn-586.pl | |||
@@ -11,7 +11,7 @@ require "x86asm.pl"; | |||
11 | &bn_div_words("bn_div_words"); | 11 | &bn_div_words("bn_div_words"); |
12 | &bn_add_words("bn_add_words"); | 12 | &bn_add_words("bn_add_words"); |
13 | &bn_sub_words("bn_sub_words"); | 13 | &bn_sub_words("bn_sub_words"); |
14 | &bn_sub_part_words("bn_sub_part_words"); | 14 | &bn_sub_part_words("bn_sub_part_words") unless $main'openbsd; |
15 | 15 | ||
16 | &asm_finish(); | 16 | &asm_finish(); |
17 | 17 | ||
diff --git a/src/lib/libcrypto/cast/asm/cast-586.pl b/src/lib/libcrypto/cast/asm/cast-586.pl index 6be0bfe572..0ed55d1905 100644 --- a/src/lib/libcrypto/cast/asm/cast-586.pl +++ b/src/lib/libcrypto/cast/asm/cast-586.pl | |||
@@ -28,7 +28,7 @@ $S4="CAST_S_table3"; | |||
28 | 28 | ||
29 | &CAST_encrypt("CAST_encrypt",1); | 29 | &CAST_encrypt("CAST_encrypt",1); |
30 | &CAST_encrypt("CAST_decrypt",0); | 30 | &CAST_encrypt("CAST_decrypt",0); |
31 | &cbc("CAST_cbc_encrypt","CAST_encrypt","CAST_decrypt",1,4,5,3,-1,-1); | 31 | &cbc("CAST_cbc_encrypt","CAST_encrypt","CAST_decrypt",1,4,5,3,-1,-1) unless $main'openbsd; |
32 | 32 | ||
33 | &asm_finish(); | 33 | &asm_finish(); |
34 | 34 | ||
diff --git a/src/lib/libcrypto/cast/c_enc.c b/src/lib/libcrypto/cast/c_enc.c index 0fe2cffecc..e80f65b698 100644 --- a/src/lib/libcrypto/cast/c_enc.c +++ b/src/lib/libcrypto/cast/c_enc.c | |||
@@ -59,6 +59,7 @@ | |||
59 | #include <openssl/cast.h> | 59 | #include <openssl/cast.h> |
60 | #include "cast_lcl.h" | 60 | #include "cast_lcl.h" |
61 | 61 | ||
62 | #ifndef OPENBSD_CAST_ASM | ||
62 | void CAST_encrypt(CAST_LONG *data, CAST_KEY *key) | 63 | void CAST_encrypt(CAST_LONG *data, CAST_KEY *key) |
63 | { | 64 | { |
64 | register CAST_LONG l,r,*k,t; | 65 | register CAST_LONG l,r,*k,t; |
@@ -122,6 +123,7 @@ void CAST_decrypt(CAST_LONG *data, CAST_KEY *key) | |||
122 | data[1]=l&0xffffffffL; | 123 | data[1]=l&0xffffffffL; |
123 | data[0]=r&0xffffffffL; | 124 | data[0]=r&0xffffffffL; |
124 | } | 125 | } |
126 | #endif | ||
125 | 127 | ||
126 | void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, | 128 | void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, |
127 | CAST_KEY *ks, unsigned char *iv, int enc) | 129 | CAST_KEY *ks, unsigned char *iv, int enc) |
diff --git a/src/lib/libcrypto/des/asm/des-586.pl b/src/lib/libcrypto/des/asm/des-586.pl index b75d3c6b3a..60d577cc8d 100644 --- a/src/lib/libcrypto/des/asm/des-586.pl +++ b/src/lib/libcrypto/des/asm/des-586.pl | |||
@@ -22,10 +22,14 @@ $R="esi"; | |||
22 | &external_label("DES_SPtrans"); | 22 | &external_label("DES_SPtrans"); |
23 | &DES_encrypt("DES_encrypt1",1); | 23 | &DES_encrypt("DES_encrypt1",1); |
24 | &DES_encrypt("DES_encrypt2",0); | 24 | &DES_encrypt("DES_encrypt2",0); |
25 | &DES_encrypt3("DES_encrypt3",1); | 25 | |
26 | &DES_encrypt3("DES_decrypt3",0); | 26 | if (!$main'openbsd) |
27 | &cbc("DES_ncbc_encrypt","DES_encrypt1","DES_encrypt1",0,4,5,3,5,-1); | 27 | { |
28 | &cbc("DES_ede3_cbc_encrypt","DES_encrypt3","DES_decrypt3",0,6,7,3,4,5); | 28 | &DES_encrypt3("DES_encrypt3",1); |
29 | &DES_encrypt3("DES_decrypt3",0); | ||
30 | &cbc("DES_ncbc_encrypt","DES_encrypt1","DES_encrypt1",0,4,5,3,5,-1); | ||
31 | &cbc("DES_ede3_cbc_encrypt","DES_encrypt3","DES_decrypt3",0,6,7,3,4,5); | ||
32 | } | ||
29 | 33 | ||
30 | &asm_finish(); | 34 | &asm_finish(); |
31 | 35 | ||
diff --git a/src/lib/libcrypto/des/des_enc.c b/src/lib/libcrypto/des/des_enc.c index 1c37ab96d3..4f09804c44 100644 --- a/src/lib/libcrypto/des/des_enc.c +++ b/src/lib/libcrypto/des/des_enc.c | |||
@@ -58,6 +58,7 @@ | |||
58 | 58 | ||
59 | #include "des_locl.h" | 59 | #include "des_locl.h" |
60 | 60 | ||
61 | #ifndef OPENBSD_DES_ASM | ||
61 | void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) | 62 | void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) |
62 | { | 63 | { |
63 | register DES_LONG l,r,t,u; | 64 | register DES_LONG l,r,t,u; |
@@ -246,6 +247,7 @@ void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc) | |||
246 | data[1]=ROTATE(r,3)&0xffffffffL; | 247 | data[1]=ROTATE(r,3)&0xffffffffL; |
247 | l=r=t=u=0; | 248 | l=r=t=u=0; |
248 | } | 249 | } |
250 | #endif | ||
249 | 251 | ||
250 | void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, | 252 | void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, |
251 | DES_key_schedule *ks2, DES_key_schedule *ks3) | 253 | DES_key_schedule *ks2, DES_key_schedule *ks3) |
diff --git a/src/lib/libcrypto/perlasm/x86asm.pl b/src/lib/libcrypto/perlasm/x86asm.pl index 1cb96e914a..7c675e3ced 100644 --- a/src/lib/libcrypto/perlasm/x86asm.pl +++ b/src/lib/libcrypto/perlasm/x86asm.pl | |||
@@ -18,9 +18,13 @@ sub main'asm_init | |||
18 | ($type,$fn,$i386)=@_; | 18 | ($type,$fn,$i386)=@_; |
19 | $filename=$fn; | 19 | $filename=$fn; |
20 | 20 | ||
21 | $elf=$cpp=$sol=$aout=$win32=$gaswin=0; | 21 | $elf=$cpp=$sol=$aout=$win32=$gaswin=$openbsd=0; |
22 | if ( ($type eq "elf")) | 22 | if ( ($type eq "elf")) |
23 | { $elf=1; require "x86unix.pl"; } | 23 | { $elf=1; require "x86unix.pl"; } |
24 | elsif ( ($type eq "openbsd-elf")) | ||
25 | { $openbsd=$elf=1; require "x86unix.pl"; } | ||
26 | elsif ( ($type eq "openbsd-a.out")) | ||
27 | { $openbsd=1; require "x86unix.pl"; } | ||
24 | elsif ( ($type eq "a.out")) | 28 | elsif ( ($type eq "a.out")) |
25 | { $aout=1; require "x86unix.pl"; } | 29 | { $aout=1; require "x86unix.pl"; } |
26 | elsif ( ($type eq "gaswin")) | 30 | elsif ( ($type eq "gaswin")) |
@@ -43,6 +47,8 @@ Pick one target type from | |||
43 | cpp - format so x86unix.cpp can be used | 47 | cpp - format so x86unix.cpp can be used |
44 | win32 - Windows 95/Windows NT | 48 | win32 - Windows 95/Windows NT |
45 | win32n - Windows 95/Windows NT NASM format | 49 | win32n - Windows 95/Windows NT NASM format |
50 | openbsd-elf - OpenBSD elf | ||
51 | openbsd-a.out - OpenBSD a.out | ||
46 | EOF | 52 | EOF |
47 | exit(1); | 53 | exit(1); |
48 | } | 54 | } |
diff --git a/src/lib/libcrypto/perlasm/x86unix.pl b/src/lib/libcrypto/perlasm/x86unix.pl index 10b669bf04..53ad5f4927 100644 --- a/src/lib/libcrypto/perlasm/x86unix.pl +++ b/src/lib/libcrypto/perlasm/x86unix.pl | |||
@@ -15,6 +15,12 @@ sub main'asm_get_output { return(@out); } | |||
15 | sub main'get_labels { return(@labels); } | 15 | sub main'get_labels { return(@labels); } |
16 | sub main'external_label { push(@labels,@_); } | 16 | sub main'external_label { push(@labels,@_); } |
17 | 17 | ||
18 | if ($main'openbsd) | ||
19 | { | ||
20 | $com_start='/*'; | ||
21 | $com_end='*/'; | ||
22 | } | ||
23 | |||
18 | if ($main'cpp) | 24 | if ($main'cpp) |
19 | { | 25 | { |
20 | $align="ALIGN"; | 26 | $align="ALIGN"; |
@@ -276,6 +282,9 @@ sub main'file | |||
276 | { | 282 | { |
277 | local($file)=@_; | 283 | local($file)=@_; |
278 | 284 | ||
285 | if ($main'openbsd) | ||
286 | { push(@out,"#include <machine/asm.h>\n"); return; } | ||
287 | |||
279 | local($tmp)=<<"EOF"; | 288 | local($tmp)=<<"EOF"; |
280 | .file "$file.s" | 289 | .file "$file.s" |
281 | .version "01.01" | 290 | .version "01.01" |
@@ -291,6 +300,9 @@ sub main'function_begin | |||
291 | &main'external_label($func); | 300 | &main'external_label($func); |
292 | $func=$under.$func; | 301 | $func=$under.$func; |
293 | 302 | ||
303 | if ($main'openbsd) | ||
304 | { push (@out, "\nENTRY($func)\n"); goto skip; } | ||
305 | |||
294 | local($tmp)=<<"EOF"; | 306 | local($tmp)=<<"EOF"; |
295 | .text | 307 | .text |
296 | .align $align | 308 | .align $align |
@@ -303,6 +315,7 @@ EOF | |||
303 | { $tmp=push(@out,"\t.def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); } | 315 | { $tmp=push(@out,"\t.def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); } |
304 | else { $tmp=push(@out,"\t.type\t$func,\@function\n"); } | 316 | else { $tmp=push(@out,"\t.type\t$func,\@function\n"); } |
305 | push(@out,"$func:\n"); | 317 | push(@out,"$func:\n"); |
318 | skip: | ||
306 | $tmp=<<"EOF"; | 319 | $tmp=<<"EOF"; |
307 | pushl %ebp | 320 | pushl %ebp |
308 | pushl %ebx | 321 | pushl %ebx |
@@ -321,6 +334,9 @@ sub main'function_begin_B | |||
321 | &main'external_label($func); | 334 | &main'external_label($func); |
322 | $func=$under.$func; | 335 | $func=$under.$func; |
323 | 336 | ||
337 | if ($main'openbsd) | ||
338 | { push(@out, "\nENTRY($func)\n"); goto skip; } | ||
339 | |||
324 | local($tmp)=<<"EOF"; | 340 | local($tmp)=<<"EOF"; |
325 | .text | 341 | .text |
326 | .align $align | 342 | .align $align |
@@ -333,6 +349,7 @@ EOF | |||
333 | { $tmp=push(@out,"\t.def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); } | 349 | { $tmp=push(@out,"\t.def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); } |
334 | else { push(@out,"\t.type $func,\@function\n"); } | 350 | else { push(@out,"\t.type $func,\@function\n"); } |
335 | push(@out,"$func:\n"); | 351 | push(@out,"$func:\n"); |
352 | skip: | ||
336 | $stack=4; | 353 | $stack=4; |
337 | } | 354 | } |
338 | 355 | ||
@@ -429,7 +446,8 @@ sub main'swtmp | |||
429 | 446 | ||
430 | sub main'comment | 447 | sub main'comment |
431 | { | 448 | { |
432 | if ($main'elf) # GNU and SVR4 as'es use different comment delimiters, | 449 | if (!$main'openbsd && $main'elf) |
450 | # GNU and SVR4 as'es use different comment delimiters, | ||
433 | { # so we just skip comments... | 451 | { # so we just skip comments... |
434 | push(@out,"\n"); | 452 | push(@out,"\n"); |
435 | return; | 453 | return; |
@@ -460,7 +478,10 @@ sub main'set_label | |||
460 | $label{$_[0]}=".${label}${_[0]}"; | 478 | $label{$_[0]}=".${label}${_[0]}"; |
461 | $label++; | 479 | $label++; |
462 | } | 480 | } |
463 | push(@out,".align $align\n") if ($_[1] != 0); | 481 | if ($main'openbsd) |
482 | { push(@out,"_ALIGN_TEXT\n") if ($_[1] != 0); } | ||
483 | else | ||
484 | { push(@out,".align $align\n") if ($_[1] != 0); } | ||
464 | push(@out,"$label{$_[0]}:\n"); | 485 | push(@out,"$label{$_[0]}:\n"); |
465 | } | 486 | } |
466 | 487 | ||
@@ -569,6 +590,16 @@ sub main'picmeup | |||
569 | ___ | 590 | ___ |
570 | push(@out,$tmp); | 591 | push(@out,$tmp); |
571 | } | 592 | } |
593 | elsif ($main'openbsd) | ||
594 | { | ||
595 | push(@out, "#ifdef PIC\n"); | ||
596 | push(@out, "\tPIC_PROLOGUE\n"); | ||
597 | &main'mov($dst,"PIC_GOT($sym)"); | ||
598 | push(@out, "\tPIC_EPILOGUE\n"); | ||
599 | push(@out, "#else\n"); | ||
600 | &main'lea($dst,&main'DWP($sym)); | ||
601 | push(@out, "#endif\n"); | ||
602 | } | ||
572 | elsif ($main'pic && ($main'elf || $main'aout)) | 603 | elsif ($main'pic && ($main'elf || $main'aout)) |
573 | { | 604 | { |
574 | push(@out,"\t.align\t8\n"); | 605 | push(@out,"\t.align\t8\n"); |
diff --git a/src/lib/libssl/crypto/Makefile b/src/lib/libssl/crypto/Makefile index dead23398f..18c744d706 100644 --- a/src/lib/libssl/crypto/Makefile +++ b/src/lib/libssl/crypto/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: Makefile,v 1.31 2003/06/02 08:45:58 markus Exp $ | 1 | # $OpenBSD: Makefile,v 1.32 2003/11/18 12:39:05 markus Exp $ |
2 | 2 | ||
3 | LIB= crypto | 3 | LIB= crypto |
4 | 4 | ||
@@ -53,17 +53,17 @@ SRCS+= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \ | |||
53 | des_old.c read2pwd.c | 53 | des_old.c read2pwd.c |
54 | SRCS+= rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c | 54 | SRCS+= rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c |
55 | SRCS+= rc2ofb64.c | 55 | SRCS+= rc2ofb64.c |
56 | SRCS+= rc4_skey.c rc4_enc.c | 56 | SRCS+= rc4_skey.c |
57 | #SRCS+= rc5_skey.c rc5_ecb.c rc5cfb64.c rc5cfb64.c | 57 | #SRCS+= rc5_skey.c rc5_ecb.c rc5cfb64.c rc5cfb64.c |
58 | #SRCS+= rc5ofb64.c rc5_enc.c | 58 | #SRCS+= rc5ofb64.c rc5_enc.c |
59 | #SRCS+= i_cbc.c i_cfb64.c i_ofb64.c i_ecb.c | 59 | #SRCS+= i_cbc.c i_cfb64.c i_ofb64.c i_ecb.c |
60 | #SRCS+= i_skey.c | 60 | #SRCS+= i_skey.c |
61 | SRCS+= bf_skey.c bf_ecb.c bf_cfb64.c bf_ofb64.c bf_enc.c | 61 | SRCS+= bf_skey.c bf_ecb.c bf_cfb64.c bf_ofb64.c |
62 | SRCS+= c_skey.c c_ecb.c c_cfb64.c c_ofb64.c c_enc.c | 62 | SRCS+= c_skey.c c_ecb.c c_cfb64.c c_ofb64.c c_enc.c |
63 | SRCS+= bn_add.c bn_div.c bn_exp.c bn_lib.c | 63 | SRCS+= bn_add.c bn_div.c bn_exp.c bn_lib.c |
64 | SRCS+= bn_mul.c bn_print.c bn_rand.c bn_shift.c | 64 | SRCS+= bn_mul.c bn_print.c bn_rand.c bn_shift.c |
65 | SRCS+= bn_word.c bn_blind.c bn_gcd.c bn_prime.c bn_err.c | 65 | SRCS+= bn_word.c bn_blind.c bn_gcd.c bn_prime.c bn_err.c |
66 | SRCS+= bn_sqr.c bn_recp.c bn_mont.c bn_mpi.c bn_asm.c bn_mod.c | 66 | SRCS+= bn_sqr.c bn_recp.c bn_mont.c bn_mpi.c bn_mod.c |
67 | SRCS+= bn_exp2.c bn_ctx.c | 67 | SRCS+= bn_exp2.c bn_ctx.c |
68 | SRCS+= bn_sqrt.c bn_kron.c | 68 | SRCS+= bn_sqrt.c bn_kron.c |
69 | SRCS+= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c | 69 | SRCS+= rsa_eay.c rsa_gen.c rsa_lib.c rsa_sign.c |
@@ -151,7 +151,8 @@ SRCS+= ec_err.c ec_mult.c ecp_nist.c ecp_smpl.c | |||
151 | ${LCRYPTO_SRC}/pkcs7 ${LCRYPTO_SRC}/x509v3 ${LCRYPTO_SRC}/pkcs12 \ | 151 | ${LCRYPTO_SRC}/pkcs7 ${LCRYPTO_SRC}/x509v3 ${LCRYPTO_SRC}/pkcs12 \ |
152 | ${LCRYPTO_SRC}/comp ${LCRYPTO_SRC}/txt_db ${LCRYPTO_SRC}/md4 \ | 152 | ${LCRYPTO_SRC}/comp ${LCRYPTO_SRC}/txt_db ${LCRYPTO_SRC}/md4 \ |
153 | ${LCRYPTO_SRC}/engine ${LCRYPTO_SRC}/dso ${LCRYPTO_SRC}/ui \ | 153 | ${LCRYPTO_SRC}/engine ${LCRYPTO_SRC}/dso ${LCRYPTO_SRC}/ui \ |
154 | ${LCRYPTO_SRC}/ocsp ${LCRYPTO_SRC}/ec ${LCRYPTO_SRC}/aes ${LCRYPTO_SRC} | 154 | ${LCRYPTO_SRC}/ocsp ${LCRYPTO_SRC}/ec ${LCRYPTO_SRC}/aes ${LCRYPTO_SRC} \ |
155 | ${.CURDIR}/arch/${MACHINE_ARCH} | ||
155 | 156 | ||
156 | HDRS=\ | 157 | HDRS=\ |
157 | crypto/aes/aes.h \ | 158 | crypto/aes/aes.h \ |
@@ -260,6 +261,42 @@ des_enc.po: | |||
260 | ${CC} ${CFLAGS} -O1 ${CPPFLAGS} -c ${.IMPSRC} -o $@ | 261 | ${CC} ${CFLAGS} -O1 ${CPPFLAGS} -c ${.IMPSRC} -o $@ |
261 | .endif | 262 | .endif |
262 | 263 | ||
264 | .if (${MACHINE_ARCH} == "i386") | ||
265 | CFLAGS+= -DMD5_ASM | ||
266 | CFLAGS+= -DSHA1_ASM | ||
267 | CFLAGS+= -DRMD160_ASM | ||
268 | CFLAGS+= -DOPENBSD_CAST_ASM | ||
269 | CFLAGS+= -DOPENBSD_DES_ASM | ||
270 | SSLASM=\ | ||
271 | bf bf-586 \ | ||
272 | bn bn-586 \ | ||
273 | bn co-586 \ | ||
274 | cast cast-586 \ | ||
275 | des des-586 \ | ||
276 | md5 md5-586 \ | ||
277 | rc4 rc4-586 \ | ||
278 | ripemd rmd-586 \ | ||
279 | sha sha1-586 | ||
280 | .for dir f in ${SSLASM} | ||
281 | SRCS+= ${f}.S | ||
282 | GENERATED+=${f}.S | ||
283 | ${f}.S: ${LCRYPTO_SRC}/${dir}/asm/${f}.pl ${LCRYPTO_SRC}/perlasm/x86unix.pl | ||
284 | /usr/bin/perl -I${LCRYPTO_SRC}/perlasm:${LCRYPTO_SRC}/${dir}/asm \ | ||
285 | ${LCRYPTO_SRC}/${dir}/asm/${f}.pl openbsd-elf 386 > ${.TARGET} | ||
286 | .endfor | ||
287 | SRCS+= bf_cbc.c | ||
288 | .else | ||
289 | .if (${MACHINE_ARCH} == "vax") | ||
290 | SRCS+= bf_enc.c | ||
291 | SRCS+= bn_asm_vax.S | ||
292 | SRCS+= rc4_enc.c | ||
293 | .else | ||
294 | SRCS+= bf_enc.c | ||
295 | SRCS+= bn_asm.c | ||
296 | SRCS+= rc4_enc.c | ||
297 | .endif | ||
298 | .endif | ||
299 | |||
263 | all beforedepend: ${GENERATED} | 300 | all beforedepend: ${GENERATED} |
264 | 301 | ||
265 | .include <bsd.lib.mk> | 302 | .include <bsd.lib.mk> |
diff --git a/src/lib/libssl/crypto/arch/vax/bn_asm_vax.S b/src/lib/libssl/crypto/arch/vax/bn_asm_vax.S new file mode 100644 index 0000000000..bd067a55d3 --- /dev/null +++ b/src/lib/libssl/crypto/arch/vax/bn_asm_vax.S | |||
@@ -0,0 +1,436 @@ | |||
1 | # $OpenBSD: bn_asm_vax.S,v 1.1 2003/11/18 12:39:05 markus Exp $ | ||
2 | # $NetBSD: bn_asm_vax.S,v 1.1 2003/11/03 10:22:28 ragge Exp $ | ||
3 | |||
4 | #include <machine/asm.h> | ||
5 | |||
6 | # w.j.m. 15-jan-1999 | ||
7 | # | ||
8 | # it's magic ... | ||
9 | # | ||
10 | # ULONG bn_mul_add_words(ULONG r[],ULONG a[],int n,ULONG w) { | ||
11 | # ULONG c = 0; | ||
12 | # int i; | ||
13 | # for(i = 0; i < n; i++) <c,r[i]> := r[i] + c + a[i] * w ; | ||
14 | # return c; | ||
15 | # } | ||
16 | |||
17 | ENTRY(bn_mul_add_words,R6) | ||
18 | movl 4(ap),r2 # *r | ||
19 | movl 8(ap),r3 # *a | ||
20 | movl 12(ap),r4 # n | ||
21 | movl 16(ap),r5 # w | ||
22 | clrl r6 # return value ("carry") | ||
23 | |||
24 | 0: emul r5,(r3),(r2),r0 # w * a[0] + r[0] -> r0 | ||
25 | |||
26 | # fixup for "negative" r[] | ||
27 | tstl (r2) | ||
28 | bgeq 1f | ||
29 | incl r1 # add 1 to highword | ||
30 | |||
31 | 1: # add saved carry to result | ||
32 | addl2 r6,r0 | ||
33 | adwc $0,r1 | ||
34 | |||
35 | # combined fixup for "negative" w, a[] | ||
36 | tstl r5 # if w is negative... | ||
37 | bgeq 1f | ||
38 | addl2 (r3),r1 # ...add a[0] again to highword | ||
39 | 1: tstl (r3) # if a[0] is negative... | ||
40 | bgeq 1f | ||
41 | addl2 r5,r1 # ...add w again to highword | ||
42 | 1: | ||
43 | movl r0,(r2)+ # save low word in dest & advance *r | ||
44 | addl2 $4,r3 # advance *a | ||
45 | movl r1,r6 # high word in r6 for return value | ||
46 | |||
47 | sobgtr r4,0b # loop? | ||
48 | |||
49 | movl r6,r0 | ||
50 | ret | ||
51 | |||
52 | # .title vax_bn_mul_words unsigned multiply & add, 32*32+32=>64 | ||
53 | #; | ||
54 | #; w.j.m. 15-jan-1999 | ||
55 | #; | ||
56 | #; it's magic ... | ||
57 | #; | ||
58 | #; ULONG bn_mul_words(ULONG r[],ULONG a[],int n,ULONG w) { | ||
59 | #; ULONG c = 0; | ||
60 | #; int i; | ||
61 | #; for(i = 0; i < num; i++) <c,r[i]> := a[i] * w + c ; | ||
62 | #; return(c); | ||
63 | #; } | ||
64 | # | ||
65 | |||
66 | ENTRY(bn_mul_words,R6) | ||
67 | movl 4(ap),r2 # *r | ||
68 | movl 8(ap),r3 # *a | ||
69 | movl 12(ap),r4 # n | ||
70 | movl 16(ap),r5 # w | ||
71 | clrl r6 # carry | ||
72 | |||
73 | 0: emul r5,(r3),r6,r0 # w * a[0] + carry -> r0 | ||
74 | |||
75 | # fixup for "negative" carry | ||
76 | tstl r6 | ||
77 | bgeq 1f | ||
78 | incl r1 | ||
79 | |||
80 | 1: # combined fixup for "negative" w, a[] | ||
81 | tstl r5 | ||
82 | bgeq 1f | ||
83 | addl2 (r3),r1 | ||
84 | 1: tstl (r3) | ||
85 | bgeq 1f | ||
86 | addl2 r5,r1 | ||
87 | |||
88 | 1: movl r0,(r2)+ | ||
89 | addl2 $4,r3 | ||
90 | movl r1,r6 | ||
91 | |||
92 | sobgtr r4,0b | ||
93 | |||
94 | movl r6,r0 | ||
95 | ret | ||
96 | |||
97 | |||
98 | |||
99 | # .title vax_bn_sqr_words unsigned square, 32*32=>64 | ||
100 | #; | ||
101 | #; w.j.m. 15-jan-1999 | ||
102 | #; | ||
103 | #; it's magic ... | ||
104 | #; | ||
105 | #; void bn_sqr_words(ULONG r[],ULONG a[],int n) { | ||
106 | #; int i; | ||
107 | #; for(i = 0; i < n; i++) <r[2*i+1],r[2*i]> := a[i] * a[i] ; | ||
108 | #; } | ||
109 | # | ||
110 | |||
111 | ENTRY(bn_sqr_words,0) | ||
112 | movl 4(ap),r2 # r | ||
113 | movl 8(ap),r3 # a | ||
114 | movl 12(ap),r4 # n | ||
115 | |||
116 | 0: movl (r3)+,r5 # r5 = a[] & advance | ||
117 | |||
118 | emul r5,r5,$0,r0 # a[0] * a[0] + 0 -> r0 | ||
119 | |||
120 | # fixup for "negative" a[] | ||
121 | tstl r5 | ||
122 | bgeq 1f | ||
123 | addl2 r5,r1 | ||
124 | addl2 r5,r1 | ||
125 | |||
126 | 1: movq r0,(r2)+ # store 64-bit result | ||
127 | |||
128 | sobgtr r4,0b # loop | ||
129 | |||
130 | ret | ||
131 | |||
132 | |||
133 | # .title vax_bn_div_words unsigned divide | ||
134 | #; | ||
135 | #; Richard Levitte 20-Nov-2000 | ||
136 | #; | ||
137 | #; ULONG bn_div_words(ULONG h, ULONG l, ULONG d) | ||
138 | #; { | ||
139 | #; return ((ULONG)((((ULLONG)h)<<32)|l) / (ULLONG)d); | ||
140 | #; } | ||
141 | #; | ||
142 | #; Using EDIV would be very easy, if it didn't do signed calculations. | ||
143 | #; Any time any of the input numbers are signed, there are problems, | ||
144 | #; usually with integer overflow, at which point it returns useless | ||
145 | #; data (the quotient gets the value of l, and the remainder becomes 0). | ||
146 | #; | ||
147 | #; If it was just for the dividend, it would be very easy, just divide | ||
148 | #; it by 2 (unsigned), do the division, multiply the resulting quotient | ||
149 | #; and remainder by 2, add the bit that was dropped when dividing by 2 | ||
150 | #; to the remainder, and do some adjustment so the remainder doesn't | ||
151 | #; end up larger than the divisor. For some cases when the divisor is | ||
152 | #; negative (from EDIV's point of view, i.e. when the highest bit is set), | ||
153 | #; dividing the dividend by 2 isn't enough, and since some operations | ||
154 | #; might generate integer overflows even when the dividend is divided by | ||
155 | #; 4 (when the high part of the shifted down dividend ends up being exactly | ||
156 | #; half of the divisor, the result is the quotient 0x80000000, which is | ||
157 | #; negative...) it needs to be divided by 8. Furthermore, the divisor needs | ||
158 | #; to be divided by 2 (unsigned) as well, to avoid more problems with the sign. | ||
159 | #; In this case, a little extra fiddling with the remainder is required. | ||
160 | #; | ||
161 | #; So, the simplest way to handle this is always to divide the dividend | ||
162 | #; by 8, and to divide the divisor by 2 if it's highest bit is set. | ||
163 | #; After EDIV has been used, the quotient gets multiplied by 8 if the | ||
164 | #; original divisor was positive, otherwise 4. The remainder, oddly | ||
165 | #; enough, is *always* multiplied by 8. | ||
166 | #; NOTE: in the case mentioned above, where the high part of the shifted | ||
167 | #; down dividend ends up being exactly half the shifted down divisor, we | ||
168 | #; end up with a 33 bit quotient. That's no problem however, it usually | ||
169 | #; means we have ended up with a too large remainder as well, and the | ||
170 | #; problem is fixed by the last part of the algorithm (next paragraph). | ||
171 | #; | ||
172 | #; The routine ends with comparing the resulting remainder with the | ||
173 | #; original divisor and if the remainder is larger, subtract the | ||
174 | #; original divisor from it, and increase the quotient by 1. This is | ||
175 | #; done until the remainder is smaller than the divisor. | ||
176 | #; | ||
177 | #; The complete algorithm looks like this: | ||
178 | #; | ||
179 | #; d' = d | ||
180 | #; l' = l & 7 | ||
181 | #; [h,l] = [h,l] >> 3 | ||
182 | #; [q,r] = floor([h,l] / d) # This is the EDIV operation | ||
183 | #; if (q < 0) q = -q # I doubt this is necessary any more | ||
184 | #; | ||
185 | #; r' = r >> 29 | ||
186 | #; if (d' >= 0) | ||
187 | #; q' = q >> 29 | ||
188 | #; q = q << 3 | ||
189 | #; else | ||
190 | #; q' = q >> 30 | ||
191 | #; q = q << 2 | ||
192 | #; r = (r << 3) + l' | ||
193 | #; | ||
194 | #; if (d' < 0) | ||
195 | #; { | ||
196 | #; [r',r] = [r',r] - q | ||
197 | #; while ([r',r] < 0) | ||
198 | #; { | ||
199 | #; [r',r] = [r',r] + d | ||
200 | #; [q',q] = [q',q] - 1 | ||
201 | #; } | ||
202 | #; } | ||
203 | #; | ||
204 | #; while ([r',r] >= d') | ||
205 | #; { | ||
206 | #; [r',r] = [r',r] - d' | ||
207 | #; [q',q] = [q',q] + 1 | ||
208 | #; } | ||
209 | #; | ||
210 | #; return q | ||
211 | # | ||
212 | #;r2 = l, q | ||
213 | #;r3 = h, r | ||
214 | #;r4 = d | ||
215 | #;r5 = l' | ||
216 | #;r6 = r' | ||
217 | #;r7 = d' | ||
218 | #;r8 = q' | ||
219 | # | ||
220 | |||
221 | ENTRY(bn_div_words,R6|R7|R8) | ||
222 | movl 4(ap),r3 # h | ||
223 | movl 8(ap),r2 # l | ||
224 | movl 12(ap),r4 # d | ||
225 | |||
226 | bicl3 $-8,r2,r5 # l' = l & 7 | ||
227 | bicl3 $7,r2,r2 | ||
228 | |||
229 | bicl3 $-8,r3,r6 | ||
230 | bicl3 $7,r3,r3 | ||
231 | |||
232 | addl2 r6,r2 | ||
233 | |||
234 | rotl $-3,r2,r2 # l = l >> 3 | ||
235 | rotl $-3,r3,r3 # h = h >> 3 | ||
236 | |||
237 | movl r4,r7 # d' = d | ||
238 | |||
239 | clrl r6 # r' = 0 | ||
240 | clrl r8 # q' = 0 | ||
241 | |||
242 | tstl r4 | ||
243 | beql 0f # Uh-oh, the divisor is 0... | ||
244 | bgtr 1f | ||
245 | rotl $-1,r4,r4 # If d is negative, shift it right. | ||
246 | bicl2 $0x80000000,r4 # Since d is then a large number, the | ||
247 | # lowest bit is insignificant | ||
248 | # (contradict that, and I'll fix the problem!) | ||
249 | 1: | ||
250 | ediv r4,r2,r2,r3 # Do the actual division | ||
251 | |||
252 | tstl r2 | ||
253 | bgeq 1f | ||
254 | mnegl r2,r2 # if q < 0, negate it | ||
255 | 1: | ||
256 | tstl r7 | ||
257 | blss 1f | ||
258 | rotl $3,r2,r2 # q = q << 3 | ||
259 | bicl3 $-8,r2,r8 # q' gets the high bits from q | ||
260 | bicl3 $7,r2,r2 | ||
261 | brb 2f | ||
262 | |||
263 | 1: # else | ||
264 | rotl $2,r2,r2 # q = q << 2 | ||
265 | bicl3 $-4,r2,r8 # q' gets the high bits from q | ||
266 | bicl3 $3,r2,r2 | ||
267 | 2: | ||
268 | rotl $3,r3,r3 # r = r << 3 | ||
269 | bicl3 $-8,r3,r6 # r' gets the high bits from r | ||
270 | bicl3 $7,r3,r3 | ||
271 | addl2 r5,r3 # r = r + l' | ||
272 | |||
273 | tstl r7 | ||
274 | bgeq 5f | ||
275 | bitl $1,r7 | ||
276 | beql 5f # if d' < 0 && d' & 1 | ||
277 | subl2 r2,r3 # [r',r] = [r',r] - [q',q] | ||
278 | sbwc r8,r6 | ||
279 | 3: | ||
280 | bgeq 5f # while r < 0 | ||
281 | decl r2 # [q',q] = [q',q] - 1 | ||
282 | sbwc $0,r8 | ||
283 | addl2 r7,r3 # [r',r] = [r',r] + d' | ||
284 | adwc $0,r6 | ||
285 | brb 3b | ||
286 | |||
287 | # The return points are placed in the middle to keep a short distance from | ||
288 | # all the branch points | ||
289 | 1: | ||
290 | # movl r3,r1 | ||
291 | movl r2,r0 | ||
292 | ret | ||
293 | 0: | ||
294 | movl $-1,r0 | ||
295 | ret | ||
296 | 5: | ||
297 | tstl r6 | ||
298 | bneq 6f | ||
299 | cmpl r3,r7 | ||
300 | blssu 1b # while [r',r] >= d' | ||
301 | 6: | ||
302 | subl2 r7,r3 # [r',r] = [r',r] - d' | ||
303 | sbwc $0,r6 | ||
304 | incl r2 # [q',q] = [q',q] + 1 | ||
305 | adwc $0,r8 | ||
306 | brb 5b | ||
307 | |||
308 | |||
309 | |||
310 | # .title vax_bn_add_words unsigned add of two arrays | ||
311 | #; | ||
312 | #; Richard Levitte 20-Nov-2000 | ||
313 | #; | ||
314 | #; ULONG bn_add_words(ULONG r[], ULONG a[], ULONG b[], int n) { | ||
315 | #; ULONG c = 0; | ||
316 | #; int i; | ||
317 | #; for (i = 0; i < n; i++) <c,r[i]> = a[i] + b[i] + c; | ||
318 | #; return(c); | ||
319 | #; } | ||
320 | # | ||
321 | |||
322 | ENTRY(bn_add_words,0) | ||
323 | movl 4(ap),r2 # r | ||
324 | movl 8(ap),r3 # a | ||
325 | movl 12(ap),r4 # b | ||
326 | movl 16(ap),r5 # n | ||
327 | clrl r0 | ||
328 | |||
329 | tstl r5 | ||
330 | bleq 1f | ||
331 | |||
332 | 0: movl (r3)+,r1 # carry untouched | ||
333 | adwc (r4)+,r1 # carry used and touched | ||
334 | movl r1,(r2)+ # carry untouched | ||
335 | sobgtr r5,0b # carry untouched | ||
336 | |||
337 | adwc $0,r0 | ||
338 | 1: ret | ||
339 | |||
340 | #; | ||
341 | #; Richard Levitte 20-Nov-2000 | ||
342 | #; | ||
343 | #; ULONG bn_sub_words(ULONG r[], ULONG a[], ULONG b[], int n) { | ||
344 | #; ULONG c = 0; | ||
345 | #; int i; | ||
346 | #; for (i = 0; i < n; i++) <c,r[i]> = a[i] - b[i] - c; | ||
347 | #; return(c); | ||
348 | #; } | ||
349 | # | ||
350 | |||
351 | ENTRY(bn_sub_words,R6) | ||
352 | movl 4(ap),r2 # r | ||
353 | movl 8(ap),r3 # a | ||
354 | movl 12(ap),r4 # b | ||
355 | movl 16(ap),r5 # n | ||
356 | clrl r0 | ||
357 | |||
358 | tstl r5 | ||
359 | bleq 1f | ||
360 | |||
361 | 0: movl (r3)+,r6 # carry untouched | ||
362 | sbwc (r4)+,r6 # carry used and touched | ||
363 | movl r6,(r2)+ # carry untouched | ||
364 | sobgtr r5,0b # carry untouched | ||
365 | |||
366 | 1: adwc $0,r0 | ||
367 | ret | ||
368 | |||
369 | # | ||
370 | # Ragge 20-Sep-2003 | ||
371 | # | ||
372 | # Multiply a vector of 4/8 longword by another. | ||
373 | # Uses two loops and 16/64 emuls. | ||
374 | # | ||
375 | |||
376 | ENTRY(bn_mul_comba4,R6|R7|R8|R9) | ||
377 | movl $4,r9 # 4*4 | ||
378 | brb 6f | ||
379 | |||
380 | ENTRY(bn_mul_comba8,R6|R7|R8|R9) | ||
381 | movl $8,r9 # 8*8 | ||
382 | |||
383 | 6: movl 8(ap),r3 # a[] | ||
384 | movl 12(ap),r7 # b[] | ||
385 | brb 5f | ||
386 | |||
387 | ENTRY(bn_sqr_comba4,R6|R7|R8|R9) | ||
388 | movl $4,r9 # 4*4 | ||
389 | brb 0f | ||
390 | |||
391 | ENTRY(bn_sqr_comba8,R6|R7|R8|R9) | ||
392 | movl $8,r9 # 8*8 | ||
393 | |||
394 | 0: | ||
395 | movl 8(ap),r3 # a[] | ||
396 | movl r3,r7 # a[] | ||
397 | |||
398 | 5: movl 4(ap),r5 # r[] | ||
399 | movl r9,r8 | ||
400 | |||
401 | clrq (r5) # clear destinatino, for add. | ||
402 | clrq 8(r5) | ||
403 | clrq 16(r5) # these only needed for comba8 | ||
404 | clrq 24(r5) | ||
405 | |||
406 | 2: clrl r4 # carry | ||
407 | movl r9,r6 # inner loop count | ||
408 | movl (r7)+,r2 # value to multiply with | ||
409 | |||
410 | 1: emul r2,(r3),r4,r0 | ||
411 | tstl r4 | ||
412 | bgeq 3f | ||
413 | incl r1 | ||
414 | 3: tstl r2 | ||
415 | bgeq 3f | ||
416 | addl2 (r3),r1 | ||
417 | 3: tstl (r3) | ||
418 | bgeq 3f | ||
419 | addl2 r2,r1 | ||
420 | |||
421 | 3: addl2 r0,(r5)+ # add to destination | ||
422 | adwc $0,r1 # remember carry | ||
423 | movl r1,r4 # add carry in next emul | ||
424 | addl2 $4,r3 | ||
425 | sobgtr r6,1b | ||
426 | |||
427 | movl r4,(r5) # save highest add result | ||
428 | |||
429 | ashl $2,r9,r4 | ||
430 | subl2 r4,r3 | ||
431 | subl2 $4,r4 | ||
432 | subl2 r4,r5 | ||
433 | |||
434 | sobgtr r8,2b | ||
435 | |||
436 | ret | ||
diff --git a/src/lib/libssl/src/crypto/bf/asm/bf-586.pl b/src/lib/libssl/src/crypto/bf/asm/bf-586.pl index b556642c94..b5a4760d09 100644 --- a/src/lib/libssl/src/crypto/bf/asm/bf-586.pl +++ b/src/lib/libssl/src/crypto/bf/asm/bf-586.pl | |||
@@ -18,7 +18,7 @@ $tmp4="edx"; | |||
18 | 18 | ||
19 | &BF_encrypt("BF_encrypt",1); | 19 | &BF_encrypt("BF_encrypt",1); |
20 | &BF_encrypt("BF_decrypt",0); | 20 | &BF_encrypt("BF_decrypt",0); |
21 | &cbc("BF_cbc_encrypt","BF_encrypt","BF_decrypt",1,4,5,3,-1,-1); | 21 | &cbc("BF_cbc_encrypt","BF_encrypt","BF_decrypt",1,4,5,3,-1,-1) unless $main'openbsd; |
22 | &asm_finish(); | 22 | &asm_finish(); |
23 | 23 | ||
24 | sub BF_encrypt | 24 | sub BF_encrypt |
diff --git a/src/lib/libssl/src/crypto/bn/asm/bn-586.pl b/src/lib/libssl/src/crypto/bn/asm/bn-586.pl index 33f6125920..9a78f63be1 100644 --- a/src/lib/libssl/src/crypto/bn/asm/bn-586.pl +++ b/src/lib/libssl/src/crypto/bn/asm/bn-586.pl | |||
@@ -11,7 +11,7 @@ require "x86asm.pl"; | |||
11 | &bn_div_words("bn_div_words"); | 11 | &bn_div_words("bn_div_words"); |
12 | &bn_add_words("bn_add_words"); | 12 | &bn_add_words("bn_add_words"); |
13 | &bn_sub_words("bn_sub_words"); | 13 | &bn_sub_words("bn_sub_words"); |
14 | &bn_sub_part_words("bn_sub_part_words"); | 14 | &bn_sub_part_words("bn_sub_part_words") unless $main'openbsd; |
15 | 15 | ||
16 | &asm_finish(); | 16 | &asm_finish(); |
17 | 17 | ||
diff --git a/src/lib/libssl/src/crypto/cast/asm/cast-586.pl b/src/lib/libssl/src/crypto/cast/asm/cast-586.pl index 6be0bfe572..0ed55d1905 100644 --- a/src/lib/libssl/src/crypto/cast/asm/cast-586.pl +++ b/src/lib/libssl/src/crypto/cast/asm/cast-586.pl | |||
@@ -28,7 +28,7 @@ $S4="CAST_S_table3"; | |||
28 | 28 | ||
29 | &CAST_encrypt("CAST_encrypt",1); | 29 | &CAST_encrypt("CAST_encrypt",1); |
30 | &CAST_encrypt("CAST_decrypt",0); | 30 | &CAST_encrypt("CAST_decrypt",0); |
31 | &cbc("CAST_cbc_encrypt","CAST_encrypt","CAST_decrypt",1,4,5,3,-1,-1); | 31 | &cbc("CAST_cbc_encrypt","CAST_encrypt","CAST_decrypt",1,4,5,3,-1,-1) unless $main'openbsd; |
32 | 32 | ||
33 | &asm_finish(); | 33 | &asm_finish(); |
34 | 34 | ||
diff --git a/src/lib/libssl/src/crypto/cast/c_enc.c b/src/lib/libssl/src/crypto/cast/c_enc.c index 0fe2cffecc..e80f65b698 100644 --- a/src/lib/libssl/src/crypto/cast/c_enc.c +++ b/src/lib/libssl/src/crypto/cast/c_enc.c | |||
@@ -59,6 +59,7 @@ | |||
59 | #include <openssl/cast.h> | 59 | #include <openssl/cast.h> |
60 | #include "cast_lcl.h" | 60 | #include "cast_lcl.h" |
61 | 61 | ||
62 | #ifndef OPENBSD_CAST_ASM | ||
62 | void CAST_encrypt(CAST_LONG *data, CAST_KEY *key) | 63 | void CAST_encrypt(CAST_LONG *data, CAST_KEY *key) |
63 | { | 64 | { |
64 | register CAST_LONG l,r,*k,t; | 65 | register CAST_LONG l,r,*k,t; |
@@ -122,6 +123,7 @@ void CAST_decrypt(CAST_LONG *data, CAST_KEY *key) | |||
122 | data[1]=l&0xffffffffL; | 123 | data[1]=l&0xffffffffL; |
123 | data[0]=r&0xffffffffL; | 124 | data[0]=r&0xffffffffL; |
124 | } | 125 | } |
126 | #endif | ||
125 | 127 | ||
126 | void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, | 128 | void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, |
127 | CAST_KEY *ks, unsigned char *iv, int enc) | 129 | CAST_KEY *ks, unsigned char *iv, int enc) |
diff --git a/src/lib/libssl/src/crypto/des/asm/des-586.pl b/src/lib/libssl/src/crypto/des/asm/des-586.pl index b75d3c6b3a..60d577cc8d 100644 --- a/src/lib/libssl/src/crypto/des/asm/des-586.pl +++ b/src/lib/libssl/src/crypto/des/asm/des-586.pl | |||
@@ -22,10 +22,14 @@ $R="esi"; | |||
22 | &external_label("DES_SPtrans"); | 22 | &external_label("DES_SPtrans"); |
23 | &DES_encrypt("DES_encrypt1",1); | 23 | &DES_encrypt("DES_encrypt1",1); |
24 | &DES_encrypt("DES_encrypt2",0); | 24 | &DES_encrypt("DES_encrypt2",0); |
25 | &DES_encrypt3("DES_encrypt3",1); | 25 | |
26 | &DES_encrypt3("DES_decrypt3",0); | 26 | if (!$main'openbsd) |
27 | &cbc("DES_ncbc_encrypt","DES_encrypt1","DES_encrypt1",0,4,5,3,5,-1); | 27 | { |
28 | &cbc("DES_ede3_cbc_encrypt","DES_encrypt3","DES_decrypt3",0,6,7,3,4,5); | 28 | &DES_encrypt3("DES_encrypt3",1); |
29 | &DES_encrypt3("DES_decrypt3",0); | ||
30 | &cbc("DES_ncbc_encrypt","DES_encrypt1","DES_encrypt1",0,4,5,3,5,-1); | ||
31 | &cbc("DES_ede3_cbc_encrypt","DES_encrypt3","DES_decrypt3",0,6,7,3,4,5); | ||
32 | } | ||
29 | 33 | ||
30 | &asm_finish(); | 34 | &asm_finish(); |
31 | 35 | ||
diff --git a/src/lib/libssl/src/crypto/des/des_enc.c b/src/lib/libssl/src/crypto/des/des_enc.c index 1c37ab96d3..4f09804c44 100644 --- a/src/lib/libssl/src/crypto/des/des_enc.c +++ b/src/lib/libssl/src/crypto/des/des_enc.c | |||
@@ -58,6 +58,7 @@ | |||
58 | 58 | ||
59 | #include "des_locl.h" | 59 | #include "des_locl.h" |
60 | 60 | ||
61 | #ifndef OPENBSD_DES_ASM | ||
61 | void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) | 62 | void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) |
62 | { | 63 | { |
63 | register DES_LONG l,r,t,u; | 64 | register DES_LONG l,r,t,u; |
@@ -246,6 +247,7 @@ void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc) | |||
246 | data[1]=ROTATE(r,3)&0xffffffffL; | 247 | data[1]=ROTATE(r,3)&0xffffffffL; |
247 | l=r=t=u=0; | 248 | l=r=t=u=0; |
248 | } | 249 | } |
250 | #endif | ||
249 | 251 | ||
250 | void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, | 252 | void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, |
251 | DES_key_schedule *ks2, DES_key_schedule *ks3) | 253 | DES_key_schedule *ks2, DES_key_schedule *ks3) |
diff --git a/src/lib/libssl/src/crypto/perlasm/x86asm.pl b/src/lib/libssl/src/crypto/perlasm/x86asm.pl index 1cb96e914a..7c675e3ced 100644 --- a/src/lib/libssl/src/crypto/perlasm/x86asm.pl +++ b/src/lib/libssl/src/crypto/perlasm/x86asm.pl | |||
@@ -18,9 +18,13 @@ sub main'asm_init | |||
18 | ($type,$fn,$i386)=@_; | 18 | ($type,$fn,$i386)=@_; |
19 | $filename=$fn; | 19 | $filename=$fn; |
20 | 20 | ||
21 | $elf=$cpp=$sol=$aout=$win32=$gaswin=0; | 21 | $elf=$cpp=$sol=$aout=$win32=$gaswin=$openbsd=0; |
22 | if ( ($type eq "elf")) | 22 | if ( ($type eq "elf")) |
23 | { $elf=1; require "x86unix.pl"; } | 23 | { $elf=1; require "x86unix.pl"; } |
24 | elsif ( ($type eq "openbsd-elf")) | ||
25 | { $openbsd=$elf=1; require "x86unix.pl"; } | ||
26 | elsif ( ($type eq "openbsd-a.out")) | ||
27 | { $openbsd=1; require "x86unix.pl"; } | ||
24 | elsif ( ($type eq "a.out")) | 28 | elsif ( ($type eq "a.out")) |
25 | { $aout=1; require "x86unix.pl"; } | 29 | { $aout=1; require "x86unix.pl"; } |
26 | elsif ( ($type eq "gaswin")) | 30 | elsif ( ($type eq "gaswin")) |
@@ -43,6 +47,8 @@ Pick one target type from | |||
43 | cpp - format so x86unix.cpp can be used | 47 | cpp - format so x86unix.cpp can be used |
44 | win32 - Windows 95/Windows NT | 48 | win32 - Windows 95/Windows NT |
45 | win32n - Windows 95/Windows NT NASM format | 49 | win32n - Windows 95/Windows NT NASM format |
50 | openbsd-elf - OpenBSD elf | ||
51 | openbsd-a.out - OpenBSD a.out | ||
46 | EOF | 52 | EOF |
47 | exit(1); | 53 | exit(1); |
48 | } | 54 | } |
diff --git a/src/lib/libssl/src/crypto/perlasm/x86unix.pl b/src/lib/libssl/src/crypto/perlasm/x86unix.pl index 10b669bf04..53ad5f4927 100644 --- a/src/lib/libssl/src/crypto/perlasm/x86unix.pl +++ b/src/lib/libssl/src/crypto/perlasm/x86unix.pl | |||
@@ -15,6 +15,12 @@ sub main'asm_get_output { return(@out); } | |||
15 | sub main'get_labels { return(@labels); } | 15 | sub main'get_labels { return(@labels); } |
16 | sub main'external_label { push(@labels,@_); } | 16 | sub main'external_label { push(@labels,@_); } |
17 | 17 | ||
18 | if ($main'openbsd) | ||
19 | { | ||
20 | $com_start='/*'; | ||
21 | $com_end='*/'; | ||
22 | } | ||
23 | |||
18 | if ($main'cpp) | 24 | if ($main'cpp) |
19 | { | 25 | { |
20 | $align="ALIGN"; | 26 | $align="ALIGN"; |
@@ -276,6 +282,9 @@ sub main'file | |||
276 | { | 282 | { |
277 | local($file)=@_; | 283 | local($file)=@_; |
278 | 284 | ||
285 | if ($main'openbsd) | ||
286 | { push(@out,"#include <machine/asm.h>\n"); return; } | ||
287 | |||
279 | local($tmp)=<<"EOF"; | 288 | local($tmp)=<<"EOF"; |
280 | .file "$file.s" | 289 | .file "$file.s" |
281 | .version "01.01" | 290 | .version "01.01" |
@@ -291,6 +300,9 @@ sub main'function_begin | |||
291 | &main'external_label($func); | 300 | &main'external_label($func); |
292 | $func=$under.$func; | 301 | $func=$under.$func; |
293 | 302 | ||
303 | if ($main'openbsd) | ||
304 | { push (@out, "\nENTRY($func)\n"); goto skip; } | ||
305 | |||
294 | local($tmp)=<<"EOF"; | 306 | local($tmp)=<<"EOF"; |
295 | .text | 307 | .text |
296 | .align $align | 308 | .align $align |
@@ -303,6 +315,7 @@ EOF | |||
303 | { $tmp=push(@out,"\t.def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); } | 315 | { $tmp=push(@out,"\t.def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); } |
304 | else { $tmp=push(@out,"\t.type\t$func,\@function\n"); } | 316 | else { $tmp=push(@out,"\t.type\t$func,\@function\n"); } |
305 | push(@out,"$func:\n"); | 317 | push(@out,"$func:\n"); |
318 | skip: | ||
306 | $tmp=<<"EOF"; | 319 | $tmp=<<"EOF"; |
307 | pushl %ebp | 320 | pushl %ebp |
308 | pushl %ebx | 321 | pushl %ebx |
@@ -321,6 +334,9 @@ sub main'function_begin_B | |||
321 | &main'external_label($func); | 334 | &main'external_label($func); |
322 | $func=$under.$func; | 335 | $func=$under.$func; |
323 | 336 | ||
337 | if ($main'openbsd) | ||
338 | { push(@out, "\nENTRY($func)\n"); goto skip; } | ||
339 | |||
324 | local($tmp)=<<"EOF"; | 340 | local($tmp)=<<"EOF"; |
325 | .text | 341 | .text |
326 | .align $align | 342 | .align $align |
@@ -333,6 +349,7 @@ EOF | |||
333 | { $tmp=push(@out,"\t.def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); } | 349 | { $tmp=push(@out,"\t.def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); } |
334 | else { push(@out,"\t.type $func,\@function\n"); } | 350 | else { push(@out,"\t.type $func,\@function\n"); } |
335 | push(@out,"$func:\n"); | 351 | push(@out,"$func:\n"); |
352 | skip: | ||
336 | $stack=4; | 353 | $stack=4; |
337 | } | 354 | } |
338 | 355 | ||
@@ -429,7 +446,8 @@ sub main'swtmp | |||
429 | 446 | ||
430 | sub main'comment | 447 | sub main'comment |
431 | { | 448 | { |
432 | if ($main'elf) # GNU and SVR4 as'es use different comment delimiters, | 449 | if (!$main'openbsd && $main'elf) |
450 | # GNU and SVR4 as'es use different comment delimiters, | ||
433 | { # so we just skip comments... | 451 | { # so we just skip comments... |
434 | push(@out,"\n"); | 452 | push(@out,"\n"); |
435 | return; | 453 | return; |
@@ -460,7 +478,10 @@ sub main'set_label | |||
460 | $label{$_[0]}=".${label}${_[0]}"; | 478 | $label{$_[0]}=".${label}${_[0]}"; |
461 | $label++; | 479 | $label++; |
462 | } | 480 | } |
463 | push(@out,".align $align\n") if ($_[1] != 0); | 481 | if ($main'openbsd) |
482 | { push(@out,"_ALIGN_TEXT\n") if ($_[1] != 0); } | ||
483 | else | ||
484 | { push(@out,".align $align\n") if ($_[1] != 0); } | ||
464 | push(@out,"$label{$_[0]}:\n"); | 485 | push(@out,"$label{$_[0]}:\n"); |
465 | } | 486 | } |
466 | 487 | ||
@@ -569,6 +590,16 @@ sub main'picmeup | |||
569 | ___ | 590 | ___ |
570 | push(@out,$tmp); | 591 | push(@out,$tmp); |
571 | } | 592 | } |
593 | elsif ($main'openbsd) | ||
594 | { | ||
595 | push(@out, "#ifdef PIC\n"); | ||
596 | push(@out, "\tPIC_PROLOGUE\n"); | ||
597 | &main'mov($dst,"PIC_GOT($sym)"); | ||
598 | push(@out, "\tPIC_EPILOGUE\n"); | ||
599 | push(@out, "#else\n"); | ||
600 | &main'lea($dst,&main'DWP($sym)); | ||
601 | push(@out, "#endif\n"); | ||
602 | } | ||
572 | elsif ($main'pic && ($main'elf || $main'aout)) | 603 | elsif ($main'pic && ($main'elf || $main'aout)) |
573 | { | 604 | { |
574 | push(@out,"\t.align\t8\n"); | 605 | push(@out,"\t.align\t8\n"); |