I'm implementing some protocol using some 3rd party repository (Private Join and Compute), and the repo only supports built-in curves in FIPS modules (P-224, 256, 348 and 512) in openssl when creating EC group:
StatusOr<ECGroup::ECGroupPtr> CreateGroup(int curve_id) {
auto ec_group_ptr = EC_GROUP_new_by_curve_name(curve_id);
// If this fails, this is usually due to an invalid curve id.
if (ec_group_ptr == nullptr) {
return InvalidArgumentError(
absl::StrCat("ECGroup::CreateGroup() - Could not create group. ",
OpenSSLErrorString()));
}
return ECGroup::ECGroupPtr(ec_group_ptr);
}
(EC_GROUP_new_by_curve_name
is in openssl/crypto/fipsmodule)
My questions:
- Can I modify the code to replace built-in curves by X25519 for my protocol? My protocol uses it for ECDH.
- If not, what's the concern except that X25519 is not FIPS verified?
- Or, simply speaking, in what use case I should use secp256r1/k1 and what for X25519?