[openssl/openssl] a9090e: Fix handling of NULL sig parameter in ECDSA_sign a...

Bernd Edlinger noreply at github.com
Tue Apr 2 15:49:59 UTC 2024


  Branch: refs/heads/openssl-3.2
  Home:   https://github.com/openssl/openssl
  Commit: a9090e8ec63ec77fb01b3689a5bc8beb9a4da918
      https://github.com/openssl/openssl/commit/a9090e8ec63ec77fb01b3689a5bc8beb9a4da918
  Author: Bernd Edlinger <bernd.edlinger at hotmail.de>
  Date:   2024-04-02 (Tue, 02 Apr 2024)

  Changed paths:
    M crypto/dsa/dsa_sign.c
    M crypto/ec/ecdsa_ossl.c
    M crypto/sm2/sm2_sign.c
    M test/dsatest.c
    M test/ecdsatest.c

  Log Message:
  -----------
  Fix handling of NULL sig parameter in ECDSA_sign and similar

The problem is, that it almost works to pass sig=NULL to the
ECDSA_sign, ECDSA_sign_ex and DSA_sign, to compute the necessary
space for the resulting signature.
But since the ECDSA signature is non-deterministic
(except when ECDSA_sign_setup/ECDSA_sign_ex are used)
the resulting length may be different when the API is called again.
This can easily cause random memory corruption.
Several internal APIs had the same issue, but since they are
never called with sig=NULL, it is better to make them return an
error in that case, instead of making the code more complex.

Reviewed-by: Dmitry Belyavskiy <beldmit at gmail.com>
Reviewed-by: Tomas Mraz <tomas at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23529)

(cherry picked from commit 1fa2bf9b1885d2e87524421fea5041d40149cffa)


  Commit: f7aaac8c140920f1ed748b8fe1558a4d4ec28793
      https://github.com/openssl/openssl/commit/f7aaac8c140920f1ed748b8fe1558a4d4ec28793
  Author: Bernd Edlinger <bernd.edlinger at hotmail.de>
  Date:   2024-04-02 (Tue, 02 Apr 2024)

  Changed paths:
    M crypto/ec/ecdsa_ossl.c

  Log Message:
  -----------
  Remove handling of NULL sig param in ossl_ecdsa_deterministic_sign

The handling of sig=NULL was broken in this function, but since it
is only used internally and was never called with sig=NULL, it is
better to return an error in that case.

Reviewed-by: Dmitry Belyavskiy <beldmit at gmail.com>
Reviewed-by: Tomas Mraz <tomas at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23529)

(cherry picked from commit 294782f3b5c4b81d682e6e8608bb6e851177494d)


Compare: https://github.com/openssl/openssl/compare/38c5f2c169a5...f7aaac8c1409

To unsubscribe from these emails, change your notification settings at https://github.com/openssl/openssl/settings/notifications


More information about the openssl-commits mailing list