OLD | NEW |
1 /* p12_utl.c */ | 1 /* p12_utl.c */ |
2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 * project 1999. | 3 * project 1999. |
4 */ | 4 */ |
5 /* ==================================================================== | 5 /* ==================================================================== |
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | 6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. |
7 * | 7 * |
8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
10 * are met: | 10 * are met: |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 * This product includes cryptographic software written by Eric Young | 53 * This product includes cryptographic software written by Eric Young |
54 * (eay@cryptsoft.com). This product includes software written by Tim | 54 * (eay@cryptsoft.com). This product includes software written by Tim |
55 * Hudson (tjh@cryptsoft.com). | 55 * Hudson (tjh@cryptsoft.com). |
56 * | 56 * |
57 */ | 57 */ |
58 | 58 |
59 #include <stdio.h> | 59 #include <stdio.h> |
60 #include "cryptlib.h" | 60 #include "cryptlib.h" |
61 #include <openssl/pkcs12.h> | 61 #include <openssl/pkcs12.h> |
62 | 62 |
63 #ifdef OPENSSL_SYS_NETWARE | |
64 /* Rename these functions to avoid name clashes on NetWare OS */ | |
65 #define uni2asc OPENSSL_uni2asc | |
66 #define asc2uni OPENSSL_asc2uni | |
67 #endif | |
68 | |
69 /* Cheap and nasty Unicode stuff */ | 63 /* Cheap and nasty Unicode stuff */ |
70 | 64 |
71 unsigned char *asc2uni(const char *asc, int asclen, unsigned char **uni, int *un
ilen) | 65 unsigned char *OPENSSL_asc2uni(const char *asc, int asclen, unsigned char **uni,
int *unilen) |
72 { | 66 { |
73 int ulen, i; | 67 int ulen, i; |
74 unsigned char *unitmp; | 68 unsigned char *unitmp; |
75 if (asclen == -1) asclen = strlen(asc); | 69 if (asclen == -1) asclen = strlen(asc); |
76 ulen = asclen*2 + 2; | 70 ulen = asclen*2 + 2; |
77 if (!(unitmp = OPENSSL_malloc(ulen))) return NULL; | 71 if (!(unitmp = OPENSSL_malloc(ulen))) return NULL; |
78 for (i = 0; i < ulen - 2; i+=2) { | 72 for (i = 0; i < ulen - 2; i+=2) { |
79 unitmp[i] = 0; | 73 unitmp[i] = 0; |
80 unitmp[i + 1] = asc[i>>1]; | 74 unitmp[i + 1] = asc[i>>1]; |
81 } | 75 } |
82 /* Make result double null terminated */ | 76 /* Make result double null terminated */ |
83 unitmp[ulen - 2] = 0; | 77 unitmp[ulen - 2] = 0; |
84 unitmp[ulen - 1] = 0; | 78 unitmp[ulen - 1] = 0; |
85 if (unilen) *unilen = ulen; | 79 if (unilen) *unilen = ulen; |
86 if (uni) *uni = unitmp; | 80 if (uni) *uni = unitmp; |
87 return unitmp; | 81 return unitmp; |
88 } | 82 } |
89 | 83 |
90 char *uni2asc(unsigned char *uni, int unilen) | 84 char *OPENSSL_uni2asc(unsigned char *uni, int unilen) |
91 { | 85 { |
92 int asclen, i; | 86 int asclen, i; |
93 char *asctmp; | 87 char *asctmp; |
94 asclen = unilen / 2; | 88 asclen = unilen / 2; |
95 /* If no terminating zero allow for one */ | 89 /* If no terminating zero allow for one */ |
96 if (!unilen || uni[unilen - 1]) asclen++; | 90 if (!unilen || uni[unilen - 1]) asclen++; |
97 uni++; | 91 uni++; |
98 if (!(asctmp = OPENSSL_malloc(asclen))) return NULL; | 92 if (!(asctmp = OPENSSL_malloc(asclen))) return NULL; |
99 for (i = 0; i < unilen; i+=2) asctmp[i>>1] = uni[i]; | 93 for (i = 0; i < unilen; i+=2) asctmp[i>>1] = uni[i]; |
100 asctmp[asclen - 1] = 0; | 94 asctmp[asclen - 1] = 0; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 return ASN1_item_unpack(bag->value.bag->value.octet, ASN1_ITEM_rptr(X509
)); | 137 return ASN1_item_unpack(bag->value.bag->value.octet, ASN1_ITEM_rptr(X509
)); |
144 } | 138 } |
145 | 139 |
146 X509_CRL *PKCS12_certbag2x509crl(PKCS12_SAFEBAG *bag) | 140 X509_CRL *PKCS12_certbag2x509crl(PKCS12_SAFEBAG *bag) |
147 { | 141 { |
148 if(M_PKCS12_bag_type(bag) != NID_crlBag) return NULL; | 142 if(M_PKCS12_bag_type(bag) != NID_crlBag) return NULL; |
149 if(M_PKCS12_cert_bag_type(bag) != NID_x509Crl) return NULL; | 143 if(M_PKCS12_cert_bag_type(bag) != NID_x509Crl) return NULL; |
150 return ASN1_item_unpack(bag->value.bag->value.octet, | 144 return ASN1_item_unpack(bag->value.bag->value.octet, |
151 ASN1_ITEM_rptr(X509_CRL)
); | 145 ASN1_ITEM_rptr(X509_CRL)
); |
152 } | 146 } |
OLD | NEW |