diff options
-rw-r--r-- | crypto/ec/build.info | 2 | ||||
-rw-r--r-- | crypto/ec/ecp_nistp521.c | 36 |
2 files changed, 35 insertions, 3 deletions
diff --git a/crypto/ec/build.info b/crypto/ec/build.info index dbe3a52..bfd16b3 100644 --- a/crypto/ec/build.info +++ b/crypto/ec/build.info @@ -31,7 +31,7 @@ IF[{- !$disabled{asm} -}] $ECASM_ppc32= $ECASM_ppc64=ecp_nistz256.c ecp_nistz256-ppc64.s x25519-ppc64.s - $ECDEF_ppc64=ECP_NISTZ256_ASM X25519_ASM + $ECDEF_ppc64=ECP_NISTZ256_ASM ECP_NISTP521_ASM X25519_ASM $ECASM_c64xplus= diff --git a/crypto/ec/ecp_nistp521.c b/crypto/ec/ecp_nistp521.c index e507c1e..02bded2 100644 --- a/crypto/ec/ecp_nistp521.c +++ b/crypto/ec/ecp_nistp521.c @@ -675,8 +675,40 @@ static void felem_reduce(felem out, const largefelem in) */ } -#define felem_square felem_square_ref -#define felem_mul felem_mul_ref +#if defined(ECP_NISTP521_ASM) +void felem_square_wrapper(largefelem out, const felem in); +void felem_mul_wrapper(largefelem out, const felem in1, const felem in2); + +static void (*felem_square_p)(largefelem out, const felem in) = + felem_square_wrapper; +static void (*felem_mul_p)(largefelem out, const felem in1, const felem in2) = + felem_mul_wrapper; + +void felem_select(void) +{ + /* Default */ + felem_square_p = felem_square_ref; + felem_mul_p = felem_mul_ref; +} + +void felem_square_wrapper(largefelem out, const felem in) +{ + felem_select(); + felem_square_p(out, in); +} + +void felem_mul_wrapper(largefelem out, const felem in1, const felem in2) +{ + felem_select(); + felem_mul_p(out, in1, in2); +} + +# define felem_square felem_square_p +# define felem_mul felem_mul_p +#else +# define felem_square felem_square_ref +# define felem_mul felem_mul_ref +#endif static void felem_square_reduce(felem out, const felem in) { |