2 * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
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
11 #include "internal/cryptlib.h"
12 #include <openssl/pkcs12.h>
14 /* Cheap and nasty Unicode stuff */
16 unsigned char *OPENSSL_asc2uni(const char *asc, int asclen,
17 unsigned char **uni, int *unilen)
20 unsigned char *unitmp;
24 ulen = asclen * 2 + 2;
25 if ((unitmp = OPENSSL_malloc(ulen)) == NULL)
27 for (i = 0; i < ulen - 2; i += 2) {
29 unitmp[i + 1] = asc[i >> 1];
31 /* Make result double null terminated */
41 char *OPENSSL_uni2asc(unsigned char *uni, int unilen)
47 /* If no terminating zero allow for one */
48 if (!unilen || uni[unilen - 1])
51 if ((asctmp = OPENSSL_malloc(asclen)) == NULL)
53 for (i = 0; i < unilen; i += 2)
54 asctmp[i >> 1] = uni[i];
55 asctmp[asclen - 1] = 0;
59 int i2d_PKCS12_bio(BIO *bp, PKCS12 *p12)
61 return ASN1_item_i2d_bio(ASN1_ITEM_rptr(PKCS12), bp, p12);
64 #ifndef OPENSSL_NO_STDIO
65 int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12)
67 return ASN1_item_i2d_fp(ASN1_ITEM_rptr(PKCS12), fp, p12);
71 PKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12)
73 return ASN1_item_d2i_bio(ASN1_ITEM_rptr(PKCS12), bp, p12);
76 #ifndef OPENSSL_NO_STDIO
77 PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12)
79 return ASN1_item_d2i_fp(ASN1_ITEM_rptr(PKCS12), fp, p12);