2 * Copyright (C) 2015 Austin English
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 typedef char ASN1char_t
;
26 typedef signed char ASN1int8_t
;
27 typedef unsigned char ASN1uint8_t
;
28 typedef unsigned short ASN1uint16_t
;
29 typedef signed short ASN1int16_t
;
30 typedef ULONG ASN1uint32_t
;
31 typedef LONG ASN1int32_t
;
33 typedef ASN1uint16_t ASN1char16_t
;
34 typedef ASN1uint32_t ASN1char32_t
;
36 typedef ASN1char_t
*ASN1ztcharstring_t
;
37 typedef ASN1char16_t
*ASN1ztchar16string_t
;
38 typedef ASN1char32_t
*ASN1ztchar32string_t
;
39 typedef ASN1int32_t ASN1enum_t
;
40 typedef ASN1uint8_t ASN1octet_t
;
41 typedef ASN1uint8_t ASN1bool_t
;
42 typedef ASN1uint16_t ASN1choice_t
;
43 typedef ASN1uint32_t ASN1magic_t
;
44 typedef ASN1ztcharstring_t ASN1objectdescriptor_t
;
46 typedef void (WINAPI
*ASN1FreeFun_t
)(void *data
);
47 typedef void (WINAPI
*ASN1GenericFun_t
)(void);
49 typedef struct ASN1encoding_s
*ASN1encoding_t
;
50 typedef struct ASN1decoding_s
*ASN1decoding_t
;
51 typedef ASN1int32_t (WINAPI
*ASN1PerEncFun_t
)(ASN1encoding_t enc
,void *data
);
52 typedef ASN1int32_t (WINAPI
*ASN1PerDecFun_t
)(ASN1decoding_t enc
,void *data
);
54 typedef struct tagASN1PerFunArr_t
{
55 const ASN1PerEncFun_t
*apfnEncoder
;
56 const ASN1PerDecFun_t
*apfnDecoder
;
59 typedef ASN1int32_t (WINAPI
*ASN1BerEncFun_t
)(ASN1encoding_t enc
,ASN1uint32_t tag
,void *data
);
60 typedef ASN1int32_t (WINAPI
*ASN1BerDecFun_t
)(ASN1decoding_t enc
,ASN1uint32_t tag
,void *data
);
62 typedef struct tagASN1BerFunArr_t
{
63 const ASN1BerEncFun_t
*apfnEncoder
;
64 const ASN1BerDecFun_t
*apfnDecoder
;
67 typedef struct tagASN1bitstring_t
73 typedef enum tagASN1blocktype_e
75 ASN1_DER_SET_OF_BLOCK
,
78 typedef struct tagASN1charstring_t
84 typedef struct tagASN1char16string_t
90 typedef struct tagASN1char32string_t
96 typedef struct tagASN1encodedOID_t
103 ASN1_PER_RULE_ALIGNED
= 0x0001,ASN1_PER_RULE_UNALIGNED
= 0x0002,ASN1_PER_RULE
= ASN1_PER_RULE_ALIGNED
| ASN1_PER_RULE_UNALIGNED
,
104 ASN1_BER_RULE_BER
= 0x0100,ASN1_BER_RULE_CER
= 0x0200,ASN1_BER_RULE_DER
= 0x0400,
105 ASN1_BER_RULE
= ASN1_BER_RULE_BER
| ASN1_BER_RULE_CER
| ASN1_BER_RULE_DER
106 } ASN1encodingrule_e
;
108 typedef enum tagASN1error_e
111 ASN1_ERR_INTERNAL
= -1001,
112 ASN1_ERR_EOD
= -1002,
113 ASN1_ERR_CORRUPT
= -1003,
114 ASN1_ERR_LARGE
= -1004,
115 ASN1_ERR_CONSTRAINT
= -1005,
116 ASN1_ERR_MEMORY
= -1006,
117 ASN1_ERR_OVERFLOW
= -1007,
118 ASN1_ERR_BADPDU
= -1008,
119 ASN1_ERR_BADARGS
= -1009,
120 ASN1_ERR_BADREAL
= -1010,
121 ASN1_ERR_BADTAG
= -1011,
122 ASN1_ERR_CHOICE
= -1012,
123 ASN1_ERR_RULE
= -1013,
124 ASN1_ERR_UTF8
= -1014,
125 ASN1_ERR_PDU_TYPE
= -1051,
126 ASN1_ERR_NYI
= -1052,
127 ASN1_WRN_EXTENDED
= 1001,
128 ASN1_WRN_NOEOD
= 1002,
131 typedef struct tagASN1generalizedtime_t
139 ASN1uint16_t millisecond
;
140 ASN1bool_t universal
;
142 } ASN1generalizedtime_t
;
144 typedef struct tagASN1intx_t
150 typedef struct tagASN1module_t
{
151 ASN1magic_t nModuleName
;
152 ASN1encodingrule_e eRule
;
153 ASN1uint32_t dwFlags
;
155 const ASN1FreeFun_t
*apfnFreeMemory
;
156 const ASN1uint32_t
*acbStructSize
;
163 typedef struct ASN1objectidentifier_s
165 struct ASN1objectidentifier_s
*next
;
167 } *ASN1objectidentifier_t
;
169 typedef struct tagASN1objectidentifier2_t
172 ASN1uint32_t value
[16];
173 } ASN1objectidentifier2_t
;
175 typedef struct tagASN1octetstring_t
181 typedef struct tagASN1open_t
191 typedef enum tagASN1option_e
193 ASN1OPT_CHANGE_RULE
= 0x101,
194 ASN1OPT_GET_RULE
= 0x201,
195 ASN1OPT_NOT_REUSE_BUFFER
= 0x301,
196 ASN1OPT_REWIND_BUFFER
= 0x302,
197 ASN1OPT_SET_DECODED_BUFFER
= 0x501,
198 ASN1OPT_DEL_DECODED_BUFFER
= 0x502,
199 ASN1OPT_GET_DECODED_BUFFER_SIZE
= 0x601,
202 typedef struct tagASN1optionparam_t
{
203 ASN1option_e eOption
;
206 ASN1encodingrule_e eRule
;
207 ASN1uint32_t cbRequiredDecodedBufSize
;
211 ASN1uint32_t cbBufSize
;
214 } ASN1optionparam_t
, ASN1optionparam_s
;
216 typedef struct tagASN1utctime_t
224 ASN1bool_t universal
;
228 typedef struct tagASN1wstring_t
234 void WINAPI
ASN1_CloseDecoder(ASN1decoding_t
);
235 void WINAPI
ASN1_CloseEncoder(ASN1encoding_t
);
236 void WINAPI
ASN1_CloseEncoder2(ASN1encoding_t
);
237 void WINAPI
ASN1_CloseModule(ASN1module_t
);
238 ASN1error_e WINAPI
ASN1_CreateDecoder(ASN1module_t
, ASN1decoding_t
*,ASN1octet_t
*, ASN1uint32_t
, ASN1decoding_t
);
239 ASN1error_e WINAPI
ASN1_CreateEncoder(ASN1module_t
, ASN1encoding_t
*, ASN1octet_t
*, ASN1uint32_t
, ASN1encoding_t
);
240 ASN1module_t WINAPI
ASN1_CreateModule(ASN1uint32_t
,ASN1encodingrule_e
,ASN1uint32_t
,ASN1uint32_t
,const ASN1GenericFun_t
[],const ASN1GenericFun_t
[],const ASN1FreeFun_t
[],const ASN1uint32_t
[],ASN1magic_t
);
241 ASN1error_e WINAPI
ASN1_Decode(ASN1decoding_t
, void** , ASN1uint32_t
, ASN1uint32_t
, ASN1octet_t
*, ASN1uint32_t
);
242 ASN1error_e WINAPI
ASN1_Encode(ASN1encoding_t
, void*, ASN1uint32_t
, ASN1uint32_t
, ASN1octet_t
*, ASN1uint32_t
);
243 void WINAPI
ASN1_FreeDecoded(ASN1decoding_t
, void*, ASN1uint32_t
);
244 void WINAPI
ASN1_FreeEncoded(ASN1encoding_t
, void*);
245 ASN1error_e WINAPI
ASN1_GetDecoderOption(ASN1decoding_t
, ASN1optionparam_t
*);
246 ASN1error_e WINAPI
ASN1_GetEncoderOption(ASN1encoding_t
, ASN1optionparam_t
*);
247 ASN1error_e WINAPI
ASN1_SetDecoderOption(ASN1decoding_t
, ASN1optionparam_t
*);
248 ASN1error_e WINAPI
ASN1_SetEncoderOption(ASN1encoding_t
, ASN1optionparam_t
*);
249 int WINAPI
ASN1bitstring_cmp(ASN1bitstring_t
*,ASN1bitstring_t
*);
250 void WINAPI
ASN1bitstring_free(ASN1bitstring_t
*);
251 int WINAPI
ASN1char16string_cmp(ASN1char16string_t
*,ASN1char16string_t
*);
252 void WINAPI
ASN1char16string_free(ASN1char16string_t
*);
253 int WINAPI
ASN1char32string_cmp(ASN1char32string_t
*,ASN1char32string_t
*);
254 void WINAPI
ASN1char32string_free(ASN1char32string_t
*);
255 int WINAPI
ASN1charstring_cmp(ASN1charstring_t
*,ASN1charstring_t
*);
256 void WINAPI
ASN1charstring_free(ASN1charstring_t
*);
257 LPVOID WINAPI
ASN1DecAlloc(ASN1decoding_t
,ASN1uint32_t
);
258 LPVOID WINAPI
ASN1DecRealloc(ASN1decoding_t
,LPVOID
,ASN1uint32_t
);
259 ASN1error_e WINAPI
ASN1DecSetError(ASN1decoding_t
,ASN1error_e
);
260 ASN1error_e WINAPI
ASN1EncSetError(ASN1encoding_t
,ASN1error_e
);
261 void WINAPI
ASN1Free(LPVOID
);
262 int WINAPI
ASN1generalizedtime_cmp(ASN1generalizedtime_t
*,ASN1generalizedtime_t
*);
263 int WINAPI
ASN1intx_cmp(ASN1intx_t
*,ASN1intx_t
*);
264 void WINAPI
ASN1intx_free(ASN1intx_t
*);
265 void WINAPI
ASN1intx_setuint32(ASN1intx_t
*,ASN1uint32_t
);
266 ASN1uint32_t WINAPI
ASN1intx_uoctets(ASN1intx_t
*);
267 ASN1int32_t WINAPI
ASN1intx2int32(ASN1intx_t
*);
268 ASN1uint32_t WINAPI
ASN1intx2uint32(ASN1intx_t
*);
269 int WINAPI
ASN1intxisuint32(ASN1intx_t
*);
270 int WINAPI
ASN1objectidentifier_cmp(ASN1objectidentifier_t
*,ASN1objectidentifier_t
*);
271 void WINAPI
ASN1objectidentifier_free(ASN1objectidentifier_t
*);
272 int WINAPI
ASN1objectidentifier2_cmp(ASN1objectidentifier2_t
*,ASN1objectidentifier2_t
*);
273 int WINAPI
ASN1octetstring_cmp(ASN1octetstring_t
*,ASN1octetstring_t
*);
274 void WINAPI
ASN1octetstring_free(ASN1octetstring_t
*);
275 int WINAPI
ASN1open_cmp(ASN1open_t
*,ASN1open_t
*);
276 void WINAPI
ASN1open_free(ASN1open_t
*);
277 ASN1uint32_t WINAPI
ASN1uint32_uoctets(ASN1uint32_t
);
278 void WINAPI
ASN1utf8string_free(ASN1wstring_t
*);
279 int WINAPI
ASN1utctime_cmp(ASN1utctime_t
*,ASN1utctime_t
*);
280 int WINAPI
ASN1ztchar16string_cmp(ASN1ztchar16string_t
*,ASN1ztchar16string_t
*);
281 void WINAPI
ASN1ztchar16string_free(ASN1ztchar16string_t
*);
282 void WINAPI
ASN1ztchar32string_free(ASN1ztchar32string_t
*);
283 int WINAPI
ASN1ztcharstring_cmp(ASN1ztcharstring_t
*,ASN1ztcharstring_t
*);
284 void WINAPI
ASN1ztcharstring_free(ASN1charstring_t
*);
290 #endif /* __MS_ASN1_H__ */