| 1 |
// Copyright (C) 1995-1998 Eric Young ([email protected]) All rights reserved. |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
#include <openssl/pem.h> |
| 5 |
|
| 6 |
#include <stdio.h> |
| 7 |
|
| 8 |
#include <openssl/err.h> |
| 9 |
#include <openssl/evp.h> |
| 10 |
#include <openssl/mem.h> |
| 11 |
#include <openssl/obj.h> |
| 12 |
#include <openssl/rand.h> |
| 13 |
#include <openssl/x509.h> |
| 14 |
|
| 15 |
// Handle 'other' PEMs: not private keys |
| 16 |
|
| 17 |
void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x, |
| 18 |
pem_password_cb *cb, void *u) { |
| 19 |
const unsigned char *p = NULL; |
| 20 |
unsigned char *data = NULL; |
| 21 |
long len; |
| 22 |
char *ret = NULL; |
| 23 |
|
| 24 |
if (!PEM_bytes_read_bio(&data, &len, NULL, name, bp, cb, u)) { |
| 25 |
return NULL; |
| 26 |
} |
| 27 |
p = data; |
| 28 |
ret = d2i(x, &p, len); |
| 29 |
if (ret == NULL) { |
| 30 |
OPENSSL_PUT_ERROR(PEM, ERR_R_ASN1_LIB); |
| 31 |
} |
| 32 |
OPENSSL_free(data); |
| 33 |
return ret; |
| 34 |
} |