diff options
author | Richard Levitte <levitte@openssl.org> | 2021-04-12 12:20:20 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2021-04-21 10:53:03 +0200 |
commit | 9cc97ddf3c8c3c6ef30b0505ad2559d3734c685d (patch) | |
tree | fbdf46bfe1c1aa93d80337ea1dc93ca9c211d0e1 /providers/implementations/encode_decode/decode_pem2der.c | |
parent | f99659535d180f15cd19c63cb53392c256e35534 (diff) |
Adapt our decoder implementations to the new way to indicate succes / failure
This includes the special decoder used in our STOREMGMT 'file:' implementation
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14834)
Diffstat (limited to 'providers/implementations/encode_decode/decode_pem2der.c')
-rw-r--r-- | providers/implementations/encode_decode/decode_pem2der.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/providers/implementations/encode_decode/decode_pem2der.c b/providers/implementations/encode_decode/decode_pem2der.c index fe6839965d..4249ce9cc7 100644 --- a/providers/implementations/encode_decode/decode_pem2der.c +++ b/providers/implementations/encode_decode/decode_pem2der.c @@ -145,9 +145,11 @@ static int pem2der_decode(void *vctx, OSSL_CORE_BIO *cin, int selection, int objtype = OSSL_OBJECT_UNKNOWN; const char *data_structure = NULL; - if (read_pem(ctx->provctx, cin, &pem_name, &pem_header, - &der, &der_len) <= 0) - return 0; + ok = read_pem(ctx->provctx, cin, &pem_name, &pem_header, + &der, &der_len) > 0; + /* We return "empty handed". This is not an error. */ + if (!ok) + return 1; /* * 10 is the number of characters in "Proc-Type:", which @@ -159,6 +161,7 @@ static int pem2der_decode(void *vctx, OSSL_CORE_BIO *cin, int selection, EVP_CIPHER_INFO cipher; struct pem2der_pass_data_st pass_data; + ok = 0; /* Assume that we fail */ pass_data.cb = pw_cb; pass_data.cbarg = pw_cbarg; if (!PEM_get_EVP_CIPHER_INFO(pem_header, &cipher) @@ -168,6 +171,12 @@ static int pem2der_decode(void *vctx, OSSL_CORE_BIO *cin, int selection, } /* + * Indicated that we successfully decoded something, or not at all. + * Ending up "empty handed" is not an error. + */ + ok = 1; + + /* * Peal off certain strings from the end of |pem_name|, as they serve * no further purpose. */ |