48e82c8e22
This commit adds a dedicated function in `EC_METHOD` to access a modular
field inversion implementation suitable for the specifics of the
implemented curve, featuring SCA countermeasures.
The new pointer is defined as:
`int (*field_inv)(const EC_GROUP*, BIGNUM *r, const BIGNUM *a, BN_CTX*)`
and computes the multiplicative inverse of `a` in the underlying field,
storing the result in `r`.
Three implementations are included, each including specific SCA
countermeasures:
- `ec_GFp_simple_field_inv()`, featuring SCA hardening through
blinding.
- `ec_GFp_mont_field_inv()`, featuring SCA hardening through Fermat's
Little Theorem (FLT) inversion.
- `ec_GF2m_simple_field_inv()`, that uses `BN_GF2m_mod_inv()` which
already features SCA hardening through blinding.
From a security point of view, this also helps addressing a leakage
previously affecting conversions from projective to affine coordinates.
This commit also adds a new error reason code (i.e.,
`EC_R_CANNOT_INVERT`) to improve consistency between the three
implementations as all of them could fail for the same reason but
through different code paths resulting in inconsistent error stack
states.
Co-authored-by: Nicola Tuveri <nic.tuv@gmail.com>
(cherry picked from commit
|
||
---|---|---|
.. | ||
asm | ||
curve448 | ||
build.info | ||
curve25519.c | ||
ec2_oct.c | ||
ec2_smpl.c | ||
ec_ameth.c | ||
ec_asn1.c | ||
ec_check.c | ||
ec_curve.c | ||
ec_cvt.c | ||
ec_err.c | ||
ec_key.c | ||
ec_kmeth.c | ||
ec_lcl.h | ||
ec_lib.c | ||
ec_mult.c | ||
ec_oct.c | ||
ec_pmeth.c | ||
ec_print.c | ||
ecdh_kdf.c | ||
ecdh_ossl.c | ||
ecdsa_ossl.c | ||
ecdsa_sign.c | ||
ecdsa_vrf.c | ||
eck_prn.c | ||
ecp_mont.c | ||
ecp_nist.c | ||
ecp_nistp224.c | ||
ecp_nistp256.c | ||
ecp_nistp521.c | ||
ecp_nistputil.c | ||
ecp_nistz256.c | ||
ecp_nistz256_table.c | ||
ecp_oct.c | ||
ecp_smpl.c | ||
ecx_meth.c |