您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Make ECDSA signing 10% faster and plug some timing leaks. None of the asymmetric crypto we inherented from OpenSSL is constant-time because of BIGNUM. BIGNUM chops leading zeros off the front of everything, so we end up leaking information about the first word, in theory. BIGNUM functions additionally tend to take the full range of inputs and then call into BN_nnmod at various points. All our secret values should be acted on in constant-time, but k in ECDSA is a particularly sensitive value. So, ecdsa_sign_setup, in an attempt to mitigate the BIGNUM leaks, would add a couple copies of the order. This does not work at all. k is used to compute two values: k^-1 and kG. The first operation when computing k^-1 is to call BN_nnmod if k is out of range. The entry point to our tuned constant-time curve implementations is to call BN_nnmod if the scalar has too many bits, which this causes. The result is both corrections are immediately undone but cause us to do more variable-time work in the meantime. Replace all these computations around k with the word-based functions added in the various preceding CLs. In doing so, replace the BN_mod_mul calls (which internally call BN_nnmod) with Montgomery reduction. We can avoid taking k^-1 out of Montgomery form, which combines nicely with Brian Smith's trick in 3426d1011946b26ff1bb2fd98a081ba4753c9cc8. Along the way, we avoid some unnecessary mallocs. BIGNUM still affects the private key itself, as well as the EC_POINTs. But this should hopefully be much better now. Also it's 10% faster: Before: Did 15000 ECDSA P-224 signing operations in 1069117us (14030.3 ops/sec) Did 18000 ECDSA P-256 signing operations in 1053908us (17079.3 ops/sec) Did 1078 ECDSA P-384 signing operations in 1087853us (990.9 ops/sec) Did 473 ECDSA P-521 signing operations in 1069835us (442.1 ops/sec) After: Did 16000 ECDSA P-224 signing operations in 1064799us (15026.3 ops/sec) Did 19000 ECDSA P-256 signing operations in 1007839us (18852.2 ops/sec) Did 1078 ECDSA P-384 signing operations in 1079413us (998.7 ops/sec) Did 484 ECDSA P-521 signing operations in 1083616us (446.7 ops/sec) Change-Id: I2a25e90fc99dac13c0616d0ea45e125a4bd8cca1 Reviewed-on: https://boringssl-review.googlesource.com/23075 Reviewed-by: Adam Langley <agl@google.com>
7 年前
12345678910111213141516171819202122232425262728293031323334
  1. EC,126,BIGNUM_OUT_OF_RANGE
  2. EC,100,BUFFER_TOO_SMALL
  3. EC,101,COORDINATES_OUT_OF_RANGE
  4. EC,102,D2I_ECPKPARAMETERS_FAILURE
  5. EC,128,DECODE_ERROR
  6. EC,103,EC_GROUP_NEW_BY_NAME_FAILURE
  7. EC,129,ENCODE_ERROR
  8. EC,104,GROUP2PKPARAMETERS_FAILURE
  9. EC,130,GROUP_MISMATCH
  10. EC,105,I2D_ECPKPARAMETERS_FAILURE
  11. EC,106,INCOMPATIBLE_OBJECTS
  12. EC,131,INVALID_COFACTOR
  13. EC,107,INVALID_COMPRESSED_POINT
  14. EC,108,INVALID_COMPRESSION_BIT
  15. EC,109,INVALID_ENCODING
  16. EC,110,INVALID_FIELD
  17. EC,111,INVALID_FORM
  18. EC,112,INVALID_GROUP_ORDER
  19. EC,113,INVALID_PRIVATE_KEY
  20. EC,133,INVALID_SCALAR
  21. EC,114,MISSING_PARAMETERS
  22. EC,115,MISSING_PRIVATE_KEY
  23. EC,116,NON_NAMED_CURVE
  24. EC,117,NOT_INITIALIZED
  25. EC,118,PKPARAMETERS2GROUP_FAILURE
  26. EC,119,POINT_AT_INFINITY
  27. EC,120,POINT_IS_NOT_ON_CURVE
  28. EC,132,PUBLIC_KEY_VALIDATION_FAILED
  29. EC,121,SLOT_FULL
  30. EC,122,UNDEFINED_GENERATOR
  31. EC,123,UNKNOWN_GROUP
  32. EC,124,UNKNOWN_ORDER
  33. EC,127,WRONG_CURVE_PARAMETERS
  34. EC,125,WRONG_ORDER