asn1.h (21997B)
1/** 2 * WinPR: Windows Portable Runtime 3 * ASN.1 Encoding & Decoding Engine 4 * 5 * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20#ifndef WINPR_ASN1_H 21#define WINPR_ASN1_H 22 23#include <winpr/winpr.h> 24#include <winpr/wtypes.h> 25 26#ifdef __cplusplus 27extern "C" 28{ 29#endif 30 31 typedef unsigned char ASN1uint8_t; 32 typedef signed char ASN1int8_t; 33 34 typedef unsigned short ASN1uint16_t; 35 typedef signed short ASN1int16_t; 36 37 typedef unsigned long ASN1uint32_t; 38 typedef signed long ASN1int32_t; 39 40 typedef ASN1uint8_t ASN1octet_t; 41 42 typedef ASN1uint8_t ASN1bool_t; 43 44 struct tagASN1intx_t 45 { 46 ASN1uint32_t length; 47 ASN1octet_t* value; 48 }; 49 typedef struct tagASN1intx_t ASN1intx_t; 50 51 struct tagASN1octetstring_t 52 { 53 ASN1uint32_t length; 54 ASN1octet_t* value; 55 }; 56 typedef struct tagASN1octetstring_t ASN1octetstring_t; 57 58 struct tagASN1octetstring2_t 59 { 60 ASN1uint32_t length; 61 ASN1octet_t value[1]; 62 }; 63 typedef struct tagASN1octetstring2_t ASN1octetstring2_t; 64 65 struct ASN1iterator_s 66 { 67 struct ASN1iterator_s* next; 68 void* value; 69 }; 70 typedef struct ASN1iterator_s ASN1iterator_t; 71 72 struct tagASN1bitstring_t 73 { 74 ASN1uint32_t length; 75 ASN1octet_t* value; 76 }; 77 typedef struct tagASN1bitstring_t ASN1bitstring_t; 78 79 typedef char ASN1char_t; 80 81 struct tagASN1charstring_t 82 { 83 ASN1uint32_t length; 84 ASN1char_t* value; 85 }; 86 typedef struct tagASN1charstring_t ASN1charstring_t; 87 88 typedef ASN1uint16_t ASN1char16_t; 89 90 struct tagASN1char16string_t 91 { 92 ASN1uint32_t length; 93 ASN1char16_t* value; 94 }; 95 typedef struct tagASN1char16string_t ASN1char16string_t; 96 97 typedef ASN1uint32_t ASN1char32_t; 98 99 struct tagASN1char32string_t 100 { 101 ASN1uint32_t length; 102 ASN1char32_t* value; 103 }; 104 typedef struct tagASN1char32string_t ASN1char32string_t; 105 106 typedef ASN1char_t* ASN1ztcharstring_t; 107 typedef ASN1char16_t* ASN1ztchar16string_t; 108 typedef ASN1char32_t* ASN1ztchar32string_t; 109 110 struct tagASN1wstring_t 111 { 112 ASN1uint32_t length; 113 WCHAR* value; 114 }; 115 typedef struct tagASN1wstring_t ASN1wstring_t; 116 117 struct ASN1objectidentifier_s 118 { 119 struct ASN1objectidentifier_s* next; 120 ASN1uint32_t value; 121 }; 122 typedef struct ASN1objectidentifier_s* ASN1objectidentifier_t; 123 124 struct tagASN1objectidentifier2_t 125 { 126 ASN1uint16_t count; 127 ASN1uint32_t value[16]; 128 }; 129 typedef struct tagASN1objectidentifier2_t ASN1objectidentifier2_t; 130 131 struct tagASN1encodedOID_t 132 { 133 ASN1uint16_t length; 134 ASN1octet_t* value; 135 }; 136 typedef struct tagASN1encodedOID_t ASN1encodedOID_t; 137 138 typedef ASN1ztcharstring_t ASN1objectdescriptor_t; 139 140 struct tagASN1generalizedtime_t 141 { 142 ASN1uint16_t year; 143 ASN1uint8_t month; 144 ASN1uint8_t day; 145 ASN1uint8_t hour; 146 ASN1uint8_t minute; 147 ASN1uint8_t second; 148 ASN1uint16_t millisecond; 149 ASN1bool_t universal; 150 ASN1int16_t diff; 151 }; 152 typedef struct tagASN1generalizedtime_t ASN1generalizedtime_t; 153 154 struct tagASN1utctime_t 155 { 156 ASN1uint8_t year; 157 ASN1uint8_t month; 158 ASN1uint8_t day; 159 ASN1uint8_t hour; 160 ASN1uint8_t minute; 161 ASN1uint8_t second; 162 ASN1bool_t universal; 163 ASN1int16_t diff; 164 }; 165 typedef struct tagASN1utctime_t ASN1utctime_t; 166 167 struct tagASN1open_t 168 { 169 ASN1uint32_t length; 170 171 union { 172 void* encoded; 173 void* value; 174 }; 175 }; 176 typedef struct tagASN1open_t ASN1open_t; 177 178 enum tagASN1blocktype_e 179 { 180 ASN1_DER_SET_OF_BLOCK, 181 }; 182 typedef enum tagASN1blocktype_e ASN1blocktype_e; 183 184 typedef ASN1int32_t ASN1enum_t; 185 typedef ASN1uint16_t ASN1choice_t; 186 typedef ASN1uint32_t ASN1magic_t; 187 188 enum 189 { 190 ASN1_CHOICE_BASE = 1, 191 ASN1_CHOICE_INVALID = -1, 192 ASN1_CHOICE_EXTENSION = 0, 193 }; 194 195 enum tagASN1error_e 196 { 197 ASN1_SUCCESS = 0, 198 ASN1_ERR_INTERNAL = -1001, 199 ASN1_ERR_EOD = -1002, 200 ASN1_ERR_CORRUPT = -1003, 201 ASN1_ERR_LARGE = -1004, 202 ASN1_ERR_CONSTRAINT = -1005, 203 ASN1_ERR_MEMORY = -1006, 204 ASN1_ERR_OVERFLOW = -1007, 205 ASN1_ERR_BADPDU = -1008, 206 ASN1_ERR_BADARGS = -1009, 207 ASN1_ERR_BADREAL = -1010, 208 ASN1_ERR_BADTAG = -1011, 209 ASN1_ERR_CHOICE = -1012, 210 ASN1_ERR_RULE = -1013, 211 ASN1_ERR_UTF8 = -1014, 212 ASN1_ERR_PDU_TYPE = -1051, 213 ASN1_ERR_NYI = -1052, 214 ASN1_WRN_EXTENDED = 1001, 215 ASN1_WRN_NOEOD = 1002, 216 }; 217 typedef enum tagASN1error_e ASN1error_e; 218 219 enum tagASN1encodingrule_e 220 { 221 ASN1_BER_RULE_BER = 0x0100, 222 ASN1_BER_RULE_CER = 0x0200, 223 ASN1_BER_RULE_DER = 0x0400, 224 ASN1_BER_RULE = ASN1_BER_RULE_BER | ASN1_BER_RULE_CER | ASN1_BER_RULE_DER, 225 }; 226 typedef enum tagASN1encodingrule_e ASN1encodingrule_e; 227 228 typedef struct ASN1encoding_s* ASN1encoding_t; 229 typedef struct ASN1decoding_s* ASN1decoding_t; 230 231 typedef ASN1int32_t (*ASN1BerEncFun_t)(ASN1encoding_t enc, ASN1uint32_t tag, void* data); 232 typedef ASN1int32_t (*ASN1BerDecFun_t)(ASN1decoding_t enc, ASN1uint32_t tag, void* data); 233 234 struct tagASN1BerFunArr_t 235 { 236 const ASN1BerEncFun_t* apfnEncoder; 237 const ASN1BerDecFun_t* apfnDecoder; 238 }; 239 typedef struct tagASN1BerFunArr_t ASN1BerFunArr_t; 240 241 typedef void (*ASN1GenericFun_t)(void); 242 typedef void (*ASN1FreeFun_t)(void* data); 243 244 struct tagASN1module_t 245 { 246 ASN1magic_t nModuleName; 247 ASN1encodingrule_e eRule; 248 ASN1uint32_t dwFlags; 249 ASN1uint32_t cPDUs; 250 const ASN1FreeFun_t* apfnFreeMemory; 251 const ASN1uint32_t* acbStructSize; 252 ASN1BerFunArr_t BER; 253 }; 254 typedef struct tagASN1module_t* ASN1module_t; 255 256 struct ASN1encoding_s 257 { 258 ASN1magic_t magic; 259 ASN1uint32_t version; 260 ASN1module_t module; 261 ASN1octet_t* buf; 262 ASN1uint32_t size; 263 ASN1uint32_t len; 264 ASN1error_e err; 265 ASN1uint32_t bit; 266 ASN1octet_t* pos; 267 ASN1uint32_t cbExtraHeader; 268 ASN1encodingrule_e eRule; 269 ASN1uint32_t dwFlags; 270 }; 271 272 struct ASN1decoding_s 273 { 274 ASN1magic_t magic; 275 ASN1uint32_t version; 276 ASN1module_t module; 277 ASN1octet_t* buf; 278 ASN1uint32_t size; 279 ASN1uint32_t len; 280 ASN1error_e err; 281 ASN1uint32_t bit; 282 ASN1octet_t* pos; 283 ASN1encodingrule_e eRule; 284 ASN1uint32_t dwFlags; 285 }; 286 287 enum 288 { 289 ASN1FLAGS_NONE = 0x00000000L, 290 ASN1FLAGS_NOASSERT = 0x00001000L, 291 }; 292 293 enum 294 { 295 ASN1ENCODE_APPEND = 0x00000001L, 296 ASN1ENCODE_REUSEBUFFER = 0x00000004L, 297 ASN1ENCODE_SETBUFFER = 0x00000008L, 298 ASN1ENCODE_ALLOCATEBUFFER = 0x00000010L, 299 ASN1ENCODE_NOASSERT = ASN1FLAGS_NOASSERT, 300 }; 301 302 enum 303 { 304 ASN1DECODE_APPENDED = 0x00000001L, 305 ASN1DECODE_REWINDBUFFER = 0x00000004L, 306 ASN1DECODE_SETBUFFER = 0x00000008L, 307 ASN1DECODE_AUTOFREEBUFFER = 0x00000010L, 308 ASN1DECODE_NOASSERT = ASN1FLAGS_NOASSERT, 309 }; 310 311 WINPR_API ASN1module_t ASN1_CreateModule(ASN1uint32_t nVersion, ASN1encodingrule_e eRule, 312 ASN1uint32_t dwFlags, ASN1uint32_t cPDU, 313 const ASN1GenericFun_t apfnEncoder[], 314 const ASN1GenericFun_t apfnDecoder[], 315 const ASN1FreeFun_t apfnFreeMemory[], 316 const ASN1uint32_t acbStructSize[], 317 ASN1magic_t nModuleName); 318 319 WINPR_API void ASN1_CloseModule(ASN1module_t pModule); 320 321 WINPR_API ASN1error_e ASN1_CreateEncoder(ASN1module_t pModule, ASN1encoding_t* ppEncoderInfo, 322 ASN1octet_t* pbBuf, ASN1uint32_t cbBufSize, 323 ASN1encoding_t pParent); 324 325 WINPR_API ASN1error_e ASN1_Encode(ASN1encoding_t pEncoderInfo, void* pDataStruct, 326 ASN1uint32_t nPduNum, ASN1uint32_t dwFlags, 327 ASN1octet_t* pbBuf, ASN1uint32_t cbBufSize); 328 329 WINPR_API void ASN1_CloseEncoder(ASN1encoding_t pEncoderInfo); 330 331 WINPR_API void ASN1_CloseEncoder2(ASN1encoding_t pEncoderInfo); 332 333 WINPR_API ASN1error_e ASN1_CreateDecoder(ASN1module_t pModule, ASN1decoding_t* ppDecoderInfo, 334 ASN1octet_t* pbBuf, ASN1uint32_t cbBufSize, 335 ASN1decoding_t pParent); 336 337 WINPR_API ASN1error_e ASN1_Decode(ASN1decoding_t pDecoderInfo, void** ppDataStruct, 338 ASN1uint32_t nPduNum, ASN1uint32_t dwFlags, 339 ASN1octet_t* pbBuf, ASN1uint32_t cbBufSize); 340 341 WINPR_API void ASN1_CloseDecoder(ASN1decoding_t pDecoderInfo); 342 343 WINPR_API void ASN1_FreeEncoded(ASN1encoding_t pEncoderInfo, void* pBuf); 344 345 WINPR_API void ASN1_FreeDecoded(ASN1decoding_t pDecoderInfo, void* pDataStruct, 346 ASN1uint32_t nPduNum); 347 348 enum tagASN1option_e 349 { 350 ASN1OPT_CHANGE_RULE = 0x101, 351 ASN1OPT_GET_RULE = 0x201, 352 ASN1OPT_NOT_REUSE_BUFFER = 0x301, 353 ASN1OPT_REWIND_BUFFER = 0x302, 354 ASN1OPT_SET_DECODED_BUFFER = 0x501, 355 ASN1OPT_DEL_DECODED_BUFFER = 0x502, 356 ASN1OPT_GET_DECODED_BUFFER_SIZE = 0x601, 357 }; 358 typedef enum tagASN1option_e ASN1option_e; 359 360 struct tagASN1optionparam_t 361 { 362 ASN1option_e eOption; 363 364 union { 365 ASN1encodingrule_e eRule; 366 ASN1uint32_t cbRequiredDecodedBufSize; 367 368 struct 369 { 370 ASN1octet_t* pbBuf; 371 ASN1uint32_t cbBufSize; 372 } Buffer; 373 }; 374 }; 375 typedef struct tagASN1optionparam_t ASN1optionparam_t; 376 typedef struct tagASN1optionparam_t ASN1optionparam_s; 377 378 WINPR_API ASN1error_e ASN1_SetEncoderOption(ASN1encoding_t pEncoderInfo, 379 ASN1optionparam_t* pOptParam); 380 WINPR_API ASN1error_e ASN1_GetEncoderOption(ASN1encoding_t pEncoderInfo, 381 ASN1optionparam_t* pOptParam); 382 383 WINPR_API ASN1error_e ASN1_SetDecoderOption(ASN1decoding_t pDecoderInfo, 384 ASN1optionparam_t* pOptParam); 385 WINPR_API ASN1error_e ASN1_GetDecoderOption(ASN1decoding_t pDecoderInfo, 386 ASN1optionparam_t* pOptParam); 387 388 WINPR_API void ASN1bitstring_free(ASN1bitstring_t* bitstring); 389 WINPR_API void ASN1octetstring_free(ASN1octetstring_t* octetstring); 390 WINPR_API void ASN1objectidentifier_free(ASN1objectidentifier_t* objectidentifier); 391 WINPR_API void ASN1charstring_free(ASN1charstring_t* charstring); 392 WINPR_API void ASN1char16string_free(ASN1char16string_t* char16string); 393 WINPR_API void ASN1char32string_free(ASN1char32string_t* char32string); 394 WINPR_API void ASN1ztcharstring_free(ASN1ztcharstring_t ztcharstring); 395 WINPR_API void ASN1ztchar16string_free(ASN1ztchar16string_t ztchar16string); 396 WINPR_API void ASN1ztchar32string_free(ASN1ztchar32string_t ztchar32string); 397 WINPR_API void ASN1open_free(ASN1open_t* open); 398 WINPR_API void ASN1utf8string_free(ASN1wstring_t* utf8string); 399 400 WINPR_API LPVOID ASN1DecAlloc(ASN1decoding_t dec, ASN1uint32_t size); 401 WINPR_API LPVOID ASN1DecRealloc(ASN1decoding_t dec, LPVOID ptr, ASN1uint32_t size); 402 403 WINPR_API void ASN1Free(LPVOID ptr); 404 405 WINPR_API ASN1error_e ASN1EncSetError(ASN1encoding_t enc, ASN1error_e err); 406 WINPR_API ASN1error_e ASN1DecSetError(ASN1decoding_t dec, ASN1error_e err); 407 408 WINPR_API ASN1uint32_t ASN1intx_uoctets(ASN1intx_t* intx); 409 WINPR_API void ASN1intx_free(ASN1intx_t* intx); 410 WINPR_API ASN1int32_t ASN1intx2int32(ASN1intx_t* intx); 411 WINPR_API ASN1uint32_t ASN1intx2uint32(ASN1intx_t* intx); 412 WINPR_API int ASN1intxisuint32(ASN1intx_t* intx); 413 WINPR_API void ASN1intx_setuint32(ASN1intx_t* dst, ASN1uint32_t val); 414 415 WINPR_API ASN1uint32_t ASN1uint32_uoctets(ASN1uint32_t val); 416 417 WINPR_API int ASN1intx_cmp(ASN1intx_t* intx1, ASN1intx_t* intx2); 418 WINPR_API int ASN1objectidentifier_cmp(ASN1objectidentifier_t* oid1, 419 ASN1objectidentifier_t* oid2); 420 WINPR_API int ASN1objectidentifier2_cmp(ASN1objectidentifier2_t* oid1, 421 ASN1objectidentifier2_t* oid2); 422 WINPR_API int ASN1bitstring_cmp(ASN1bitstring_t* str1, ASN1bitstring_t* str2, int length); 423 WINPR_API int ASN1octetstring_cmp(ASN1octetstring_t* str1, ASN1octetstring_t* str2); 424 WINPR_API int ASN1charstring_cmp(ASN1charstring_t* str1, ASN1charstring_t* str2); 425 WINPR_API int ASN1char16string_cmp(ASN1char16string_t* str1, ASN1char16string_t* str2); 426 WINPR_API int ASN1char32string_cmp(ASN1char32string_t* str1, ASN1char32string_t* str2); 427 WINPR_API int ASN1ztcharstring_cmp(ASN1ztcharstring_t str1, ASN1ztcharstring_t str2); 428 WINPR_API int ASN1ztchar16string_cmp(ASN1ztchar16string_t str1, ASN1ztchar16string_t str2); 429 WINPR_API int ASN1ztchar32string_cmp(ASN1ztchar32string_t str1, ASN1ztchar32string_t str2); 430 WINPR_API int ASN1open_cmp(ASN1open_t* open1, ASN1open_t* open2); 431 WINPR_API int ASN1generalizedtime_cmp(ASN1generalizedtime_t* t1, ASN1generalizedtime_t* t2); 432 WINPR_API int ASN1utctime_cmp(ASN1utctime_t* t1, ASN1utctime_t* t2); 433 434 WINPR_API int ASN1BEREncCharString(ASN1encoding_t enc, ASN1uint32_t tag, ASN1uint32_t len, 435 ASN1char_t* val); 436 WINPR_API int ASN1DEREncCharString(ASN1encoding_t enc, ASN1uint32_t tag, ASN1uint32_t len, 437 ASN1char_t* val); 438 WINPR_API int ASN1BEREncChar16String(ASN1encoding_t enc, ASN1uint32_t tag, ASN1uint32_t len, 439 ASN1char16_t* val); 440 WINPR_API int ASN1DEREncChar16String(ASN1encoding_t enc, ASN1uint32_t tag, ASN1uint32_t len, 441 ASN1char16_t* val); 442 WINPR_API int ASN1BEREncChar32String(ASN1encoding_t enc, ASN1uint32_t tag, ASN1uint32_t len, 443 ASN1char32_t* val); 444 WINPR_API int ASN1DEREncChar32String(ASN1encoding_t enc, ASN1uint32_t tag, ASN1uint32_t len, 445 ASN1char32_t* val); 446 WINPR_API int ASN1BEREncOctetString(ASN1encoding_t enc, ASN1uint32_t tag, ASN1uint32_t len, 447 ASN1octet_t* val); 448 WINPR_API int ASN1DEREncOctetString(ASN1encoding_t enc, ASN1uint32_t tag, ASN1uint32_t len, 449 ASN1octet_t* val); 450 WINPR_API int ASN1BEREncBitString(ASN1encoding_t enc, ASN1uint32_t tag, ASN1uint32_t bitlen, 451 ASN1octet_t* val); 452 WINPR_API int ASN1DEREncBitString(ASN1encoding_t enc, ASN1uint32_t tag, ASN1uint32_t bitlen, 453 ASN1octet_t* val); 454 WINPR_API int ASN1BEREncGeneralizedTime(ASN1encoding_t enc, ASN1uint32_t tag, 455 ASN1generalizedtime_t* val); 456 WINPR_API int ASN1DEREncGeneralizedTime(ASN1encoding_t enc, ASN1uint32_t tag, 457 ASN1generalizedtime_t* val); 458 WINPR_API int ASN1BEREncS32(ASN1encoding_t enc, ASN1uint32_t tag, ASN1int32_t val); 459 WINPR_API int ASN1BEREncSX(ASN1encoding_t enc, ASN1uint32_t tag, ASN1intx_t* val); 460 WINPR_API int ASN1BEREncZeroMultibyteString(ASN1encoding_t enc, ASN1uint32_t tag, 461 ASN1ztcharstring_t val); 462 WINPR_API int ASN1DEREncZeroMultibyteString(ASN1encoding_t enc, ASN1uint32_t tag, 463 ASN1ztcharstring_t val); 464 WINPR_API int ASN1BEREncMultibyteString(ASN1encoding_t enc, ASN1uint32_t tag, 465 ASN1charstring_t* val); 466 WINPR_API int ASN1DEREncMultibyteString(ASN1encoding_t enc, ASN1uint32_t tag, 467 ASN1charstring_t* val); 468 WINPR_API int ASN1BEREncNull(ASN1encoding_t enc, ASN1uint32_t tag); 469 WINPR_API int ASN1BEREncObjectIdentifier(ASN1encoding_t enc, ASN1uint32_t tag, 470 ASN1objectidentifier_t* val); 471 WINPR_API int ASN1BEREncObjectIdentifier2(ASN1encoding_t enc, ASN1uint32_t tag, 472 ASN1objectidentifier2_t* val); 473 WINPR_API int ASN1BEREncRemoveZeroBits(ASN1uint32_t* nbits, ASN1octet_t* val); 474 WINPR_API int ASN1BEREncRemoveZeroBits2(ASN1uint32_t* nbits, ASN1octet_t* val, 475 ASN1uint32_t minlen); 476 WINPR_API int ASN1BEREncUTCTime(ASN1encoding_t enc, ASN1uint32_t tag, ASN1utctime_t* val); 477 WINPR_API int ASN1DEREncUTCTime(ASN1encoding_t enc, ASN1uint32_t tag, ASN1utctime_t* val); 478 WINPR_API int ASN1BEREncFlush(ASN1encoding_t enc); 479 WINPR_API int ASN1BEREncOpenType(ASN1encoding_t enc, ASN1open_t* val); 480 WINPR_API int ASN1BERDecExplicitTag(ASN1decoding_t dec, ASN1uint32_t tag, ASN1decoding_t* dd, 481 ASN1octet_t** ppBufEnd); 482 483 WINPR_API int ASN1BERDecEndOfContents(ASN1decoding_t dec, ASN1decoding_t dd, 484 ASN1octet_t* pBufEnd); 485 WINPR_API int ASN1BERDecOctetString(ASN1decoding_t dec, ASN1uint32_t tag, 486 ASN1octetstring_t* val); 487 WINPR_API int ASN1BERDecOctetString2(ASN1decoding_t dec, ASN1uint32_t tag, 488 ASN1octetstring_t* val); 489 WINPR_API int ASN1BERDecBitString(ASN1decoding_t dec, ASN1uint32_t tag, ASN1bitstring_t* val); 490 WINPR_API int ASN1BERDecBitString2(ASN1decoding_t dec, ASN1uint32_t tag, ASN1bitstring_t* val); 491 WINPR_API int ASN1BERDecChar16String(ASN1decoding_t dec, ASN1uint32_t tag, 492 ASN1char16string_t* val); 493 WINPR_API int ASN1BERDecChar32String(ASN1decoding_t dec, ASN1uint32_t tag, 494 ASN1char32string_t* val); 495 WINPR_API int ASN1BERDecCharString(ASN1decoding_t dec, ASN1uint32_t tag, ASN1charstring_t* val); 496 WINPR_API int ASN1BERDecGeneralizedTime(ASN1decoding_t dec, ASN1uint32_t tag, 497 ASN1generalizedtime_t* val); 498 WINPR_API int ASN1BERDecZeroMultibyteString(ASN1decoding_t dec, ASN1uint32_t tag, 499 ASN1ztcharstring_t* val); 500 WINPR_API int ASN1BERDecMultibyteString(ASN1decoding_t dec, ASN1uint32_t tag, 501 ASN1charstring_t* val); 502 WINPR_API int ASN1BERDecNull(ASN1decoding_t dec, ASN1uint32_t tag); 503 WINPR_API int ASN1BERDecObjectIdentifier(ASN1decoding_t dec, ASN1uint32_t tag, 504 ASN1objectidentifier_t* val); 505 WINPR_API int ASN1BERDecObjectIdentifier2(ASN1decoding_t dec, ASN1uint32_t tag, 506 ASN1objectidentifier2_t* val); 507 WINPR_API int ASN1BERDecS8Val(ASN1decoding_t dec, ASN1uint32_t tag, ASN1int8_t* val); 508 WINPR_API int ASN1BERDecS16Val(ASN1decoding_t dec, ASN1uint32_t tag, ASN1int16_t* val); 509 WINPR_API int ASN1BERDecS32Val(ASN1decoding_t dec, ASN1uint32_t tag, ASN1int32_t* val); 510 WINPR_API int ASN1BERDecSXVal(ASN1decoding_t dec, ASN1uint32_t tag, ASN1intx_t* val); 511 WINPR_API int ASN1BERDecU8Val(ASN1decoding_t dec, ASN1uint32_t tag, ASN1uint8_t* val); 512 WINPR_API int ASN1BERDecU16Val(ASN1decoding_t dec, ASN1uint32_t tag, ASN1uint16_t* val); 513 WINPR_API int ASN1BERDecU32Val(ASN1decoding_t dec, ASN1uint32_t tag, ASN1uint32_t* val); 514 WINPR_API int ASN1BERDecUTCTime(ASN1decoding_t dec, ASN1uint32_t tag, ASN1utctime_t* val); 515 WINPR_API int ASN1BERDecZeroCharString(ASN1decoding_t dec, ASN1uint32_t tag, 516 ASN1ztcharstring_t* val); 517 WINPR_API int ASN1BERDecZeroChar16String(ASN1decoding_t dec, ASN1uint32_t tag, 518 ASN1ztchar16string_t* val); 519 WINPR_API int ASN1BERDecZeroChar32String(ASN1decoding_t dec, ASN1uint32_t tag, 520 ASN1ztchar32string_t* val); 521 WINPR_API int ASN1BERDecSkip(ASN1decoding_t dec); 522 WINPR_API int ASN1BERDecFlush(ASN1decoding_t dec); 523 WINPR_API int ASN1BERDecOpenType(ASN1decoding_t dec, ASN1open_t* val); 524 WINPR_API int ASN1BERDecOpenType2(ASN1decoding_t dec, ASN1open_t* val); 525 526 WINPR_API int ASN1BEREncCheck(ASN1encoding_t enc, ASN1uint32_t noctets); 527 WINPR_API int ASN1BEREncTag(ASN1encoding_t enc, ASN1uint32_t tag); 528 WINPR_API int ASN1BEREncExplicitTag(ASN1encoding_t enc, ASN1uint32_t tag, 529 ASN1uint32_t* pnLenOff); 530 WINPR_API int ASN1BEREncEndOfContents(ASN1encoding_t enc, ASN1uint32_t nLenOff); 531 WINPR_API int ASN1BEREncLength(ASN1encoding_t enc, ASN1uint32_t len); 532 533 WINPR_API int ASN1BERDecCheck(ASN1decoding_t dec, ASN1uint32_t len); 534 WINPR_API int ASN1BERDecTag(ASN1decoding_t dec, ASN1uint32_t tag, ASN1uint32_t* constructed); 535 WINPR_API int ASN1BERDecLength(ASN1decoding_t dec, ASN1uint32_t* len, ASN1uint32_t* infinite); 536 WINPR_API int ASN1BERDecNotEndOfContents(ASN1decoding_t dec, ASN1octet_t* pBufEnd); 537 WINPR_API int ASN1BERDecPeekTag(ASN1decoding_t dec, ASN1uint32_t* tag); 538 539 WINPR_API int ASN1BEREncU32(ASN1encoding_t enc, ASN1uint32_t tag, ASN1uint32_t val); 540 WINPR_API int ASN1BEREncBool(ASN1encoding_t enc, ASN1uint32_t tag, ASN1bool_t val); 541 WINPR_API int ASN1BERDecBool(ASN1decoding_t dec, ASN1uint32_t tag, ASN1bool_t* val); 542 WINPR_API int ASN1BEREncEoid(ASN1encoding_t enc, ASN1uint32_t tag, ASN1encodedOID_t* val); 543 WINPR_API int ASN1BERDecEoid(ASN1decoding_t dec, ASN1uint32_t tag, ASN1encodedOID_t* val); 544 WINPR_API int ASN1BERDotVal2Eoid(ASN1encoding_t enc, char* pszDotVal, ASN1encodedOID_t* pOut); 545 WINPR_API int ASN1BEREoid2DotVal(ASN1decoding_t dec, ASN1encodedOID_t* pIn, char** ppszDotVal); 546 WINPR_API void ASN1BEREoid_free(ASN1encodedOID_t* val); 547 WINPR_API int ASN1BEREncUTF8String(ASN1encoding_t enc, ASN1uint32_t tag, ASN1uint32_t length, 548 WCHAR* value); 549 WINPR_API int ASN1DEREncUTF8String(ASN1encoding_t enc, ASN1uint32_t tag, ASN1uint32_t length, 550 WCHAR* value); 551 WINPR_API int ASN1BERDecUTF8String(ASN1decoding_t dec, ASN1uint32_t tag, ASN1wstring_t* val); 552 WINPR_API int ASN1DEREncBeginBlk(ASN1encoding_t enc, ASN1blocktype_e eBlkType, void** ppBlk); 553 WINPR_API int ASN1DEREncNewBlkElement(void* pBlk, ASN1encoding_t* enc2); 554 WINPR_API int ASN1DEREncFlushBlkElement(void* pBlk); 555 WINPR_API int ASN1DEREncEndBlk(void* pBlk); 556 557#ifdef __cplusplus 558} 559#endif 560 561#endif /* WINPR_ASN1_H */