diff options
-rw-r--r-- | lib/libssl/crypto/Makefile | 47 | ||||
-rw-r--r-- | lib/libssl/crypto/arch/vax/bn_asm_vax.S | 436 | ||||
-rw-r--r-- | lib/libssl/src/crypto/bf/asm/bf-586.pl | 2 | ||||
-rw-r--r-- | lib/libssl/src/crypto/bn/asm/bn-586.pl | 2 | ||||
-rw-r--r-- | lib/libssl/src/crypto/cast/asm/cast-586.pl | 2 | ||||
-rw-r--r-- | lib/libssl/src/crypto/cast/c_enc.c | 2 | ||||
-rw-r--r-- | lib/libssl/src/crypto/des/asm/des-586.pl | 12 | ||||
-rw-r--r-- | lib/libssl/src/crypto/des/des_enc.c | 2 | ||||
-rw-r--r-- | lib/libssl/src/crypto/perlasm/x86asm.pl | 8 | ||||
-rw-r--r-- | lib/libssl/src/crypto/perlasm/x86unix.pl | 35 |
10 files changed, 533 insertions, 15 deletions
diff --git a/lib/libssl/crypto/Makefile b/lib/libssl/crypto/Makefile index dead23398f6..18c744d706c 100644 --- a/lib/libssl/crypto/Makefile +++ b/lib/libssl/crypto/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.31 2003/06/02 08:45:58 markus Exp $ +# $OpenBSD: Makefile,v 1.32 2003/11/18 12:39:05 markus Exp $ LIB= crypto @@ -53,17 +53,17 @@ SRCS+= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \ des_old.c read2pwd.c SRCS+= rc2_ecb.c rc2_skey.c rc2_cbc.c rc2cfb64.c SRCS+= rc2ofb64.c -SRCS+= rc4_skey.c rc4_enc.c +SRCS+= rc4_skey.c #SRCS+= rc5_skey.c rc5_ecb.c rc5cfb64.c rc5cfb64.c #SRCS+= rc5ofb64.c rc5_enc.c #SRCS+= i_cbc.c i_cfb64.c i_ofb64.c i_ecb.c #SRCS+= i_skey.c -SRCS+= bf_skey.c bf_ecb.c bf_cfb64.c bf_ofb64.c bf_enc.c +SRCS+= bf_skey.c bf_ecb.c bf_cfb64.c bf_ofb64.c SRCS+= c_skey.c c_ecb.c c_cfb64.c c_ofb64.c c_enc.c SRCS+= bn_add.c bn_div.c bn_exp.c bn_lib.c SRCS+= bn_mul.c bn_print.c bn_rand.c bn_shift.c SRCS+= bn_word.c bn_blind.c bn_gcd.c bn_prime.c bn_err.c -SRCS+= bn_sqr.c bn_recp.c bn_mont.c bn_mpi.c bn_asm.c bn_mod.c +SRCS+= bn_sqr.c bn_recp.c bn_mont.c bn_mpi.c bn_mod.c SRCS+= bn_exp2.c bn_ctx.c SRCS+= bn_sqrt.c bn_kron.c 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 ${LCRYPTO_SRC}/pkcs7 ${LCRYPTO_SRC}/x509v3 ${LCRYPTO_SRC}/pkcs12 \ ${LCRYPTO_SRC}/comp ${LCRYPTO_SRC}/txt_db ${LCRYPTO_SRC}/md4 \ ${LCRYPTO_SRC}/engine ${LCRYPTO_SRC}/dso ${LCRYPTO_SRC}/ui \ - ${LCRYPTO_SRC}/ocsp ${LCRYPTO_SRC}/ec ${LCRYPTO_SRC}/aes ${LCRYPTO_SRC} + ${LCRYPTO_SRC}/ocsp ${LCRYPTO_SRC}/ec ${LCRYPTO_SRC}/aes ${LCRYPTO_SRC} \ + ${.CURDIR}/arch/${MACHINE_ARCH} HDRS=\ crypto/aes/aes.h \ @@ -260,6 +261,42 @@ des_enc.po: ${CC} ${CFLAGS} -O1 ${CPPFLAGS} -c ${.IMPSRC} -o $@ .endif +.if (${MACHINE_ARCH} == "i386") +CFLAGS+= -DMD5_ASM +CFLAGS+= -DSHA1_ASM +CFLAGS+= -DRMD160_ASM +CFLAGS+= -DOPENBSD_CAST_ASM +CFLAGS+= -DOPENBSD_DES_ASM +SSLASM=\ + bf bf-586 \ + bn bn-586 \ + bn co-586 \ + cast cast-586 \ + des des-586 \ + md5 md5-586 \ + rc4 rc4-586 \ + ripemd rmd-586 \ + sha sha1-586 +.for dir f in ${SSLASM} +SRCS+= ${f}.S +GENERATED+=${f}.S +${f}.S: ${LCRYPTO_SRC}/${dir}/asm/${f}.pl ${LCRYPTO_SRC}/perlasm/x86unix.pl + /usr/bin/perl -I${LCRYPTO_SRC}/perlasm:${LCRYPTO_SRC}/${dir}/asm \ + ${LCRYPTO_SRC}/${dir}/asm/${f}.pl openbsd-elf 386 > ${.TARGET} +.endfor +SRCS+= bf_cbc.c +.else +.if (${MACHINE_ARCH} == "vax") +SRCS+= bf_enc.c +SRCS+= bn_asm_vax.S +SRCS+= rc4_enc.c +.else +SRCS+= bf_enc.c +SRCS+= bn_asm.c +SRCS+= rc4_enc.c +.endif +.endif + all beforedepend: ${GENERATED} .include <bsd.lib.mk> diff --git a/lib/libssl/crypto/arch/vax/bn_asm_vax.S b/lib/libssl/crypto/arch/vax/bn_asm_vax.S new file mode 100644 index 00000000000..bd067a55d36 --- /dev/null +++ b/lib/libssl/crypto/arch/vax/bn_asm_vax.S @@ -0,0 +1,436 @@ +# $OpenBSD: bn_asm_vax.S,v 1.1 2003/11/18 12:39:05 markus Exp $ +# $NetBSD: bn_asm_vax.S,v 1.1 2003/11/03 10:22:28 ragge Exp $ + +#include <machine/asm.h> + +# w.j.m. 15-jan-1999 +# +# it's magic ... +# +# ULONG bn_mul_add_words(ULONG r[],ULONG a[],int n,ULONG w) { +# ULONG c = 0; +# int i; +# for(i = 0; i < n; i++) <c,r[i]> := r[i] + c + a[i] * w ; +# return c; +# } + +ENTRY(bn_mul_add_words,R6) + movl 4(ap),r2 # *r + movl 8(ap),r3 # *a + movl 12(ap),r4 # n + movl 16(ap),r5 # w + clrl r6 # return value ("carry") + +0: emul r5,(r3),(r2),r0 # w * a[0] + r[0] -> r0 + + # fixup for "negative" r[] + tstl (r2) + bgeq 1f + incl r1 # add 1 to highword + +1: # add saved carry to result + addl2 r6,r0 + adwc $0,r1 + + # combined fixup for "negative" w, a[] + tstl r5 # if w is negative... + bgeq 1f + addl2 (r3),r1 # ...add a[0] again to highword +1: tstl (r3) # if a[0] is negative... + bgeq 1f + addl2 r5,r1 # ...add w again to highword +1: + movl r0,(r2)+ # save low word in dest & advance *r + addl2 $4,r3 # advance *a + movl r1,r6 # high word in r6 for return value + + sobgtr r4,0b # loop? + + movl r6,r0 + ret + +# .title vax_bn_mul_words unsigned multiply & add, 32*32+32=>64 +#; +#; w.j.m. 15-jan-1999 +#; +#; it's magic ... +#; +#; ULONG bn_mul_words(ULONG r[],ULONG a[],int n,ULONG w) { +#; ULONG c = 0; +#; int i; +#; for(i = 0; i < num; i++) <c,r[i]> := a[i] * w + c ; +#; return(c); +#; } +# + +ENTRY(bn_mul_words,R6) + movl 4(ap),r2 # *r + movl 8(ap),r3 # *a + movl 12(ap),r4 # n + movl 16(ap),r5 # w + clrl r6 # carry + +0: emul r5,(r3),r6,r0 # w * a[0] + carry -> r0 + + # fixup for "negative" carry + tstl r6 + bgeq 1f + incl r1 + +1: # combined fixup for "negative" w, a[] + tstl r5 + bgeq 1f + addl2 (r3),r1 +1: tstl (r3) + bgeq 1f + addl2 r5,r1 + +1: movl r0,(r2)+ + addl2 $4,r3 + movl r1,r6 + + sobgtr r4,0b + + movl r6,r0 + ret + + + +# .title vax_bn_sqr_words unsigned square, 32*32=>64 +#; +#; w.j.m. 15-jan-1999 +#; +#; it's magic ... +#; +#; void bn_sqr_words(ULONG r[],ULONG a[],int n) { +#; int i; +#; for(i = 0; i < n; i++) <r[2*i+1],r[2*i]> := a[i] * a[i] ; +#; } +# + +ENTRY(bn_sqr_words,0) + movl 4(ap),r2 # r + movl 8(ap),r3 # a + movl 12(ap),r4 # n + +0: movl (r3)+,r5 # r5 = a[] & advance + + emul r5,r5,$0,r0 # a[0] * a[0] + 0 -> r0 + + # fixup for "negative" a[] + tstl r5 + bgeq 1f + addl2 r5,r1 + addl2 r5,r1 + +1: movq r0,(r2)+ # store 64-bit result + + sobgtr r4,0b # loop + + ret + + +# .title vax_bn_div_words unsigned divide +#; +#; Richard Levitte 20-Nov-2000 +#; +#; ULONG bn_div_words(ULONG h, ULONG l, ULONG d) +#; { +#; return ((ULONG)((((ULLONG)h)<<32)|l) / (ULLONG)d); +#; } +#; +#; Using EDIV would be very easy, if it didn't do signed calculations. +#; Any time any of the input numbers are signed, there are problems, +#; usually with integer overflow, at which point it returns useless +#; data (the quotient gets the value of l, and the remainder becomes 0). +#; +#; If it was just for the dividend, it would be very easy, just divide +#; it by 2 (unsigned), do the division, multiply the resulting quotient +#; and remainder by 2, add the bit that was dropped when dividing by 2 +#; to the remainder, and do some adjustment so the remainder doesn't +#; end up larger than the divisor. For some cases when the divisor is +#; negative (from EDIV's point of view, i.e. when the highest bit is set), +#; dividing the dividend by 2 isn't enough, and since some operations +#; might generate integer overflows even when the dividend is divided by +#; 4 (when the high part of the shifted down dividend ends up being exactly +#; half of the divisor, the result is the quotient 0x80000000, which is +#; negative...) it needs to be divided by 8. Furthermore, the divisor needs +#; to be divided by 2 (unsigned) as well, to avoid more problems with the sign. +#; In this case, a little extra fiddling with the remainder is required. +#; +#; So, the simplest way to handle this is always to divide the dividend +#; by 8, and to divide the divisor by 2 if it's highest bit is set. +#; After EDIV has been used, the quotient gets multiplied by 8 if the +#; original divisor was positive, otherwise 4. The remainder, oddly +#; enough, is *always* multiplied by 8. +#; NOTE: in the case mentioned above, where the high part of the shifted +#; down dividend ends up being exactly half the shifted down divisor, we +#; end up with a 33 bit quotient. That's no problem however, it usually +#; means we have ended up with a too large remainder as well, and the +#; problem is fixed by the last part of the algorithm (next paragraph). +#; +#; The routine ends with comparing the resulting remainder with the +#; original divisor and if the remainder is larger, subtract the +#; original divisor from it, and increase the quotient by 1. This is +#; done until the remainder is smaller than the divisor. +#; +#; The complete algorithm looks like this: +#; +#; d' = d +#; l' = l & 7 +#; [h,l] = [h,l] >> 3 +#; [q,r] = floor([h,l] / d) # This is the EDIV operation +#; if (q < 0) q = -q # I doubt this is necessary any more +#; +#; r' = r >> 29 +#; if (d' >= 0) +#; q' = q >> 29 +#; q = q << 3 +#; else +#; q' = q >> 30 +#; q = q << 2 +#; r = (r << 3) + l' +#; +#; if (d' < 0) +#; { +#; [r',r] = [r',r] - q +#; while ([r',r] < 0) +#; { +#; [r',r] = [r',r] + d +#; [q',q] = [q',q] - 1 +#; } +#; } +#; +#; while ([r',r] >= d') +#; { +#; [r',r] = [r',r] - d' +#; [q',q] = [q',q] + 1 +#; } +#; +#; return q +# +#;r2 = l, q +#;r3 = h, r +#;r4 = d +#;r5 = l' +#;r6 = r' +#;r7 = d' +#;r8 = q' +# + +ENTRY(bn_div_words,R6|R7|R8) + movl 4(ap),r3 # h + movl 8(ap),r2 # l + movl 12(ap),r4 # d + + bicl3 $-8,r2,r5 # l' = l & 7 + bicl3 $7,r2,r2 + + bicl3 $-8,r3,r6 + bicl3 $7,r3,r3 + + addl2 r6,r2 + + rotl $-3,r2,r2 # l = l >> 3 + rotl $-3,r3,r3 # h = h >> 3 + + movl r4,r7 # d' = d + + clrl r6 # r' = 0 + clrl r8 # q' = 0 + + tstl r4 + beql 0f # Uh-oh, the divisor is 0... + bgtr 1f + rotl $-1,r4,r4 # If d is negative, shift it right. + bicl2 $0x80000000,r4 # Since d is then a large number, the + # lowest bit is insignificant + # (contradict that, and I'll fix the problem!) +1: + ediv r4,r2,r2,r3 # Do the actual division + + tstl r2 + bgeq 1f + mnegl r2,r2 # if q < 0, negate it +1: + tstl r7 + blss 1f + rotl $3,r2,r2 # q = q << 3 + bicl3 $-8,r2,r8 # q' gets the high bits from q + bicl3 $7,r2,r2 + brb 2f + +1: # else + rotl $2,r2,r2 # q = q << 2 + bicl3 $-4,r2,r8 # q' gets the high bits from q + bicl3 $3,r2,r2 +2: + rotl $3,r3,r3 # r = r << 3 + bicl3 $-8,r3,r6 # r' gets the high bits from r + bicl3 $7,r3,r3 + addl2 r5,r3 # r = r + l' + + tstl r7 + bgeq 5f + bitl $1,r7 + beql 5f # if d' < 0 && d' & 1 + subl2 r2,r3 # [r',r] = [r',r] - [q',q] + sbwc r8,r6 +3: + bgeq 5f # while r < 0 + decl r2 # [q',q] = [q',q] - 1 + sbwc $0,r8 + addl2 r7,r3 # [r',r] = [r',r] + d' + adwc $0,r6 + brb 3b + +# The return points are placed in the middle to keep a short distance from +# all the branch points +1: +# movl r3,r1 + movl r2,r0 + ret +0: + movl $-1,r0 + ret +5: + tstl r6 + bneq 6f + cmpl r3,r7 + blssu 1b # while [r',r] >= d' +6: + subl2 r7,r3 # [r',r] = [r',r] - d' + sbwc $0,r6 + incl r2 # [q',q] = [q',q] + 1 + adwc $0,r8 + brb 5b + + + +# .title vax_bn_add_words unsigned add of two arrays +#; +#; Richard Levitte 20-Nov-2000 +#; +#; ULONG bn_add_words(ULONG r[], ULONG a[], ULONG b[], int n) { +#; ULONG c = 0; +#; int i; +#; for (i = 0; i < n; i++) <c,r[i]> = a[i] + b[i] + c; +#; return(c); +#; } +# + +ENTRY(bn_add_words,0) + movl 4(ap),r2 # r + movl 8(ap),r3 # a + movl 12(ap),r4 # b + movl 16(ap),r5 # n + clrl r0 + + tstl r5 + bleq 1f + +0: movl (r3)+,r1 # carry untouched + adwc (r4)+,r1 # carry used and touched + movl r1,(r2)+ # carry untouched + sobgtr r5,0b # carry untouched + + adwc $0,r0 +1: ret + +#; +#; Richard Levitte 20-Nov-2000 +#; +#; ULONG bn_sub_words(ULONG r[], ULONG a[], ULONG b[], int n) { +#; ULONG c = 0; +#; int i; +#; for (i = 0; i < n; i++) <c,r[i]> = a[i] - b[i] - c; +#; return(c); +#; } +# + +ENTRY(bn_sub_words,R6) + movl 4(ap),r2 # r + movl 8(ap),r3 # a + movl 12(ap),r4 # b + movl 16(ap),r5 # n + clrl r0 + + tstl r5 + bleq 1f + +0: movl (r3)+,r6 # carry untouched + sbwc (r4)+,r6 # carry used and touched + movl r6,(r2)+ # carry untouched + sobgtr r5,0b # carry untouched + +1: adwc $0,r0 + ret + +# +# Ragge 20-Sep-2003 +# +# Multiply a vector of 4/8 longword by another. +# Uses two loops and 16/64 emuls. +# + +ENTRY(bn_mul_comba4,R6|R7|R8|R9) + movl $4,r9 # 4*4 + brb 6f + +ENTRY(bn_mul_comba8,R6|R7|R8|R9) + movl $8,r9 # 8*8 + +6: movl 8(ap),r3 # a[] + movl 12(ap),r7 # b[] + brb 5f + +ENTRY(bn_sqr_comba4,R6|R7|R8|R9) + movl $4,r9 # 4*4 + brb 0f + +ENTRY(bn_sqr_comba8,R6|R7|R8|R9) + movl $8,r9 # 8*8 + +0: + movl 8(ap),r3 # a[] + movl r3,r7 # a[] + +5: movl 4(ap),r5 # r[] + movl r9,r8 + + clrq (r5) # clear destinatino, for add. + clrq 8(r5) + clrq 16(r5) # these only needed for comba8 + clrq 24(r5) + +2: clrl r4 # carry + movl r9,r6 # inner loop count + movl (r7)+,r2 # value to multiply with + +1: emul r2,(r3),r4,r0 + tstl r4 + bgeq 3f + incl r1 +3: tstl r2 + bgeq 3f + addl2 (r3),r1 +3: tstl (r3) + bgeq 3f + addl2 r2,r1 + +3: addl2 r0,(r5)+ # add to destination + adwc $0,r1 # remember carry + movl r1,r4 # add carry in next emul + addl2 $4,r3 + sobgtr r6,1b + + movl r4,(r5) # save highest add result + + ashl $2,r9,r4 + subl2 r4,r3 + subl2 $4,r4 + subl2 r4,r5 + + sobgtr r8,2b + + ret diff --git a/lib/libssl/src/crypto/bf/asm/bf-586.pl b/lib/libssl/src/crypto/bf/asm/bf-586.pl index b556642c949..b5a4760d09c 100644 --- a/lib/libssl/src/crypto/bf/asm/bf-586.pl +++ b/lib/libssl/src/crypto/bf/asm/bf-586.pl @@ -18,7 +18,7 @@ $tmp4="edx"; &BF_encrypt("BF_encrypt",1); &BF_encrypt("BF_decrypt",0); -&cbc("BF_cbc_encrypt","BF_encrypt","BF_decrypt",1,4,5,3,-1,-1); +&cbc("BF_cbc_encrypt","BF_encrypt","BF_decrypt",1,4,5,3,-1,-1) unless $main'openbsd; &asm_finish(); sub BF_encrypt diff --git a/lib/libssl/src/crypto/bn/asm/bn-586.pl b/lib/libssl/src/crypto/bn/asm/bn-586.pl index 33f61259201..9a78f63be13 100644 --- a/lib/libssl/src/crypto/bn/asm/bn-586.pl +++ b/lib/libssl/src/crypto/bn/asm/bn-586.pl @@ -11,7 +11,7 @@ require "x86asm.pl"; &bn_div_words("bn_div_words"); &bn_add_words("bn_add_words"); &bn_sub_words("bn_sub_words"); -&bn_sub_part_words("bn_sub_part_words"); +&bn_sub_part_words("bn_sub_part_words") unless $main'openbsd; &asm_finish(); diff --git a/lib/libssl/src/crypto/cast/asm/cast-586.pl b/lib/libssl/src/crypto/cast/asm/cast-586.pl index 6be0bfe5724..0ed55d1905e 100644 --- a/lib/libssl/src/crypto/cast/asm/cast-586.pl +++ b/lib/libssl/src/crypto/cast/asm/cast-586.pl @@ -28,7 +28,7 @@ $S4="CAST_S_table3"; &CAST_encrypt("CAST_encrypt",1); &CAST_encrypt("CAST_decrypt",0); -&cbc("CAST_cbc_encrypt","CAST_encrypt","CAST_decrypt",1,4,5,3,-1,-1); +&cbc("CAST_cbc_encrypt","CAST_encrypt","CAST_decrypt",1,4,5,3,-1,-1) unless $main'openbsd; &asm_finish(); diff --git a/lib/libssl/src/crypto/cast/c_enc.c b/lib/libssl/src/crypto/cast/c_enc.c index 0fe2cffeccf..e80f65b6986 100644 --- a/lib/libssl/src/crypto/cast/c_enc.c +++ b/lib/libssl/src/crypto/cast/c_enc.c @@ -59,6 +59,7 @@ #include <openssl/cast.h> #include "cast_lcl.h" +#ifndef OPENBSD_CAST_ASM void CAST_encrypt(CAST_LONG *data, CAST_KEY *key) { register CAST_LONG l,r,*k,t; @@ -122,6 +123,7 @@ void CAST_decrypt(CAST_LONG *data, CAST_KEY *key) data[1]=l&0xffffffffL; data[0]=r&0xffffffffL; } +#endif void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, CAST_KEY *ks, unsigned char *iv, int enc) diff --git a/lib/libssl/src/crypto/des/asm/des-586.pl b/lib/libssl/src/crypto/des/asm/des-586.pl index b75d3c6b3a4..60d577cc8d5 100644 --- a/lib/libssl/src/crypto/des/asm/des-586.pl +++ b/lib/libssl/src/crypto/des/asm/des-586.pl @@ -22,10 +22,14 @@ $R="esi"; &external_label("DES_SPtrans"); &DES_encrypt("DES_encrypt1",1); &DES_encrypt("DES_encrypt2",0); -&DES_encrypt3("DES_encrypt3",1); -&DES_encrypt3("DES_decrypt3",0); -&cbc("DES_ncbc_encrypt","DES_encrypt1","DES_encrypt1",0,4,5,3,5,-1); -&cbc("DES_ede3_cbc_encrypt","DES_encrypt3","DES_decrypt3",0,6,7,3,4,5); + +if (!$main'openbsd) + { + &DES_encrypt3("DES_encrypt3",1); + &DES_encrypt3("DES_decrypt3",0); + &cbc("DES_ncbc_encrypt","DES_encrypt1","DES_encrypt1",0,4,5,3,5,-1); + &cbc("DES_ede3_cbc_encrypt","DES_encrypt3","DES_decrypt3",0,6,7,3,4,5); + } &asm_finish(); diff --git a/lib/libssl/src/crypto/des/des_enc.c b/lib/libssl/src/crypto/des/des_enc.c index 1c37ab96d3d..4f09804c44f 100644 --- a/lib/libssl/src/crypto/des/des_enc.c +++ b/lib/libssl/src/crypto/des/des_enc.c @@ -58,6 +58,7 @@ #include "des_locl.h" +#ifndef OPENBSD_DES_ASM void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) { register DES_LONG l,r,t,u; @@ -246,6 +247,7 @@ void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc) data[1]=ROTATE(r,3)&0xffffffffL; l=r=t=u=0; } +#endif void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, DES_key_schedule *ks2, DES_key_schedule *ks3) diff --git a/lib/libssl/src/crypto/perlasm/x86asm.pl b/lib/libssl/src/crypto/perlasm/x86asm.pl index 1cb96e914ab..7c675e3ced3 100644 --- a/lib/libssl/src/crypto/perlasm/x86asm.pl +++ b/lib/libssl/src/crypto/perlasm/x86asm.pl @@ -18,9 +18,13 @@ sub main'asm_init ($type,$fn,$i386)=@_; $filename=$fn; - $elf=$cpp=$sol=$aout=$win32=$gaswin=0; + $elf=$cpp=$sol=$aout=$win32=$gaswin=$openbsd=0; if ( ($type eq "elf")) { $elf=1; require "x86unix.pl"; } + elsif ( ($type eq "openbsd-elf")) + { $openbsd=$elf=1; require "x86unix.pl"; } + elsif ( ($type eq "openbsd-a.out")) + { $openbsd=1; require "x86unix.pl"; } elsif ( ($type eq "a.out")) { $aout=1; require "x86unix.pl"; } elsif ( ($type eq "gaswin")) @@ -43,6 +47,8 @@ Pick one target type from cpp - format so x86unix.cpp can be used win32 - Windows 95/Windows NT win32n - Windows 95/Windows NT NASM format + openbsd-elf - OpenBSD elf + openbsd-a.out - OpenBSD a.out EOF exit(1); } diff --git a/lib/libssl/src/crypto/perlasm/x86unix.pl b/lib/libssl/src/crypto/perlasm/x86unix.pl index 10b669bf049..53ad5f49279 100644 --- a/lib/libssl/src/crypto/perlasm/x86unix.pl +++ b/lib/libssl/src/crypto/perlasm/x86unix.pl @@ -15,6 +15,12 @@ sub main'asm_get_output { return(@out); } sub main'get_labels { return(@labels); } sub main'external_label { push(@labels,@_); } +if ($main'openbsd) + { + $com_start='/*'; + $com_end='*/'; + } + if ($main'cpp) { $align="ALIGN"; @@ -276,6 +282,9 @@ sub main'file { local($file)=@_; + if ($main'openbsd) + { push(@out,"#include <machine/asm.h>\n"); return; } + local($tmp)=<<"EOF"; .file "$file.s" .version "01.01" @@ -291,6 +300,9 @@ sub main'function_begin &main'external_label($func); $func=$under.$func; + if ($main'openbsd) + { push (@out, "\nENTRY($func)\n"); goto skip; } + local($tmp)=<<"EOF"; .text .align $align @@ -303,6 +315,7 @@ EOF { $tmp=push(@out,"\t.def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); } else { $tmp=push(@out,"\t.type\t$func,\@function\n"); } push(@out,"$func:\n"); +skip: $tmp=<<"EOF"; pushl %ebp pushl %ebx @@ -321,6 +334,9 @@ sub main'function_begin_B &main'external_label($func); $func=$under.$func; + if ($main'openbsd) + { push(@out, "\nENTRY($func)\n"); goto skip; } + local($tmp)=<<"EOF"; .text .align $align @@ -333,6 +349,7 @@ EOF { $tmp=push(@out,"\t.def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); } else { push(@out,"\t.type $func,\@function\n"); } push(@out,"$func:\n"); +skip: $stack=4; } @@ -429,7 +446,8 @@ sub main'swtmp sub main'comment { - if ($main'elf) # GNU and SVR4 as'es use different comment delimiters, + if (!$main'openbsd && $main'elf) + # GNU and SVR4 as'es use different comment delimiters, { # so we just skip comments... push(@out,"\n"); return; @@ -460,7 +478,10 @@ sub main'set_label $label{$_[0]}=".${label}${_[0]}"; $label++; } - push(@out,".align $align\n") if ($_[1] != 0); + if ($main'openbsd) + { push(@out,"_ALIGN_TEXT\n") if ($_[1] != 0); } + else + { push(@out,".align $align\n") if ($_[1] != 0); } push(@out,"$label{$_[0]}:\n"); } @@ -569,6 +590,16 @@ sub main'picmeup ___ push(@out,$tmp); } + elsif ($main'openbsd) + { + push(@out, "#ifdef PIC\n"); + push(@out, "\tPIC_PROLOGUE\n"); + &main'mov($dst,"PIC_GOT($sym)"); + push(@out, "\tPIC_EPILOGUE\n"); + push(@out, "#else\n"); + &main'lea($dst,&main'DWP($sym)); + push(@out, "#endif\n"); + } elsif ($main'pic && ($main'elf || $main'aout)) { push(@out,"\t.align\t8\n"); |