summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn
diff options
context:
space:
mode:
authordjm <>2008-09-06 12:15:54 +0000
committerdjm <>2008-09-06 12:15:54 +0000
commitf519f07de9bfb123f2b32aa3965e6f73c8364b80 (patch)
treead353b318ee632f73212a174cffac9bb9e573b7c /src/lib/libcrypto/bn
parent89b182c5db7ea802edfc3ee734b4899b43e13e09 (diff)
parentf1625f274acf5dcd5601f6cb5e29e233b2a441a3 (diff)
downloadopenbsd-f519f07de9bfb123f2b32aa3965e6f73c8364b80.tar.gz
openbsd-f519f07de9bfb123f2b32aa3965e6f73c8364b80.tar.bz2
openbsd-f519f07de9bfb123f2b32aa3965e6f73c8364b80.zip
This commit was generated by cvs2git to track changes on a CVS vendor
branch.
Diffstat (limited to 'src/lib/libcrypto/bn')
-rw-r--r--src/lib/libcrypto/bn/Makefile286
-rw-r--r--src/lib/libcrypto/bn/asm/mo-586.pl603
2 files changed, 755 insertions, 134 deletions
diff --git a/src/lib/libcrypto/bn/Makefile b/src/lib/libcrypto/bn/Makefile
index 9969d242cc..e97c751390 100644
--- a/src/lib/libcrypto/bn/Makefile
+++ b/src/lib/libcrypto/bn/Makefile
@@ -8,11 +8,6 @@ CC= cc
8CPP= $(CC) -E 8CPP= $(CC) -E
9INCLUDES= -I.. -I$(TOP) -I../../include 9INCLUDES= -I.. -I$(TOP) -I../../include
10CFLAG=-g 10CFLAG=-g
11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile 11MAKEFILE= Makefile
17AR= ar r 12AR= ar r
18 13
@@ -22,6 +17,7 @@ BN_ASM= bn_asm.o
22 17
23CFLAGS= $(INCLUDES) $(CFLAG) 18CFLAGS= $(INCLUDES) $(CFLAG)
24ASFLAGS= $(INCLUDES) $(ASFLAG) 19ASFLAGS= $(INCLUDES) $(ASFLAG)
20AFLAGS= $(ASFLAGS)
25 21
26GENERAL=Makefile 22GENERAL=Makefile
27TEST=bntest.c exptest.c 23TEST=bntest.c exptest.c
@@ -31,12 +27,14 @@ LIB=$(TOP)/libcrypto.a
31LIBSRC= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c bn_mod.c \ 27LIBSRC= bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c bn_mod.c \
32 bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \ 28 bn_print.c bn_rand.c bn_shift.c bn_word.c bn_blind.c \
33 bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_asm.c \ 29 bn_kron.c bn_sqrt.c bn_gcd.c bn_prime.c bn_err.c bn_sqr.c bn_asm.c \
34 bn_recp.c bn_mont.c bn_mpi.c bn_exp2.c bn_x931p.c 30 bn_recp.c bn_mont.c bn_mpi.c bn_exp2.c bn_gf2m.c bn_nist.c \
31 bn_depr.c bn_const.c
35 32
36LIBOBJ= bn_add.o bn_div.o bn_exp.o bn_lib.o bn_ctx.o bn_mul.o bn_mod.o \ 33LIBOBJ= bn_add.o bn_div.o bn_exp.o bn_lib.o bn_ctx.o bn_mul.o bn_mod.o \
37 bn_print.o bn_rand.o bn_shift.o bn_word.o bn_blind.o \ 34 bn_print.o bn_rand.o bn_shift.o bn_word.o bn_blind.o \
38 bn_kron.o bn_sqrt.o bn_gcd.o bn_prime.o bn_err.o bn_sqr.o $(BN_ASM) \ 35 bn_kron.o bn_sqrt.o bn_gcd.o bn_prime.o bn_err.o bn_sqr.o $(BN_ASM) \
39 bn_recp.o bn_mont.o bn_mpi.o bn_exp2.o bn_x931p.o 36 bn_recp.o bn_mont.o bn_mpi.o bn_exp2.o bn_gf2m.o bn_nist.o \
37 bn_depr.o bn_const.o
40 38
41SRC= $(LIBSRC) 39SRC= $(LIBSRC)
42 40
@@ -64,70 +62,60 @@ lib: $(LIBOBJ)
64 $(RANLIB) $(LIB) || echo Never mind. 62 $(RANLIB) $(LIB) || echo Never mind.
65 @touch lib 63 @touch lib
66 64
67# elf 65# ELF
68asm/bn86-elf.s: asm/bn-586.pl ../perlasm/x86asm.pl 66bn86-elf.s: asm/bn-586.pl ../perlasm/x86asm.pl
69 (cd asm; $(PERL) bn-586.pl elf $(CFLAGS) > bn86-elf.s) 67 (cd asm; $(PERL) bn-586.pl elf $(CFLAGS) > ../$@)
70 68co86-elf.s: asm/co-586.pl ../perlasm/x86asm.pl
71asm/co86-elf.s: asm/co-586.pl ../perlasm/x86asm.pl 69 (cd asm; $(PERL) co-586.pl elf $(CFLAGS) > ../$@)
72 (cd asm; $(PERL) co-586.pl elf $(CFLAGS) > co86-elf.s) 70mo86-elf.s: asm/mo-586.pl ../perlasm/x86asm.pl
73 71 (cd asm; $(PERL) mo-586.pl elf $(CFLAGS) > ../$@)
72# COFF
73bn86-cof.s: asm/bn-586.pl ../perlasm/x86asm.pl
74 (cd asm; $(PERL) bn-586.pl coff $(CFLAGS) > ../$@)
75co86-cof.s: asm/co-586.pl ../perlasm/x86asm.pl
76 (cd asm; $(PERL) co-586.pl coff $(CFLAGS) > ../$@)
77mo86-cof.s: asm/mo-586.pl ../perlasm/x86asm.pl
78 (cd asm; $(PERL) mo-586.pl coff $(CFLAGS) > ../$@)
74# a.out 79# a.out
75asm/bn86-out.o: asm/bn86unix.cpp 80bn86-out.s: asm/bn-586.pl ../perlasm/x86asm.pl
76 $(CPP) -DOUT asm/bn86unix.cpp | as -o asm/bn86-out.o 81 (cd asm; $(PERL) bn-586.pl a.out $(CFLAGS) > ../$@)
77 82co86-out.s: asm/co-586.pl ../perlasm/x86asm.pl
78asm/co86-out.o: asm/co86unix.cpp 83 (cd asm; $(PERL) co-586.pl a.out $(CFLAGS) > ../$@)
79 $(CPP) -DOUT asm/co86unix.cpp | as -o asm/co86-out.o 84mo86-out.s: asm/mo-586.pl ../perlasm/x86asm.pl
80 85 (cd asm; $(PERL) mo-586.pl a.out $(CFLAGS) > ../$@)
81# bsdi 86
82asm/bn86bsdi.o: asm/bn86unix.cpp 87sparcv8.o: asm/sparcv8.S
83 $(CPP) -DBSDI asm/bn86unix.cpp | sed 's/ :/:/' | as -o asm/bn86bsdi.o 88 $(CC) $(CFLAGS) -c asm/sparcv8.S
84 89sparcv8plus.o: asm/sparcv8plus.S
85asm/co86bsdi.o: asm/co86unix.cpp 90 $(CC) $(CFLAGS) -c asm/sparcv8plus.S
86 $(CPP) -DBSDI asm/co86unix.cpp | sed 's/ :/:/' | as -o asm/co86bsdi.o 91
87 92bn-mips3.o: asm/mips3.s
88asm/bn86unix.cpp: asm/bn-586.pl ../perlasm/x86asm.pl 93 @if [ "$(CC)" = "gcc" ]; then \
89 (cd asm; $(PERL) bn-586.pl cpp >bn86unix.cpp ) 94 ABI=`expr "$(CFLAGS)" : ".*-mabi=\([n3264]*\)"` && \
90 95 as -$$ABI -O -o $@ asm/mips3.s; \
91asm/co86unix.cpp: asm/co-586.pl ../perlasm/x86asm.pl 96 else $(CC) -c $(CFLAGS) -o $@ asm/mips3.s; fi
92 (cd asm; $(PERL) co-586.pl cpp >co86unix.cpp ) 97
93 98x86_64-gcc.o: asm/x86_64-gcc.c
94asm/sparcv8.o: asm/sparcv8.S 99 $(CC) $(CFLAGS) -c -o $@ asm/x86_64-gcc.c
95 100x86_64-mont.s: asm/x86_64-mont.pl
96asm/sparcv8plus.o: asm/sparcv8plus.S 101 $(PERL) asm/x86_64-mont.pl $@
97 102
98# Old GNU assembler doesn't understand V9 instructions, so we 103bn-ia64.s: asm/ia64.S
99# hire /usr/ccs/bin/as to do the job. Note that option is called 104 $(CC) $(CFLAGS) -E asm/ia64.S > $@
100# *-gcc27, but even gcc 2>=8 users may experience similar problem 105
101# if they didn't bother to upgrade GNU assembler. Such users should 106# GNU assembler fails to compile PA-RISC2 modules, insist on calling
102# not choose this option, but be adviced to *remove* GNU assembler 107# vendor assembler...
103# or upgrade it. 108pa-risc2W.o: asm/pa-risc2W.s
104asm/sparcv8plus-gcc27.o: asm/sparcv8plus.S 109 /usr/ccs/bin/as -o pa-risc2W.o asm/pa-risc2W.s
105 $(CC) $(ASFLAGS) -E asm/sparcv8plus.S | \ 110pa-risc2.o: asm/pa-risc2.s
106 /usr/ccs/bin/as -xarch=v8plus - -o asm/sparcv8plus-gcc27.o 111 /usr/ccs/bin/as -o pa-risc2.o asm/pa-risc2.s
107 112
108 113# ppc - AIX, Linux, MacOS X...
109asm/ia64.o: asm/ia64.S 114linux_ppc32.s: asm/ppc.pl; $(PERL) $< $@
110 115linux_ppc64.s: asm/ppc.pl; $(PERL) $< $@
111# Some compiler drivers (most notably HP-UX and Intel C++) don't 116aix_ppc32.s: asm/ppc.pl; $(PERL) asm/ppc.pl $@
112# understand .S extension:-( I wish I could pipe output from cc -E, 117aix_ppc64.s: asm/ppc.pl; $(PERL) asm/ppc.pl $@
113# but it's too compiler driver/ABI dependent to cover with a single 118osx_ppc32.s: asm/ppc.pl; $(PERL) $< $@
114# rule... <appro@fy.chalmers.se>
115asm/ia64-cpp.o: asm/ia64.S
116 $(CC) $(ASFLAGS) -E asm/ia64.S > /tmp/ia64.$$$$.s && \
117 $(CC) $(ASFLAGS) -c -o asm/ia64-cpp.o /tmp/ia64.$$$$.s; \
118 rm -f /tmp/ia64.$$$$.s
119
120asm/x86_64-gcc.o: asm/x86_64-gcc.c
121 $(CC) $(ASFLAGS) -c -o $@ $<
122
123asm/pa-risc2W.o: asm/pa-risc2W.s
124 /usr/ccs/bin/as -o asm/pa-risc2W.o asm/pa-risc2W.s
125
126asm/linux_ppc32.s: asm/ppc.pl; $(PERL) $< $@
127asm/linux_ppc64.s: asm/ppc.pl; $(PERL) $< $@
128asm/aix_ppc32.s: asm/ppc.pl; $(PERL) asm/ppc.pl $@
129asm/aix_ppc64.s: asm/ppc.pl; $(PERL) asm/ppc.pl $@
130asm/osx_ppc32.s: asm/ppc.pl; $(PERL) $< $@
131 119
132files: 120files:
133 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO 121 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
@@ -138,6 +126,7 @@ links:
138 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) 126 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
139 127
140install: 128install:
129 @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
141 @headerlist="$(EXHEADER)"; for i in $$headerlist ; \ 130 @headerlist="$(EXHEADER)"; for i in $$headerlist ; \
142 do \ 131 do \
143 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ 132 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
@@ -161,6 +150,7 @@ lint:
161 lint -DLINT $(INCLUDES) $(SRC)>fluff 150 lint -DLINT $(INCLUDES) $(SRC)>fluff
162 151
163depend: 152depend:
153 @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
164 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC) 154 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
165 155
166dclean: 156dclean:
@@ -168,7 +158,7 @@ dclean:
168 mv -f Makefile.new $(MAKEFILE) 158 mv -f Makefile.new $(MAKEFILE)
169 159
170clean: 160clean:
171 rm -f asm/co86unix.cpp asm/bn86unix.cpp asm/*-elf.* *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff bn_asm.s 161 rm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
172 162
173# DO NOT DELETE THIS LINE -- make depend depends on it. 163# DO NOT DELETE THIS LINE -- make depend depends on it.
174 164
@@ -176,101 +166,131 @@ bn_add.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
176bn_add.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 166bn_add.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
177bn_add.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 167bn_add.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
178bn_add.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 168bn_add.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
179bn_add.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 169bn_add.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
180bn_add.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 170bn_add.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
181bn_add.o: ../cryptlib.h bn_add.c bn_lcl.h 171bn_add.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_add.c bn_lcl.h
182bn_asm.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h 172bn_asm.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
183bn_asm.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 173bn_asm.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
184bn_asm.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 174bn_asm.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
185bn_asm.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 175bn_asm.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
186bn_asm.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 176bn_asm.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
187bn_asm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 177bn_asm.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
188bn_asm.o: ../cryptlib.h bn_asm.c bn_lcl.h 178bn_asm.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_asm.c bn_lcl.h
189bn_blind.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h 179bn_blind.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
190bn_blind.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 180bn_blind.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
191bn_blind.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 181bn_blind.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
192bn_blind.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 182bn_blind.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
193bn_blind.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 183bn_blind.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
194bn_blind.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 184bn_blind.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
195bn_blind.o: ../cryptlib.h bn_blind.c bn_lcl.h 185bn_blind.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_blind.c bn_lcl.h
186bn_const.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
187bn_const.o: ../../include/openssl/ossl_typ.h bn.h bn_const.c
196bn_ctx.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h 188bn_ctx.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
197bn_ctx.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 189bn_ctx.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
198bn_ctx.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 190bn_ctx.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
199bn_ctx.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 191bn_ctx.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
200bn_ctx.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 192bn_ctx.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
201bn_ctx.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 193bn_ctx.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
202bn_ctx.o: ../cryptlib.h bn_ctx.c bn_lcl.h 194bn_ctx.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_ctx.c bn_lcl.h
195bn_depr.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
196bn_depr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
197bn_depr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
198bn_depr.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
199bn_depr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
200bn_depr.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
201bn_depr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
202bn_depr.o: ../cryptlib.h bn_depr.c bn_lcl.h
203bn_div.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h 203bn_div.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
204bn_div.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 204bn_div.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
205bn_div.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 205bn_div.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
206bn_div.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 206bn_div.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
207bn_div.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 207bn_div.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
208bn_div.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 208bn_div.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
209bn_div.o: ../cryptlib.h bn_div.c bn_lcl.h 209bn_div.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_div.c bn_lcl.h
210bn_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h 210bn_err.o: ../../include/openssl/bio.h ../../include/openssl/bn.h
211bn_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h 211bn_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
212bn_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h 212bn_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
213bn_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h 213bn_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
214bn_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h 214bn_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
215bn_err.o: ../../include/openssl/symhacks.h bn_err.c 215bn_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
216bn_err.o: bn_err.c
216bn_exp.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h 217bn_exp.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
217bn_exp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 218bn_exp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
218bn_exp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 219bn_exp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
219bn_exp.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 220bn_exp.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
220bn_exp.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 221bn_exp.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
221bn_exp.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 222bn_exp.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
222bn_exp.o: ../cryptlib.h bn_exp.c bn_lcl.h 223bn_exp.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_exp.c bn_lcl.h
223bn_exp2.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h 224bn_exp2.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
224bn_exp2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 225bn_exp2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
225bn_exp2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 226bn_exp2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
226bn_exp2.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 227bn_exp2.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
227bn_exp2.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 228bn_exp2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
228bn_exp2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 229bn_exp2.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
229bn_exp2.o: ../cryptlib.h bn_exp2.c bn_lcl.h 230bn_exp2.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_exp2.c bn_lcl.h
230bn_gcd.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h 231bn_gcd.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
231bn_gcd.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 232bn_gcd.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
232bn_gcd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 233bn_gcd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
233bn_gcd.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 234bn_gcd.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
234bn_gcd.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 235bn_gcd.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
235bn_gcd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 236bn_gcd.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
236bn_gcd.o: ../cryptlib.h bn_gcd.c bn_lcl.h 237bn_gcd.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_gcd.c bn_lcl.h
237bn_kron.o: ../../include/openssl/bn.h ../../include/openssl/e_os2.h 238bn_gf2m.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
238bn_kron.o: ../../include/openssl/opensslconf.h bn_kron.c bn_lcl.h 239bn_gf2m.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
240bn_gf2m.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
241bn_gf2m.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
242bn_gf2m.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
243bn_gf2m.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
244bn_gf2m.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_gf2m.c bn_lcl.h
245bn_kron.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
246bn_kron.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
247bn_kron.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
248bn_kron.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
249bn_kron.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
250bn_kron.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
251bn_kron.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_kron.c bn_lcl.h
239bn_lib.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h 252bn_lib.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
240bn_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 253bn_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
241bn_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 254bn_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
242bn_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 255bn_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
243bn_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 256bn_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
244bn_lib.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 257bn_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
245bn_lib.o: ../cryptlib.h bn_lcl.h bn_lib.c 258bn_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_lib.c
246bn_mod.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h 259bn_mod.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
247bn_mod.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 260bn_mod.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
248bn_mod.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 261bn_mod.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
249bn_mod.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 262bn_mod.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
250bn_mod.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 263bn_mod.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
251bn_mod.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 264bn_mod.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
252bn_mod.o: ../cryptlib.h bn_lcl.h bn_mod.c 265bn_mod.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_mod.c
253bn_mont.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h 266bn_mont.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
254bn_mont.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 267bn_mont.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
255bn_mont.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 268bn_mont.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
256bn_mont.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 269bn_mont.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
257bn_mont.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 270bn_mont.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
258bn_mont.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 271bn_mont.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
259bn_mont.o: ../cryptlib.h bn_lcl.h bn_mont.c 272bn_mont.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_mont.c
260bn_mpi.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h 273bn_mpi.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
261bn_mpi.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 274bn_mpi.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
262bn_mpi.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 275bn_mpi.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
263bn_mpi.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 276bn_mpi.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
264bn_mpi.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 277bn_mpi.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
265bn_mpi.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 278bn_mpi.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
266bn_mpi.o: ../cryptlib.h bn_lcl.h bn_mpi.c 279bn_mpi.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_mpi.c
267bn_mul.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h 280bn_mul.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
268bn_mul.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 281bn_mul.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
269bn_mul.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 282bn_mul.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
270bn_mul.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 283bn_mul.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
271bn_mul.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 284bn_mul.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
272bn_mul.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 285bn_mul.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
273bn_mul.o: ../cryptlib.h bn_lcl.h bn_mul.c 286bn_mul.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_mul.c
287bn_nist.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
288bn_nist.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
289bn_nist.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
290bn_nist.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
291bn_nist.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
292bn_nist.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
293bn_nist.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_nist.c
274bn_prime.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h 294bn_prime.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
275bn_prime.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 295bn_prime.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
276bn_prime.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 296bn_prime.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
@@ -283,9 +303,9 @@ bn_print.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
283bn_print.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 303bn_print.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
284bn_print.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 304bn_print.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
285bn_print.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 305bn_print.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
286bn_print.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 306bn_print.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
287bn_print.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 307bn_print.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
288bn_print.o: ../cryptlib.h bn_lcl.h bn_print.c 308bn_print.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_print.c
289bn_rand.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h 309bn_rand.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
290bn_rand.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 310bn_rand.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
291bn_rand.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 311bn_rand.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
@@ -298,36 +318,34 @@ bn_recp.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
298bn_recp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 318bn_recp.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
299bn_recp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 319bn_recp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
300bn_recp.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 320bn_recp.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
301bn_recp.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 321bn_recp.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
302bn_recp.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 322bn_recp.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
303bn_recp.o: ../cryptlib.h bn_lcl.h bn_recp.c 323bn_recp.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_recp.c
304bn_shift.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h 324bn_shift.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
305bn_shift.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 325bn_shift.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
306bn_shift.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 326bn_shift.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
307bn_shift.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 327bn_shift.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
308bn_shift.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 328bn_shift.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
309bn_shift.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 329bn_shift.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
310bn_shift.o: ../cryptlib.h bn_lcl.h bn_shift.c 330bn_shift.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_shift.c
311bn_sqr.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h 331bn_sqr.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
312bn_sqr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 332bn_sqr.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
313bn_sqr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 333bn_sqr.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
314bn_sqr.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 334bn_sqr.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
315bn_sqr.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 335bn_sqr.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
316bn_sqr.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 336bn_sqr.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
317bn_sqr.o: ../cryptlib.h bn_lcl.h bn_sqr.c 337bn_sqr.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_sqr.c
318bn_sqrt.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h 338bn_sqrt.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
319bn_sqrt.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 339bn_sqrt.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
320bn_sqrt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 340bn_sqrt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
321bn_sqrt.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 341bn_sqrt.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
322bn_sqrt.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 342bn_sqrt.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
323bn_sqrt.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 343bn_sqrt.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
324bn_sqrt.o: ../cryptlib.h bn_lcl.h bn_sqrt.c 344bn_sqrt.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_sqrt.c
325bn_word.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h 345bn_word.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
326bn_word.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h 346bn_word.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
327bn_word.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h 347bn_word.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
328bn_word.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h 348bn_word.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
329bn_word.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h 349bn_word.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
330bn_word.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h 350bn_word.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
331bn_word.o: ../cryptlib.h bn_lcl.h bn_word.c 351bn_word.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_lcl.h bn_word.c
332bn_x931p.o: ../../include/openssl/bn.h ../../include/openssl/e_os2.h
333bn_x931p.o: ../../include/openssl/opensslconf.h bn_x931p.c
diff --git a/src/lib/libcrypto/bn/asm/mo-586.pl b/src/lib/libcrypto/bn/asm/mo-586.pl
new file mode 100644
index 0000000000..0982293094
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/mo-586.pl
@@ -0,0 +1,603 @@
1#!/usr/bin/env perl
2
3# This is crypto/bn/asm/x86-mont.pl (with asciz from crypto/perlasm/x86asm.pl)
4# from OpenSSL 0.9.9-dev
5
6sub ::asciz
7{ my @str=unpack("C*",shift);
8 push @str,0;
9 while ($#str>15) {
10 &data_byte(@str[0..15]);
11 foreach (0..15) { shift @str; }
12 }
13 &data_byte(@str) if (@str);
14}
15
16# ====================================================================
17# Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
18# project. The module is, however, dual licensed under OpenSSL and
19# CRYPTOGAMS licenses depending on where you obtain it. For further
20# details see http://www.openssl.org/~appro/cryptogams/.
21# ====================================================================
22
23# October 2005
24#
25# This is a "teaser" code, as it can be improved in several ways...
26# First of all non-SSE2 path should be implemented (yes, for now it
27# performs Montgomery multiplication/convolution only on SSE2-capable
28# CPUs such as P4, others fall down to original code). Then inner loop
29# can be unrolled and modulo-scheduled to improve ILP and possibly
30# moved to 128-bit XMM register bank (though it would require input
31# rearrangement and/or increase bus bandwidth utilization). Dedicated
32# squaring procedure should give further performance improvement...
33# Yet, for being draft, the code improves rsa512 *sign* benchmark by
34# 110%(!), rsa1024 one - by 70% and rsa4096 - by 20%:-)
35
36# December 2006
37#
38# Modulo-scheduling SSE2 loops results in further 15-20% improvement.
39# Integer-only code [being equipped with dedicated squaring procedure]
40# gives ~40% on rsa512 sign benchmark...
41
42push(@INC,"perlasm","../../perlasm");
43require "x86asm.pl";
44
45&asm_init($ARGV[0],$0);
46
47$sse2=0;
48for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
49
50&external_label("OPENSSL_ia32cap_P") if ($sse2);
51
52&function_begin("bn_mul_mont");
53
54$i="edx";
55$j="ecx";
56$ap="esi"; $tp="esi"; # overlapping variables!!!
57$rp="edi"; $bp="edi"; # overlapping variables!!!
58$np="ebp";
59$num="ebx";
60
61$_num=&DWP(4*0,"esp"); # stack top layout
62$_rp=&DWP(4*1,"esp");
63$_ap=&DWP(4*2,"esp");
64$_bp=&DWP(4*3,"esp");
65$_np=&DWP(4*4,"esp");
66$_n0=&DWP(4*5,"esp"); $_n0q=&QWP(4*5,"esp");
67$_sp=&DWP(4*6,"esp");
68$_bpend=&DWP(4*7,"esp");
69$frame=32; # size of above frame rounded up to 16n
70
71 &xor ("eax","eax");
72 &mov ("edi",&wparam(5)); # int num
73 &cmp ("edi",4);
74 &jl (&label("just_leave"));
75
76 &lea ("esi",&wparam(0)); # put aside pointer to argument block
77 &lea ("edx",&wparam(1)); # load ap
78 &mov ("ebp","esp"); # saved stack pointer!
79 &add ("edi",2); # extra two words on top of tp
80 &neg ("edi");
81 &lea ("esp",&DWP(-$frame,"esp","edi",4)); # alloca($frame+4*(num+2))
82 &neg ("edi");
83
84 # minimize cache contention by arraning 2K window between stack
85 # pointer and ap argument [np is also position sensitive vector,
86 # but it's assumed to be near ap, as it's allocated at ~same
87 # time].
88 &mov ("eax","esp");
89 &sub ("eax","edx");
90 &and ("eax",2047);
91 &sub ("esp","eax"); # this aligns sp and ap modulo 2048
92
93 &xor ("edx","esp");
94 &and ("edx",2048);
95 &xor ("edx",2048);
96 &sub ("esp","edx"); # this splits them apart modulo 4096
97
98 &and ("esp",-64); # align to cache line
99
100 ################################# load argument block...
101 &mov ("eax",&DWP(0*4,"esi"));# BN_ULONG *rp
102 &mov ("ebx",&DWP(1*4,"esi"));# const BN_ULONG *ap
103 &mov ("ecx",&DWP(2*4,"esi"));# const BN_ULONG *bp
104 &mov ("edx",&DWP(3*4,"esi"));# const BN_ULONG *np
105 &mov ("esi",&DWP(4*4,"esi"));# const BN_ULONG *n0
106 #&mov ("edi",&DWP(5*4,"esi"));# int num
107
108 &mov ("esi",&DWP(0,"esi")); # pull n0[0]
109 &mov ($_rp,"eax"); # ... save a copy of argument block
110 &mov ($_ap,"ebx");
111 &mov ($_bp,"ecx");
112 &mov ($_np,"edx");
113 &mov ($_n0,"esi");
114 &lea ($num,&DWP(-3,"edi")); # num=num-1 to assist modulo-scheduling
115 #&mov ($_num,$num); # redundant as $num is not reused
116 &mov ($_sp,"ebp"); # saved stack pointer!
117
118if($sse2) {
119$acc0="mm0"; # mmx register bank layout
120$acc1="mm1";
121$car0="mm2";
122$car1="mm3";
123$mul0="mm4";
124$mul1="mm5";
125$temp="mm6";
126$mask="mm7";
127
128 &picmeup("eax","OPENSSL_ia32cap_P");
129 &bt (&DWP(0,"eax"),26);
130 &jnc (&label("non_sse2"));
131
132 &mov ("eax",-1);
133 &movd ($mask,"eax"); # mask 32 lower bits
134
135 &mov ($ap,$_ap); # load input pointers
136 &mov ($bp,$_bp);
137 &mov ($np,$_np);
138
139 &xor ($i,$i); # i=0
140 &xor ($j,$j); # j=0
141
142 &movd ($mul0,&DWP(0,$bp)); # bp[0]
143 &movd ($mul1,&DWP(0,$ap)); # ap[0]
144 &movd ($car1,&DWP(0,$np)); # np[0]
145
146 &pmuludq($mul1,$mul0); # ap[0]*bp[0]
147 &movq ($car0,$mul1);
148 &movq ($acc0,$mul1); # I wish movd worked for
149 &pand ($acc0,$mask); # inter-register transfers
150
151 &pmuludq($mul1,$_n0q); # *=n0
152
153 &pmuludq($car1,$mul1); # "t[0]"*np[0]*n0
154 &paddq ($car1,$acc0);
155
156 &movd ($acc1,&DWP(4,$np)); # np[1]
157 &movd ($acc0,&DWP(4,$ap)); # ap[1]
158
159 &psrlq ($car0,32);
160 &psrlq ($car1,32);
161
162 &inc ($j); # j++
163&set_label("1st",16);
164 &pmuludq($acc0,$mul0); # ap[j]*bp[0]
165 &pmuludq($acc1,$mul1); # np[j]*m1
166 &paddq ($car0,$acc0); # +=c0
167 &paddq ($car1,$acc1); # +=c1
168
169 &movq ($acc0,$car0);
170 &pand ($acc0,$mask);
171 &movd ($acc1,&DWP(4,$np,$j,4)); # np[j+1]
172 &paddq ($car1,$acc0); # +=ap[j]*bp[0];
173 &movd ($acc0,&DWP(4,$ap,$j,4)); # ap[j+1]
174 &psrlq ($car0,32);
175 &movd (&DWP($frame-4,"esp",$j,4),$car1); # tp[j-1]=
176 &psrlq ($car1,32);
177
178 &lea ($j,&DWP(1,$j));
179 &cmp ($j,$num);
180 &jl (&label("1st"));
181
182 &pmuludq($acc0,$mul0); # ap[num-1]*bp[0]
183 &pmuludq($acc1,$mul1); # np[num-1]*m1
184 &paddq ($car0,$acc0); # +=c0
185 &paddq ($car1,$acc1); # +=c1
186
187 &movq ($acc0,$car0);
188 &pand ($acc0,$mask);
189 &paddq ($car1,$acc0); # +=ap[num-1]*bp[0];
190 &movd (&DWP($frame-4,"esp",$j,4),$car1); # tp[num-2]=
191
192 &psrlq ($car0,32);
193 &psrlq ($car1,32);
194
195 &paddq ($car1,$car0);
196 &movq (&QWP($frame,"esp",$num,4),$car1); # tp[num].tp[num-1]
197
198 &inc ($i); # i++
199&set_label("outer");
200 &xor ($j,$j); # j=0
201
202 &movd ($mul0,&DWP(0,$bp,$i,4)); # bp[i]
203 &movd ($mul1,&DWP(0,$ap)); # ap[0]
204 &movd ($temp,&DWP($frame,"esp")); # tp[0]
205 &movd ($car1,&DWP(0,$np)); # np[0]
206 &pmuludq($mul1,$mul0); # ap[0]*bp[i]
207
208 &paddq ($mul1,$temp); # +=tp[0]
209 &movq ($acc0,$mul1);
210 &movq ($car0,$mul1);
211 &pand ($acc0,$mask);
212
213 &pmuludq($mul1,$_n0q); # *=n0
214
215 &pmuludq($car1,$mul1);
216 &paddq ($car1,$acc0);
217
218 &movd ($temp,&DWP($frame+4,"esp")); # tp[1]
219 &movd ($acc1,&DWP(4,$np)); # np[1]
220 &movd ($acc0,&DWP(4,$ap)); # ap[1]
221
222 &psrlq ($car0,32);
223 &psrlq ($car1,32);
224 &paddq ($car0,$temp); # +=tp[1]
225
226 &inc ($j); # j++
227 &dec ($num);
228&set_label("inner");
229 &pmuludq($acc0,$mul0); # ap[j]*bp[i]
230 &pmuludq($acc1,$mul1); # np[j]*m1
231 &paddq ($car0,$acc0); # +=c0
232 &paddq ($car1,$acc1); # +=c1
233
234 &movq ($acc0,$car0);
235 &movd ($temp,&DWP($frame+4,"esp",$j,4));# tp[j+1]
236 &pand ($acc0,$mask);
237 &movd ($acc1,&DWP(4,$np,$j,4)); # np[j+1]
238 &paddq ($car1,$acc0); # +=ap[j]*bp[i]+tp[j]
239 &movd ($acc0,&DWP(4,$ap,$j,4)); # ap[j+1]
240 &psrlq ($car0,32);
241 &movd (&DWP($frame-4,"esp",$j,4),$car1);# tp[j-1]=
242 &psrlq ($car1,32);
243 &paddq ($car0,$temp); # +=tp[j+1]
244
245 &dec ($num);
246 &lea ($j,&DWP(1,$j)); # j++
247 &jnz (&label("inner"));
248
249 &mov ($num,$j);
250 &pmuludq($acc0,$mul0); # ap[num-1]*bp[i]
251 &pmuludq($acc1,$mul1); # np[num-1]*m1
252 &paddq ($car0,$acc0); # +=c0
253 &paddq ($car1,$acc1); # +=c1
254
255 &movq ($acc0,$car0);
256 &pand ($acc0,$mask);
257 &paddq ($car1,$acc0); # +=ap[num-1]*bp[i]+tp[num-1]
258 &movd (&DWP($frame-4,"esp",$j,4),$car1); # tp[num-2]=
259 &psrlq ($car0,32);
260 &psrlq ($car1,32);
261
262 &movd ($temp,&DWP($frame+4,"esp",$num,4)); # += tp[num]
263 &paddq ($car1,$car0);
264 &paddq ($car1,$temp);
265 &movq (&QWP($frame,"esp",$num,4),$car1); # tp[num].tp[num-1]
266
267 &lea ($i,&DWP(1,$i)); # i++
268 &cmp ($i,$num);
269 &jle (&label("outer"));
270
271 &emms (); # done with mmx bank
272 &jmp (&label("common_tail"));
273
274&set_label("non_sse2",16);
275}
276
277if (0) {
278 &mov ("esp",$_sp);
279 &xor ("eax","eax"); # signal "not fast enough [yet]"
280 &jmp (&label("just_leave"));
281 # While the below code provides competitive performance for
282 # all key lengthes on modern Intel cores, it's still more
283 # than 10% slower for 4096-bit key elsewhere:-( "Competitive"
284 # means compared to the original integer-only assembler.
285 # 512-bit RSA sign is better by ~40%, but that's about all
286 # one can say about all CPUs...
287} else {
288$inp="esi"; # integer path uses these registers differently
289$word="edi";
290$carry="ebp";
291
292 &mov ($inp,$_ap);
293 &lea ($carry,&DWP(1,$num));
294 &mov ($word,$_bp);
295 &xor ($j,$j); # j=0
296 &mov ("edx",$inp);
297 &and ($carry,1); # see if num is even
298 &sub ("edx",$word); # see if ap==bp
299 &lea ("eax",&DWP(4,$word,$num,4)); # &bp[num]
300 &or ($carry,"edx");
301 &mov ($word,&DWP(0,$word)); # bp[0]
302 &jz (&label("bn_sqr_mont"));
303 &mov ($_bpend,"eax");
304 &mov ("eax",&DWP(0,$inp));
305 &xor ("edx","edx");
306
307&set_label("mull",16);
308 &mov ($carry,"edx");
309 &mul ($word); # ap[j]*bp[0]
310 &add ($carry,"eax");
311 &lea ($j,&DWP(1,$j));
312 &adc ("edx",0);
313 &mov ("eax",&DWP(0,$inp,$j,4)); # ap[j+1]
314 &cmp ($j,$num);
315 &mov (&DWP($frame-4,"esp",$j,4),$carry); # tp[j]=
316 &jl (&label("mull"));
317
318 &mov ($carry,"edx");
319 &mul ($word); # ap[num-1]*bp[0]
320 &mov ($word,$_n0);
321 &add ("eax",$carry);
322 &mov ($inp,$_np);
323 &adc ("edx",0);
324 &imul ($word,&DWP($frame,"esp")); # n0*tp[0]
325
326 &mov (&DWP($frame,"esp",$num,4),"eax"); # tp[num-1]=
327 &xor ($j,$j);
328 &mov (&DWP($frame+4,"esp",$num,4),"edx"); # tp[num]=
329 &mov (&DWP($frame+8,"esp",$num,4),$j); # tp[num+1]=
330
331 &mov ("eax",&DWP(0,$inp)); # np[0]
332 &mul ($word); # np[0]*m
333 &add ("eax",&DWP($frame,"esp")); # +=tp[0]
334 &mov ("eax",&DWP(4,$inp)); # np[1]
335 &adc ("edx",0);
336 &inc ($j);
337
338 &jmp (&label("2ndmadd"));
339
340&set_label("1stmadd",16);
341 &mov ($carry,"edx");
342 &mul ($word); # ap[j]*bp[i]
343 &add ($carry,&DWP($frame,"esp",$j,4)); # +=tp[j]
344 &lea ($j,&DWP(1,$j));
345 &adc ("edx",0);
346 &add ($carry,"eax");
347 &mov ("eax",&DWP(0,$inp,$j,4)); # ap[j+1]
348 &adc ("edx",0);
349 &cmp ($j,$num);
350 &mov (&DWP($frame-4,"esp",$j,4),$carry); # tp[j]=
351 &jl (&label("1stmadd"));
352
353 &mov ($carry,"edx");
354 &mul ($word); # ap[num-1]*bp[i]
355 &add ("eax",&DWP($frame,"esp",$num,4)); # +=tp[num-1]
356 &mov ($word,$_n0);
357 &adc ("edx",0);
358 &mov ($inp,$_np);
359 &add ($carry,"eax");
360 &adc ("edx",0);
361 &imul ($word,&DWP($frame,"esp")); # n0*tp[0]
362
363 &xor ($j,$j);
364 &add ("edx",&DWP($frame+4,"esp",$num,4)); # carry+=tp[num]
365 &mov (&DWP($frame,"esp",$num,4),$carry); # tp[num-1]=
366 &adc ($j,0);
367 &mov ("eax",&DWP(0,$inp)); # np[0]
368 &mov (&DWP($frame+4,"esp",$num,4),"edx"); # tp[num]=
369 &mov (&DWP($frame+8,"esp",$num,4),$j); # tp[num+1]=
370
371 &mul ($word); # np[0]*m
372 &add ("eax",&DWP($frame,"esp")); # +=tp[0]
373 &mov ("eax",&DWP(4,$inp)); # np[1]
374 &adc ("edx",0);
375 &mov ($j,1);
376
377&set_label("2ndmadd",16);
378 &mov ($carry,"edx");
379 &mul ($word); # np[j]*m
380 &add ($carry,&DWP($frame,"esp",$j,4)); # +=tp[j]
381 &lea ($j,&DWP(1,$j));
382 &adc ("edx",0);
383 &add ($carry,"eax");
384 &mov ("eax",&DWP(0,$inp,$j,4)); # np[j+1]
385 &adc ("edx",0);
386 &cmp ($j,$num);
387 &mov (&DWP($frame-8,"esp",$j,4),$carry); # tp[j-1]=
388 &jl (&label("2ndmadd"));
389
390 &mov ($carry,"edx");
391 &mul ($word); # np[j]*m
392 &add ($carry,&DWP($frame,"esp",$num,4)); # +=tp[num-1]
393 &adc ("edx",0);
394 &add ($carry,"eax");
395 &adc ("edx",0);
396 &mov (&DWP($frame-4,"esp",$num,4),$carry); # tp[num-2]=
397
398 &xor ("eax","eax");
399 &mov ($j,$_bp); # &bp[i]
400 &add ("edx",&DWP($frame+4,"esp",$num,4)); # carry+=tp[num]
401 &adc ("eax",&DWP($frame+8,"esp",$num,4)); # +=tp[num+1]
402 &lea ($j,&DWP(4,$j));
403 &mov (&DWP($frame,"esp",$num,4),"edx"); # tp[num-1]=
404 &cmp ($j,$_bpend);
405 &mov (&DWP($frame+4,"esp",$num,4),"eax"); # tp[num]=
406 &je (&label("common_tail"));
407
408 &mov ($word,&DWP(0,$j)); # bp[i+1]
409 &mov ($inp,$_ap);
410 &mov ($_bp,$j); # &bp[++i]
411 &xor ($j,$j);
412 &xor ("edx","edx");
413 &mov ("eax",&DWP(0,$inp));
414 &jmp (&label("1stmadd"));
415
416&set_label("bn_sqr_mont",16);
417$sbit=$num;
418 &mov ($_num,$num);
419 &mov ($_bp,$j); # i=0
420
421 &mov ("eax",$word); # ap[0]
422 &mul ($word); # ap[0]*ap[0]
423 &mov (&DWP($frame,"esp"),"eax"); # tp[0]=
424 &mov ($sbit,"edx");
425 &shr ("edx",1);
426 &and ($sbit,1);
427 &inc ($j);
428&set_label("sqr",16);
429 &mov ("eax",&DWP(0,$inp,$j,4)); # ap[j]
430 &mov ($carry,"edx");
431 &mul ($word); # ap[j]*ap[0]
432 &add ("eax",$carry);
433 &lea ($j,&DWP(1,$j));
434 &adc ("edx",0);
435 &lea ($carry,&DWP(0,$sbit,"eax",2));
436 &shr ("eax",31);
437 &cmp ($j,$_num);
438 &mov ($sbit,"eax");
439 &mov (&DWP($frame-4,"esp",$j,4),$carry); # tp[j]=
440 &jl (&label("sqr"));
441
442 &mov ("eax",&DWP(0,$inp,$j,4)); # ap[num-1]
443 &mov ($carry,"edx");
444 &mul ($word); # ap[num-1]*ap[0]
445 &add ("eax",$carry);
446 &mov ($word,$_n0);
447 &adc ("edx",0);
448 &mov ($inp,$_np);
449 &lea ($carry,&DWP(0,$sbit,"eax",2));
450 &imul ($word,&DWP($frame,"esp")); # n0*tp[0]
451 &shr ("eax",31);
452 &mov (&DWP($frame,"esp",$j,4),$carry); # tp[num-1]=
453
454 &lea ($carry,&DWP(0,"eax","edx",2));
455 &mov ("eax",&DWP(0,$inp)); # np[0]
456 &shr ("edx",31);
457 &mov (&DWP($frame+4,"esp",$j,4),$carry); # tp[num]=
458 &mov (&DWP($frame+8,"esp",$j,4),"edx"); # tp[num+1]=
459
460 &mul ($word); # np[0]*m
461 &add ("eax",&DWP($frame,"esp")); # +=tp[0]
462 &mov ($num,$j);
463 &adc ("edx",0);
464 &mov ("eax",&DWP(4,$inp)); # np[1]
465 &mov ($j,1);
466
467&set_label("3rdmadd",16);
468 &mov ($carry,"edx");
469 &mul ($word); # np[j]*m
470 &add ($carry,&DWP($frame,"esp",$j,4)); # +=tp[j]
471 &adc ("edx",0);
472 &add ($carry,"eax");
473 &mov ("eax",&DWP(4,$inp,$j,4)); # np[j+1]
474 &adc ("edx",0);
475 &mov (&DWP($frame-4,"esp",$j,4),$carry); # tp[j-1]=
476
477 &mov ($carry,"edx");
478 &mul ($word); # np[j+1]*m
479 &add ($carry,&DWP($frame+4,"esp",$j,4)); # +=tp[j+1]
480 &lea ($j,&DWP(2,$j));
481 &adc ("edx",0);
482 &add ($carry,"eax");
483 &mov ("eax",&DWP(0,$inp,$j,4)); # np[j+2]
484 &adc ("edx",0);
485 &cmp ($j,$num);
486 &mov (&DWP($frame-8,"esp",$j,4),$carry); # tp[j]=
487 &jl (&label("3rdmadd"));
488
489 &mov ($carry,"edx");
490 &mul ($word); # np[j]*m
491 &add ($carry,&DWP($frame,"esp",$num,4)); # +=tp[num-1]
492 &adc ("edx",0);
493 &add ($carry,"eax");
494 &adc ("edx",0);
495 &mov (&DWP($frame-4,"esp",$num,4),$carry); # tp[num-2]=
496
497 &mov ($j,$_bp); # i
498 &xor ("eax","eax");
499 &mov ($inp,$_ap);
500 &add ("edx",&DWP($frame+4,"esp",$num,4)); # carry+=tp[num]
501 &adc ("eax",&DWP($frame+8,"esp",$num,4)); # +=tp[num+1]
502 &mov (&DWP($frame,"esp",$num,4),"edx"); # tp[num-1]=
503 &cmp ($j,$num);
504 &mov (&DWP($frame+4,"esp",$num,4),"eax"); # tp[num]=
505 &je (&label("common_tail"));
506
507 &mov ($word,&DWP(4,$inp,$j,4)); # ap[i]
508 &lea ($j,&DWP(1,$j));
509 &mov ("eax",$word);
510 &mov ($_bp,$j); # ++i
511 &mul ($word); # ap[i]*ap[i]
512 &add ("eax",&DWP($frame,"esp",$j,4)); # +=tp[i]
513 &adc ("edx",0);
514 &mov (&DWP($frame,"esp",$j,4),"eax"); # tp[i]=
515 &xor ($carry,$carry);
516 &cmp ($j,$num);
517 &lea ($j,&DWP(1,$j));
518 &je (&label("sqrlast"));
519
520 &mov ($sbit,"edx"); # zaps $num
521 &shr ("edx",1);
522 &and ($sbit,1);
523&set_label("sqradd",16);
524 &mov ("eax",&DWP(0,$inp,$j,4)); # ap[j]
525 &mov ($carry,"edx");
526 &mul ($word); # ap[j]*ap[i]
527 &add ("eax",$carry);
528 &lea ($carry,&DWP(0,"eax","eax"));
529 &adc ("edx",0);
530 &shr ("eax",31);
531 &add ($carry,&DWP($frame,"esp",$j,4)); # +=tp[j]
532 &lea ($j,&DWP(1,$j));
533 &adc ("eax",0);
534 &add ($carry,$sbit);
535 &adc ("eax",0);
536 &cmp ($j,$_num);
537 &mov (&DWP($frame-4,"esp",$j,4),$carry); # tp[j]=
538 &mov ($sbit,"eax");
539 &jle (&label("sqradd"));
540
541 &mov ($carry,"edx");
542 &lea ("edx",&DWP(0,$sbit,"edx",2));
543 &shr ($carry,31);
544&set_label("sqrlast");
545 &mov ($word,$_n0);
546 &mov ($inp,$_np);
547 &imul ($word,&DWP($frame,"esp")); # n0*tp[0]
548
549 &add ("edx",&DWP($frame,"esp",$j,4)); # +=tp[num]
550 &mov ("eax",&DWP(0,$inp)); # np[0]
551 &adc ($carry,0);
552 &mov (&DWP($frame,"esp",$j,4),"edx"); # tp[num]=
553 &mov (&DWP($frame+4,"esp",$j,4),$carry); # tp[num+1]=
554
555 &mul ($word); # np[0]*m
556 &add ("eax",&DWP($frame,"esp")); # +=tp[0]
557 &lea ($num,&DWP(-1,$j));
558 &adc ("edx",0);
559 &mov ($j,1);
560 &mov ("eax",&DWP(4,$inp)); # np[1]
561
562 &jmp (&label("3rdmadd"));
563}
564
565&set_label("common_tail",16);
566 &mov ($np,$_np); # load modulus pointer
567 &mov ($rp,$_rp); # load result pointer
568 &lea ($tp,&DWP($frame,"esp")); # [$ap and $bp are zapped]
569
570 &mov ("eax",&DWP(0,$tp)); # tp[0]
571 &mov ($j,$num); # j=num-1
572 &xor ($i,$i); # i=0 and clear CF!
573
574&set_label("sub",16);
575 &sbb ("eax",&DWP(0,$np,$i,4));
576 &mov (&DWP(0,$rp,$i,4),"eax"); # rp[i]=tp[i]-np[i]
577 &dec ($j); # doesn't affect CF!
578 &mov ("eax",&DWP(4,$tp,$i,4)); # tp[i+1]
579 &lea ($i,&DWP(1,$i)); # i++
580 &jge (&label("sub"));
581
582 &sbb ("eax",0); # handle upmost overflow bit
583 &and ($tp,"eax");
584 &not ("eax");
585 &mov ($np,$rp);
586 &and ($np,"eax");
587 &or ($tp,$np); # tp=carry?tp:rp
588
589&set_label("copy",16); # copy or in-place refresh
590 &mov ("eax",&DWP(0,$tp,$num,4));
591 &mov (&DWP(0,$rp,$num,4),"eax"); # rp[i]=tp[i]
592 &mov (&DWP($frame,"esp",$num,4),$j); # zap temporary vector
593 &dec ($num);
594 &jge (&label("copy"));
595
596 &mov ("esp",$_sp); # pull saved stack pointer
597 &mov ("eax",1);
598&set_label("just_leave");
599&function_end("bn_mul_mont");
600
601&asciz("Montgomery Multiplication for x86, CRYPTOGAMS by <appro\@openssl.org>");
602
603&asm_finish();