Made ec_c25519_m62 implementation the default on supported architectures.

This commit is contained in:
Thomas Pornin 2018-12-08 21:12:27 +01:00
parent 52a69fe3de
commit b2a08e908d
2 changed files with 27 additions and 0 deletions

View File

@ -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);

View File

@ -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, }
};