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
;
68 ASN1_PER_RULE_ALIGNED
= 0x0001,ASN1_PER_RULE_UNALIGNED
= 0x0002,ASN1_PER_RULE
= ASN1_PER_RULE_ALIGNED
| ASN1_PER_RULE_UNALIGNED
,
69 ASN1_BER_RULE_BER
= 0x0100,ASN1_BER_RULE_CER
= 0x0200,ASN1_BER_RULE_DER
= 0x0400,
70 ASN1_BER_RULE
= ASN1_BER_RULE_BER
| ASN1_BER_RULE_CER
| ASN1_BER_RULE_DER
73 typedef enum tagASN1error_e
76 ASN1_ERR_INTERNAL
= -1001,
78 ASN1_ERR_CORRUPT
= -1003,
79 ASN1_ERR_LARGE
= -1004,
80 ASN1_ERR_CONSTRAINT
= -1005,
81 ASN1_ERR_MEMORY
= -1006,
82 ASN1_ERR_OVERFLOW
= -1007,
83 ASN1_ERR_BADPDU
= -1008,
84 ASN1_ERR_BADARGS
= -1009,
85 ASN1_ERR_BADREAL
= -1010,
86 ASN1_ERR_BADTAG
= -1011,
87 ASN1_ERR_CHOICE
= -1012,
88 ASN1_ERR_RULE
= -1013,
89 ASN1_ERR_UTF8
= -1014,
90 ASN1_ERR_PDU_TYPE
= -1051,
92 ASN1_WRN_EXTENDED
= 1001,
93 ASN1_WRN_NOEOD
= 1002,
96 typedef struct tagASN1module_t
{
97 ASN1magic_t nModuleName
;
98 ASN1encodingrule_e eRule
;
101 const ASN1FreeFun_t
*apfnFreeMemory
;
102 const ASN1uint32_t
*acbStructSize
;
109 typedef enum tagASN1option_e
111 ASN1OPT_CHANGE_RULE
= 0x101,
112 ASN1OPT_GET_RULE
= 0x201,
113 ASN1OPT_NOT_REUSE_BUFFER
= 0x301,
114 ASN1OPT_REWIND_BUFFER
= 0x302,
115 ASN1OPT_SET_DECODED_BUFFER
= 0x501,
116 ASN1OPT_DEL_DECODED_BUFFER
= 0x502,
117 ASN1OPT_GET_DECODED_BUFFER_SIZE
= 0x601,
120 typedef struct tagASN1optionparam_t
{
121 ASN1option_e eOption
;
124 ASN1encodingrule_e eRule
;
125 ASN1uint32_t cbRequiredDecodedBufSize
;
129 ASN1uint32_t cbBufSize
;
132 } ASN1optionparam_t
, ASN1optionparam_s
;
134 void WINAPI
ASN1_CloseDecoder(ASN1decoding_t
);
135 void WINAPI
ASN1_CloseEncoder(ASN1encoding_t
);
136 void WINAPI
ASN1_CloseEncoder2(ASN1encoding_t
);
137 void WINAPI
ASN1_CloseModule(ASN1module_t
);
138 ASN1error_e WINAPI
ASN1_CreateDecoder(ASN1module_t
, ASN1decoding_t
*,ASN1octet_t
*, ASN1uint32_t
, ASN1decoding_t
);
139 ASN1error_e WINAPI
ASN1_CreateEncoder(ASN1module_t
, ASN1encoding_t
*, ASN1octet_t
*, ASN1uint32_t
, ASN1encoding_t
);
140 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
);
141 ASN1error_e WINAPI
ASN1_Decode(ASN1decoding_t
, void** , ASN1uint32_t
, ASN1uint32_t
, ASN1octet_t
*, ASN1uint32_t
);
142 ASN1error_e WINAPI
ASN1_Encode(ASN1encoding_t
, void*, ASN1uint32_t
, ASN1uint32_t
, ASN1octet_t
*, ASN1uint32_t
);
143 void WINAPI
ASN1_FreeDecoded(ASN1decoding_t
, void*, ASN1uint32_t
);
144 void WINAPI
ASN1_FreeEncoded(ASN1encoding_t
, void*);
145 ASN1error_e WINAPI
ASN1_GetDecoderOption(ASN1decoding_t
, ASN1optionparam_t
*);
146 ASN1error_e WINAPI
ASN1_GetEncoderOption(ASN1encoding_t
, ASN1optionparam_t
*);
147 ASN1error_e WINAPI
ASN1_SetDecoderOption(ASN1decoding_t
, ASN1optionparam_t
*);
148 ASN1error_e WINAPI
ASN1_SetEncoderOption(ASN1encoding_t
, ASN1optionparam_t
*);
154 #endif /* __MS_ASN1_H__ */