diff options
author | Richard Levitte <levitte@openssl.org> | 2020-09-07 12:25:17 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-09-09 16:35:22 +0200 |
commit | 8ae40cf57d2138af92a3479e23f35037ae8c5c30 (patch) | |
tree | 18b15b731f9b593f93716e05884cb0b9ba0a54a5 /providers/implementations/encode_decode/decode_pem2der.c | |
parent | ce43db7a3fcd18866385a4552f5e4a83adfc0979 (diff) |
ENCODER: Refactor provider implementations, and some cleanup
The encoder implementations were implemented by unnecessarily copying
code into numerous topical source files, making them hard to maintain.
This changes merges all those into two source files, one that encodes
into DER and PEM, the other to text.
Diverse small cleanups are included.
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12803)
Diffstat (limited to 'providers/implementations/encode_decode/decode_pem2der.c')
-rw-r--r-- | providers/implementations/encode_decode/decode_pem2der.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/providers/implementations/encode_decode/decode_pem2der.c b/providers/implementations/encode_decode/decode_pem2der.c index cbee397982..6e669884de 100644 --- a/providers/implementations/encode_decode/decode_pem2der.c +++ b/providers/implementations/encode_decode/decode_pem2der.c @@ -24,7 +24,18 @@ #include "prov/bio.h" #include "prov/implementations.h" #include "prov/providercommonerr.h" -#include "encoder_local.h" +#include "endecoder_local.h" + +static int read_pem(PROV_CTX *provctx, OSSL_CORE_BIO *cin, + char **pem_name, char **pem_header, + unsigned char **data, long *len) +{ + BIO *in = bio_new_from_core_bio(provctx, cin); + int ok = (PEM_read_bio(in, pem_name, pem_header, data, len) > 0); + + BIO_free(in); + return ok; +} static OSSL_FUNC_decoder_newctx_fn pem2der_newctx; static OSSL_FUNC_decoder_freectx_fn pem2der_freectx; @@ -104,8 +115,8 @@ static int pem2der_decode(void *vctx, OSSL_CORE_BIO *cin, long der_len = 0; int ok = 0; - if (ossl_prov_read_pem(ctx->provctx, cin, &pem_name, &pem_header, - &der, &der_len) <= 0) + if (read_pem(ctx->provctx, cin, &pem_name, &pem_header, + &der, &der_len) <= 0) return 0; /* |