pem_oth.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  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. #include <stdio.h>
  10. #include "internal/cryptlib.h"
  11. #include <openssl/buffer.h>
  12. #include <openssl/objects.h>
  13. #include <openssl/evp.h>
  14. #include <openssl/x509.h>
  15. #include <openssl/pem.h>
  16. /* Handle 'other' PEMs: not private keys */
  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. {
  20. const unsigned char *p = NULL;
  21. unsigned char *data = NULL;
  22. long len;
  23. char *ret = NULL;
  24. if (!PEM_bytes_read_bio(&data, &len, NULL, name, bp, cb, u))
  25. return NULL;
  26. p = data;
  27. ret = d2i(x, &p, len);
  28. if (ret == NULL)
  29. PEMerr(PEM_F_PEM_ASN1_READ_BIO, ERR_R_ASN1_LIB);
  30. OPENSSL_free(data);
  31. return ret;
  32. }