Don't create an ECX key with short keys
authorMatt Caswell <matt@openssl.org>
Mon, 15 Nov 2021 12:14:03 +0000 (12:14 +0000)
committerMatt Caswell <matt@openssl.org>
Tue, 16 Nov 2021 13:21:06 +0000 (13:21 +0000)
commit50938aec35fd57fb3bec707ead2eee381fcfaf04
treee49845958e2a8165c8e63076b4fc8bba27364f4f
parentc9007bda79291179ed2df31b3dfd9f1311102847
Don't create an ECX key with short keys

If an ECX key is created and the private key is too short, a fromdata
call would create the key, and then later detect the error and report it
after freeing the key. However freeing the key was calling
OPENSSL_secure_clear_free() and assuming that the private key was of the
correct length. If it was actually too short this will write over memory
that it shouldn't.

Fixes #17017

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17041)
crypto/ec/ecx_backend.c