FreeRDP
er.h
1 
21 #ifndef FREERDP_CRYPTO_ER_H
22 #define FREERDP_CRYPTO_ER_H
23 
24 #include <freerdp/api.h>
25 #include <freerdp/types.h>
26 
27 #include <winpr/stream.h>
28 
29 /* ER type */
30 
31 /* Class - bits 8 and 7 */
32 #define ER_CLASS_MASK 0xC0
33 #define ER_CLASS_UNIV 0x00 /* 0 0 */
34 #define ER_CLASS_APPL 0x40 /* 0 1 */
35 #define ER_CLASS_CTXT 0x80 /* 1 0 */
36 #define ER_CLASS_PRIV 0xC0 /* 1 1 */
37 
38 /* P/C - bit 6 */
39 #define ER_PC_MASK 0x20
40 #define ER_PRIMITIVE 0x00 /* 0 */
41 #define ER_CONSTRUCT 0x20 /* 1 */
42 
43 /* Tag - bits 5 to 1 */
44 #define ER_TAG_MASK 0x1F
45 #define ER_TAG_BOOLEAN 0x01
46 #define ER_TAG_INTEGER 0x02
47 #define ER_TAG_BIT_STRING 0x03
48 #define ER_TAG_OCTET_STRING 0x04
49 #define ER_TAG_OBJECT_IDENTIFIER 0x06
50 #define ER_TAG_ENUMERATED 0x0A
51 #define ER_TAG_SEQUENCE 0x10
52 #define ER_TAG_SEQUENCE_OF 0x10
53 #define ER_TAG_GENERAL_STRING 0x1B
54 #define ER_TAG_GENERALIZED_TIME 0x18
55 
56 #define ER_PC(_pc) (_pc ? ER_CONSTRUCT : ER_PRIMITIVE)
57 
58 #ifdef __cplusplus
59 extern "C"
60 {
61 #endif
62 
63  FREERDP_API void er_read_length(wStream* s, int* length);
64  FREERDP_API int er_write_length(wStream* s, int length, BOOL flag);
65  FREERDP_API int _er_skip_length(int length);
66  FREERDP_API int er_get_content_length(int length);
67  FREERDP_API BOOL er_read_universal_tag(wStream* s, BYTE tag, BOOL pc);
68  FREERDP_API void er_write_universal_tag(wStream* s, BYTE tag, BOOL pc);
69  FREERDP_API BOOL er_read_application_tag(wStream* s, BYTE tag, int* length);
70  FREERDP_API void er_write_application_tag(wStream* s, BYTE tag, int length, BOOL flag);
71  FREERDP_API BOOL er_read_enumerated(wStream* s, BYTE* enumerated, BYTE count);
72  FREERDP_API void er_write_enumerated(wStream* s, BYTE enumerated, BYTE count, BOOL flag);
73  FREERDP_API BOOL er_read_contextual_tag(wStream* s, BYTE tag, int* length, BOOL pc);
74  FREERDP_API int er_write_contextual_tag(wStream* s, BYTE tag, int length, BOOL pc, BOOL flag);
75  FREERDP_API int er_skip_contextual_tag(int length);
76  FREERDP_API BOOL er_read_sequence_tag(wStream* s, int* length);
77  FREERDP_API int er_write_sequence_tag(wStream* s, int length, BOOL flag);
78  FREERDP_API int er_skip_sequence(int length);
79  FREERDP_API int er_skip_sequence_tag(int length);
80  FREERDP_API BOOL er_read_bit_string(wStream* s, int* length, BYTE* padding);
81  FREERDP_API BOOL er_write_bit_string_tag(wStream* s, UINT32 length, BYTE padding, BOOL flag);
82  FREERDP_API BOOL er_read_octet_string(wStream* s, int* length);
83  FREERDP_API void er_write_octet_string(wStream* s, BYTE* oct_str, int length, BOOL flag);
84  FREERDP_API int er_write_octet_string_tag(wStream* s, int length, BOOL flag);
85  FREERDP_API int er_skip_octet_string(int length);
86  FREERDP_API BOOL er_read_BOOL(wStream* s, BOOL* value);
87  FREERDP_API void er_write_BOOL(wStream* s, BOOL value);
88  FREERDP_API BOOL er_read_integer(wStream* s, UINT32* value);
89  FREERDP_API int er_write_integer(wStream* s, INT32 value);
90  FREERDP_API BOOL er_read_integer_length(wStream* s, int* length);
91  FREERDP_API int er_skip_integer(INT32 value);
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif /* FREERDP_CRYPTO_ER_H */