diff --git a/include/msasn1.h b/include/msasn1.h index 89a6255a5fe..dd0bcb5b3df 100644 --- a/include/msasn1.h +++ b/include/msasn1.h @@ -43,6 +43,11 @@ typedef ASN1uint16_t ASN1choice_t; typedef ASN1uint32_t ASN1magic_t; typedef ASN1ztcharstring_t ASN1objectdescriptor_t; +#define ASN1_MAKE_VERSION(major,minor) (((major) << 16) | (minor)) +#define ASN1_THIS_VERSION ASN1_MAKE_VERSION(1,0) + +#define ASN1DECFREE_NON_PDU_ID ((ASN1uint32_t)-1) + typedef void (WINAPI *ASN1FreeFun_t)(void *data); typedef void (WINAPI *ASN1GenericFun_t)(void); @@ -64,6 +69,30 @@ typedef struct tagASN1BerFunArr_t { const ASN1BerDecFun_t *apfnDecoder; } ASN1BerFunArr_t; +enum +{ + ASN1FLAGS_NONE = 0x00000000, + ASN1FLAGS_NOASSERT = 0x00001000 +}; + +enum +{ + ASN1ENCODE_APPEND = 0x00000001, + ASN1ENCODE_REUSEBUFFER = 0x00000004, + ASN1ENCODE_SETBUFFER = 0x00000008, + ASN1ENCODE_ALLOCATEBUFFER = 0x00000010, + ASN1ENCODE_NOASSERT = ASN1FLAGS_NOASSERT +}; + +enum +{ + ASN1DECODE_APPENDED = 0x00000001, + ASN1DECODE_REWINDBUFFER = 0x00000004, + ASN1DECODE_SETBUFFER = 0x00000008, + ASN1DECODE_AUTOFREEBUFFER = 0x00000010, + ASN1DECODE_NOASSERT = ASN1FLAGS_NOASSERT +}; + typedef struct tagASN1bitstring_t { ASN1uint32_t length; @@ -128,6 +157,9 @@ typedef enum tagASN1error_e ASN1_WRN_NOEOD = 1002, } ASN1error_e; +#define ASN1_SUCCEEDED(ret) (((int)(ret)) >= 0) +#define ASN1_FAILED(ret) (((int)(ret)) < 0) + typedef struct tagASN1generalizedtime_t { ASN1uint16_t year; @@ -147,19 +179,52 @@ typedef struct tagASN1intx_t ASN1octet_t *value; } ASN1intx_t; -typedef struct tagASN1module_t { +typedef struct tagASN1module_t +{ ASN1magic_t nModuleName; ASN1encodingrule_e eRule; ASN1uint32_t dwFlags; ASN1uint32_t cPDUs; const ASN1FreeFun_t *apfnFreeMemory; const ASN1uint32_t *acbStructSize; - union { - ASN1PerFunArr_t PER; - ASN1BerFunArr_t BER; + union + { + ASN1PerFunArr_t PER; + ASN1BerFunArr_t BER; }; } *ASN1module_t; +struct ASN1encoding_s +{ + ASN1magic_t magic; + ASN1uint32_t version; + ASN1module_t module; + ASN1octet_t *buf; + ASN1uint32_t size; + ASN1uint32_t len; + ASN1error_e err; + ASN1uint32_t bit; + ASN1octet_t *pos; + ASN1uint32_t cbExtraHeader; + ASN1encodingrule_e eRule; + ASN1uint32_t dwFlags; +}; + +struct ASN1decoding_s +{ + ASN1magic_t magic; + ASN1uint32_t version; + ASN1module_t module; + ASN1octet_t *buf; + ASN1uint32_t size; + ASN1uint32_t len; + ASN1error_e err; + ASN1uint32_t bit; + ASN1octet_t *pos; + ASN1encodingrule_e eRule; + ASN1uint32_t dwFlags; +}; + typedef struct ASN1objectidentifier_s { struct ASN1objectidentifier_s *next;