Allow for bn_mul_mont assembler.
This commit is contained in:
parent
ce0e12d29a
commit
da5c0127ac
4 changed files with 29 additions and 0 deletions
|
@ -1248,6 +1248,8 @@ $bn_obj = $bn_asm unless $bn_obj ne "";
|
|||
$cflags.=" -DOPENSSL_BN_ASM_PART_WORDS" if ($bn_obj =~ /bn86/);
|
||||
$cflags.=" -DOPENSSL_IA32_SSE2" if (!$no_sse2 && $bn_obj =~ /bn86/);
|
||||
|
||||
$cflags.=" -DOPENSSL_BN_ASM_MONT" if ($bn_obj =~ /\-mont|mo86\-/);
|
||||
|
||||
if ($fips)
|
||||
{
|
||||
$openssl_other_defines.="#define OPENSSL_FIPS\n";
|
||||
|
|
|
@ -67,16 +67,22 @@ bn86-elf.s: asm/bn-586.pl ../perlasm/x86asm.pl
|
|||
(cd asm; $(PERL) bn-586.pl elf $(CFLAGS) > ../$@)
|
||||
co86-elf.s: asm/co-586.pl ../perlasm/x86asm.pl
|
||||
(cd asm; $(PERL) co-586.pl elf $(CFLAGS) > ../$@)
|
||||
mo86-elf.s: asm/x86-mont.pl ../perlasm/x86asm.pl
|
||||
(cd asm; $(PERL) x86-mont.pl elf $(CFLAGS) > ../$@)
|
||||
# COFF
|
||||
bn86-cof.s: asm/bn-586.pl ../perlasm/x86asm.pl
|
||||
(cd asm; $(PERL) bn-586.pl coff $(CFLAGS) > ../$@)
|
||||
co86-cof.s: asm/co-586.pl ../perlasm/x86asm.pl
|
||||
(cd asm; $(PERL) co-586.pl coff $(CFLAGS) > ../$@)
|
||||
mo86-cof.s: asm/x86-mont.pl ../perlasm/x86asm.pl
|
||||
(cd asm; $(PERL) x86-mont.pl coff $(CFLAGS) > ../$@)
|
||||
# a.out
|
||||
bn86-out.s: asm/bn-586.pl ../perlasm/x86asm.pl
|
||||
(cd asm; $(PERL) bn-586.pl a.out $(CFLAGS) > ../$@)
|
||||
co86-out.s: asm/co-586.pl ../perlasm/x86asm.pl
|
||||
(cd asm; $(PERL) co-586.pl a.out $(CFLAGS) > ../$@)
|
||||
mo86-out.s: asm/x86-mont.pl ../perlasm/x86asm.pl
|
||||
(cd asm; $(PERL) x86-mont.pl a.out $(CFLAGS) > ../$@)
|
||||
|
||||
sparcv8.o: asm/sparcv8.S
|
||||
$(CC) $(CFLAGS) -c asm/sparcv8.S
|
||||
|
@ -91,6 +97,8 @@ bn-mips3.o: asm/mips3.s
|
|||
|
||||
x86_64-gcc.o: asm/x86_64-gcc.c
|
||||
$(CC) $(CFLAGS) -c -o $@ asm/x86_64-gcc.c
|
||||
x86_64-mont.s: asm/x86_64-mont.pl
|
||||
$(PERL) asm/x86_64-mont.pl $@
|
||||
|
||||
bn-ia64.s: asm/ia64.S
|
||||
$(CC) $(CFLAGS) -E asm/ia64.S > $@
|
||||
|
@ -112,6 +120,9 @@ aix_ppc32.s: asm/ppc.pl; $(PERL) asm/ppc.pl $@
|
|||
aix_ppc64.s: asm/ppc.pl; $(PERL) asm/ppc.pl $@
|
||||
osx_ppc32.s: asm/ppc.pl; $(PERL) $< $@
|
||||
|
||||
# GNU make "catch all"
|
||||
%-mont.s: asm/%-mont.pl; $(PERL) $< $(CFLAGS) > $@
|
||||
|
||||
files:
|
||||
$(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
|
||||
|
||||
|
|
|
@ -481,6 +481,7 @@ BN_ULONG bn_add_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
|
|||
int cl, int dl);
|
||||
BN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
|
||||
int cl, int dl);
|
||||
int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np,const BN_ULONG *n0, int num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -127,6 +127,21 @@ int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
|
|||
{
|
||||
BIGNUM *tmp;
|
||||
int ret=0;
|
||||
#if defined(OPENSSL_BN_ASM_MONT) && defined(MONT_WORD)
|
||||
int num = mont->N.top;
|
||||
|
||||
if (num>1 && a->top==num && b->top==num)
|
||||
{
|
||||
if (bn_wexpand(r,num) == NULL) return(0);
|
||||
if (bn_mul_mont(r->d,a->d,b->d,mont->N.d,&mont->n0,num))
|
||||
{
|
||||
r->neg = a->neg^b->neg;
|
||||
r->top = num;
|
||||
bn_correct_top(r);
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
tmp = BN_CTX_get(ctx);
|
||||
|
|
Loading…
Reference in a new issue