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

Bernd Edlinger noreply at github.com
Tue Apr 2 15:51:56 UTC 2024


  Branch: refs/heads/openssl-3.0
  Home:   https://github.com/openssl/openssl
  Commit: 2fe6c0fbb5ae7e2279e80d7cdff99a1bd2a45733
      https://github.com/openssl/openssl/commit/2fe6c0fbb5ae7e2279e80d7cdff99a1bd2a45733
  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)



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