mirleft / ocaml-nocrypto

OCaml cryptographic library
ISC License
112 stars 52 forks source link

Consider constant-time exponentiation instead of blinding #172

Open mratsim opened 3 years ago

mratsim commented 3 years ago

Blinding is problematic as it ties in security with a good source of randomness (which arguably we have with a secret key input but even then).

Furthermore, even with blinding, the fact that you use branches will still leave your library exposed to fault attacks.

Lastly, there have been many de-blinding techniques in the recent years including RSA attacks on OpenSSL:

And while targeted at elliptic curve scalar multiplication, scalar multiplication and finite field exponentiation is the same algorithm so those papers are relevant as well

For reference this is a constant-time exponentiation implementation: https://github.com/mratsim/constantine/blob/afb33a5/constantine/arithmetic/limbs_montgomery.nim#L449-L628