Clear OpenSSL errors on EVP_MD_CTX_create failures
This commit is contained in:
@@ -39,17 +39,20 @@ main() {
|
||||
EVP_MD_CTX *evp_md_ctx = EVP_MD_CTX_create();
|
||||
|
||||
if (ctx == NULL || evp_md_ctx == NULL) {
|
||||
ERR_clear_error();
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (EVP_PKEY_keygen_init(ctx) != 1 ||
|
||||
EVP_PKEY_keygen(ctx, &pkey) != 1 || pkey == NULL)
|
||||
{
|
||||
ERR_clear_error();
|
||||
return (1);
|
||||
}
|
||||
|
||||
bytes = sizeof(buf);
|
||||
if (EVP_PKEY_get_raw_public_key(pkey, buf, &bytes) != 1) {
|
||||
ERR_clear_error();
|
||||
return (1);
|
||||
}
|
||||
|
||||
@@ -64,6 +67,7 @@ main() {
|
||||
EVP_DigestSign(evp_md_ctx, buf, &bytes,
|
||||
(const unsigned char *)"test", 4) != 1)
|
||||
{
|
||||
ERR_clear_error();
|
||||
return (1);
|
||||
}
|
||||
|
||||
@@ -80,17 +84,20 @@ main() {
|
||||
ctx = EVP_PKEY_CTX_new_id(NID_ED448, NULL);
|
||||
evp_md_ctx = EVP_MD_CTX_create();
|
||||
if (ctx == NULL || evp_md_ctx == NULL) {
|
||||
ERR_clear_error();
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (EVP_PKEY_keygen_init(ctx) != 1 ||
|
||||
EVP_PKEY_keygen(ctx, &pkey) != 1 || pkey == NULL)
|
||||
{
|
||||
ERR_clear_error();
|
||||
return (1);
|
||||
}
|
||||
|
||||
bytes = sizeof(buf);
|
||||
if (EVP_PKEY_get_raw_public_key(pkey, buf, &bytes) != 1) {
|
||||
ERR_clear_error();
|
||||
return (1);
|
||||
}
|
||||
|
||||
@@ -105,6 +112,7 @@ main() {
|
||||
EVP_DigestSign(evp_md_ctx, buf, &bytes,
|
||||
(const unsigned char *)"test", 4) != 1)
|
||||
{
|
||||
ERR_clear_error();
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ main() {
|
||||
unsigned int siglen = sizeof(buf);
|
||||
|
||||
if (e == NULL || n == NULL || ctx == NULL || evp_md_ctx == NULL) {
|
||||
ERR_clear_error();
|
||||
return (1);
|
||||
}
|
||||
|
||||
@@ -62,11 +63,13 @@ main() {
|
||||
EVP_PKEY_CTX_set1_rsa_keygen_pubexp(ctx, e) != 1 ||
|
||||
EVP_PKEY_keygen(ctx, &pkey) != 1 || pkey == NULL)
|
||||
{
|
||||
ERR_clear_error();
|
||||
return (1);
|
||||
}
|
||||
|
||||
EVP_PKEY_get_bn_param(pkey, OSSL_PKEY_PARAM_RSA_N, &n);
|
||||
if (n == NULL) {
|
||||
ERR_clear_error();
|
||||
return (1);
|
||||
}
|
||||
|
||||
@@ -90,6 +93,7 @@ main() {
|
||||
EVP_DigestUpdate(evp_md_ctx, "test", 4) != 1 ||
|
||||
EVP_SignFinal(evp_md_ctx, buf, &siglen, pkey) != 1)
|
||||
{
|
||||
ERR_clear_error();
|
||||
return (1);
|
||||
}
|
||||
bytes = siglen;
|
||||
@@ -103,6 +107,7 @@ main() {
|
||||
EVP_DigestUpdate(evp_md_ctx, "test", 4) != 1 ||
|
||||
EVP_SignFinal(evp_md_ctx, buf, &siglen, pkey) != 1)
|
||||
{
|
||||
ERR_clear_error();
|
||||
return (1);
|
||||
}
|
||||
bytes = siglen;
|
||||
@@ -116,6 +121,7 @@ main() {
|
||||
EVP_DigestUpdate(evp_md_ctx, "test", 4) != 1 ||
|
||||
EVP_SignFinal(evp_md_ctx, buf, &siglen, pkey) != 1)
|
||||
{
|
||||
ERR_clear_error();
|
||||
return (1);
|
||||
}
|
||||
bytes = siglen;
|
||||
|
||||
Reference in New Issue
Block a user