mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
libseckey: Fix error checking when building ECDSA signatures
OpenSSL function i2d_ECDSA_SIG() returns a negative value in case of an error, so check the returned length for <= zero to detect an error. Reported-by: Holger Dengler <dengler@linux.ibm.com> Reviewed-by: Holger Dengler <dengler@linux.ibm.com> Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
e621d2dfa2
commit
fcfd4a6158
@@ -776,6 +776,10 @@ int SK_UTIL_build_ecdsa_signature(const unsigned char *raw_sig,
|
||||
bn_s = NULL;
|
||||
|
||||
der_len = i2d_ECDSA_SIG(ec_sig, NULL);
|
||||
if (der_len <= 0) {
|
||||
rc = -EIO;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (sig == NULL) {
|
||||
*sig_len = der_len;
|
||||
@@ -788,13 +792,14 @@ int SK_UTIL_build_ecdsa_signature(const unsigned char *raw_sig,
|
||||
|
||||
memset(sig, 0, *sig_len);
|
||||
der = sig;
|
||||
*sig_len = i2d_ECDSA_SIG(ec_sig, &der);
|
||||
|
||||
if (*sig_len == 0) {
|
||||
der_len = i2d_ECDSA_SIG(ec_sig, &der);
|
||||
if (der_len <= 0) {
|
||||
rc = -EIO;
|
||||
goto out;
|
||||
}
|
||||
|
||||
*sig_len = der_len;
|
||||
|
||||
out:
|
||||
if (ec_sig != NULL)
|
||||
ECDSA_SIG_free(ec_sig);
|
||||
|
||||
Reference in New Issue
Block a user