Blame crypto/pem/pem_oth.c

Packit c4476c
/*
Packit c4476c
 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
 *
Packit c4476c
 * Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
 * this file except in compliance with the License.  You can obtain a copy
Packit c4476c
 * in the file LICENSE in the source distribution or at
Packit c4476c
 * https://www.openssl.org/source/license.html
Packit c4476c
 */
Packit c4476c
Packit c4476c
#include <stdio.h>
Packit c4476c
#include "internal/cryptlib.h"
Packit c4476c
#include <openssl/buffer.h>
Packit c4476c
#include <openssl/objects.h>
Packit c4476c
#include <openssl/evp.h>
Packit c4476c
#include <openssl/x509.h>
Packit c4476c
#include <openssl/pem.h>
Packit c4476c
Packit c4476c
/* Handle 'other' PEMs: not private keys */
Packit c4476c
Packit c4476c
void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x,
Packit c4476c
                        pem_password_cb *cb, void *u)
Packit c4476c
{
Packit c4476c
    const unsigned char *p = NULL;
Packit c4476c
    unsigned char *data = NULL;
Packit c4476c
    long len;
Packit c4476c
    char *ret = NULL;
Packit c4476c
Packit c4476c
    if (!PEM_bytes_read_bio(&data, &len, NULL, name, bp, cb, u))
Packit c4476c
        return NULL;
Packit c4476c
    p = data;
Packit c4476c
    ret = d2i(x, &p, len);
Packit c4476c
    if (ret == NULL)
Packit c4476c
        PEMerr(PEM_F_PEM_ASN1_READ_BIO, ERR_R_ASN1_LIB);
Packit c4476c
    OPENSSL_free(data);
Packit c4476c
    return ret;
Packit c4476c
}