cscg24-guacamole

CSCG 2024 Challenge 'Guacamole Mashup'
git clone https://git.sinitax.com/sinitax/cscg24-guacamole
Log | Files | Refs | sfeed.txt

ber.h (3585B)


      1/**
      2 * FreeRDP: A Remote Desktop Protocol Implementation
      3 * ASN.1 Basic Encoding Rules (BER)
      4 *
      5 * Copyright 2011-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 FREERDP_CRYPTO_BER_H
     21#define FREERDP_CRYPTO_BER_H
     22
     23#include <freerdp/api.h>
     24#include <freerdp/types.h>
     25
     26#include <winpr/stream.h>
     27
     28/* BER type */
     29
     30/* Class - bits 8 and 7 */
     31#define BER_CLASS_MASK 0xC0
     32#define BER_CLASS_UNIV 0x00 /* 0 0 */
     33#define BER_CLASS_APPL 0x40 /* 0 1 */
     34#define BER_CLASS_CTXT 0x80 /* 1 0 */
     35#define BER_CLASS_PRIV 0xC0 /* 1 1 */
     36
     37/* P/C - bit 6 */
     38#define BER_PC_MASK 0x20
     39#define BER_PRIMITIVE 0x00 /* 0 */
     40#define BER_CONSTRUCT 0x20 /* 1 */
     41
     42/* Tag - bits 5 to 1 */
     43#define BER_TAG_MASK 0x1F
     44#define BER_TAG_BOOLEAN 0x01
     45#define BER_TAG_INTEGER 0x02
     46#define BER_TAG_BIT_STRING 0x03
     47#define BER_TAG_OCTET_STRING 0x04
     48#define BER_TAG_OBJECT_IDENFIER 0x06
     49#define BER_TAG_ENUMERATED 0x0A
     50#define BER_TAG_SEQUENCE 0x10
     51#define BER_TAG_SEQUENCE_OF 0x10
     52
     53#define BER_PC(_pc) (_pc ? BER_CONSTRUCT : BER_PRIMITIVE)
     54
     55#ifdef __cplusplus
     56extern "C"
     57{
     58#endif
     59
     60	FREERDP_API BOOL ber_read_length(wStream* s, size_t* length);
     61	FREERDP_API size_t ber_write_length(wStream* s, size_t length);
     62	FREERDP_API size_t _ber_sizeof_length(size_t length);
     63	FREERDP_API BOOL ber_read_universal_tag(wStream* s, BYTE tag, BOOL pc);
     64	FREERDP_API size_t ber_write_universal_tag(wStream* s, BYTE tag, BOOL pc);
     65	FREERDP_API BOOL ber_read_application_tag(wStream* s, BYTE tag, size_t* length);
     66	FREERDP_API void ber_write_application_tag(wStream* s, BYTE tag, size_t length);
     67	FREERDP_API BOOL ber_read_enumerated(wStream* s, BYTE* enumerated, BYTE count);
     68	FREERDP_API void ber_write_enumerated(wStream* s, BYTE enumerated, BYTE count);
     69	FREERDP_API BOOL ber_read_contextual_tag(wStream* s, BYTE tag, size_t* length, BOOL pc);
     70	FREERDP_API size_t ber_write_contextual_tag(wStream* s, BYTE tag, size_t length, BOOL pc);
     71	FREERDP_API size_t ber_sizeof_contextual_tag(size_t length);
     72	FREERDP_API BOOL ber_read_sequence_tag(wStream* s, size_t* length);
     73	FREERDP_API size_t ber_write_sequence_tag(wStream* s, size_t length);
     74	FREERDP_API size_t ber_sizeof_sequence(size_t length);
     75	FREERDP_API size_t ber_sizeof_sequence_tag(size_t length);
     76	FREERDP_API BOOL ber_read_bit_string(wStream* s, size_t* length, BYTE* padding);
     77	FREERDP_API size_t ber_write_octet_string(wStream* s, const BYTE* oct_str, size_t length);
     78	FREERDP_API BOOL ber_read_octet_string_tag(wStream* s, size_t* length);
     79	FREERDP_API size_t ber_write_octet_string_tag(wStream* s, size_t length);
     80	FREERDP_API size_t ber_sizeof_octet_string(size_t length);
     81	FREERDP_API BOOL ber_read_BOOL(wStream* s, BOOL* value);
     82	FREERDP_API void ber_write_BOOL(wStream* s, BOOL value);
     83	FREERDP_API BOOL ber_read_integer(wStream* s, UINT32* value);
     84	FREERDP_API size_t ber_write_integer(wStream* s, UINT32 value);
     85	FREERDP_API BOOL ber_read_integer_length(wStream* s, size_t* length);
     86	FREERDP_API size_t ber_sizeof_integer(UINT32 value);
     87
     88#ifdef __cplusplus
     89}
     90#endif
     91
     92#endif /* FREERDP_CRYPTO_BER_H */