openssl/crypto/ec
Billy Brumley e0033efc30 SCA hardening for mod. field inversion in EC_GROUP
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>

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/8254)
2019-02-17 21:02:36 +02:00
..
asm ARM64 assembly pack: make it Windows-friendly. 2019-02-16 17:01:15 +01:00
curve448 Remove unnecessary trailing whitespace 2019-02-05 16:25:11 +01:00
build.info Build: Remove BEGINRAW / ENDRAW / OVERRIDE 2019-01-31 16:19:49 +01:00
curve25519.c curve25519.c: improve formula alignment 2018-12-06 19:38:13 +01:00
ec2_oct.c Following the license change, modify the boilerplates in crypto/ec/ 2018-12-06 14:51:47 +01:00
ec2_smpl.c SCA hardening for mod. field inversion in EC_GROUP 2019-02-17 21:02:36 +02:00
ec_ameth.c Following the license change, modify the boilerplates in crypto/ec/ 2018-12-06 14:51:47 +01:00
ec_asn1.c Following the license change, modify the boilerplates in crypto/ec/ 2018-12-06 14:51:47 +01:00
ec_check.c Following the license change, modify the boilerplates in crypto/ec/ 2018-12-06 14:51:47 +01:00
ec_curve.c Following the license change, modify the boilerplates in crypto/ec/ 2018-12-06 14:51:47 +01:00
ec_cvt.c Following the license change, modify the boilerplates in crypto/ec/ 2018-12-06 14:51:47 +01:00
ec_err.c SCA hardening for mod. field inversion in EC_GROUP 2019-02-17 21:02:36 +02:00
ec_key.c Following the license change, modify the boilerplates in crypto/ec/ 2018-12-06 14:51:47 +01:00
ec_kmeth.c Following the license change, modify the boilerplates in crypto/ec/ 2018-12-06 14:51:47 +01:00
ec_lcl.h SCA hardening for mod. field inversion in EC_GROUP 2019-02-17 21:02:36 +02:00
ec_lib.c Add EC_GROUP_get0_field 2019-02-15 16:43:18 +02:00
ec_mult.c Following the license change, modify the boilerplates in crypto/ec/ 2018-12-06 14:51:47 +01:00
ec_oct.c Following the license change, modify the boilerplates in crypto/ec/ 2018-12-06 14:51:47 +01:00
ec_pmeth.c Following the license change, modify the boilerplates in crypto/ec/ 2018-12-06 14:51:47 +01:00
ec_print.c Following the license change, modify the boilerplates in crypto/ec/ 2018-12-06 14:51:47 +01:00
ecdh_kdf.c Following the license change, modify the boilerplates in crypto/ec/ 2018-12-06 14:51:47 +01:00
ecdh_ossl.c Following the license change, modify the boilerplates in crypto/ec/ 2018-12-06 14:51:47 +01:00
ecdsa_ossl.c Following the license change, modify the boilerplates in crypto/ec/ 2018-12-06 14:51:47 +01:00
ecdsa_sign.c Following the license change, modify the boilerplates in crypto/ec/ 2018-12-06 14:51:47 +01:00
ecdsa_vrf.c Following the license change, modify the boilerplates in crypto/ec/ 2018-12-06 14:51:47 +01:00
eck_prn.c Following the license change, modify the boilerplates in crypto/ec/ 2018-12-06 14:51:47 +01:00
ecp_mont.c SCA hardening for mod. field inversion in EC_GROUP 2019-02-17 21:02:36 +02:00
ecp_nist.c SCA hardening for mod. field inversion in EC_GROUP 2019-02-17 21:02:36 +02:00
ecp_nistp224.c SCA hardening for mod. field inversion in EC_GROUP 2019-02-17 21:02:36 +02:00
ecp_nistp256.c SCA hardening for mod. field inversion in EC_GROUP 2019-02-17 21:02:36 +02:00
ecp_nistp521.c SCA hardening for mod. field inversion in EC_GROUP 2019-02-17 21:02:36 +02:00
ecp_nistputil.c Following the license change, modify the boilerplates in crypto/ec/ 2018-12-06 14:51:47 +01:00
ecp_nistz256.c SCA hardening for mod. field inversion in EC_GROUP 2019-02-17 21:02:36 +02:00
ecp_nistz256_table.c Following the license change, modify the boilerplates in crypto/ec/ 2018-12-06 14:51:47 +01:00
ecp_oct.c Following the license change, modify the boilerplates in crypto/ec/ 2018-12-06 14:51:47 +01:00
ecp_smpl.c SCA hardening for mod. field inversion in EC_GROUP 2019-02-17 21:02:36 +02:00
ecx_meth.c Following the license change, modify the boilerplates in crypto/ec/ 2018-12-06 14:51:47 +01:00