From: Thomas Pornin Date: Sat, 8 Dec 2018 20:12:27 +0000 (+0100) Subject: Made ec_c25519_m62 implementation the default on supported architectures. X-Git-Url: https://bearssl.org/gitweb//home/git/?a=commitdiff_plain;h=b2a08e908d6a1802c9d50aca699193b38b31a0b2;p=BearSSL Made ec_c25519_m62 implementation the default on supported architectures. --- diff --git a/src/ec/ec_all_m31.c b/src/ec/ec_all_m31.c index 0552c4b..b217d7c 100644 --- a/src/ec/ec_all_m31.c +++ b/src/ec/ec_all_m31.c @@ -31,7 +31,11 @@ api_generator(int curve, size_t *len) case BR_EC_secp256r1: return br_ec_p256_m31.generator(curve, len); case BR_EC_curve25519: +#if BR_INT128 || BR_UMUL128 + return br_ec_c25519_m62.generator(curve, len); +#else return br_ec_c25519_m31.generator(curve, len); +#endif default: return br_ec_prime_i31.generator(curve, len); } @@ -44,7 +48,11 @@ api_order(int curve, size_t *len) case BR_EC_secp256r1: return br_ec_p256_m31.order(curve, len); case BR_EC_curve25519: +#if BR_INT128 || BR_UMUL128 + return br_ec_c25519_m62.order(curve, len); +#else return br_ec_c25519_m31.order(curve, len); +#endif default: return br_ec_prime_i31.order(curve, len); } @@ -57,7 +65,11 @@ api_xoff(int curve, size_t *len) case BR_EC_secp256r1: return br_ec_p256_m31.xoff(curve, len); case BR_EC_curve25519: +#if BR_INT128 || BR_UMUL128 + return br_ec_c25519_m62.xoff(curve, len); +#else return br_ec_c25519_m31.xoff(curve, len); +#endif default: return br_ec_prime_i31.xoff(curve, len); } @@ -71,7 +83,11 @@ api_mul(unsigned char *G, size_t Glen, case BR_EC_secp256r1: return br_ec_p256_m31.mul(G, Glen, kb, kblen, curve); case BR_EC_curve25519: +#if BR_INT128 || BR_UMUL128 + return br_ec_c25519_m62.mul(G, Glen, kb, kblen, curve); +#else return br_ec_c25519_m31.mul(G, Glen, kb, kblen, curve); +#endif default: return br_ec_prime_i31.mul(G, Glen, kb, kblen, curve); } @@ -85,7 +101,11 @@ api_mulgen(unsigned char *R, case BR_EC_secp256r1: return br_ec_p256_m31.mulgen(R, x, xlen, curve); case BR_EC_curve25519: +#if BR_INT128 || BR_UMUL128 + return br_ec_c25519_m62.mulgen(R, x, xlen, curve); +#else return br_ec_c25519_m31.mulgen(R, x, xlen, curve); +#endif default: return br_ec_prime_i31.mulgen(R, x, xlen, curve); } @@ -101,8 +121,13 @@ api_muladd(unsigned char *A, const unsigned char *B, size_t len, return br_ec_p256_m31.muladd(A, B, len, x, xlen, y, ylen, curve); case BR_EC_curve25519: +#if BR_INT128 || BR_UMUL128 + return br_ec_c25519_m62.muladd(A, B, len, + x, xlen, y, ylen, curve); +#else return br_ec_c25519_m31.muladd(A, B, len, x, xlen, y, ylen, curve); +#endif default: return br_ec_prime_i31.muladd(A, B, len, x, xlen, y, ylen, curve); diff --git a/tools/names.c b/tools/names.c index 6d6fec0..8d6a67e 100644 --- a/tools/names.c +++ b/tools/names.c @@ -517,6 +517,8 @@ static const struct { (const void *(*)(void))&br_rsa_i62_pkcs1_sign_get }, { "rsa_i62_pkcs1_vrfy", "i62", (const void *(*)(void))&br_rsa_i62_pkcs1_vrfy_get }, + { "ec_c25519_m62", "m62", + (const void *(*)(void))&br_ec_c25519_m62_get }, { 0, 0, 0, } };