diff options
Diffstat (limited to 'providers/implementations/encode_decode/endecoder_common.c')
-rw-r--r-- | providers/implementations/encode_decode/endecoder_common.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/providers/implementations/encode_decode/endecoder_common.c b/providers/implementations/encode_decode/endecoder_common.c index c85fe915ac..7d26e2a340 100644 --- a/providers/implementations/encode_decode/endecoder_common.c +++ b/providers/implementations/encode_decode/endecoder_common.c @@ -8,7 +8,9 @@ */ #include <openssl/core.h> - +#include <openssl/buffer.h> +#include "internal/asn1.h" +#include "prov/bio.h" #include "endecoder_local.h" OSSL_FUNC_keymgmt_new_fn * @@ -82,3 +84,18 @@ void ossl_prov_free_key(const OSSL_DISPATCH *fns, void *key) kmgmt_free(key); } +int ossl_read_der(PROV_CTX *provctx, OSSL_CORE_BIO *cin, unsigned char **data, + long *len) +{ + BUF_MEM *mem = NULL; + BIO *in = ossl_bio_new_from_core_bio(provctx, cin); + int ok = (asn1_d2i_read_bio(in, &mem) >= 0); + + if (ok) { + *data = (unsigned char *)mem->data; + *len = (long)mem->length; + OPENSSL_free(mem); + } + BIO_free(in); + return ok; +} |