]> git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/pem/pem_oth.c
Copyright consolidation 04/10
[thirdparty/openssl.git] / crypto / pem / pem_oth.c
1 /*
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10 #include <stdio.h>
11 #include "internal/cryptlib.h"
12 #include <openssl/buffer.h>
13 #include <openssl/objects.h>
14 #include <openssl/evp.h>
15 #include <openssl/rand.h>
16 #include <openssl/x509.h>
17 #include <openssl/pem.h>
18
19 /* Handle 'other' PEMs: not private keys */
20
21 void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x,
22 pem_password_cb *cb, void *u)
23 {
24 const unsigned char *p = NULL;
25 unsigned char *data = NULL;
26 long len;
27 char *ret = NULL;
28
29 if (!PEM_bytes_read_bio(&data, &len, NULL, name, bp, cb, u))
30 return NULL;
31 p = data;
32 ret = d2i(x, &p, len);
33 if (ret == NULL)
34 PEMerr(PEM_F_PEM_ASN1_READ_BIO, ERR_R_ASN1_LIB);
35 OPENSSL_free(data);
36 return (ret);
37 }