[openssl/openssl] 1fa2bf: 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/master
  Home:   https://github.com/openssl/openssl
  Commit: 1fa2bf9b1885d2e87524421fea5041d40149cffa
      https://github.com/openssl/openssl/commit/1fa2bf9b1885d2e87524421fea5041d40149cffa
  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)


  Commit: 294782f3b5c4b81d682e6e8608bb6e851177494d
      https://github.com/openssl/openssl/commit/294782f3b5c4b81d682e6e8608bb6e851177494d
  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)


Compare: https://github.com/openssl/openssl/compare/387418893e45...294782f3b5c4

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