openssl/crypto/ec
Billy Brumley 48e82c8e22 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>

(cherry picked from commit e0033efc30)

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/8262)
2019-02-20 19:54:19 +02:00
..
asm Fix some CFI issues in x86_64 assembly 2019-02-17 23:41:11 +01:00
curve448 Remove unnecessary trailing whitespace 2019-02-05 16:29:17 +01:00
build.info Add ec/asm/x25519-ppc64.pl module. 2018-07-26 14:01:49 +02:00
curve25519.c curve25519.c: improve formula alignment 2018-12-06 20:55:00 +01:00
ec2_oct.c Update copyright year 2018-09-11 13:45:17 +01:00
ec2_smpl.c SCA hardening for mod. field inversion in EC_GROUP 2019-02-20 19:54:19 +02:00
ec_ameth.c Stop marking default digest for EC keys as mandatory 2018-11-24 08:49:32 +02:00
ec_asn1.c Use the new non-curve type specific EC functions internally 2018-07-31 09:08:38 +01:00
ec_check.c
ec_curve.c Use the new non-curve type specific EC functions internally 2018-07-31 09:08:38 +01:00
ec_cvt.c Update copyright year 2018-09-11 13:45:17 +01:00
ec_err.c SCA hardening for mod. field inversion in EC_GROUP 2019-02-20 19:54:19 +02:00
ec_key.c Fix segfault in RSA_free() (and DSA/DH/EC_KEY) 2018-09-05 15:22:35 +03:00
ec_kmeth.c Update copyright year 2018-09-11 13:45:17 +01:00
ec_lcl.h SCA hardening for mod. field inversion in EC_GROUP 2019-02-20 19:54:19 +02:00
ec_lib.c [test] throw error from wrapper function instead of an EC_METHOD specific one 2018-09-03 20:25:41 +02:00
ec_mult.c Timing vulnerability in ECDSA signature generation (CVE-2018-0735) 2018-10-29 07:59:23 +10:00
ec_oct.c Deprecate the EC curve type specific functions in 1.2.0 2018-07-31 09:08:50 +01:00
ec_pmeth.c EVP module documentation pass 2018-10-17 13:31:59 +03:00
ec_print.c Update copyright year 2018-04-17 15:18:40 +02:00
ecdh_kdf.c EVP module documentation pass 2018-10-17 13:31:59 +03:00
ecdh_ossl.c Use the new non-curve type specific EC functions internally 2018-07-31 09:08:38 +01:00
ecdsa_ossl.c Use the new non-curve type specific EC functions internally 2018-07-31 09:08:38 +01:00
ecdsa_sign.c Useless includes 2016-06-18 16:30:24 -04:00
ecdsa_vrf.c Useless includes 2016-06-18 16:30:24 -04:00
eck_prn.c Update copyright year 2018-09-11 13:45:17 +01:00
ecp_mont.c SCA hardening for mod. field inversion in EC_GROUP 2019-02-20 19:54:19 +02:00
ecp_nist.c SCA hardening for mod. field inversion in EC_GROUP 2019-02-20 19:54:19 +02:00
ecp_nistp224.c SCA hardening for mod. field inversion in EC_GROUP 2019-02-20 19:54:19 +02:00
ecp_nistp256.c SCA hardening for mod. field inversion in EC_GROUP 2019-02-20 19:54:19 +02:00
ecp_nistp521.c SCA hardening for mod. field inversion in EC_GROUP 2019-02-20 19:54:19 +02:00
ecp_nistputil.c
ecp_nistz256.c SCA hardening for mod. field inversion in EC_GROUP 2019-02-20 19:54:19 +02:00
ecp_nistz256_table.c Copyright consolidation 05/10 2016-05-17 15:38:09 -04:00
ecp_oct.c Update copyright year 2018-09-11 13:45:17 +01:00
ecp_smpl.c SCA hardening for mod. field inversion in EC_GROUP 2019-02-20 19:54:19 +02:00
ecx_meth.c Improve the usability of the ca app using EdDSA 2018-08-22 16:35:54 +01:00