[openssl/openssl] be4717: 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.3
  Home:   https://github.com/openssl/openssl
  Commit: be4717602dbd387ef4de6ab0a2311881fe31a67a
      https://github.com/openssl/openssl/commit/be4717602dbd387ef4de6ab0a2311881fe31a67a
  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: e4308e7a98947c24e17a93de92147ee6815da581
      https://github.com/openssl/openssl/commit/e4308e7a98947c24e17a93de92147ee6815da581
  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/996ccb5b1cdc...e4308e7a9894

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