2
* FreeRDP: A Remote Desktop Protocol Implementation
3
* ASN.1 Encoding Rules (BER/DER common functions)
5
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6
* Modified by Jiten Pathy
8
* Licensed under the Apache License, Version 2.0 (the "License");
9
* you may not use this file except in compliance with the License.
10
* You may obtain a copy of the License at
12
* http://www.apache.org/licenses/LICENSE-2.0
14
* Unless required by applicable law or agreed to in writing, software
15
* distributed under the License is distributed on an "AS IS" BASIS,
16
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
* See the License for the specific language governing permissions and
18
* limitations under the License.
21
#ifndef FREERDP_CRYPTO_ER_H
22
#define FREERDP_CRYPTO_ER_H
24
#include <freerdp/api.h>
25
#include <freerdp/types.h>
28
#include <winpr/stream.h>
32
/* Class - bits 8 and 7 */
33
#define ER_CLASS_MASK 0xC0
34
#define ER_CLASS_UNIV 0x00 /* 0 0 */
35
#define ER_CLASS_APPL 0x40 /* 0 1 */
36
#define ER_CLASS_CTXT 0x80 /* 1 0 */
37
#define ER_CLASS_PRIV 0xC0 /* 1 1 */
40
#define ER_PC_MASK 0x20
41
#define ER_PRIMITIVE 0x00 /* 0 */
42
#define ER_CONSTRUCT 0x20 /* 1 */
44
/* Tag - bits 5 to 1 */
45
#define ER_TAG_MASK 0x1F
46
#define ER_TAG_BOOLEAN 0x01
47
#define ER_TAG_INTEGER 0x02
48
#define ER_TAG_BIT_STRING 0x03
49
#define ER_TAG_OCTET_STRING 0x04
50
#define ER_TAG_OBJECT_IDENFIER 0x06
51
#define ER_TAG_ENUMERATED 0x0A
52
#define ER_TAG_SEQUENCE 0x10
53
#define ER_TAG_SEQUENCE_OF 0x10
54
#define ER_TAG_GENERAL_STRING 0x1B
55
#define ER_TAG_GENERALIZED_TIME 0x18
57
#define ER_PC(_pc) (_pc ? ER_CONSTRUCT : ER_PRIMITIVE)
59
FREERDP_API void er_read_length(wStream* s, int* length);
60
FREERDP_API int er_write_length(wStream* s, int length, BOOL flag);
61
FREERDP_API int _er_skip_length(int length);
62
FREERDP_API int er_get_content_length(int length);
63
FREERDP_API BOOL er_read_universal_tag(wStream* s, BYTE tag, BOOL pc);
64
FREERDP_API void er_write_universal_tag(wStream* s, BYTE tag, BOOL pc);
65
FREERDP_API BOOL er_read_application_tag(wStream* s, BYTE tag, int* length);
66
FREERDP_API void er_write_application_tag(wStream* s, BYTE tag, int length, BOOL flag);
67
FREERDP_API BOOL er_read_application_tag(wStream* s, BYTE tag, int* length);
68
FREERDP_API BOOL er_read_enumerated(wStream* s, BYTE* enumerated, BYTE count);
69
FREERDP_API void er_write_enumerated(wStream* s, BYTE enumerated, BYTE count, BOOL flag);
70
FREERDP_API BOOL er_read_contextual_tag(wStream* s, BYTE tag, int* length, BOOL pc);
71
FREERDP_API int er_write_contextual_tag(wStream* s, BYTE tag, int length, BOOL pc, BOOL flag);
72
FREERDP_API int er_skip_contextual_tag(int length);
73
FREERDP_API BOOL er_read_sequence_tag(wStream* s, int* length);
74
FREERDP_API int er_write_sequence_tag(wStream* s, int length, BOOL flag);
75
FREERDP_API int er_skip_sequence(int length);
76
FREERDP_API int er_skip_sequence_tag(int length);
77
FREERDP_API BOOL er_read_bit_string(wStream* s, int* length, BYTE* padding);
78
FREERDP_API BOOL er_write_bit_string_tag(wStream* s, UINT32 length, BYTE padding, BOOL flag);
79
FREERDP_API BOOL er_read_octet_string(wStream* s, int* length);
80
FREERDP_API void er_write_octet_string(wStream* s, BYTE* oct_str, int length, BOOL flag);
81
FREERDP_API int er_write_octet_string_tag(wStream* s, int length, BOOL flag);
82
FREERDP_API int er_skip_octet_string(int length);
83
FREERDP_API BOOL er_read_BOOL(wStream* s, BOOL* value);
84
FREERDP_API void er_write_BOOL(wStream* s, BOOL value);
85
FREERDP_API BOOL er_read_integer(wStream* s, UINT32* value);
86
FREERDP_API int er_write_integer(wStream* s, INT32 value);
87
FREERDP_API BOOL er_read_integer_length(wStream* s, int* length);
88
FREERDP_API int er_skip_integer(INT32 value);
90
#endif /* FREERDP_CRYPTO_ER_H */