]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/pem/pem_oth.c
Copyright consolidation 04/10
[thirdparty/openssl.git] / crypto / pem / pem_oth.c
CommitLineData
62867571
RS
1/*
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
1241126a 3 *
62867571
RS
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
1241126a
DSH
8 */
9
10#include <stdio.h>
b39fc560 11#include "internal/cryptlib.h"
1241126a
DSH
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
8bb826ee 21void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x,
0f113f3e
MC
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;
1241126a 28
0f113f3e
MC
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}