]>
git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/pkcs12/p12_utl.c
c4feb90b9e3f34b21d9990c60cc0d447caa6ea72
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
)
45 /* string must contain an even number of bytes */
49 /* If no terminating zero allow for one */
50 if (!unilen
|| uni
[unilen
- 1])
53 if ((asctmp
= OPENSSL_malloc(asclen
)) == NULL
)
55 for (i
= 0; i
< unilen
; i
+= 2)
56 asctmp
[i
>> 1] = uni
[i
];
57 asctmp
[asclen
- 1] = 0;
61 int i2d_PKCS12_bio(BIO
*bp
, PKCS12
*p12
)
63 return ASN1_item_i2d_bio(ASN1_ITEM_rptr(PKCS12
), bp
, p12
);
66 #ifndef OPENSSL_NO_STDIO
67 int i2d_PKCS12_fp(FILE *fp
, PKCS12
*p12
)
69 return ASN1_item_i2d_fp(ASN1_ITEM_rptr(PKCS12
), fp
, p12
);
73 PKCS12
*d2i_PKCS12_bio(BIO
*bp
, PKCS12
**p12
)
75 return ASN1_item_d2i_bio(ASN1_ITEM_rptr(PKCS12
), bp
, p12
);
78 #ifndef OPENSSL_NO_STDIO
79 PKCS12
*d2i_PKCS12_fp(FILE *fp
, PKCS12
**p12
)
81 return ASN1_item_d2i_fp(ASN1_ITEM_rptr(PKCS12
), fp
, p12
);