[crypto,er/der] refactor module
* Rename functions with a freerdp_ prefix * Fix function arguments, use size_t * Add CMake option WITH_FREERDP_3x_DEPRECATED
This commit is contained in:
parent
60609251fb
commit
20a27e5caa
@ -156,6 +156,11 @@ if (WITH_FREERDP_DEPRECATED)
|
||||
add_definitions(-DWITH_FREERDP_DEPRECATED)
|
||||
endif()
|
||||
|
||||
option(WITH_FREERDP_3x_DEPRECATED "Build FreeRDP 3x deprecated symbols (stuff deprecated during the 3.x cycle)" ON)
|
||||
if (WITH_FREERDP_3x_DEPRECATED)
|
||||
add_definitions(-DWITH_FREERDP_3x_DEPRECATED)
|
||||
endif()
|
||||
|
||||
option(WITH_FREERDP_DEPRECATED_COMMANDLINE "Build FreeRDP deprecated command line options" OFF)
|
||||
if (WITH_FREERDP_DEPRECATED_COMMANDLINE)
|
||||
add_definitions(-DWITH_FREERDP_DEPRECATED_COMMANDLINE)
|
||||
|
@ -86,11 +86,13 @@ extern "C"
|
||||
WINPR_ATTR_MALLOC(freerdp_client_codecs_free, 1)
|
||||
FREERDP_API rdpCodecs* freerdp_client_codecs_new(UINT32 TheadingFlags);
|
||||
|
||||
#if defined(WITH_FREERDP_3x_DEPRECATED)
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.6.0] Use freerdp_client_codecs_free",
|
||||
void codecs_free(rdpCodecs* codecs));
|
||||
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.6.0] Use freerdp_client_codecs_new",
|
||||
rdpCodecs* codecs_new(rdpContext* context));
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -25,8 +25,432 @@
|
||||
|
||||
#include <winpr/stream.h>
|
||||
|
||||
/**
|
||||
* \defgroup FreeRDP_BER BER read/write functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* BER type */
|
||||
|
||||
/* Class - bits 8 and 7 */
|
||||
#define FREERDP_BER_CLASS_MASK 0xC0 /** @since version 3.9.0 */
|
||||
#define FREERDP_BER_CLASS_UNIV 0x00 /** @since version 3.9.0 */ /* 0 0 */
|
||||
#define FREERDP_BER_CLASS_APPL 0x40 /** @since version 3.9.0 */ /* 0 1 */
|
||||
#define FREERDP_BER_CLASS_CTXT 0x80 /** @since version 3.9.0 */ /* 1 0 */
|
||||
#define FREERDP_BER_CLASS_PRIV 0xC0 /** @since version 3.9.0 */ /* 1 1 */
|
||||
|
||||
/* P/C - bit 6 */
|
||||
#define FREERDP_BER_PC_MASK 0x20 /** @since version 3.9.0 */
|
||||
#define FREERDP_BER_PRIMITIVE 0x00 /** @since version 3.9.0 */ /* 0 */
|
||||
#define FREERDP_BER_CONSTRUCT 0x20 /** @since version 3.9.0 */ /* 1 */
|
||||
|
||||
/* Tag - bits 5 to 1 */
|
||||
#define FREERDP_BER_TAG_MASK 0x1F /** @since version 3.9.0 */
|
||||
#define FREERDP_BER_TAG_BOOLEAN 0x01 /** @since version 3.9.0 */
|
||||
#define FREERDP_BER_TAG_INTEGER 0x02 /** @since version 3.9.0 */
|
||||
#define FREERDP_BER_TAG_BIT_STRING 0x03 /** @since version 3.9.0 */
|
||||
#define FREERDP_BER_TAG_OCTET_STRING 0x04 /** @since version 3.9.0 */
|
||||
#define FREERDP_BER_TAG_OBJECT_IDENFIER 0x06 /** @since version 3.9.0 */
|
||||
#define FREERDP_BER_TAG_ENUMERATED 0x0A /** @since version 3.9.0 */
|
||||
#define FREERDP_BER_TAG_SEQUENCE 0x10 /** @since version 3.9.0 */
|
||||
#define FREERDP_BER_TAG_SEQUENCE_OF 0x10 /** @since version 3.9.0 */
|
||||
|
||||
#define FREERDP_BER_PC(_pc) \
|
||||
(_pc ? FREERDP_BER_CONSTRUCT : FREERDP_BER_PRIMITIVE) /** @since version 3.9.0 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Read BER length.
|
||||
* @param s The stream to read from
|
||||
* @param length A pointer set to the length read
|
||||
* @return \b TRUE for success, \b FALSE for any failure
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_ber_read_length(wStream* s, size_t* length);
|
||||
|
||||
/**
|
||||
* @brief Write BER length.
|
||||
* @param s The stream to write to
|
||||
* @param length The length value to write
|
||||
* @return Number of bytes written
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_ber_write_length(wStream* s, size_t length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_ber_sizeof_length
|
||||
* @param length the length value to write
|
||||
* @return Size of length field
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_ber_sizeof_length(size_t length);
|
||||
|
||||
/**
|
||||
* @brief Read BER Universal tag.
|
||||
* @param s The stream to read from
|
||||
* @param tag BER universally-defined tag
|
||||
* @param pc primitive \b FALSE or constructed \b TRUE
|
||||
* @return \b TRUE for success, \b FALSE for any failure
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_ber_read_universal_tag(wStream* s, BYTE tag, BOOL pc);
|
||||
|
||||
/**
|
||||
* @brief Write BER Universal tag.
|
||||
* @param s The stream to write to
|
||||
* @param tag BER universally-defined tag
|
||||
* @param pc primitive \b FALSE or constructed \b TRUE
|
||||
* @return Number of bytes written
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_ber_write_universal_tag(wStream* s, BYTE tag, BOOL pc);
|
||||
|
||||
/**
|
||||
* @brief Read BER Application tag.
|
||||
* @param s The stream to read from
|
||||
* @param tag BER application-defined tag
|
||||
* @param length A pointer set to the length read
|
||||
* @return \b TRUE for success, \b FALSE for any failure
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_ber_read_application_tag(wStream* s, BYTE tag, size_t* length);
|
||||
|
||||
/**
|
||||
* @brief Write BER Application tag.
|
||||
* @param s The stream to write to
|
||||
* @param tag BER application-defined tag
|
||||
* @param length The length value to write
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API void freerdp_ber_write_application_tag(wStream* s, BYTE tag, size_t length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_ber_read_enumerated
|
||||
* @param s The stream to read from
|
||||
* @param enumerated A pointer set to the enumerated value read
|
||||
* @param count The maximum expected enumerated value
|
||||
* @return \b TRUE for success, \b FALSE for any failure
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_ber_read_enumerated(wStream* s, BYTE* enumerated, BYTE count);
|
||||
|
||||
/**
|
||||
* @brief freerdp_ber_write_enumerated
|
||||
* @param s The stream to write to
|
||||
* @param enumerated The enumerated value to write
|
||||
* @param count The maximum enumerated value expected, must be larger than \b enumerated
|
||||
* @return \b TRUE for success, \b FALSE for any failure
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_ber_write_enumerated(wStream* s, BYTE enumerated, BYTE count);
|
||||
|
||||
/**
|
||||
* @brief freerdp_ber_read_contextual_tag
|
||||
* @param s The stream to read from
|
||||
* @param tag BER contextual-defined tag
|
||||
* @param length A pointer set to the length read
|
||||
* @param pc primitive \b FALSE or constructed \b TRUE
|
||||
* @return \b TRUE for success, \b FALSE for any failure
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_ber_read_contextual_tag(wStream* s, BYTE tag, size_t* length, BOOL pc);
|
||||
|
||||
/**
|
||||
* @brief freerdp_ber_write_contextual_tag
|
||||
* @param s The stream to write to
|
||||
* @param tag BER contextual-defined tag
|
||||
* @param length The length value to write
|
||||
* @param pc primitive \b FALSE or constructed \b TRUE
|
||||
* @return Number of bytes written
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_ber_write_contextual_tag(wStream* s, BYTE tag, size_t length,
|
||||
BOOL pc);
|
||||
|
||||
/**
|
||||
* @brief freerdp_ber_sizeof_contextual_tag
|
||||
* @param length The lenght value to write
|
||||
* @return Number of bytes required
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_ber_sizeof_contextual_tag(size_t length);
|
||||
|
||||
/**
|
||||
* @brief Read BER SEQUENCE tag.
|
||||
* @param s The stream to read from
|
||||
* @param length A pointer set to the length read
|
||||
* @return \b TRUE for success, \b FALSE for any failure
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_ber_read_sequence_tag(wStream* s, size_t* length);
|
||||
|
||||
/**
|
||||
* @brief Write BER SEQUENCE tag.
|
||||
* @param s The stream to write to
|
||||
* @param length The lenght value to write
|
||||
* @return Number of bytes written
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_ber_write_sequence_tag(wStream* s, size_t length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_ber_sizeof_sequence
|
||||
* @param length The length value to write
|
||||
* @return Number of bytes required
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_ber_sizeof_sequence(size_t length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_ber_sizeof_sequence_tag
|
||||
* @param length The length value to write
|
||||
* @return Number of bytes required
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_ber_sizeof_sequence_tag(size_t length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_ber_read_bit_string
|
||||
* @param s The stream to read from
|
||||
* @param length A pointer set to the length read
|
||||
* @param padding A pointer set to the padding value read
|
||||
* @return \b TRUE for success, \b FALSE for any failure
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_ber_read_bit_string(wStream* s, size_t* length, BYTE* padding);
|
||||
|
||||
/**
|
||||
* @brief freerdp_ber_read_octet_string_tag
|
||||
* @param s The stream to read from
|
||||
* @param length A pointer set to the length read
|
||||
* @return \b TRUE for success, \b FALSE for any failure
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_ber_read_octet_string_tag(wStream* s, size_t* length);
|
||||
|
||||
/**
|
||||
* @brief Read a BER OCTET_STRING
|
||||
* @param s The stream to read from
|
||||
* @param content A pointer set to the string read
|
||||
* @param length A pointer set to the length read
|
||||
* @return \b TRUE for success, \b FALSE for any failure
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_ber_read_octet_string(wStream* s, BYTE** content, size_t* length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_ber_write_octet_string_tag
|
||||
* @param s The stream to write to
|
||||
* @param length The length value to write
|
||||
* @return Number of bytes written
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_ber_write_octet_string_tag(wStream* s, size_t length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_ber_sizeof_octet_string
|
||||
* @param length The length value to write
|
||||
* @return Number of bytes required
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_ber_sizeof_octet_string(size_t length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_ber_sizeof_contextual_octet_string
|
||||
* @param length The length of the string
|
||||
* @return Number of bytes required
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_ber_sizeof_contextual_octet_string(size_t length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_ber_write_char_to_unicode_octet_string
|
||||
* @param s The stream to write to
|
||||
* @param str The string to write
|
||||
* @return Number of bytes written
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_ber_write_char_to_unicode_octet_string(wStream* s, const char* str);
|
||||
|
||||
/**
|
||||
* @brief freerdp_ber_write_contextual_char_to_unicode_octet_string
|
||||
* @param s The stream to write to
|
||||
* @param tag BER contextual-defined tag
|
||||
* @param oct_str The string to write
|
||||
* @return Number of bytes written
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_ber_write_contextual_char_to_unicode_octet_string(
|
||||
wStream* s, BYTE tag, const char* oct_str);
|
||||
|
||||
/**
|
||||
* @brief Write a BER OCTET_STRING
|
||||
* @param s The stream to write to
|
||||
* @param oct_str The string to write
|
||||
* @param length The length of the string in bytes
|
||||
* @return Number of bytes written
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_ber_write_octet_string(wStream* s, const BYTE* oct_str,
|
||||
size_t length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_ber_read_char_from_unicode_octet_string
|
||||
* @param s The stream to read from
|
||||
* @param str A pointer to the string read
|
||||
* @return \b TRUE for success, \b FALSE for any failure
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_ber_read_char_from_unicode_octet_string(wStream* s, char** str);
|
||||
|
||||
/**
|
||||
* @brief freerdp_ber_read_unicode_octet_string
|
||||
* @param s The stream to read from
|
||||
* @param str A pointer to the string to read
|
||||
* @return \b TRUE for success, \b FALSE for any failure
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_ber_read_unicode_octet_string(wStream* s, LPWSTR* str);
|
||||
|
||||
/**
|
||||
* @brief freerdp_ber_write_contextual_octet_string
|
||||
* @param s The stream to write to
|
||||
* @param tag BER contextual-defined tag
|
||||
* @param oct_str The string to write
|
||||
* @param length The length of the string in bytes
|
||||
* @return Number of bytes written
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_ber_write_contextual_octet_string(wStream* s, BYTE tag,
|
||||
const BYTE* oct_str,
|
||||
size_t length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_ber_write_contextual_unicode_octet_string
|
||||
* @param s The stream to write to
|
||||
* @param tag BER contextual-defined tag
|
||||
* @param str The string to write
|
||||
* @return Number of bytes written
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_ber_write_contextual_unicode_octet_string(wStream* s, BYTE tag,
|
||||
const WCHAR* str);
|
||||
|
||||
/**
|
||||
* @brief Read a BER BOOLEAN
|
||||
* @param s The stream to read from
|
||||
* @param value A pointer to the value read, must not be NULL
|
||||
* @return \b TRUE for success, \b FALSE for any failure
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_ber_read_BOOL(wStream* s, BOOL* value);
|
||||
|
||||
/**
|
||||
* @brief Write a BER BOOLEAN
|
||||
* @param s The stream to write to
|
||||
* @param value The value to write
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API void freerdp_ber_write_BOOL(wStream* s, BOOL value);
|
||||
|
||||
/**
|
||||
* @brief Read a BER INTEGER
|
||||
* @param s The stream to read from
|
||||
* @return \b TRUE for success, \b FALSE for any failure
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_ber_read_integer(wStream* s, UINT32* value);
|
||||
|
||||
/**
|
||||
* @brief Write a BER INTEGER
|
||||
* @param s The stream to write to
|
||||
* @param value The value to write
|
||||
* @return The size in bytes that were written
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_ber_write_integer(wStream* s, UINT32 value);
|
||||
|
||||
/**
|
||||
* @brief freerdp_ber_write_contextual_integer
|
||||
* @param s The stream to write to
|
||||
* @param tag BER contextual-defined tag
|
||||
* @param value The value to write
|
||||
* @return Number of bytes written
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_ber_write_contextual_integer(wStream* s, BYTE tag, UINT32 value);
|
||||
|
||||
/**
|
||||
* @brief freerdp_ber_read_integer_length
|
||||
* @param s The stream to read from
|
||||
* @param length A pointer set to the length read
|
||||
* @return \b TRUE for success, \b FALSE for any failure
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_ber_read_integer_length(wStream* s, size_t* length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_ber_sizeof_integer
|
||||
* @param value The integer value to write
|
||||
* @return Number of bytes required by \b value
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_ber_sizeof_integer(UINT32 value);
|
||||
|
||||
/**
|
||||
* @brief freerdp_ber_sizeof_contextual_integer
|
||||
* @param value The integer value to write
|
||||
* @return Number of byte written
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_ber_sizeof_contextual_integer(UINT32 value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(WITH_FREERDP_3x_DEPRECATED)
|
||||
/* Class - bits 8 and 7 */
|
||||
#define BER_CLASS_MASK 0xC0
|
||||
#define BER_CLASS_UNIV 0x00 /* 0 0 */
|
||||
@ -57,50 +481,106 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
FREERDP_API BOOL ber_read_length(wStream* s, size_t* length);
|
||||
FREERDP_API size_t ber_write_length(wStream* s, size_t length);
|
||||
FREERDP_API size_t _ber_sizeof_length(size_t length);
|
||||
FREERDP_API BOOL ber_read_universal_tag(wStream* s, BYTE tag, BOOL pc);
|
||||
FREERDP_API size_t ber_write_universal_tag(wStream* s, BYTE tag, BOOL pc);
|
||||
FREERDP_API BOOL ber_read_application_tag(wStream* s, BYTE tag, size_t* length);
|
||||
FREERDP_API void ber_write_application_tag(wStream* s, BYTE tag, size_t length);
|
||||
FREERDP_API BOOL ber_read_enumerated(wStream* s, BYTE* enumerated, BYTE count);
|
||||
FREERDP_API void ber_write_enumerated(wStream* s, BYTE enumerated, BYTE count);
|
||||
FREERDP_API BOOL ber_read_contextual_tag(wStream* s, BYTE tag, size_t* length, BOOL pc);
|
||||
FREERDP_API size_t ber_write_contextual_tag(wStream* s, BYTE tag, size_t length, BOOL pc);
|
||||
FREERDP_API size_t ber_sizeof_contextual_tag(size_t length);
|
||||
FREERDP_API BOOL ber_read_sequence_tag(wStream* s, size_t* length);
|
||||
FREERDP_API size_t ber_write_sequence_tag(wStream* s, size_t length);
|
||||
FREERDP_API size_t ber_sizeof_sequence(size_t length);
|
||||
FREERDP_API size_t ber_sizeof_sequence_tag(size_t length);
|
||||
FREERDP_API BOOL ber_read_bit_string(wStream* s, size_t* length, BYTE* padding);
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_read_length",
|
||||
BOOL ber_read_length(wStream* s, size_t* length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_write_length",
|
||||
size_t ber_write_length(wStream* s, size_t length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_sizeof_length",
|
||||
size_t _ber_sizeof_length(size_t length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_read_universal_tag",
|
||||
BOOL ber_read_universal_tag(wStream* s, BYTE tag, BOOL pc));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_write_universal_tag",
|
||||
size_t ber_write_universal_tag(wStream* s, BYTE tag, BOOL pc));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_read_application_tag",
|
||||
BOOL ber_read_application_tag(wStream* s, BYTE tag,
|
||||
size_t* length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_write_application_tag",
|
||||
void ber_write_application_tag(wStream* s, BYTE tag,
|
||||
size_t length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_read_enumerated",
|
||||
BOOL ber_read_enumerated(wStream* s, BYTE* enumerated,
|
||||
BYTE count));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_write_enumerated",
|
||||
void ber_write_enumerated(wStream* s, BYTE enumerated,
|
||||
BYTE count));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_read_contextual_tag",
|
||||
BOOL ber_read_contextual_tag(wStream* s, BYTE tag,
|
||||
size_t* length, BOOL pc));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_write_contextual_tag",
|
||||
size_t ber_write_contextual_tag(wStream* s, BYTE tag,
|
||||
size_t length, BOOL pc));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_sizeof_contextual_tag",
|
||||
size_t ber_sizeof_contextual_tag(size_t length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_read_sequence_tag",
|
||||
BOOL ber_read_sequence_tag(wStream* s, size_t* length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_write_sequence_tag",
|
||||
size_t ber_write_sequence_tag(wStream* s, size_t length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_sizeof_sequence",
|
||||
size_t ber_sizeof_sequence(size_t length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_sizeof_sequence_tag",
|
||||
size_t ber_sizeof_sequence_tag(size_t length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_read_bit_string",
|
||||
BOOL ber_read_bit_string(wStream* s, size_t* length,
|
||||
BYTE* padding));
|
||||
|
||||
FREERDP_API BOOL ber_read_octet_string_tag(wStream* s, size_t* length);
|
||||
FREERDP_API BOOL ber_read_octet_string(wStream* s, BYTE** content, size_t* length);
|
||||
FREERDP_API size_t ber_write_octet_string_tag(wStream* s, size_t length);
|
||||
FREERDP_API size_t ber_sizeof_octet_string(size_t length);
|
||||
FREERDP_API size_t ber_sizeof_contextual_octet_string(size_t length);
|
||||
FREERDP_API size_t ber_write_char_to_unicode_octet_string(wStream* s, const char* str);
|
||||
FREERDP_API size_t ber_write_contextual_char_to_unicode_octet_string(wStream* s, BYTE tag,
|
||||
const char* oct_str);
|
||||
FREERDP_API size_t ber_write_octet_string(wStream* s, const BYTE* oct_str, size_t length);
|
||||
FREERDP_API BOOL ber_read_char_from_unicode_octet_string(wStream* s, char** str);
|
||||
FREERDP_API BOOL ber_read_unicode_octet_string(wStream* s, LPWSTR* str);
|
||||
FREERDP_API size_t ber_write_contextual_octet_string(wStream* s, BYTE tag, const BYTE* oct_str,
|
||||
size_t length);
|
||||
FREERDP_API size_t ber_write_contextual_unicode_octet_string(wStream* s, BYTE tag, LPWSTR str);
|
||||
|
||||
FREERDP_API BOOL ber_read_BOOL(wStream* s, BOOL* value);
|
||||
FREERDP_API void ber_write_BOOL(wStream* s, BOOL value);
|
||||
FREERDP_API BOOL ber_read_integer(wStream* s, UINT32* value);
|
||||
FREERDP_API size_t ber_write_integer(wStream* s, UINT32 value);
|
||||
FREERDP_API size_t ber_write_contextual_integer(wStream* s, BYTE tag, UINT32 value);
|
||||
FREERDP_API BOOL ber_read_integer_length(wStream* s, size_t* length);
|
||||
FREERDP_API size_t ber_sizeof_integer(UINT32 value);
|
||||
FREERDP_API size_t ber_sizeof_contextual_integer(UINT32 value);
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_read_octet_string_tag",
|
||||
BOOL ber_read_octet_string_tag(wStream* s, size_t* length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_read_octet_string",
|
||||
BOOL ber_read_octet_string(wStream* s, BYTE** content,
|
||||
size_t* length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_write_octet_string_tag",
|
||||
size_t ber_write_octet_string_tag(wStream* s, size_t length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_sizeof_octet_string",
|
||||
size_t ber_sizeof_octet_string(size_t length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_sizeof_contextual_octet_string",
|
||||
size_t ber_sizeof_contextual_octet_string(size_t length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR(
|
||||
"[since 3.9.0] use freerdp_ber_write_char_to_unicode_octet_string",
|
||||
size_t ber_write_char_to_unicode_octet_string(wStream* s, const char* str));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR(
|
||||
"[since 3.9.0] use freerdp_ber_write_contextual_char_to_unicode_octet_string",
|
||||
size_t ber_write_contextual_char_to_unicode_octet_string(wStream* s, BYTE tag,
|
||||
const char* oct_str));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_write_octet_string",
|
||||
size_t ber_write_octet_string(wStream* s, const BYTE* oct_str,
|
||||
size_t length));
|
||||
FREERDP_API
|
||||
WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_read_char_from_unicode_octet_string",
|
||||
BOOL ber_read_char_from_unicode_octet_string(wStream* s, char** str));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_read_unicode_octet_string",
|
||||
BOOL ber_read_unicode_octet_string(wStream* s, LPWSTR* str));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_write_contextual_octet_string",
|
||||
size_t ber_write_contextual_octet_string(wStream* s, BYTE tag,
|
||||
const BYTE* oct_str,
|
||||
size_t length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR(
|
||||
"[since 3.9.0] use freerdp_ber_write_contextual_unicode_octet_string",
|
||||
size_t ber_write_contextual_unicode_octet_string(wStream* s, BYTE tag, const LPWSTR str));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_read_BOOL",
|
||||
BOOL ber_read_BOOL(wStream* s, BOOL* value));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_write_BOOL",
|
||||
void ber_write_BOOL(wStream* s, BOOL value));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_read_integer",
|
||||
BOOL ber_read_integer(wStream* s, UINT32* value));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_write_integer",
|
||||
size_t ber_write_integer(wStream* s, UINT32 value));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_write_contextual_integer",
|
||||
size_t ber_write_contextual_integer(wStream* s, BYTE tag,
|
||||
UINT32 value));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_read_integer_length",
|
||||
BOOL ber_read_integer_length(wStream* s, size_t* length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_sizeof_integer",
|
||||
size_t ber_sizeof_integer(UINT32 value));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_ber_sizeof_contextual_integer",
|
||||
size_t ber_sizeof_contextual_integer(UINT32 value));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* FREERDP_CRYPTO_BER_H */
|
||||
|
@ -22,23 +22,133 @@
|
||||
|
||||
#include <freerdp/crypto/er.h>
|
||||
|
||||
/**
|
||||
* \defgroup FreeRDP_DER DER read/write functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
FREERDP_API int _der_skip_length(int length);
|
||||
FREERDP_API int der_write_length(wStream* s, int length);
|
||||
FREERDP_API int der_get_content_length(int length);
|
||||
FREERDP_API int der_skip_octet_string(int length);
|
||||
FREERDP_API int der_skip_sequence_tag(int length);
|
||||
FREERDP_API int der_write_sequence_tag(wStream* s, int length);
|
||||
FREERDP_API int der_skip_contextual_tag(int length);
|
||||
FREERDP_API int der_write_contextual_tag(wStream* s, BYTE tag, int length, BOOL pc);
|
||||
FREERDP_API void der_write_octet_string(wStream* s, BYTE* oct_str, int length);
|
||||
/**
|
||||
* @brief freerdp_der_skip_length
|
||||
* @param length The length of the sequence in bytes, limited to \b UINT16_MAX
|
||||
* @return Number of bytes skipped
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_der_skip_length(size_t length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_der_write_length
|
||||
* @param s The stream to write to
|
||||
* @param length The length of the sequence in bytes, limited to \b UINT16_MAX
|
||||
* @return Number of bytes written
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_der_write_length(wStream* s, size_t length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_der_get_content_length
|
||||
* @param length The length of the sequence in bytes, limited to \b UINT16_MAX
|
||||
* @return Length of the contents without header bytes
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_der_get_content_length(size_t length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_der_skip_octet_string
|
||||
* @param length The length of the sequence in bytes, limited to \b UINT16_MAX
|
||||
* @return Number of bytes skipped
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_der_skip_octet_string(size_t length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_der_skip_sequence_tag
|
||||
* @param length The length of the sequence in bytes, limited to \b UINT16_MAX
|
||||
* @return The number of bytes skipped.
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_der_skip_sequence_tag(size_t length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_der_write_sequence_tag
|
||||
* @param s The stream to write to.
|
||||
* @param length The length of the sequence in bytes, limited to \b UINT16_MAX
|
||||
* @return The number of bytes written
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_der_write_sequence_tag(wStream* s, size_t length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_der_skip_contextual_tag
|
||||
* @param length The length of the sequence in bytes, limited to \b UINT16_MAX
|
||||
* @return Number of bytes skipped
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_der_skip_contextual_tag(size_t length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_der_write_contextual_tag
|
||||
* @param s The stream to write to
|
||||
* @param tag A tag to write
|
||||
* @param length The length of the sequence in bytes, limited to \b UINT16_MAX
|
||||
* @param pc Switch types, \b TRUE for \b ER_CONSTRUCT else \b ER_PRIMITIVE
|
||||
* @return Number of bytes written
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_der_write_contextual_tag(wStream* s, BYTE tag, size_t length,
|
||||
BOOL pc);
|
||||
|
||||
/**
|
||||
* @brief freerdp_der_write_octet_string
|
||||
* @param s The stream to write to
|
||||
* @param oct_str The string to write
|
||||
* @param length The length of the sequence in bytes, limited to \b UINT16_MAX
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API void freerdp_der_write_octet_string(wStream* s, const BYTE* oct_str, size_t length);
|
||||
|
||||
#if defined(WITH_FREERDP_3x_DEPRECATED)
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_der_skip_length",
|
||||
int _der_skip_length(int length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_der_write_length",
|
||||
int der_write_length(wStream* s, int length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_der_get_content_length",
|
||||
int der_get_content_length(int length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_der_skip_octet_string",
|
||||
int der_skip_octet_string(int length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_der_skip_sequence_tag",
|
||||
int der_skip_sequence_tag(int length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_der_write_sequence_tag",
|
||||
int der_write_sequence_tag(wStream* s, int length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_der_skip_contextual_tag",
|
||||
int der_skip_contextual_tag(int length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_der_write_contextual_tag",
|
||||
int der_write_contextual_tag(wStream* s, BYTE tag, int length,
|
||||
BOOL pc));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_der_write_octet_string",
|
||||
void der_write_octet_string(wStream* s, const BYTE* oct_str,
|
||||
int length));
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* FREERDP_CRYPTO_DER_H */
|
||||
|
@ -21,13 +21,361 @@
|
||||
#ifndef FREERDP_CRYPTO_ER_H
|
||||
#define FREERDP_CRYPTO_ER_H
|
||||
|
||||
#include <winpr/wtypes.h>
|
||||
|
||||
#include <freerdp/api.h>
|
||||
#include <freerdp/types.h>
|
||||
|
||||
#include <winpr/stream.h>
|
||||
|
||||
/**
|
||||
* \defgroup FreeRDP_ER ER read/write functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* ER type */
|
||||
|
||||
/* Class - bits 8 and 7 */
|
||||
#define FREERDP_ER_CLASS_MASK 0xC0 /** @since version 3.9.0 */
|
||||
#define FREERDP_ER_CLASS_UNIV 0x00 /** @since version 3.9.0 */ /* 0 0 */
|
||||
#define FREERDP_ER_CLASS_APPL 0x40 /** @since version 3.9.0 */ /* 0 1 */
|
||||
#define FREERDP_ER_CLASS_CTXT 0x80 /** @since version 3.9.0 */ /* 1 0 */
|
||||
#define FREERDP_ER_CLASS_PRIV 0xC0 /** @since version 3.9.0 */ /* 1 1 */
|
||||
|
||||
/* P/C - bit 6 */
|
||||
#define FREERDP_ER_PC_MASK 0x20 /** @since version 3.9.0 */
|
||||
#define FREERDP_ER_PRIMITIVE 0x00 /** @since version 3.9.0 */ /* 0 */
|
||||
#define FREERDP_ER_CONSTRUCT 0x20 /** @since version 3.9.0 */ /* 1 */
|
||||
|
||||
/* Tag - bits 5 to 1 */
|
||||
#define FREERDP_ER_TAG_MASK 0x1F /** @since version 3.9.0 */
|
||||
#define FREERDP_ER_TAG_BOOLEAN 0x01 /** @since version 3.9.0 */
|
||||
#define FREERDP_ER_TAG_INTEGER 0x02 /** @since version 3.9.0 */
|
||||
#define FREERDP_ER_TAG_BIT_STRING 0x03 /** @since version 3.9.0 */
|
||||
#define FREERDP_ER_TAG_OCTET_STRING 0x04 /** @since version 3.9.0 */
|
||||
#define FREERDP_ER_TAG_OBJECT_IDENTIFIER 0x06 /** @since version 3.9.0 */
|
||||
#define FREERDP_ER_TAG_ENUMERATED 0x0A /** @since version 3.9.0 */
|
||||
#define FREERDP_ER_TAG_SEQUENCE 0x10 /** @since version 3.9.0 */
|
||||
#define FREERDP_ER_TAG_SEQUENCE_OF 0x10 /** @since version 3.9.0 */
|
||||
#define FREERDP_ER_TAG_GENERAL_STRING 0x1B /** @since version 3.9.0 */
|
||||
#define FREERDP_ER_TAG_GENERALIZED_TIME 0x18 /** @since version 3.9.0 */
|
||||
|
||||
#define FREERDP_ER_PC(_pc) \
|
||||
(_pc ? FREERDP_ER_CONSTRUCT : FREERDP_ER_PRIMITIVE) /** @since version 3.9.0 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_read_length
|
||||
* @param s The stream to read from
|
||||
* @param length A pointer receiving the lenght read
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API void freerdp_er_read_length(wStream* s, size_t* length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_write_length
|
||||
* @param s The stream to write to
|
||||
* @param length The length to write
|
||||
* @param flag \b TRUE write DER, \b FALSE write BER
|
||||
* @return The number of bytes written
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_er_write_length(wStream* s, size_t length, BOOL flag);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_skip_length
|
||||
* @param length The value of the length field
|
||||
* @return The number of bytes used by the length field
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_er_skip_length(size_t length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_get_content_length
|
||||
* @param length Extract the contents length form the length of the field including headers
|
||||
* @return The number of bytes used by contents
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_er_get_content_length(size_t length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_read_universal_tag
|
||||
* @param s The stream to read from
|
||||
* @param tag A tag value to write to the header. Range limited by \b FREERDP_ER_TAG_MASK
|
||||
* @param pc Type of tag. See \b FREERDP_ER_PC for details
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_er_read_universal_tag(wStream* s, BYTE tag, BOOL pc);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_write_universal_tag
|
||||
* @param s The stream to write to
|
||||
* @param tag A tag value to write to the header. Range limited by \b FREERDP_ER_TAG_MASK
|
||||
* @param pc Type of tag. See \b FREERDP_ER_PC for details
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API void freerdp_er_write_universal_tag(wStream* s, BYTE tag, BOOL pc);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_read_application_tag
|
||||
* @param s The stream to read from
|
||||
* @param tag A tag value to write to the header. Range limited by \b FREERDP_ER_TAG_MASK
|
||||
* @param length A pointer receiving the length of the field
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_er_read_application_tag(wStream* s, BYTE tag, size_t* length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_write_application_tag
|
||||
* @param s The stream to write to
|
||||
* @param tag A tag value to write to the header. Range limited by \b FREERDP_ER_TAG_MASK
|
||||
* @param length Content length in bytes
|
||||
* @param flag \b TRUE write DER, \b FALSE write BER
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API void freerdp_er_write_application_tag(wStream* s, BYTE tag, size_t length,
|
||||
BOOL flag);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_read_enumerated
|
||||
* @param s The stream to read from
|
||||
* @param enumerated A pointer receiving the enumerated value
|
||||
* @param count The upper bound for expected enumerated values
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_er_read_enumerated(wStream* s, BYTE* enumerated, BYTE count);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_write_enumerated
|
||||
* @param s The stream to write to
|
||||
* @param enumerated The enumerated value to write
|
||||
* @param count \b UNUSED
|
||||
* @param flag \b TRUE write DER, \b FALSE write BER
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API void freerdp_er_write_enumerated(wStream* s, BYTE enumerated, BYTE count,
|
||||
BOOL flag);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_read_contextual_tag
|
||||
* @param s The stream to read from
|
||||
* @param tag A tag value to write to the header. Range limited by \b FREERDP_ER_TAG_MASK
|
||||
* @param length A pointer receiving the length of the field
|
||||
* @param pc Type of tag. See \b FREERDP_ER_PC for details
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_er_read_contextual_tag(wStream* s, BYTE tag, size_t* length, BOOL pc);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_write_contextual_tag
|
||||
* @param s The stream to write to
|
||||
* @param tag A tag value to write to the header. Range limited by \b FREERDP_ER_TAG_MASK
|
||||
* @param length Content length in bytes
|
||||
* @param pc Type of tag. See \b FREERDP_ER_PC for details
|
||||
* @param flag \b TRUE write DER, \b FALSE write BER
|
||||
* @return Number of bytes used by tag
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_er_write_contextual_tag(wStream* s, BYTE tag, size_t length, BOOL pc,
|
||||
BOOL flag);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_skip_contextual_tag
|
||||
* @param length The content length of the tag
|
||||
* @return Number of bytes used by tag
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_er_skip_contextual_tag(size_t length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_read_sequence_tag
|
||||
* @param s The stream to read from
|
||||
* @param length A pointer receiving the length of the field
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_er_read_sequence_tag(wStream* s, size_t* length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_write_sequence_tag
|
||||
* @param s The stream to write to
|
||||
* @param length Content length in bytes
|
||||
* @param flag \b TRUE write DER, \b FALSE write BER
|
||||
* @return Number of bytes written
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_er_write_sequence_tag(wStream* s, size_t length, BOOL flag);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_skip_sequence
|
||||
* @param length The content length of the tag
|
||||
* @return Number of bytes used by sequence and headers
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_er_skip_sequence(size_t length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_skip_sequence_tag
|
||||
* @param length The content length of the tag
|
||||
* @return Number of bytes used by tag
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_er_skip_sequence_tag(size_t length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_read_bit_string
|
||||
* @param s The stream to read from
|
||||
* @param length A pointer receiving the length of the field
|
||||
* @param padding A pointer receiving the value of the padding byte
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_er_read_bit_string(wStream* s, size_t* length, BYTE* padding);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_write_bit_string_tag
|
||||
* @param s The stream to write to
|
||||
* @param length Content length in bytes
|
||||
* @param padding Value of padding byte to write after the field.
|
||||
* @param flag \b TRUE write DER, \b FALSE write BER
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_er_write_bit_string_tag(wStream* s, UINT32 length, BYTE padding,
|
||||
BOOL flag);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_read_octet_string
|
||||
* @param s The stream to read from
|
||||
* @param length A pointer receiving the length of the string
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_er_read_octet_string(wStream* s, size_t* length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_write_octet_string
|
||||
* @param s The stream to write to
|
||||
* @param oct_str A pointer to the string to write
|
||||
* @param length The byte length of the string
|
||||
* @param flag \b TRUE write DER, \b FALSE write BER
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API void freerdp_er_write_octet_string(wStream* s, const BYTE* oct_str, size_t length,
|
||||
BOOL flag);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_write_octet_string_tag
|
||||
* @param s The stream to write to
|
||||
* @param length The length of the string
|
||||
* @param flag \b TRUE write DER, \b FALSE write BER
|
||||
* @return The number of bytes written
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_er_write_octet_string_tag(wStream* s, size_t length, BOOL flag);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_skip_octet_string
|
||||
* @param length The length of the contents
|
||||
* @return The number of bytes to skip including headers
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_er_skip_octet_string(size_t length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_read_BOOL
|
||||
* @param s The stream to read from
|
||||
* @param value A pointer receiving the BOOL value read
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_er_read_BOOL(wStream* s, BOOL* value);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_write_BOOL
|
||||
* @param s The stream to write to
|
||||
* @param value The value to write
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API void freerdp_er_write_BOOL(wStream* s, BOOL value);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_read_integer
|
||||
* @param s The stream to read from
|
||||
* @param value A pointer receiving the integer value read
|
||||
* @return Number of bytes read
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_er_read_integer(wStream* s, INT32* value);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_write_integer
|
||||
* @param s The stream to write to
|
||||
* @param value The integer value to write
|
||||
* @return Number of bytes written
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_er_write_integer(wStream* s, INT32 value);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_read_integer_length
|
||||
* @param s The stream to read from
|
||||
* @param length receives the byte length of the integer and headers
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_er_read_integer_length(wStream* s, size_t* length);
|
||||
|
||||
/**
|
||||
* @brief freerdp_er_skip_integer
|
||||
* @param value The value skip
|
||||
* @return The bytes to skip including the header bytes
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API size_t freerdp_er_skip_integer(INT32 value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(WITH_FREERDP_3x_DEPRECATED)
|
||||
/* Class - bits 8 and 7 */
|
||||
#define ER_CLASS_MASK 0xC0
|
||||
#define ER_CLASS_UNIV 0x00 /* 0 0 */
|
||||
@ -60,38 +408,82 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
FREERDP_API void er_read_length(wStream* s, int* length);
|
||||
FREERDP_API int er_write_length(wStream* s, int length, BOOL flag);
|
||||
FREERDP_API int _er_skip_length(int length);
|
||||
FREERDP_API int er_get_content_length(int length);
|
||||
FREERDP_API BOOL er_read_universal_tag(wStream* s, BYTE tag, BOOL pc);
|
||||
FREERDP_API void er_write_universal_tag(wStream* s, BYTE tag, BOOL pc);
|
||||
FREERDP_API BOOL er_read_application_tag(wStream* s, BYTE tag, int* length);
|
||||
FREERDP_API void er_write_application_tag(wStream* s, BYTE tag, int length, BOOL flag);
|
||||
FREERDP_API BOOL er_read_enumerated(wStream* s, BYTE* enumerated, BYTE count);
|
||||
FREERDP_API void er_write_enumerated(wStream* s, BYTE enumerated, BYTE count, BOOL flag);
|
||||
FREERDP_API BOOL er_read_contextual_tag(wStream* s, BYTE tag, int* length, BOOL pc);
|
||||
FREERDP_API int er_write_contextual_tag(wStream* s, BYTE tag, int length, BOOL pc, BOOL flag);
|
||||
FREERDP_API int er_skip_contextual_tag(int length);
|
||||
FREERDP_API BOOL er_read_sequence_tag(wStream* s, int* length);
|
||||
FREERDP_API int er_write_sequence_tag(wStream* s, int length, BOOL flag);
|
||||
FREERDP_API int er_skip_sequence(int length);
|
||||
FREERDP_API int er_skip_sequence_tag(int length);
|
||||
FREERDP_API BOOL er_read_bit_string(wStream* s, int* length, BYTE* padding);
|
||||
FREERDP_API BOOL er_write_bit_string_tag(wStream* s, UINT32 length, BYTE padding, BOOL flag);
|
||||
FREERDP_API BOOL er_read_octet_string(wStream* s, int* length);
|
||||
FREERDP_API void er_write_octet_string(wStream* s, BYTE* oct_str, int length, BOOL flag);
|
||||
FREERDP_API int er_write_octet_string_tag(wStream* s, int length, BOOL flag);
|
||||
FREERDP_API int er_skip_octet_string(int length);
|
||||
FREERDP_API BOOL er_read_BOOL(wStream* s, BOOL* value);
|
||||
FREERDP_API void er_write_BOOL(wStream* s, BOOL value);
|
||||
FREERDP_API BOOL er_read_integer(wStream* s, UINT32* value);
|
||||
FREERDP_API int er_write_integer(wStream* s, INT32 value);
|
||||
FREERDP_API BOOL er_read_integer_length(wStream* s, int* length);
|
||||
FREERDP_API int er_skip_integer(INT32 value);
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_read_length",
|
||||
void er_read_length(wStream* s, int* length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_write_length",
|
||||
int er_write_length(wStream* s, int length, BOOL flag));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp__er_skip_length",
|
||||
int _er_skip_length(int length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_get_content_length",
|
||||
int er_get_content_length(int length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_read_universal_tag",
|
||||
BOOL er_read_universal_tag(wStream* s, BYTE tag, BOOL pc));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_write_universal_tag",
|
||||
void er_write_universal_tag(wStream* s, BYTE tag, BOOL pc));
|
||||
FREERDP_API
|
||||
WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_read_application_tag",
|
||||
BOOL er_read_application_tag(wStream* s, BYTE tag, int* length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_write_application_tag",
|
||||
void er_write_application_tag(wStream* s, BYTE tag, int length,
|
||||
BOOL flag));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_read_enumerated",
|
||||
BOOL er_read_enumerated(wStream* s, BYTE* enumerated,
|
||||
BYTE count));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_write_enumerated",
|
||||
void er_write_enumerated(wStream* s, BYTE enumerated,
|
||||
BYTE count, BOOL flag));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_read_contextual_tag",
|
||||
BOOL er_read_contextual_tag(wStream* s, BYTE tag, int* length,
|
||||
BOOL pc));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_write_contextual_tag",
|
||||
int er_write_contextual_tag(wStream* s, BYTE tag, int length,
|
||||
BOOL pc, BOOL flag));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_skip_contextual_tag",
|
||||
int er_skip_contextual_tag(int length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_read_sequence_tag",
|
||||
BOOL er_read_sequence_tag(wStream* s, int* length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_write_sequence_tag",
|
||||
int er_write_sequence_tag(wStream* s, int length, BOOL flag));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_skip_sequence",
|
||||
int er_skip_sequence(int length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_skip_sequence_tag",
|
||||
int er_skip_sequence_tag(int length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_read_bit_string",
|
||||
BOOL er_read_bit_string(wStream* s, int* length,
|
||||
BYTE* padding));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_write_bit_string_tag",
|
||||
BOOL er_write_bit_string_tag(wStream* s, UINT32 length,
|
||||
BYTE padding, BOOL flag));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_read_octet_string",
|
||||
BOOL er_read_octet_string(wStream* s, int* length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_write_octet_string",
|
||||
void er_write_octet_string(wStream* s, BYTE* oct_str,
|
||||
int length, BOOL flag));
|
||||
FREERDP_API
|
||||
WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_write_octet_string_tag",
|
||||
int er_write_octet_string_tag(wStream* s, int length, BOOL flag));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_skip_octet_string",
|
||||
int er_skip_octet_string(int length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_read_BOOL",
|
||||
BOOL er_read_BOOL(wStream* s, BOOL* value));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_write_BOOL",
|
||||
void er_write_BOOL(wStream* s, BOOL value));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_read_integer",
|
||||
BOOL er_read_integer(wStream* s, INT32* value));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_write_integer",
|
||||
int er_write_integer(wStream* s, INT32 value));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_read_integer_length",
|
||||
BOOL er_read_integer_length(wStream* s, int* length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_er_skip_integer",
|
||||
int er_skip_integer(INT32 value));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* FREERDP_CRYPTO_ER_H */
|
||||
|
@ -24,39 +24,311 @@
|
||||
|
||||
#include <winpr/stream.h>
|
||||
|
||||
/**
|
||||
* \defgroup FreeRDP_PER PER read/write functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
FREERDP_API BOOL per_read_length(wStream* s, UINT16* length);
|
||||
FREERDP_API BOOL per_write_length(wStream* s, UINT16 length);
|
||||
FREERDP_API BOOL per_read_choice(wStream* s, BYTE* choice);
|
||||
FREERDP_API BOOL per_write_choice(wStream* s, BYTE choice);
|
||||
FREERDP_API BOOL per_read_selection(wStream* s, BYTE* selection);
|
||||
FREERDP_API BOOL per_write_selection(wStream* s, BYTE selection);
|
||||
FREERDP_API BOOL per_read_number_of_sets(wStream* s, BYTE* number);
|
||||
FREERDP_API BOOL per_write_number_of_sets(wStream* s, BYTE number);
|
||||
FREERDP_API BOOL per_read_padding(wStream* s, UINT16 length);
|
||||
FREERDP_API BOOL per_write_padding(wStream* s, UINT16 length);
|
||||
FREERDP_API BOOL per_read_integer(wStream* s, UINT32* integer);
|
||||
FREERDP_API BOOL per_read_integer16(wStream* s, UINT16* integer, UINT16 min);
|
||||
FREERDP_API BOOL per_write_integer(wStream* s, UINT32 integer);
|
||||
FREERDP_API BOOL per_write_integer16(wStream* s, UINT16 integer, UINT16 min);
|
||||
FREERDP_API BOOL per_read_enumerated(wStream* s, BYTE* enumerated, BYTE count);
|
||||
FREERDP_API BOOL per_write_enumerated(wStream* s, BYTE enumerated, BYTE count);
|
||||
FREERDP_API BOOL per_write_object_identifier(wStream* s, const BYTE oid[6]);
|
||||
FREERDP_API BOOL per_read_object_identifier(wStream* s, const BYTE oid[6]);
|
||||
FREERDP_API BOOL per_read_octet_string(wStream* s, const BYTE* oct_str, UINT16 length,
|
||||
UINT16 min);
|
||||
FREERDP_API BOOL per_write_octet_string(wStream* s, const BYTE* oct_str, UINT16 length,
|
||||
UINT16 min);
|
||||
FREERDP_API BOOL per_read_numeric_string(wStream* s, UINT16 min);
|
||||
FREERDP_API BOOL per_write_numeric_string(wStream* s, const BYTE* num_str, UINT16 length,
|
||||
UINT16 min);
|
||||
/**
|
||||
* @brief Read PER length.
|
||||
* @param s The stream to read from
|
||||
* @param length A pointer to return the length read, must not be NULL
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_per_read_length(wStream* s, UINT16* length);
|
||||
|
||||
/**
|
||||
* @brief Write PER length.
|
||||
* @param s The stream to write to
|
||||
* @param length The lenght value to write
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_per_write_length(wStream* s, UINT16 length);
|
||||
|
||||
/**
|
||||
* @brief Read PER CHOICE.
|
||||
* @param s The stream to read from
|
||||
* @param choice A pointer receiving the choice value
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_per_read_choice(wStream* s, BYTE* choice);
|
||||
|
||||
/**
|
||||
* @brief Write PER CHOICE.
|
||||
* @param s The stream to write to
|
||||
* @param choice The choice value to write
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_per_write_choice(wStream* s, BYTE choice);
|
||||
|
||||
/**
|
||||
* @brief Read PER selection for OPTIONAL fields.
|
||||
* @param s The stream to read from
|
||||
* @param selection A pointer receiving the selection value read
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_per_read_selection(wStream* s, BYTE* selection);
|
||||
|
||||
/**
|
||||
* @brief Write PER selection for OPTIONAL fields.
|
||||
* @param s The stream to write to
|
||||
* @param selection The selection value to write
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_per_write_selection(wStream* s, BYTE selection);
|
||||
|
||||
/**
|
||||
* @brief Read PER number of sets for SET OF.
|
||||
* @param s The stream to read from
|
||||
* @param number A pointer receiving the number value read
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_per_read_number_of_sets(wStream* s, BYTE* number);
|
||||
|
||||
/**
|
||||
* @brief Write PER number of sets for SET OF.
|
||||
* @param s The stream to write to
|
||||
* @param number The number value to write
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_per_write_number_of_sets(wStream* s, BYTE number);
|
||||
|
||||
/**
|
||||
* @brief Read PER padding with zeros.
|
||||
* @param s The stream to read from
|
||||
* @param length The length of the padding
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_per_read_padding(wStream* s, UINT16 length);
|
||||
|
||||
/**
|
||||
* @brief Write PER padding with zeros.
|
||||
* @param s The stream to write to
|
||||
* @param length The length of the padding
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_per_write_padding(wStream* s, UINT16 length);
|
||||
|
||||
/**
|
||||
* @brief Read PER INTEGER.
|
||||
* @param s The stream to read from
|
||||
* @param integer The integer result variable pointer, must not be NULL
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_per_read_integer(wStream* s, UINT32* integer);
|
||||
|
||||
/**
|
||||
* @brief Read PER INTEGER (UINT16).
|
||||
* @param s The stream to read from
|
||||
* @param integer The integer result variable pointer, must not be NULL
|
||||
* @param min The smallest value expected, will be added to the value read
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_per_read_integer16(wStream* s, UINT16* integer, UINT16 min);
|
||||
|
||||
/**
|
||||
* @brief Write PER INTEGER.
|
||||
* @param s The stream to write to
|
||||
* @param integer The integer value to write
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_per_write_integer(wStream* s, UINT32 integer);
|
||||
|
||||
/**
|
||||
* @brief Read PER INTEGER(UINT16).
|
||||
* @param s The stream to write to
|
||||
* @param integer The integer value to write
|
||||
* @param min The smallest value supported, will be subtracted from \b integer
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_per_write_integer16(wStream* s, UINT16 integer, UINT16 min);
|
||||
|
||||
/**
|
||||
* @brief Read PER ENUMERATED.
|
||||
* @param s The stream to read from
|
||||
* @param enumerated enumerated result variable, must not be NULL
|
||||
* @param count enumeration count
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_per_read_enumerated(wStream* s, BYTE* enumerated, BYTE count);
|
||||
|
||||
/**
|
||||
* @brief Write PER ENUMERATED.
|
||||
* @param s The stream to write to
|
||||
* @param enumerated enumerated variable
|
||||
* @param count enumeration count
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_per_write_enumerated(wStream* s, BYTE enumerated, BYTE count);
|
||||
|
||||
/**
|
||||
* @brief Write PER OBJECT_IDENTIFIER (OID).
|
||||
* @param s The stream to write to
|
||||
* @param oid object identifier (oid)
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_per_write_object_identifier(wStream* s, const BYTE oid[6]);
|
||||
|
||||
/**
|
||||
* @brief Read PER OBJECT_IDENTIFIER (OID).
|
||||
* @param s The stream to read from
|
||||
* @param oid object identifier (oid)
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_per_read_object_identifier(wStream* s, const BYTE oid[6]);
|
||||
|
||||
/**
|
||||
* @brief Read PER OCTET_STRING.
|
||||
* @param s The stream to read from
|
||||
* @param oct_str octet string
|
||||
* @param length string length
|
||||
* @param min minimum length
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_per_read_octet_string(wStream* s, const BYTE* oct_str, UINT16 length,
|
||||
UINT16 min);
|
||||
|
||||
/**
|
||||
* @brief Write PER OCTET_STRING.
|
||||
* @param s The stream to write to
|
||||
* @param oct_str octet string
|
||||
* @param length string length
|
||||
* @param min minimum string length
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_per_write_octet_string(wStream* s, const BYTE* oct_str, UINT16 length,
|
||||
UINT16 min);
|
||||
|
||||
/**
|
||||
* @brief Read PER NumericString.
|
||||
* @param s The stream to read from
|
||||
* @param min minimum string length
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_per_read_numeric_string(wStream* s, UINT16 min);
|
||||
|
||||
/**
|
||||
* @brief Write PER NumericString.
|
||||
* @param s The stream to write to
|
||||
* @param num_str numeric string
|
||||
* @param length string length
|
||||
* @param min minimum string length
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*
|
||||
* @since version 3.9.0
|
||||
*/
|
||||
FREERDP_API BOOL freerdp_per_write_numeric_string(wStream* s, const BYTE* num_str,
|
||||
UINT16 length, UINT16 min);
|
||||
|
||||
#if defined(WITH_FREERDP_3x_DEPRECATED)
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_per_read_length",
|
||||
BOOL per_read_length(wStream* s, UINT16* length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_per_write_length",
|
||||
BOOL per_write_length(wStream* s, UINT16 length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_per_read_choice",
|
||||
BOOL per_read_choice(wStream* s, BYTE* choice));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_per_write_choice",
|
||||
BOOL per_write_choice(wStream* s, BYTE choice));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_per_read_selection",
|
||||
BOOL per_read_selection(wStream* s, BYTE* selection));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_per_write_selection",
|
||||
BOOL per_write_selection(wStream* s, BYTE selection));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_per_read_number_of_sets",
|
||||
BOOL per_read_number_of_sets(wStream* s, BYTE* number));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_per_write_number_of_sets",
|
||||
BOOL per_write_number_of_sets(wStream* s, BYTE number));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_per_read_padding",
|
||||
BOOL per_read_padding(wStream* s, UINT16 length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_per_write_padding",
|
||||
BOOL per_write_padding(wStream* s, UINT16 length));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_per_read_integer",
|
||||
BOOL per_read_integer(wStream* s, UINT32* integer));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_per_read_integer16",
|
||||
BOOL per_read_integer16(wStream* s, UINT16* integer,
|
||||
UINT16 min));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_per_write_integer",
|
||||
BOOL per_write_integer(wStream* s, UINT32 integer));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_per_write_integer16",
|
||||
BOOL per_write_integer16(wStream* s, UINT16 integer,
|
||||
UINT16 min));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_per_read_enumerated",
|
||||
BOOL per_read_enumerated(wStream* s, BYTE* enumerated,
|
||||
BYTE count));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_per_write_enumerated",
|
||||
BOOL per_write_enumerated(wStream* s, BYTE enumerated,
|
||||
BYTE count));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_per_write_object_identifier",
|
||||
BOOL per_write_object_identifier(wStream* s,
|
||||
const BYTE oid[6]));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_per_read_object_identifier",
|
||||
BOOL per_read_object_identifier(wStream* s,
|
||||
const BYTE oid[6]));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_per_read_octet_string",
|
||||
BOOL per_read_octet_string(wStream* s, const BYTE* oct_str,
|
||||
UINT16 length, UINT16 min));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_per_write_octet_string",
|
||||
BOOL per_write_octet_string(wStream* s, const BYTE* oct_str,
|
||||
UINT16 length, UINT16 min));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_per_read_numeric_string",
|
||||
BOOL per_read_numeric_string(wStream* s, UINT16 min));
|
||||
FREERDP_API WINPR_DEPRECATED_VAR("[since 3.9.0] use freerdp_per_write_numeric_string",
|
||||
BOOL per_write_numeric_string(wStream* s, const BYTE* num_str,
|
||||
UINT16 length, UINT16 min));
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* FREERDP_CRYPTO_PER_H */
|
||||
|
@ -86,11 +86,13 @@ extern "C"
|
||||
size_t InterceptCount;
|
||||
|
||||
/* clipboard specific settings */
|
||||
#if defined(WITH_FREERDP_3x_DEPRECATED)
|
||||
WINPR_DEPRECATED_VAR("[since 3.6.0] Unused, ignore", BOOL TextOnly);
|
||||
WINPR_DEPRECATED_VAR("[since 3.6.0] Unused, ignore", UINT32 MaxTextLength);
|
||||
|
||||
/* gfx settings */
|
||||
WINPR_DEPRECATED_VAR("[since 3.6.0] Unused, ignore", BOOL DecodeGFX);
|
||||
#endif
|
||||
|
||||
/* modules */
|
||||
char** Modules; /* module file names to load */
|
||||
|
@ -302,11 +302,13 @@ extern "C"
|
||||
FREERDP_API void shadow_subsystem_set_entry_builtin(const char* name);
|
||||
FREERDP_API void shadow_subsystem_set_entry(pfnShadowSubsystemEntry pEntry);
|
||||
|
||||
#if defined(WITH_FREERDP_3x_DEPRECATED)
|
||||
FREERDP_API WINPR_DEPRECATED_VAR(
|
||||
"[since 3.4.0] Use shadow_subsystem_pointer_convert_alpha_pointer_data_to_format instead",
|
||||
int shadow_subsystem_pointer_convert_alpha_pointer_data(
|
||||
const BYTE* WINPR_RESTRICT pixels, BOOL premultiplied, UINT32 width, UINT32 height,
|
||||
SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE* WINPR_RESTRICT pointerColor));
|
||||
#endif
|
||||
|
||||
/** @brief Convert a pointer image from input format to RDP specific encoding
|
||||
*
|
||||
@ -346,11 +348,13 @@ extern "C"
|
||||
|
||||
FREERDP_API int shadow_capture_align_clip_rect(RECTANGLE_16* rect, const RECTANGLE_16* clip);
|
||||
|
||||
#if defined(WITH_FREERDP_3x_DEPRECATED)
|
||||
FREERDP_API WINPR_DEPRECATED_VAR(
|
||||
"[since 3.4.0] Use shadow_capture_compare_with_format",
|
||||
int shadow_capture_compare(const BYTE* WINPR_RESTRICT pData1, UINT32 nStep1, UINT32 nWidth,
|
||||
UINT32 nHeight, const BYTE* WINPR_RESTRICT pData2, UINT32 nStep2,
|
||||
RECTANGLE_16* WINPR_RESTRICT rect));
|
||||
#endif
|
||||
|
||||
/** @brief Compare two framebuffer images of possibly different formats with each other
|
||||
*
|
||||
|
@ -239,6 +239,7 @@ BOOL freerdp_client_codecs_reset(rdpCodecs* codecs, UINT32 flags, UINT32 width,
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if defined(WITH_FREERDP_3x_DEPRECATED)
|
||||
rdpCodecs* codecs_new(rdpContext* context)
|
||||
{
|
||||
if (!context || !context->settings)
|
||||
@ -252,6 +253,7 @@ void codecs_free(rdpCodecs* codecs)
|
||||
{
|
||||
freerdp_client_codecs_free(codecs);
|
||||
}
|
||||
#endif
|
||||
|
||||
rdpCodecs* freerdp_client_codecs_new(UINT32 ThreadingFlags)
|
||||
{
|
||||
|
@ -230,7 +230,7 @@ BOOL fastpath_read_header_rdp(rdpFastPath* fastpath, wStream* s, UINT16* length)
|
||||
fastpath->numberEvents = (header & 0x3C) >> 2;
|
||||
}
|
||||
|
||||
if (!per_read_length(s, length))
|
||||
if (!freerdp_per_read_length(s, length))
|
||||
return FALSE;
|
||||
|
||||
const size_t pos = Stream_GetPosition(s);
|
||||
|
@ -366,45 +366,45 @@ BOOL gcc_read_conference_create_request(wStream* s, rdpMcs* mcs)
|
||||
WINPR_ASSERT(s);
|
||||
WINPR_ASSERT(mcs);
|
||||
/* ConnectData */
|
||||
if (!per_read_choice(s, &choice))
|
||||
if (!freerdp_per_read_choice(s, &choice))
|
||||
return FALSE;
|
||||
|
||||
if (!per_read_object_identifier(s, t124_02_98_oid))
|
||||
if (!freerdp_per_read_object_identifier(s, t124_02_98_oid))
|
||||
return FALSE;
|
||||
|
||||
/* ConnectData::connectPDU (OCTET_STRING) */
|
||||
if (!per_read_length(s, &length))
|
||||
if (!freerdp_per_read_length(s, &length))
|
||||
return FALSE;
|
||||
|
||||
/* ConnectGCCPDU */
|
||||
if (!per_read_choice(s, &choice))
|
||||
if (!freerdp_per_read_choice(s, &choice))
|
||||
return FALSE;
|
||||
|
||||
if (!per_read_selection(s, &selection))
|
||||
if (!freerdp_per_read_selection(s, &selection))
|
||||
return FALSE;
|
||||
|
||||
/* ConferenceCreateRequest::conferenceName */
|
||||
if (!per_read_numeric_string(s, 1)) /* ConferenceName::numeric */
|
||||
if (!freerdp_per_read_numeric_string(s, 1)) /* ConferenceName::numeric */
|
||||
return FALSE;
|
||||
|
||||
if (!per_read_padding(s, 1)) /* padding */
|
||||
if (!freerdp_per_read_padding(s, 1)) /* padding */
|
||||
return FALSE;
|
||||
|
||||
/* UserData (SET OF SEQUENCE) */
|
||||
if (!per_read_number_of_sets(s, &number) || number != 1) /* one set of UserData */
|
||||
if (!freerdp_per_read_number_of_sets(s, &number) || number != 1) /* one set of UserData */
|
||||
return FALSE;
|
||||
|
||||
if (!per_read_choice(s, &choice) ||
|
||||
if (!freerdp_per_read_choice(s, &choice) ||
|
||||
choice != 0xC0) /* UserData::value present + select h221NonStandard (1) */
|
||||
return FALSE;
|
||||
|
||||
/* h221NonStandard */
|
||||
if (!per_read_octet_string(s, h221_cs_key, 4,
|
||||
4)) /* h221NonStandard, client-to-server H.221 key, "Duca" */
|
||||
if (!freerdp_per_read_octet_string(s, h221_cs_key, 4,
|
||||
4)) /* h221NonStandard, client-to-server H.221 key, "Duca" */
|
||||
return FALSE;
|
||||
|
||||
/* userData::value (OCTET_STRING) */
|
||||
if (!per_read_length(s, &length))
|
||||
if (!freerdp_per_read_length(s, &length))
|
||||
return FALSE;
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, length))
|
||||
@ -431,36 +431,39 @@ BOOL gcc_write_conference_create_request(wStream* s, wStream* userData)
|
||||
WINPR_ASSERT(s);
|
||||
WINPR_ASSERT(userData);
|
||||
/* ConnectData */
|
||||
if (!per_write_choice(s, 0)) /* From Key select object (0) of type OBJECT_IDENTIFIER */
|
||||
if (!freerdp_per_write_choice(s, 0)) /* From Key select object (0) of type OBJECT_IDENTIFIER */
|
||||
return FALSE;
|
||||
if (!per_write_object_identifier(s, t124_02_98_oid)) /* ITU-T T.124 (02/98) OBJECT_IDENTIFIER */
|
||||
if (!freerdp_per_write_object_identifier(
|
||||
s, t124_02_98_oid)) /* ITU-T T.124 (02/98) OBJECT_IDENTIFIER */
|
||||
return FALSE;
|
||||
/* ConnectData::connectPDU (OCTET_STRING) */
|
||||
if (!per_write_length(s, Stream_GetPosition(userData) + 14)) /* connectPDU length */
|
||||
if (!freerdp_per_write_length(s, Stream_GetPosition(userData) + 14)) /* connectPDU length */
|
||||
return FALSE;
|
||||
/* ConnectGCCPDU */
|
||||
if (!per_write_choice(s, 0)) /* From ConnectGCCPDU select conferenceCreateRequest (0) of type
|
||||
ConferenceCreateRequest */
|
||||
if (!freerdp_per_write_choice(s, 0)) /* From ConnectGCCPDU select conferenceCreateRequest (0) of
|
||||
type ConferenceCreateRequest */
|
||||
return FALSE;
|
||||
if (!per_write_selection(s, 0x08)) /* select optional userData from ConferenceCreateRequest */
|
||||
if (!freerdp_per_write_selection(
|
||||
s, 0x08)) /* select optional userData from ConferenceCreateRequest */
|
||||
return FALSE;
|
||||
/* ConferenceCreateRequest::conferenceName */
|
||||
if (!per_write_numeric_string(s, (BYTE*)"1", 1, 1)) /* ConferenceName::numeric */
|
||||
if (!freerdp_per_write_numeric_string(s, (BYTE*)"1", 1, 1)) /* ConferenceName::numeric */
|
||||
return FALSE;
|
||||
if (!per_write_padding(s, 1)) /* padding */
|
||||
if (!freerdp_per_write_padding(s, 1)) /* padding */
|
||||
return FALSE;
|
||||
/* UserData (SET OF SEQUENCE) */
|
||||
if (!per_write_number_of_sets(s, 1)) /* one set of UserData */
|
||||
if (!freerdp_per_write_number_of_sets(s, 1)) /* one set of UserData */
|
||||
return FALSE;
|
||||
if (!per_write_choice(s, 0xC0)) /* UserData::value present + select h221NonStandard (1) */
|
||||
if (!freerdp_per_write_choice(s,
|
||||
0xC0)) /* UserData::value present + select h221NonStandard (1) */
|
||||
return FALSE;
|
||||
/* h221NonStandard */
|
||||
if (!per_write_octet_string(s, h221_cs_key, 4,
|
||||
4)) /* h221NonStandard, client-to-server H.221 key, "Duca" */
|
||||
if (!freerdp_per_write_octet_string(
|
||||
s, h221_cs_key, 4, 4)) /* h221NonStandard, client-to-server H.221 key, "Duca" */
|
||||
return FALSE;
|
||||
/* userData::value (OCTET_STRING) */
|
||||
return per_write_octet_string(s, Stream_Buffer(userData), Stream_GetPosition(userData),
|
||||
0); /* array of client data blocks */
|
||||
return freerdp_per_write_octet_string(s, Stream_Buffer(userData), Stream_GetPosition(userData),
|
||||
0); /* array of client data blocks */
|
||||
}
|
||||
|
||||
BOOL gcc_read_conference_create_response(wStream* s, rdpMcs* mcs)
|
||||
@ -474,44 +477,45 @@ BOOL gcc_read_conference_create_response(wStream* s, rdpMcs* mcs)
|
||||
WINPR_ASSERT(s);
|
||||
WINPR_ASSERT(mcs);
|
||||
/* ConnectData */
|
||||
if (!per_read_choice(s, &choice) || !per_read_object_identifier(s, t124_02_98_oid))
|
||||
if (!freerdp_per_read_choice(s, &choice) ||
|
||||
!freerdp_per_read_object_identifier(s, t124_02_98_oid))
|
||||
return FALSE;
|
||||
|
||||
/* ConnectData::connectPDU (OCTET_STRING) */
|
||||
if (!per_read_length(s, &length))
|
||||
if (!freerdp_per_read_length(s, &length))
|
||||
return FALSE;
|
||||
|
||||
/* ConnectGCCPDU */
|
||||
if (!per_read_choice(s, &choice))
|
||||
if (!freerdp_per_read_choice(s, &choice))
|
||||
return FALSE;
|
||||
|
||||
/* ConferenceCreateResponse::nodeID (UserID) */
|
||||
if (!per_read_integer16(s, &nodeID, 1001))
|
||||
if (!freerdp_per_read_integer16(s, &nodeID, 1001))
|
||||
return FALSE;
|
||||
|
||||
/* ConferenceCreateResponse::tag (INTEGER) */
|
||||
if (!per_read_integer(s, &tag))
|
||||
if (!freerdp_per_read_integer(s, &tag))
|
||||
return FALSE;
|
||||
|
||||
/* ConferenceCreateResponse::result (ENUMERATED) */
|
||||
if (!per_read_enumerated(s, &result, MCS_Result_enum_length))
|
||||
if (!freerdp_per_read_enumerated(s, &result, MCS_Result_enum_length))
|
||||
return FALSE;
|
||||
|
||||
/* number of UserData sets */
|
||||
if (!per_read_number_of_sets(s, &number))
|
||||
if (!freerdp_per_read_number_of_sets(s, &number))
|
||||
return FALSE;
|
||||
|
||||
/* UserData::value present + select h221NonStandard (1) */
|
||||
if (!per_read_choice(s, &choice))
|
||||
if (!freerdp_per_read_choice(s, &choice))
|
||||
return FALSE;
|
||||
|
||||
/* h221NonStandard */
|
||||
if (!per_read_octet_string(s, h221_sc_key, 4,
|
||||
4)) /* h221NonStandard, server-to-client H.221 key, "McDn" */
|
||||
if (!freerdp_per_read_octet_string(s, h221_sc_key, 4,
|
||||
4)) /* h221NonStandard, server-to-client H.221 key, "McDn" */
|
||||
return FALSE;
|
||||
|
||||
/* userData (OCTET_STRING) */
|
||||
if (!per_read_length(s, &length))
|
||||
if (!freerdp_per_read_length(s, &length))
|
||||
return FALSE;
|
||||
|
||||
if (!gcc_read_server_data_blocks(s, mcs, length))
|
||||
@ -528,39 +532,39 @@ BOOL gcc_write_conference_create_response(wStream* s, wStream* userData)
|
||||
WINPR_ASSERT(s);
|
||||
WINPR_ASSERT(userData);
|
||||
/* ConnectData */
|
||||
if (!per_write_choice(s, 0))
|
||||
if (!freerdp_per_write_choice(s, 0))
|
||||
return FALSE;
|
||||
if (!per_write_object_identifier(s, t124_02_98_oid))
|
||||
if (!freerdp_per_write_object_identifier(s, t124_02_98_oid))
|
||||
return FALSE;
|
||||
/* ConnectData::connectPDU (OCTET_STRING) */
|
||||
/* This length MUST be ignored by the client according to [MS-RDPBCGR] */
|
||||
if (!per_write_length(s, 0x2A))
|
||||
if (!freerdp_per_write_length(s, 0x2A))
|
||||
return FALSE;
|
||||
/* ConnectGCCPDU */
|
||||
if (!per_write_choice(s, 0x14))
|
||||
if (!freerdp_per_write_choice(s, 0x14))
|
||||
return FALSE;
|
||||
/* ConferenceCreateResponse::nodeID (UserID) */
|
||||
if (!per_write_integer16(s, 0x79F3, 1001))
|
||||
if (!freerdp_per_write_integer16(s, 0x79F3, 1001))
|
||||
return FALSE;
|
||||
/* ConferenceCreateResponse::tag (INTEGER) */
|
||||
if (!per_write_integer(s, 1))
|
||||
if (!freerdp_per_write_integer(s, 1))
|
||||
return FALSE;
|
||||
/* ConferenceCreateResponse::result (ENUMERATED) */
|
||||
if (!per_write_enumerated(s, 0, MCS_Result_enum_length))
|
||||
if (!freerdp_per_write_enumerated(s, 0, MCS_Result_enum_length))
|
||||
return FALSE;
|
||||
/* number of UserData sets */
|
||||
if (!per_write_number_of_sets(s, 1))
|
||||
if (!freerdp_per_write_number_of_sets(s, 1))
|
||||
return FALSE;
|
||||
/* UserData::value present + select h221NonStandard (1) */
|
||||
if (!per_write_choice(s, 0xC0))
|
||||
if (!freerdp_per_write_choice(s, 0xC0))
|
||||
return FALSE;
|
||||
/* h221NonStandard */
|
||||
if (!per_write_octet_string(s, h221_sc_key, 4,
|
||||
4)) /* h221NonStandard, server-to-client H.221 key, "McDn" */
|
||||
if (!freerdp_per_write_octet_string(
|
||||
s, h221_sc_key, 4, 4)) /* h221NonStandard, server-to-client H.221 key, "McDn" */
|
||||
return FALSE;
|
||||
/* userData (OCTET_STRING) */
|
||||
return per_write_octet_string(s, Stream_Buffer(userData), Stream_GetPosition(userData),
|
||||
0); /* array of server data blocks */
|
||||
return freerdp_per_write_octet_string(s, Stream_Buffer(userData), Stream_GetPosition(userData),
|
||||
0); /* array of server data blocks */
|
||||
}
|
||||
|
||||
static BOOL gcc_read_client_unused1_data(wStream* s)
|
||||
|
@ -351,7 +351,7 @@ BOOL mcs_read_domain_mcspdu_header(wStream* s, DomainMCSPDU domainMCSPDU, UINT16
|
||||
if (!tpdu_read_data(s, &li, *length))
|
||||
return FALSE;
|
||||
|
||||
if (!per_read_choice(s, &choice))
|
||||
if (!freerdp_per_read_choice(s, &choice))
|
||||
return FALSE;
|
||||
|
||||
const DomainMCSPDU MCSPDU = (choice >> 2);
|
||||
@ -386,7 +386,7 @@ BOOL mcs_write_domain_mcspdu_header(wStream* s, DomainMCSPDU domainMCSPDU, UINT1
|
||||
return FALSE;
|
||||
if (!tpdu_write_data(s))
|
||||
return FALSE;
|
||||
return per_write_choice(s, (BYTE)((domainMCSPDU << 2) | options));
|
||||
return freerdp_per_write_choice(s, (BYTE)((domainMCSPDU << 2) | options));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -428,15 +428,15 @@ static BOOL mcs_read_domain_parameters(wStream* s, DomainParameters* domainParam
|
||||
if (!s || !domainParameters)
|
||||
return FALSE;
|
||||
|
||||
return ber_read_sequence_tag(s, &length) &&
|
||||
ber_read_integer(s, &(domainParameters->maxChannelIds)) &&
|
||||
ber_read_integer(s, &(domainParameters->maxUserIds)) &&
|
||||
ber_read_integer(s, &(domainParameters->maxTokenIds)) &&
|
||||
ber_read_integer(s, &(domainParameters->numPriorities)) &&
|
||||
ber_read_integer(s, &(domainParameters->minThroughput)) &&
|
||||
ber_read_integer(s, &(domainParameters->maxHeight)) &&
|
||||
ber_read_integer(s, &(domainParameters->maxMCSPDUsize)) &&
|
||||
ber_read_integer(s, &(domainParameters->protocolVersion));
|
||||
return freerdp_ber_read_sequence_tag(s, &length) &&
|
||||
freerdp_ber_read_integer(s, &(domainParameters->maxChannelIds)) &&
|
||||
freerdp_ber_read_integer(s, &(domainParameters->maxUserIds)) &&
|
||||
freerdp_ber_read_integer(s, &(domainParameters->maxTokenIds)) &&
|
||||
freerdp_ber_read_integer(s, &(domainParameters->numPriorities)) &&
|
||||
freerdp_ber_read_integer(s, &(domainParameters->minThroughput)) &&
|
||||
freerdp_ber_read_integer(s, &(domainParameters->maxHeight)) &&
|
||||
freerdp_ber_read_integer(s, &(domainParameters->maxMCSPDUsize)) &&
|
||||
freerdp_ber_read_integer(s, &(domainParameters->protocolVersion));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -461,16 +461,16 @@ static BOOL mcs_write_domain_parameters(wStream* s, DomainParameters* domainPara
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ber_write_integer(tmps, domainParameters->maxChannelIds);
|
||||
ber_write_integer(tmps, domainParameters->maxUserIds);
|
||||
ber_write_integer(tmps, domainParameters->maxTokenIds);
|
||||
ber_write_integer(tmps, domainParameters->numPriorities);
|
||||
ber_write_integer(tmps, domainParameters->minThroughput);
|
||||
ber_write_integer(tmps, domainParameters->maxHeight);
|
||||
ber_write_integer(tmps, domainParameters->maxMCSPDUsize);
|
||||
ber_write_integer(tmps, domainParameters->protocolVersion);
|
||||
freerdp_ber_write_integer(tmps, domainParameters->maxChannelIds);
|
||||
freerdp_ber_write_integer(tmps, domainParameters->maxUserIds);
|
||||
freerdp_ber_write_integer(tmps, domainParameters->maxTokenIds);
|
||||
freerdp_ber_write_integer(tmps, domainParameters->numPriorities);
|
||||
freerdp_ber_write_integer(tmps, domainParameters->minThroughput);
|
||||
freerdp_ber_write_integer(tmps, domainParameters->maxHeight);
|
||||
freerdp_ber_write_integer(tmps, domainParameters->maxMCSPDUsize);
|
||||
freerdp_ber_write_integer(tmps, domainParameters->protocolVersion);
|
||||
length = Stream_GetPosition(tmps);
|
||||
ber_write_sequence_tag(s, length);
|
||||
freerdp_ber_write_sequence_tag(s, length);
|
||||
Stream_Write(s, Stream_Buffer(tmps), length);
|
||||
Stream_Free(tmps, TRUE);
|
||||
return TRUE;
|
||||
@ -660,25 +660,25 @@ BOOL mcs_recv_connect_initial(rdpMcs* mcs, wStream* s)
|
||||
if (!tpdu_read_data(s, &li, tlength))
|
||||
return FALSE;
|
||||
|
||||
if (!ber_read_application_tag(s, MCS_TYPE_CONNECT_INITIAL, &length))
|
||||
if (!freerdp_ber_read_application_tag(s, MCS_TYPE_CONNECT_INITIAL, &length))
|
||||
return FALSE;
|
||||
|
||||
/* callingDomainSelector (OCTET_STRING) */
|
||||
if (!ber_read_octet_string_tag(s, &length) ||
|
||||
if (!freerdp_ber_read_octet_string_tag(s, &length) ||
|
||||
(!Stream_CheckAndLogRequiredLength(TAG, s, length)))
|
||||
return FALSE;
|
||||
|
||||
Stream_Seek(s, length);
|
||||
|
||||
/* calledDomainSelector (OCTET_STRING) */
|
||||
if (!ber_read_octet_string_tag(s, &length) ||
|
||||
if (!freerdp_ber_read_octet_string_tag(s, &length) ||
|
||||
(!Stream_CheckAndLogRequiredLength(TAG, s, length)))
|
||||
return FALSE;
|
||||
|
||||
Stream_Seek(s, length);
|
||||
|
||||
/* upwardFlag (BOOLEAN) */
|
||||
if (!ber_read_BOOL(s, &upwardFlag))
|
||||
if (!freerdp_ber_read_BOOL(s, &upwardFlag))
|
||||
return FALSE;
|
||||
|
||||
/* targetParameters (DomainParameters) */
|
||||
@ -693,7 +693,7 @@ BOOL mcs_recv_connect_initial(rdpMcs* mcs, wStream* s)
|
||||
if (!mcs_read_domain_parameters(s, &mcs->maximumParameters))
|
||||
return FALSE;
|
||||
|
||||
if (!ber_read_octet_string_tag(s, &length) ||
|
||||
if (!freerdp_ber_read_octet_string_tag(s, &length) ||
|
||||
(!Stream_CheckAndLogRequiredLength(TAG, s, length)))
|
||||
return FALSE;
|
||||
|
||||
@ -733,11 +733,11 @@ BOOL mcs_write_connect_initial(wStream* s, rdpMcs* mcs, wStream* userData)
|
||||
}
|
||||
|
||||
/* callingDomainSelector (OCTET_STRING) */
|
||||
ber_write_octet_string(tmps, callingDomainSelector, sizeof(callingDomainSelector));
|
||||
freerdp_ber_write_octet_string(tmps, callingDomainSelector, sizeof(callingDomainSelector));
|
||||
/* calledDomainSelector (OCTET_STRING) */
|
||||
ber_write_octet_string(tmps, calledDomainSelector, sizeof(calledDomainSelector));
|
||||
freerdp_ber_write_octet_string(tmps, calledDomainSelector, sizeof(calledDomainSelector));
|
||||
/* upwardFlag (BOOLEAN) */
|
||||
ber_write_BOOL(tmps, TRUE);
|
||||
freerdp_ber_write_BOOL(tmps, TRUE);
|
||||
|
||||
/* targetParameters (DomainParameters) */
|
||||
if (!mcs_write_domain_parameters(tmps, &mcs->targetParameters))
|
||||
@ -752,10 +752,10 @@ BOOL mcs_write_connect_initial(wStream* s, rdpMcs* mcs, wStream* userData)
|
||||
goto out;
|
||||
|
||||
/* userData (OCTET_STRING) */
|
||||
ber_write_octet_string(tmps, Stream_Buffer(userData), Stream_GetPosition(userData));
|
||||
freerdp_ber_write_octet_string(tmps, Stream_Buffer(userData), Stream_GetPosition(userData));
|
||||
length = Stream_GetPosition(tmps);
|
||||
/* Connect-Initial (APPLICATION 101, IMPLICIT SEQUENCE) */
|
||||
ber_write_application_tag(s, MCS_TYPE_CONNECT_INITIAL, length);
|
||||
freerdp_ber_write_application_tag(s, MCS_TYPE_CONNECT_INITIAL, length);
|
||||
Stream_Write(s, Stream_Buffer(tmps), length);
|
||||
ret = TRUE;
|
||||
out:
|
||||
@ -790,16 +790,16 @@ BOOL mcs_write_connect_response(wStream* s, rdpMcs* mcs, wStream* userData)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ber_write_enumerated(tmps, 0, MCS_Result_enum_length);
|
||||
ber_write_integer(tmps, 0); /* calledConnectId */
|
||||
freerdp_ber_write_enumerated(tmps, 0, MCS_Result_enum_length);
|
||||
freerdp_ber_write_integer(tmps, 0); /* calledConnectId */
|
||||
|
||||
if (!mcs_write_domain_parameters(tmps, &(mcs->domainParameters)))
|
||||
goto out;
|
||||
|
||||
/* userData (OCTET_STRING) */
|
||||
ber_write_octet_string(tmps, Stream_Buffer(userData), Stream_GetPosition(userData));
|
||||
freerdp_ber_write_octet_string(tmps, Stream_Buffer(userData), Stream_GetPosition(userData));
|
||||
length = Stream_GetPosition(tmps);
|
||||
ber_write_application_tag(s, MCS_TYPE_CONNECT_RESPONSE, length);
|
||||
freerdp_ber_write_application_tag(s, MCS_TYPE_CONNECT_RESPONSE, length);
|
||||
Stream_Write(s, Stream_Buffer(tmps), length);
|
||||
ret = TRUE;
|
||||
out:
|
||||
@ -911,11 +911,11 @@ BOOL mcs_recv_connect_response(rdpMcs* mcs, wStream* s)
|
||||
if (!tpdu_read_data(s, &li, tlength))
|
||||
return FALSE;
|
||||
|
||||
if (!ber_read_application_tag(s, MCS_TYPE_CONNECT_RESPONSE, &length) ||
|
||||
!ber_read_enumerated(s, &result, MCS_Result_enum_length) ||
|
||||
!ber_read_integer(s, &calledConnectId) ||
|
||||
if (!freerdp_ber_read_application_tag(s, MCS_TYPE_CONNECT_RESPONSE, &length) ||
|
||||
!freerdp_ber_read_enumerated(s, &result, MCS_Result_enum_length) ||
|
||||
!freerdp_ber_read_integer(s, &calledConnectId) ||
|
||||
!mcs_read_domain_parameters(s, &(mcs->domainParameters)) ||
|
||||
!ber_read_octet_string_tag(s, &length))
|
||||
!freerdp_ber_read_octet_string_tag(s, &length))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@ -1022,10 +1022,10 @@ BOOL mcs_recv_erect_domain_request(rdpMcs* mcs, wStream* s)
|
||||
if (!mcs_read_domain_mcspdu_header(s, DomainMCSPDU_ErectDomainRequest, &length, NULL))
|
||||
return FALSE;
|
||||
|
||||
if (!per_read_integer(s, &subHeight)) /* subHeight (INTEGER) */
|
||||
if (!freerdp_per_read_integer(s, &subHeight)) /* subHeight (INTEGER) */
|
||||
return FALSE;
|
||||
|
||||
if (!per_read_integer(s, &subInterval)) /* subInterval (INTEGER) */
|
||||
if (!freerdp_per_read_integer(s, &subInterval)) /* subInterval (INTEGER) */
|
||||
return FALSE;
|
||||
|
||||
return tpkt_ensure_stream_consumed(s, length);
|
||||
@ -1055,8 +1055,8 @@ BOOL mcs_send_erect_domain_request(rdpMcs* mcs)
|
||||
}
|
||||
|
||||
mcs_write_domain_mcspdu_header(s, DomainMCSPDU_ErectDomainRequest, length, 0);
|
||||
per_write_integer(s, 0); /* subHeight (INTEGER) */
|
||||
per_write_integer(s, 0); /* subInterval (INTEGER) */
|
||||
freerdp_per_write_integer(s, 0); /* subHeight (INTEGER) */
|
||||
freerdp_per_write_integer(s, 0); /* subInterval (INTEGER) */
|
||||
Stream_SealLength(s);
|
||||
status = transport_write(mcs->transport, s);
|
||||
Stream_Free(s, TRUE);
|
||||
@ -1128,9 +1128,10 @@ BOOL mcs_recv_attach_user_confirm(rdpMcs* mcs, wStream* s)
|
||||
|
||||
if (!mcs_read_domain_mcspdu_header(s, DomainMCSPDU_AttachUserConfirm, &length, NULL))
|
||||
return FALSE;
|
||||
if (!per_read_enumerated(s, &result, MCS_Result_enum_length)) /* result */
|
||||
if (!freerdp_per_read_enumerated(s, &result, MCS_Result_enum_length)) /* result */
|
||||
return FALSE;
|
||||
if (!per_read_integer16(s, &(mcs->userId), MCS_BASE_CHANNEL_ID)) /* initiator (UserId) */
|
||||
if (!freerdp_per_read_integer16(s, &(mcs->userId),
|
||||
MCS_BASE_CHANNEL_ID)) /* initiator (UserId) */
|
||||
return FALSE;
|
||||
return tpkt_ensure_stream_consumed(s, length);
|
||||
}
|
||||
@ -1160,8 +1161,8 @@ BOOL mcs_send_attach_user_confirm(rdpMcs* mcs)
|
||||
|
||||
mcs->userId = mcs->baseChannelId++;
|
||||
mcs_write_domain_mcspdu_header(s, DomainMCSPDU_AttachUserConfirm, length, 2);
|
||||
per_write_enumerated(s, 0, MCS_Result_enum_length); /* result */
|
||||
per_write_integer16(s, mcs->userId, MCS_BASE_CHANNEL_ID); /* initiator (UserId) */
|
||||
freerdp_per_write_enumerated(s, 0, MCS_Result_enum_length); /* result */
|
||||
freerdp_per_write_integer16(s, mcs->userId, MCS_BASE_CHANNEL_ID); /* initiator (UserId) */
|
||||
Stream_SealLength(s);
|
||||
status = transport_write(mcs->transport, s);
|
||||
Stream_Free(s, TRUE);
|
||||
@ -1187,7 +1188,7 @@ BOOL mcs_recv_channel_join_request(rdpMcs* mcs, const rdpSettings* settings, wSt
|
||||
if (!mcs_read_domain_mcspdu_header(s, DomainMCSPDU_ChannelJoinRequest, &length, NULL))
|
||||
return FALSE;
|
||||
|
||||
if (!per_read_integer16(s, &userId, MCS_BASE_CHANNEL_ID))
|
||||
if (!freerdp_per_read_integer16(s, &userId, MCS_BASE_CHANNEL_ID))
|
||||
return FALSE;
|
||||
if (userId != mcs->userId)
|
||||
{
|
||||
@ -1196,7 +1197,7 @@ BOOL mcs_recv_channel_join_request(rdpMcs* mcs, const rdpSettings* settings, wSt
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
if (!per_read_integer16(s, channelId, 0))
|
||||
if (!freerdp_per_read_integer16(s, channelId, 0))
|
||||
return FALSE;
|
||||
|
||||
return tpkt_ensure_stream_consumed(s, length);
|
||||
@ -1229,8 +1230,8 @@ BOOL mcs_send_channel_join_request(rdpMcs* mcs, UINT16 channelId)
|
||||
}
|
||||
|
||||
mcs_write_domain_mcspdu_header(s, DomainMCSPDU_ChannelJoinRequest, length, 0);
|
||||
per_write_integer16(s, mcs->userId, MCS_BASE_CHANNEL_ID);
|
||||
per_write_integer16(s, channelId, 0);
|
||||
freerdp_per_write_integer16(s, mcs->userId, MCS_BASE_CHANNEL_ID);
|
||||
freerdp_per_write_integer16(s, channelId, 0);
|
||||
Stream_SealLength(s);
|
||||
status = transport_write(mcs->transport, s);
|
||||
Stream_Free(s, TRUE);
|
||||
@ -1256,13 +1257,13 @@ BOOL mcs_recv_channel_join_confirm(rdpMcs* mcs, wStream* s, UINT16* channelId)
|
||||
if (!mcs_read_domain_mcspdu_header(s, DomainMCSPDU_ChannelJoinConfirm, &length, NULL))
|
||||
return FALSE;
|
||||
|
||||
if (!per_read_enumerated(s, &result, MCS_Result_enum_length)) /* result */
|
||||
if (!freerdp_per_read_enumerated(s, &result, MCS_Result_enum_length)) /* result */
|
||||
return FALSE;
|
||||
if (!per_read_integer16(s, &initiator, MCS_BASE_CHANNEL_ID)) /* initiator (UserId) */
|
||||
if (!freerdp_per_read_integer16(s, &initiator, MCS_BASE_CHANNEL_ID)) /* initiator (UserId) */
|
||||
return FALSE;
|
||||
if (!per_read_integer16(s, &requested, 0)) /* requested (ChannelId) */
|
||||
if (!freerdp_per_read_integer16(s, &requested, 0)) /* requested (ChannelId) */
|
||||
return FALSE;
|
||||
if (!per_read_integer16(s, channelId, 0)) /* channelId */
|
||||
if (!freerdp_per_read_integer16(s, channelId, 0)) /* channelId */
|
||||
return FALSE;
|
||||
return tpkt_ensure_stream_consumed(s, length);
|
||||
}
|
||||
@ -1292,13 +1293,13 @@ BOOL mcs_send_channel_join_confirm(rdpMcs* mcs, UINT16 channelId)
|
||||
|
||||
if (!mcs_write_domain_mcspdu_header(s, DomainMCSPDU_ChannelJoinConfirm, length, 2))
|
||||
goto fail;
|
||||
if (!per_write_enumerated(s, 0, MCS_Result_enum_length)) /* result */
|
||||
if (!freerdp_per_write_enumerated(s, 0, MCS_Result_enum_length)) /* result */
|
||||
goto fail;
|
||||
if (!per_write_integer16(s, mcs->userId, MCS_BASE_CHANNEL_ID)) /* initiator (UserId) */
|
||||
if (!freerdp_per_write_integer16(s, mcs->userId, MCS_BASE_CHANNEL_ID)) /* initiator (UserId) */
|
||||
goto fail;
|
||||
if (!per_write_integer16(s, channelId, 0)) /* requested (ChannelId) */
|
||||
if (!freerdp_per_write_integer16(s, channelId, 0)) /* requested (ChannelId) */
|
||||
goto fail;
|
||||
if (!per_write_integer16(s, channelId, 0)) /* channelId */
|
||||
if (!freerdp_per_write_integer16(s, channelId, 0)) /* channelId */
|
||||
goto fail;
|
||||
Stream_SealLength(s);
|
||||
status = transport_write(mcs->transport, s);
|
||||
@ -1379,7 +1380,7 @@ BOOL mcs_send_disconnect_provider_ultimatum(rdpMcs* mcs)
|
||||
if (!mcs_write_domain_mcspdu_header(s, DomainMCSPDU_DisconnectProviderUltimatum, length, 1))
|
||||
goto fail;
|
||||
|
||||
if (!per_write_enumerated(s, 0x80, 0))
|
||||
if (!freerdp_per_write_enumerated(s, 0x80, 0))
|
||||
goto fail;
|
||||
status = transport_write(mcs->transport, s);
|
||||
fail:
|
||||
|
@ -559,7 +559,7 @@ BOOL rdp_read_header(rdpRdp* rdp, wStream* s, UINT16* length, UINT16* channelId)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!per_read_choice(s, &choice))
|
||||
if (!freerdp_per_read_choice(s, &choice))
|
||||
return FALSE;
|
||||
|
||||
const DomainMCSPDU domainMCSPDU = (DomainMCSPDU)(choice >> 2);
|
||||
@ -625,15 +625,15 @@ BOOL rdp_read_header(rdpRdp* rdp, wStream* s, UINT16* length, UINT16* channelId)
|
||||
if (!Stream_CheckAndLogRequiredLengthWLog(rdp->log, s, 5))
|
||||
return FALSE;
|
||||
|
||||
if (!per_read_integer16(s, &initiator, MCS_BASE_CHANNEL_ID)) /* initiator (UserId) */
|
||||
if (!freerdp_per_read_integer16(s, &initiator, MCS_BASE_CHANNEL_ID)) /* initiator (UserId) */
|
||||
return FALSE;
|
||||
|
||||
if (!per_read_integer16(s, channelId, 0)) /* channelId */
|
||||
if (!freerdp_per_read_integer16(s, channelId, 0)) /* channelId */
|
||||
return FALSE;
|
||||
|
||||
Stream_Read_UINT8(s, byte); /* dataPriority + Segmentation (0x70) */
|
||||
|
||||
if (!per_read_length(s, length)) /* userData (OCTET_STRING) */
|
||||
if (!freerdp_per_read_length(s, length)) /* userData (OCTET_STRING) */
|
||||
return FALSE;
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLengthWLog(rdp->log, s, *length))
|
||||
@ -676,9 +676,9 @@ BOOL rdp_write_header(rdpRdp* rdp, wStream* s, size_t length, UINT16 channelId)
|
||||
|
||||
if (!mcs_write_domain_mcspdu_header(s, MCSPDU, length, 0))
|
||||
return FALSE;
|
||||
if (!per_write_integer16(s, rdp->mcs->userId, MCS_BASE_CHANNEL_ID)) /* initiator */
|
||||
if (!freerdp_per_write_integer16(s, rdp->mcs->userId, MCS_BASE_CHANNEL_ID)) /* initiator */
|
||||
return FALSE;
|
||||
if (!per_write_integer16(s, channelId, 0)) /* channelId */
|
||||
if (!freerdp_per_write_integer16(s, channelId, 0)) /* channelId */
|
||||
return FALSE;
|
||||
if (!Stream_EnsureRemainingCapacity(s, 3))
|
||||
return FALSE;
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#define TAG FREERDP_TAG("crypto")
|
||||
|
||||
BOOL ber_read_length(wStream* s, size_t* length)
|
||||
BOOL freerdp_ber_read_length(wStream* s, size_t* length)
|
||||
{
|
||||
BYTE byte = 0;
|
||||
|
||||
@ -66,13 +66,7 @@ BOOL ber_read_length(wStream* s, size_t* length)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write BER length.
|
||||
* @param s stream
|
||||
* @param length length
|
||||
*/
|
||||
|
||||
size_t ber_write_length(wStream* s, size_t length)
|
||||
size_t freerdp_ber_write_length(wStream* s, size_t length)
|
||||
{
|
||||
WINPR_ASSERT(s);
|
||||
|
||||
@ -99,7 +93,7 @@ size_t ber_write_length(wStream* s, size_t length)
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t _ber_sizeof_length(size_t length)
|
||||
size_t freerdp_ber_sizeof_length(size_t length)
|
||||
{
|
||||
if (length > 0xFF)
|
||||
return 3;
|
||||
@ -110,19 +104,11 @@ size_t _ber_sizeof_length(size_t length)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read BER Universal tag.
|
||||
*
|
||||
* @param s The stream to read from
|
||||
* @param tag BER universally-defined tag
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*/
|
||||
|
||||
BOOL ber_read_universal_tag(wStream* s, BYTE tag, BOOL pc)
|
||||
BOOL freerdp_ber_read_universal_tag(wStream* s, BYTE tag, BOOL pc)
|
||||
{
|
||||
BYTE byte = 0;
|
||||
const BYTE expect = (BER_CLASS_UNIV | BER_PC(pc) | (BER_TAG_MASK & tag));
|
||||
const BYTE expect =
|
||||
(FREERDP_BER_CLASS_UNIV | FREERDP_BER_PC(pc) | (FREERDP_BER_TAG_MASK & tag));
|
||||
|
||||
WINPR_ASSERT(s);
|
||||
|
||||
@ -140,28 +126,15 @@ BOOL ber_read_universal_tag(wStream* s, BYTE tag, BOOL pc)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write BER Universal tag.
|
||||
* @param s stream
|
||||
* @param tag BER universally-defined tag
|
||||
* @param pc primitive (FALSE) or constructed (TRUE)
|
||||
*/
|
||||
|
||||
size_t ber_write_universal_tag(wStream* s, BYTE tag, BOOL pc)
|
||||
size_t freerdp_ber_write_universal_tag(wStream* s, BYTE tag, BOOL pc)
|
||||
{
|
||||
WINPR_ASSERT(s);
|
||||
Stream_Write_UINT8(s, (BER_CLASS_UNIV | BER_PC(pc)) | (BER_TAG_MASK & tag));
|
||||
Stream_Write_UINT8(s, (FREERDP_BER_CLASS_UNIV | FREERDP_BER_PC(pc)) |
|
||||
(FREERDP_BER_TAG_MASK & tag));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read BER Application tag.
|
||||
* @param s stream
|
||||
* @param tag BER application-defined tag
|
||||
* @param length length
|
||||
*/
|
||||
|
||||
BOOL ber_read_application_tag(wStream* s, BYTE tag, size_t* length)
|
||||
BOOL freerdp_ber_read_application_tag(wStream* s, BYTE tag, size_t* length)
|
||||
{
|
||||
BYTE byte = 0;
|
||||
|
||||
@ -170,7 +143,8 @@ BOOL ber_read_application_tag(wStream* s, BYTE tag, size_t* length)
|
||||
|
||||
if (tag > 30)
|
||||
{
|
||||
const BYTE expect = ((BER_CLASS_APPL | BER_CONSTRUCT) | BER_TAG_MASK);
|
||||
const BYTE expect =
|
||||
((FREERDP_BER_CLASS_APPL | FREERDP_BER_CONSTRUCT) | FREERDP_BER_TAG_MASK);
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
|
||||
return FALSE;
|
||||
@ -191,11 +165,12 @@ BOOL ber_read_application_tag(wStream* s, BYTE tag, size_t* length)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return ber_read_length(s, length);
|
||||
return freerdp_ber_read_length(s, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
const BYTE expect = ((BER_CLASS_APPL | BER_CONSTRUCT) | (BER_TAG_MASK & tag));
|
||||
const BYTE expect =
|
||||
((FREERDP_BER_CLASS_APPL | FREERDP_BER_CONSTRUCT) | (FREERDP_BER_TAG_MASK & tag));
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
||||
return FALSE;
|
||||
@ -208,41 +183,37 @@ BOOL ber_read_application_tag(wStream* s, BYTE tag, size_t* length)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return ber_read_length(s, length);
|
||||
return freerdp_ber_read_length(s, length);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write BER Application tag.
|
||||
* @param s stream
|
||||
* @param tag BER application-defined tag
|
||||
* @param length length
|
||||
*/
|
||||
|
||||
void ber_write_application_tag(wStream* s, BYTE tag, size_t length)
|
||||
void freerdp_ber_write_application_tag(wStream* s, BYTE tag, size_t length)
|
||||
{
|
||||
WINPR_ASSERT(s);
|
||||
|
||||
if (tag > 30)
|
||||
{
|
||||
WINPR_ASSERT(Stream_GetRemainingCapacity(s) >= 2);
|
||||
Stream_Write_UINT8(s, (BER_CLASS_APPL | BER_CONSTRUCT) | BER_TAG_MASK);
|
||||
Stream_Write_UINT8(s,
|
||||
(FREERDP_BER_CLASS_APPL | FREERDP_BER_CONSTRUCT) | FREERDP_BER_TAG_MASK);
|
||||
Stream_Write_UINT8(s, tag);
|
||||
ber_write_length(s, length);
|
||||
freerdp_ber_write_length(s, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
WINPR_ASSERT(Stream_GetRemainingCapacity(s) >= 1);
|
||||
Stream_Write_UINT8(s, (BER_CLASS_APPL | BER_CONSTRUCT) | (BER_TAG_MASK & tag));
|
||||
ber_write_length(s, length);
|
||||
Stream_Write_UINT8(s, (FREERDP_BER_CLASS_APPL | FREERDP_BER_CONSTRUCT) |
|
||||
(FREERDP_BER_TAG_MASK & tag));
|
||||
freerdp_ber_write_length(s, length);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL ber_read_contextual_tag(wStream* s, BYTE tag, size_t* length, BOOL pc)
|
||||
BOOL freerdp_ber_read_contextual_tag(wStream* s, BYTE tag, size_t* length, BOOL pc)
|
||||
{
|
||||
const BYTE expect = ((BER_CLASS_CTXT | BER_PC(pc)) | (BER_TAG_MASK & tag));
|
||||
const BYTE expect =
|
||||
((FREERDP_BER_CLASS_CTXT | FREERDP_BER_PC(pc)) | (FREERDP_BER_TAG_MASK & tag));
|
||||
BYTE byte = 0;
|
||||
|
||||
WINPR_ASSERT(s);
|
||||
@ -264,25 +235,27 @@ BOOL ber_read_contextual_tag(wStream* s, BYTE tag, size_t* length, BOOL pc)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return ber_read_length(s, length);
|
||||
return freerdp_ber_read_length(s, length);
|
||||
}
|
||||
|
||||
size_t ber_write_contextual_tag(wStream* s, BYTE tag, size_t length, BOOL pc)
|
||||
size_t freerdp_ber_write_contextual_tag(wStream* s, BYTE tag, size_t length, BOOL pc)
|
||||
{
|
||||
WINPR_ASSERT(s);
|
||||
WINPR_ASSERT(Stream_GetRemainingCapacity(s) >= 1);
|
||||
Stream_Write_UINT8(s, (BER_CLASS_CTXT | BER_PC(pc)) | (BER_TAG_MASK & tag));
|
||||
return 1 + ber_write_length(s, length);
|
||||
Stream_Write_UINT8(s, (FREERDP_BER_CLASS_CTXT | FREERDP_BER_PC(pc)) |
|
||||
(FREERDP_BER_TAG_MASK & tag));
|
||||
return 1 + freerdp_ber_write_length(s, length);
|
||||
}
|
||||
|
||||
size_t ber_sizeof_contextual_tag(size_t length)
|
||||
size_t freerdp_ber_sizeof_contextual_tag(size_t length)
|
||||
{
|
||||
return 1 + _ber_sizeof_length(length);
|
||||
return 1 + freerdp_ber_sizeof_length(length);
|
||||
}
|
||||
|
||||
BOOL ber_read_sequence_tag(wStream* s, size_t* length)
|
||||
BOOL freerdp_ber_read_sequence_tag(wStream* s, size_t* length)
|
||||
{
|
||||
const BYTE expect = ((BER_CLASS_UNIV | BER_CONSTRUCT) | (BER_TAG_SEQUENCE_OF));
|
||||
const BYTE expect =
|
||||
((FREERDP_BER_CLASS_UNIV | FREERDP_BER_CONSTRUCT) | (FREERDP_BER_TAG_SEQUENCE_OF));
|
||||
BYTE byte = 0;
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
||||
@ -296,38 +269,34 @@ BOOL ber_read_sequence_tag(wStream* s, size_t* length)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return ber_read_length(s, length);
|
||||
return freerdp_ber_read_length(s, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write BER SEQUENCE tag.
|
||||
* @param s stream
|
||||
* @param length length
|
||||
*/
|
||||
|
||||
size_t ber_write_sequence_tag(wStream* s, size_t length)
|
||||
size_t freerdp_ber_write_sequence_tag(wStream* s, size_t length)
|
||||
{
|
||||
Stream_Write_UINT8(s, (BER_CLASS_UNIV | BER_CONSTRUCT) | (BER_TAG_MASK & BER_TAG_SEQUENCE));
|
||||
return 1 + ber_write_length(s, length);
|
||||
Stream_Write_UINT8(s, (FREERDP_BER_CLASS_UNIV | FREERDP_BER_CONSTRUCT) |
|
||||
(FREERDP_BER_TAG_MASK & FREERDP_BER_TAG_SEQUENCE));
|
||||
return 1 + freerdp_ber_write_length(s, length);
|
||||
}
|
||||
|
||||
size_t ber_sizeof_sequence(size_t length)
|
||||
size_t freerdp_ber_sizeof_sequence(size_t length)
|
||||
{
|
||||
return 1 + _ber_sizeof_length(length) + length;
|
||||
return 1 + freerdp_ber_sizeof_length(length) + length;
|
||||
}
|
||||
|
||||
size_t ber_sizeof_sequence_tag(size_t length)
|
||||
size_t freerdp_ber_sizeof_sequence_tag(size_t length)
|
||||
{
|
||||
return 1 + _ber_sizeof_length(length);
|
||||
return 1 + freerdp_ber_sizeof_length(length);
|
||||
}
|
||||
|
||||
BOOL ber_read_enumerated(wStream* s, BYTE* enumerated, BYTE count)
|
||||
BOOL freerdp_ber_read_enumerated(wStream* s, BYTE* enumerated, BYTE count)
|
||||
{
|
||||
size_t length = 0;
|
||||
|
||||
WINPR_ASSERT(enumerated);
|
||||
|
||||
if (!ber_read_universal_tag(s, BER_TAG_ENUMERATED, FALSE) || !ber_read_length(s, &length))
|
||||
if (!freerdp_ber_read_universal_tag(s, FREERDP_BER_TAG_ENUMERATED, FALSE) ||
|
||||
!freerdp_ber_read_length(s, &length))
|
||||
return FALSE;
|
||||
|
||||
if (length != 1)
|
||||
@ -350,16 +319,20 @@ BOOL ber_read_enumerated(wStream* s, BYTE* enumerated, BYTE count)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void ber_write_enumerated(wStream* s, BYTE enumerated, BYTE count)
|
||||
BOOL freerdp_ber_write_enumerated(wStream* s, BYTE enumerated, BYTE count)
|
||||
{
|
||||
ber_write_universal_tag(s, BER_TAG_ENUMERATED, FALSE);
|
||||
ber_write_length(s, 1);
|
||||
if (enumerated >= count)
|
||||
return FALSE;
|
||||
freerdp_ber_write_universal_tag(s, FREERDP_BER_TAG_ENUMERATED, FALSE);
|
||||
freerdp_ber_write_length(s, 1);
|
||||
Stream_Write_UINT8(s, enumerated);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL ber_read_bit_string(wStream* s, size_t* length, BYTE* padding)
|
||||
BOOL freerdp_ber_read_bit_string(wStream* s, size_t* length, BYTE* padding)
|
||||
{
|
||||
if (!ber_read_universal_tag(s, BER_TAG_BIT_STRING, FALSE) || !ber_read_length(s, length))
|
||||
if (!freerdp_ber_read_universal_tag(s, FREERDP_BER_TAG_BIT_STRING, FALSE) ||
|
||||
!freerdp_ber_read_length(s, length))
|
||||
return FALSE;
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
||||
@ -369,76 +342,72 @@ BOOL ber_read_bit_string(wStream* s, size_t* length, BYTE* padding)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a BER OCTET_STRING
|
||||
* @param s stream
|
||||
* @param oct_str octet string
|
||||
* @param length string length
|
||||
*/
|
||||
|
||||
size_t ber_write_octet_string(wStream* s, const BYTE* oct_str, size_t length)
|
||||
size_t freerdp_ber_write_octet_string(wStream* s, const BYTE* oct_str, size_t length)
|
||||
{
|
||||
size_t size = 0;
|
||||
|
||||
WINPR_ASSERT(oct_str || (length == 0));
|
||||
size += ber_write_universal_tag(s, BER_TAG_OCTET_STRING, FALSE);
|
||||
size += ber_write_length(s, length);
|
||||
size += freerdp_ber_write_universal_tag(s, FREERDP_BER_TAG_OCTET_STRING, FALSE);
|
||||
size += freerdp_ber_write_length(s, length);
|
||||
Stream_Write(s, oct_str, length);
|
||||
size += length;
|
||||
return size;
|
||||
}
|
||||
|
||||
size_t ber_write_contextual_octet_string(wStream* s, BYTE tag, const BYTE* oct_str, size_t length)
|
||||
size_t freerdp_ber_write_contextual_octet_string(wStream* s, BYTE tag, const BYTE* oct_str,
|
||||
size_t length)
|
||||
{
|
||||
size_t inner = ber_sizeof_octet_string(length);
|
||||
size_t inner = freerdp_ber_sizeof_octet_string(length);
|
||||
size_t ret = 0;
|
||||
size_t r = 0;
|
||||
|
||||
ret = ber_write_contextual_tag(s, tag, inner, TRUE);
|
||||
ret = freerdp_ber_write_contextual_tag(s, tag, inner, TRUE);
|
||||
if (!ret)
|
||||
return 0;
|
||||
|
||||
r = ber_write_octet_string(s, oct_str, length);
|
||||
r = freerdp_ber_write_octet_string(s, oct_str, length);
|
||||
if (!r)
|
||||
return 0;
|
||||
return ret + r;
|
||||
}
|
||||
|
||||
size_t ber_write_char_to_unicode_octet_string(wStream* s, const char* str)
|
||||
size_t freerdp_ber_write_char_to_unicode_octet_string(wStream* s, const char* str)
|
||||
{
|
||||
WINPR_ASSERT(str);
|
||||
size_t size = 0;
|
||||
size_t length = strlen(str) + 1;
|
||||
size += ber_write_universal_tag(s, BER_TAG_OCTET_STRING, FALSE);
|
||||
size += ber_write_length(s, length * sizeof(WCHAR));
|
||||
size += freerdp_ber_write_universal_tag(s, FREERDP_BER_TAG_OCTET_STRING, FALSE);
|
||||
size += freerdp_ber_write_length(s, length * sizeof(WCHAR));
|
||||
|
||||
if (Stream_Write_UTF16_String_From_UTF8(s, length, str, length, TRUE) < 0)
|
||||
return 0;
|
||||
return size + length * sizeof(WCHAR);
|
||||
}
|
||||
|
||||
size_t ber_write_contextual_unicode_octet_string(wStream* s, BYTE tag, LPWSTR str)
|
||||
size_t freerdp_ber_write_contextual_unicode_octet_string(wStream* s, BYTE tag, const WCHAR* str)
|
||||
{
|
||||
WINPR_ASSERT(str);
|
||||
size_t len = _wcslen(str) * sizeof(WCHAR);
|
||||
size_t inner_len = ber_sizeof_octet_string(len);
|
||||
size_t inner_len = freerdp_ber_sizeof_octet_string(len);
|
||||
size_t ret = 0;
|
||||
|
||||
ret = ber_write_contextual_tag(s, tag, inner_len, TRUE);
|
||||
return ret + ber_write_octet_string(s, (const BYTE*)str, len);
|
||||
ret = freerdp_ber_write_contextual_tag(s, tag, inner_len, TRUE);
|
||||
return ret + freerdp_ber_write_octet_string(s, (const BYTE*)str, len);
|
||||
}
|
||||
|
||||
size_t ber_write_contextual_char_to_unicode_octet_string(wStream* s, BYTE tag, const char* str)
|
||||
size_t freerdp_ber_write_contextual_char_to_unicode_octet_string(wStream* s, BYTE tag,
|
||||
const char* str)
|
||||
{
|
||||
size_t ret = 0;
|
||||
size_t len = strlen(str);
|
||||
size_t inner_len = ber_sizeof_octet_string(len * 2);
|
||||
size_t inner_len = freerdp_ber_sizeof_octet_string(len * 2);
|
||||
|
||||
WINPR_ASSERT(Stream_GetRemainingCapacity(s) < ber_sizeof_contextual_tag(inner_len) + inner_len);
|
||||
WINPR_ASSERT(Stream_GetRemainingCapacity(s) <
|
||||
freerdp_ber_sizeof_contextual_tag(inner_len) + inner_len);
|
||||
|
||||
ret = ber_write_contextual_tag(s, tag, inner_len, TRUE);
|
||||
ret += ber_write_universal_tag(s, BER_TAG_OCTET_STRING, FALSE);
|
||||
ret += ber_write_length(s, len * sizeof(WCHAR));
|
||||
ret = freerdp_ber_write_contextual_tag(s, tag, inner_len, TRUE);
|
||||
ret += freerdp_ber_write_universal_tag(s, FREERDP_BER_TAG_OCTET_STRING, FALSE);
|
||||
ret += freerdp_ber_write_length(s, len * sizeof(WCHAR));
|
||||
|
||||
if (Stream_Write_UTF16_String_From_UTF8(s, len, str, len, TRUE) < 0)
|
||||
return 0;
|
||||
@ -446,12 +415,12 @@ size_t ber_write_contextual_char_to_unicode_octet_string(wStream* s, BYTE tag, c
|
||||
return ret + len;
|
||||
}
|
||||
|
||||
BOOL ber_read_unicode_octet_string(wStream* s, LPWSTR* str)
|
||||
BOOL freerdp_ber_read_unicode_octet_string(wStream* s, LPWSTR* str)
|
||||
{
|
||||
LPWSTR ret = NULL;
|
||||
size_t length = 0;
|
||||
|
||||
if (!ber_read_octet_string_tag(s, &length))
|
||||
if (!freerdp_ber_read_octet_string_tag(s, &length))
|
||||
return FALSE;
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, length))
|
||||
@ -468,13 +437,13 @@ BOOL ber_read_unicode_octet_string(wStream* s, LPWSTR* str)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL ber_read_char_from_unicode_octet_string(wStream* s, char** str)
|
||||
BOOL freerdp_ber_read_char_from_unicode_octet_string(wStream* s, char** str)
|
||||
{
|
||||
size_t length = 0;
|
||||
char* ptr = NULL;
|
||||
|
||||
*str = NULL;
|
||||
if (!ber_read_octet_string_tag(s, &length))
|
||||
if (!freerdp_ber_read_octet_string_tag(s, &length))
|
||||
return FALSE;
|
||||
|
||||
ptr = Stream_Read_UTF16_String_As_UTF8(s, length / sizeof(WCHAR), NULL);
|
||||
@ -484,12 +453,13 @@ BOOL ber_read_char_from_unicode_octet_string(wStream* s, char** str)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL ber_read_octet_string_tag(wStream* s, size_t* length)
|
||||
BOOL freerdp_ber_read_octet_string_tag(wStream* s, size_t* length)
|
||||
{
|
||||
return ber_read_universal_tag(s, BER_TAG_OCTET_STRING, FALSE) && ber_read_length(s, length);
|
||||
return freerdp_ber_read_universal_tag(s, FREERDP_BER_TAG_OCTET_STRING, FALSE) &&
|
||||
freerdp_ber_read_length(s, length);
|
||||
}
|
||||
|
||||
BOOL ber_read_octet_string(wStream* s, BYTE** content, size_t* length)
|
||||
BOOL freerdp_ber_read_octet_string(wStream* s, BYTE** content, size_t* length)
|
||||
{
|
||||
BYTE* ret = NULL;
|
||||
|
||||
@ -497,7 +467,7 @@ BOOL ber_read_octet_string(wStream* s, BYTE** content, size_t* length)
|
||||
WINPR_ASSERT(content);
|
||||
WINPR_ASSERT(length);
|
||||
|
||||
if (!ber_read_octet_string_tag(s, length))
|
||||
if (!freerdp_ber_read_octet_string_tag(s, length))
|
||||
return FALSE;
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, *length))
|
||||
return FALSE;
|
||||
@ -511,39 +481,32 @@ BOOL ber_read_octet_string(wStream* s, BYTE** content, size_t* length)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
size_t ber_write_octet_string_tag(wStream* s, size_t length)
|
||||
size_t freerdp_ber_write_octet_string_tag(wStream* s, size_t length)
|
||||
{
|
||||
ber_write_universal_tag(s, BER_TAG_OCTET_STRING, FALSE);
|
||||
ber_write_length(s, length);
|
||||
return 1 + _ber_sizeof_length(length);
|
||||
freerdp_ber_write_universal_tag(s, FREERDP_BER_TAG_OCTET_STRING, FALSE);
|
||||
freerdp_ber_write_length(s, length);
|
||||
return 1 + freerdp_ber_sizeof_length(length);
|
||||
}
|
||||
|
||||
size_t ber_sizeof_octet_string(size_t length)
|
||||
size_t freerdp_ber_sizeof_octet_string(size_t length)
|
||||
{
|
||||
return 1 + _ber_sizeof_length(length) + length;
|
||||
return 1 + freerdp_ber_sizeof_length(length) + length;
|
||||
}
|
||||
|
||||
size_t ber_sizeof_contextual_octet_string(size_t length)
|
||||
size_t freerdp_ber_sizeof_contextual_octet_string(size_t length)
|
||||
{
|
||||
size_t ret = ber_sizeof_octet_string(length);
|
||||
return ber_sizeof_contextual_tag(ret) + ret;
|
||||
size_t ret = freerdp_ber_sizeof_octet_string(length);
|
||||
return freerdp_ber_sizeof_contextual_tag(ret) + ret;
|
||||
}
|
||||
|
||||
/** \brief Read a BER BOOLEAN
|
||||
*
|
||||
* @param s The stream to read from.
|
||||
* @param value A pointer to the value read, must not be NULL
|
||||
*
|
||||
* \return \b TRUE for success, \b FALSE for any failure
|
||||
*/
|
||||
|
||||
BOOL ber_read_BOOL(wStream* s, BOOL* value)
|
||||
BOOL freerdp_ber_read_BOOL(wStream* s, BOOL* value)
|
||||
{
|
||||
size_t length = 0;
|
||||
BYTE v = 0;
|
||||
|
||||
WINPR_ASSERT(value);
|
||||
if (!ber_read_universal_tag(s, BER_TAG_BOOLEAN, FALSE) || !ber_read_length(s, &length))
|
||||
if (!freerdp_ber_read_universal_tag(s, FREERDP_BER_TAG_BOOLEAN, FALSE) ||
|
||||
!freerdp_ber_read_length(s, &length))
|
||||
return FALSE;
|
||||
|
||||
if (length != 1)
|
||||
@ -559,29 +522,22 @@ BOOL ber_read_BOOL(wStream* s, BOOL* value)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a BER BOOLEAN
|
||||
*
|
||||
* @param s A pointer to the stream to write to
|
||||
* @param value The value to write
|
||||
*/
|
||||
|
||||
void ber_write_BOOL(wStream* s, BOOL value)
|
||||
void freerdp_ber_write_BOOL(wStream* s, BOOL value)
|
||||
{
|
||||
ber_write_universal_tag(s, BER_TAG_BOOLEAN, FALSE);
|
||||
ber_write_length(s, 1);
|
||||
freerdp_ber_write_universal_tag(s, FREERDP_BER_TAG_BOOLEAN, FALSE);
|
||||
freerdp_ber_write_length(s, 1);
|
||||
Stream_Write_UINT8(s, (value == TRUE) ? 0xFF : 0);
|
||||
}
|
||||
|
||||
BOOL ber_read_integer(wStream* s, UINT32* value)
|
||||
BOOL freerdp_ber_read_integer(wStream* s, UINT32* value)
|
||||
{
|
||||
size_t length = 0;
|
||||
|
||||
WINPR_ASSERT(s);
|
||||
|
||||
if (!ber_read_universal_tag(s, BER_TAG_INTEGER, FALSE))
|
||||
if (!freerdp_ber_read_universal_tag(s, FREERDP_BER_TAG_INTEGER, FALSE))
|
||||
return FALSE;
|
||||
if (!ber_read_length(s, &length))
|
||||
if (!freerdp_ber_read_length(s, &length))
|
||||
return FALSE;
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, length))
|
||||
return FALSE;
|
||||
@ -625,39 +581,30 @@ BOOL ber_read_integer(wStream* s, UINT32* value)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a BER INTEGER
|
||||
*
|
||||
* @param s A pointer to the stream to write to
|
||||
* @param value The value to write
|
||||
*
|
||||
* @return The size in bytes that were written
|
||||
*/
|
||||
|
||||
size_t ber_write_integer(wStream* s, UINT32 value)
|
||||
size_t freerdp_ber_write_integer(wStream* s, UINT32 value)
|
||||
{
|
||||
WINPR_ASSERT(s);
|
||||
|
||||
if (value < 0x80)
|
||||
{
|
||||
ber_write_universal_tag(s, BER_TAG_INTEGER, FALSE);
|
||||
ber_write_length(s, 1);
|
||||
freerdp_ber_write_universal_tag(s, FREERDP_BER_TAG_INTEGER, FALSE);
|
||||
freerdp_ber_write_length(s, 1);
|
||||
|
||||
Stream_Write_UINT8(s, value);
|
||||
return 3;
|
||||
}
|
||||
else if (value < 0x8000)
|
||||
{
|
||||
ber_write_universal_tag(s, BER_TAG_INTEGER, FALSE);
|
||||
ber_write_length(s, 2);
|
||||
freerdp_ber_write_universal_tag(s, FREERDP_BER_TAG_INTEGER, FALSE);
|
||||
freerdp_ber_write_length(s, 2);
|
||||
|
||||
Stream_Write_UINT16_BE(s, value);
|
||||
return 4;
|
||||
}
|
||||
else if (value < 0x800000)
|
||||
{
|
||||
ber_write_universal_tag(s, BER_TAG_INTEGER, FALSE);
|
||||
ber_write_length(s, 3);
|
||||
freerdp_ber_write_universal_tag(s, FREERDP_BER_TAG_INTEGER, FALSE);
|
||||
freerdp_ber_write_length(s, 3);
|
||||
|
||||
Stream_Write_UINT8(s, (value >> 16));
|
||||
Stream_Write_UINT16_BE(s, (value & 0xFFFF));
|
||||
@ -665,8 +612,8 @@ size_t ber_write_integer(wStream* s, UINT32 value)
|
||||
}
|
||||
else if (value < 0x80000000)
|
||||
{
|
||||
ber_write_universal_tag(s, BER_TAG_INTEGER, FALSE);
|
||||
ber_write_length(s, 4);
|
||||
freerdp_ber_write_universal_tag(s, FREERDP_BER_TAG_INTEGER, FALSE);
|
||||
freerdp_ber_write_length(s, 4);
|
||||
|
||||
Stream_Write_UINT32_BE(s, value);
|
||||
return 6;
|
||||
@ -674,28 +621,28 @@ size_t ber_write_integer(wStream* s, UINT32 value)
|
||||
else
|
||||
{
|
||||
/* treat as signed integer i.e. NT/HRESULT error codes */
|
||||
ber_write_universal_tag(s, BER_TAG_INTEGER, FALSE);
|
||||
ber_write_length(s, 4);
|
||||
freerdp_ber_write_universal_tag(s, FREERDP_BER_TAG_INTEGER, FALSE);
|
||||
freerdp_ber_write_length(s, 4);
|
||||
|
||||
Stream_Write_UINT32_BE(s, value);
|
||||
return 6;
|
||||
}
|
||||
}
|
||||
|
||||
size_t ber_write_contextual_integer(wStream* s, BYTE tag, UINT32 value)
|
||||
size_t freerdp_ber_write_contextual_integer(wStream* s, BYTE tag, UINT32 value)
|
||||
{
|
||||
size_t len = ber_sizeof_integer(value);
|
||||
size_t len = freerdp_ber_sizeof_integer(value);
|
||||
|
||||
WINPR_ASSERT(s);
|
||||
|
||||
WINPR_ASSERT(Stream_EnsureRemainingCapacity(s, len + 5));
|
||||
|
||||
len += ber_write_contextual_tag(s, tag, len, TRUE);
|
||||
ber_write_integer(s, value);
|
||||
len += freerdp_ber_write_contextual_tag(s, tag, len, TRUE);
|
||||
freerdp_ber_write_integer(s, value);
|
||||
return len;
|
||||
}
|
||||
|
||||
size_t ber_sizeof_integer(UINT32 value)
|
||||
size_t freerdp_ber_sizeof_integer(UINT32 value)
|
||||
{
|
||||
if (value < 0x80)
|
||||
{
|
||||
@ -720,13 +667,202 @@ size_t ber_sizeof_integer(UINT32 value)
|
||||
}
|
||||
}
|
||||
|
||||
size_t ber_sizeof_contextual_integer(UINT32 value)
|
||||
size_t freerdp_ber_sizeof_contextual_integer(UINT32 value)
|
||||
{
|
||||
size_t intSize = ber_sizeof_integer(value);
|
||||
return ber_sizeof_contextual_tag(intSize) + intSize;
|
||||
size_t intSize = freerdp_ber_sizeof_integer(value);
|
||||
return freerdp_ber_sizeof_contextual_tag(intSize) + intSize;
|
||||
}
|
||||
|
||||
BOOL freerdp_ber_read_integer_length(wStream* s, size_t* length)
|
||||
{
|
||||
return freerdp_ber_read_universal_tag(s, FREERDP_BER_TAG_INTEGER, FALSE) &&
|
||||
freerdp_ber_read_length(s, length);
|
||||
}
|
||||
|
||||
#if defined(WITH_FREERDP_3x_DEPRECATED)
|
||||
|
||||
BOOL ber_read_length(wStream* s, size_t* length)
|
||||
{
|
||||
return freerdp_ber_read_length(s, length);
|
||||
}
|
||||
|
||||
size_t ber_write_length(wStream* s, size_t length)
|
||||
{
|
||||
return freerdp_ber_write_length(s, length);
|
||||
}
|
||||
|
||||
size_t _ber_sizeof_length(size_t length)
|
||||
{
|
||||
return freerdp_ber_sizeof_length(length);
|
||||
}
|
||||
|
||||
BOOL ber_read_universal_tag(wStream* s, BYTE tag, BOOL pc)
|
||||
{
|
||||
return freerdp_ber_read_universal_tag(s, tag, pc);
|
||||
}
|
||||
|
||||
size_t ber_write_universal_tag(wStream* s, BYTE tag, BOOL pc)
|
||||
{
|
||||
return freerdp_ber_write_universal_tag(s, tag, pc);
|
||||
}
|
||||
|
||||
BOOL ber_read_application_tag(wStream* s, BYTE tag, size_t* length)
|
||||
{
|
||||
return freerdp_ber_read_application_tag(s, tag, length);
|
||||
}
|
||||
|
||||
void ber_write_application_tag(wStream* s, BYTE tag, size_t length)
|
||||
{
|
||||
freerdp_ber_write_application_tag(s, tag, length);
|
||||
}
|
||||
|
||||
BOOL ber_read_enumerated(wStream* s, BYTE* enumerated, BYTE count)
|
||||
{
|
||||
return freerdp_ber_read_enumerated(s, enumerated, count);
|
||||
}
|
||||
|
||||
void ber_write_enumerated(wStream* s, BYTE enumerated, BYTE count)
|
||||
{
|
||||
freerdp_ber_write_enumerated(s, enumerated, count);
|
||||
}
|
||||
|
||||
BOOL ber_read_contextual_tag(wStream* s, BYTE tag, size_t* length, BOOL pc)
|
||||
{
|
||||
return freerdp_ber_read_contextual_tag(s, tag, length, pc);
|
||||
}
|
||||
|
||||
size_t ber_write_contextual_tag(wStream* s, BYTE tag, size_t length, BOOL pc)
|
||||
{
|
||||
return freerdp_ber_write_contextual_tag(s, tag, length, pc);
|
||||
}
|
||||
|
||||
size_t ber_sizeof_contextual_tag(size_t length)
|
||||
{
|
||||
return freerdp_ber_sizeof_contextual_tag(length);
|
||||
}
|
||||
|
||||
BOOL ber_read_sequence_tag(wStream* s, size_t* length)
|
||||
{
|
||||
return freerdp_ber_read_sequence_tag(s, length);
|
||||
}
|
||||
|
||||
size_t ber_write_sequence_tag(wStream* s, size_t length)
|
||||
{
|
||||
return freerdp_ber_write_sequence_tag(s, length);
|
||||
}
|
||||
|
||||
size_t ber_sizeof_sequence(size_t length)
|
||||
{
|
||||
return freerdp_ber_sizeof_sequence(length);
|
||||
}
|
||||
|
||||
size_t ber_sizeof_sequence_tag(size_t length)
|
||||
{
|
||||
return freerdp_ber_sizeof_sequence_tag(length);
|
||||
}
|
||||
|
||||
BOOL ber_read_bit_string(wStream* s, size_t* length, BYTE* padding)
|
||||
{
|
||||
return freerdp_ber_read_bit_string(s, length, padding);
|
||||
}
|
||||
|
||||
BOOL ber_read_octet_string_tag(wStream* s, size_t* length)
|
||||
{
|
||||
return freerdp_ber_read_octet_string_tag(s, length);
|
||||
}
|
||||
|
||||
BOOL ber_read_octet_string(wStream* s, BYTE** content, size_t* length)
|
||||
{
|
||||
return freerdp_ber_read_octet_string(s, content, length);
|
||||
}
|
||||
|
||||
size_t ber_write_octet_string_tag(wStream* s, size_t length)
|
||||
{
|
||||
return freerdp_ber_write_octet_string_tag(s, length);
|
||||
}
|
||||
|
||||
size_t ber_sizeof_octet_string(size_t length)
|
||||
{
|
||||
return freerdp_ber_sizeof_octet_string(length);
|
||||
}
|
||||
|
||||
size_t ber_sizeof_contextual_octet_string(size_t length)
|
||||
{
|
||||
return freerdp_ber_sizeof_contextual_octet_string(length);
|
||||
}
|
||||
|
||||
size_t ber_write_char_to_unicode_octet_string(wStream* s, const char* str)
|
||||
{
|
||||
return freerdp_ber_write_char_to_unicode_octet_string(s, str);
|
||||
}
|
||||
|
||||
size_t ber_write_contextual_char_to_unicode_octet_string(wStream* s, BYTE tag, const char* oct_str)
|
||||
{
|
||||
return freerdp_ber_write_contextual_char_to_unicode_octet_string(s, tag, oct_str);
|
||||
}
|
||||
|
||||
size_t ber_write_octet_string(wStream* s, const BYTE* oct_str, size_t length)
|
||||
{
|
||||
return freerdp_ber_write_octet_string(s, oct_str, length);
|
||||
}
|
||||
|
||||
BOOL ber_read_char_from_unicode_octet_string(wStream* s, char** str)
|
||||
{
|
||||
return freerdp_ber_read_char_from_unicode_octet_string(s, str);
|
||||
}
|
||||
|
||||
BOOL ber_read_unicode_octet_string(wStream* s, LPWSTR* str)
|
||||
{
|
||||
return freerdp_ber_read_unicode_octet_string(s, str);
|
||||
}
|
||||
|
||||
size_t ber_write_contextual_octet_string(wStream* s, BYTE tag, const BYTE* oct_str, size_t length)
|
||||
{
|
||||
return freerdp_ber_write_contextual_octet_string(s, tag, oct_str, length);
|
||||
}
|
||||
|
||||
size_t ber_write_contextual_unicode_octet_string(wStream* s, BYTE tag, const LPWSTR str)
|
||||
{
|
||||
return freerdp_ber_write_contextual_unicode_octet_string(s, tag, str);
|
||||
}
|
||||
|
||||
BOOL ber_read_BOOL(wStream* s, BOOL* value)
|
||||
{
|
||||
return freerdp_ber_read_BOOL(s, value);
|
||||
}
|
||||
|
||||
void ber_write_BOOL(wStream* s, BOOL value)
|
||||
{
|
||||
freerdp_ber_write_BOOL(s, value);
|
||||
}
|
||||
|
||||
BOOL ber_read_integer(wStream* s, UINT32* value)
|
||||
{
|
||||
return freerdp_ber_read_integer(s, value);
|
||||
}
|
||||
|
||||
size_t ber_write_integer(wStream* s, UINT32 value)
|
||||
{
|
||||
return freerdp_ber_write_integer(s, value);
|
||||
}
|
||||
|
||||
size_t ber_write_contextual_integer(wStream* s, BYTE tag, UINT32 value)
|
||||
{
|
||||
return freerdp_ber_write_contextual_integer(s, tag, value);
|
||||
}
|
||||
|
||||
BOOL ber_read_integer_length(wStream* s, size_t* length)
|
||||
{
|
||||
return ber_read_universal_tag(s, BER_TAG_INTEGER, FALSE) && ber_read_length(s, length);
|
||||
return freerdp_ber_read_integer_length(s, length);
|
||||
}
|
||||
|
||||
size_t ber_sizeof_integer(UINT32 value)
|
||||
{
|
||||
return freerdp_ber_sizeof_integer(value);
|
||||
}
|
||||
|
||||
size_t ber_sizeof_contextual_integer(UINT32 value)
|
||||
{
|
||||
return freerdp_ber_sizeof_contextual_integer(value);
|
||||
}
|
||||
#endif
|
||||
|
@ -312,84 +312,87 @@ static BOOL certificate_read_x509_certificate(const rdpCertBlob* cert, rdpCertIn
|
||||
if (!s)
|
||||
return FALSE;
|
||||
|
||||
if (!ber_read_sequence_tag(s, &length)) /* Certificate (SEQUENCE) */
|
||||
if (!freerdp_ber_read_sequence_tag(s, &length)) /* Certificate (SEQUENCE) */
|
||||
goto error;
|
||||
|
||||
error++;
|
||||
|
||||
if (!ber_read_sequence_tag(s, &length)) /* TBSCertificate (SEQUENCE) */
|
||||
if (!freerdp_ber_read_sequence_tag(s, &length)) /* TBSCertificate (SEQUENCE) */
|
||||
goto error;
|
||||
|
||||
error++;
|
||||
|
||||
if (!ber_read_contextual_tag(s, 0, &length, TRUE)) /* Explicit Contextual Tag [0] */
|
||||
if (!freerdp_ber_read_contextual_tag(s, 0, &length, TRUE)) /* Explicit Contextual Tag [0] */
|
||||
goto error;
|
||||
|
||||
error++;
|
||||
|
||||
if (!ber_read_integer(s, &version)) /* version (INTEGER) */
|
||||
if (!freerdp_ber_read_integer(s, &version)) /* version (INTEGER) */
|
||||
goto error;
|
||||
|
||||
error++;
|
||||
version++;
|
||||
|
||||
/* serialNumber */
|
||||
if (!ber_read_integer(s, NULL)) /* CertificateSerialNumber (INTEGER) */
|
||||
if (!freerdp_ber_read_integer(s, NULL)) /* CertificateSerialNumber (INTEGER) */
|
||||
goto error;
|
||||
|
||||
error++;
|
||||
|
||||
/* signature */
|
||||
if (!ber_read_sequence_tag(s, &length) ||
|
||||
if (!freerdp_ber_read_sequence_tag(s, &length) ||
|
||||
!Stream_SafeSeek(s, length)) /* AlgorithmIdentifier (SEQUENCE) */
|
||||
goto error;
|
||||
|
||||
error++;
|
||||
|
||||
/* issuer */
|
||||
if (!ber_read_sequence_tag(s, &length) || !Stream_SafeSeek(s, length)) /* Name (SEQUENCE) */
|
||||
if (!freerdp_ber_read_sequence_tag(s, &length) ||
|
||||
!Stream_SafeSeek(s, length)) /* Name (SEQUENCE) */
|
||||
goto error;
|
||||
|
||||
error++;
|
||||
|
||||
/* validity */
|
||||
if (!ber_read_sequence_tag(s, &length) || !Stream_SafeSeek(s, length)) /* Validity (SEQUENCE) */
|
||||
if (!freerdp_ber_read_sequence_tag(s, &length) ||
|
||||
!Stream_SafeSeek(s, length)) /* Validity (SEQUENCE) */
|
||||
goto error;
|
||||
|
||||
error++;
|
||||
|
||||
/* subject */
|
||||
if (!ber_read_sequence_tag(s, &length) || !Stream_SafeSeek(s, length)) /* Name (SEQUENCE) */
|
||||
if (!freerdp_ber_read_sequence_tag(s, &length) ||
|
||||
!Stream_SafeSeek(s, length)) /* Name (SEQUENCE) */
|
||||
goto error;
|
||||
|
||||
error++;
|
||||
|
||||
/* subjectPublicKeyInfo */
|
||||
if (!ber_read_sequence_tag(s, &length)) /* SubjectPublicKeyInfo (SEQUENCE) */
|
||||
if (!freerdp_ber_read_sequence_tag(s, &length)) /* SubjectPublicKeyInfo (SEQUENCE) */
|
||||
goto error;
|
||||
|
||||
error++;
|
||||
|
||||
/* subjectPublicKeyInfo::AlgorithmIdentifier */
|
||||
if (!ber_read_sequence_tag(s, &length) ||
|
||||
if (!freerdp_ber_read_sequence_tag(s, &length) ||
|
||||
!Stream_SafeSeek(s, length)) /* AlgorithmIdentifier (SEQUENCE) */
|
||||
goto error;
|
||||
|
||||
error++;
|
||||
|
||||
/* subjectPublicKeyInfo::subjectPublicKey */
|
||||
if (!ber_read_bit_string(s, &length, &padding)) /* BIT_STRING */
|
||||
if (!freerdp_ber_read_bit_string(s, &length, &padding)) /* BIT_STRING */
|
||||
goto error;
|
||||
|
||||
error++;
|
||||
|
||||
/* RSAPublicKey (SEQUENCE) */
|
||||
if (!ber_read_sequence_tag(s, &length)) /* SEQUENCE */
|
||||
if (!freerdp_ber_read_sequence_tag(s, &length)) /* SEQUENCE */
|
||||
goto error;
|
||||
|
||||
error++;
|
||||
|
||||
if (!ber_read_integer_length(s, &modulus_length)) /* modulus (INTEGER) */
|
||||
if (!freerdp_ber_read_integer_length(s, &modulus_length)) /* modulus (INTEGER) */
|
||||
goto error;
|
||||
|
||||
error++;
|
||||
@ -418,7 +421,7 @@ static BOOL certificate_read_x509_certificate(const rdpCertBlob* cert, rdpCertIn
|
||||
|
||||
error++;
|
||||
|
||||
if (!ber_read_integer_length(s, &exponent_length)) /* publicExponent (INTEGER) */
|
||||
if (!freerdp_ber_read_integer_length(s, &exponent_length)) /* publicExponent (INTEGER) */
|
||||
goto error;
|
||||
|
||||
error++;
|
||||
|
@ -17,13 +17,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <freerdp/config.h>
|
||||
|
||||
#include <winpr/assert.h>
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/wtypes.h>
|
||||
|
||||
#include <freerdp/crypto/der.h>
|
||||
|
||||
int _der_skip_length(int length)
|
||||
size_t freerdp_der_skip_length(size_t length)
|
||||
{
|
||||
if (length > 0x7F && length <= 0xFF)
|
||||
return 2;
|
||||
@ -33,28 +37,30 @@ int _der_skip_length(int length)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int der_write_length(wStream* s, int length)
|
||||
size_t freerdp_der_write_length(wStream* s, size_t length)
|
||||
{
|
||||
WINPR_ASSERT(length <= UINT16_MAX);
|
||||
|
||||
if (length > 0x7F && length <= 0xFF)
|
||||
{
|
||||
Stream_Write_UINT8(s, 0x81);
|
||||
Stream_Write_UINT8(s, length);
|
||||
Stream_Write_UINT8(s, (UINT8)length);
|
||||
return 2;
|
||||
}
|
||||
else if (length > 0xFF)
|
||||
{
|
||||
Stream_Write_UINT8(s, 0x82);
|
||||
Stream_Write_UINT16_BE(s, length);
|
||||
Stream_Write_UINT16_BE(s, (UINT16)length);
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
Stream_Write_UINT8(s, length);
|
||||
Stream_Write_UINT8(s, (UINT8)length);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int der_get_content_length(int length)
|
||||
size_t freerdp_der_get_content_length(size_t length)
|
||||
{
|
||||
if (length > 0x81 && length <= 0x102)
|
||||
return length - 3;
|
||||
@ -64,41 +70,116 @@ int der_get_content_length(int length)
|
||||
return length - 2;
|
||||
}
|
||||
|
||||
int der_skip_contextual_tag(int length)
|
||||
size_t freerdp_der_skip_contextual_tag(size_t length)
|
||||
{
|
||||
return _der_skip_length(length) + 1;
|
||||
return freerdp_der_skip_length(length) + 1;
|
||||
}
|
||||
|
||||
int der_write_contextual_tag(wStream* s, BYTE tag, int length, BOOL pc)
|
||||
size_t freerdp_der_write_contextual_tag(wStream* s, BYTE tag, size_t length, BOOL pc)
|
||||
{
|
||||
Stream_Write_UINT8(s, (ER_CLASS_CTXT | ER_PC(pc)) | (ER_TAG_MASK & tag));
|
||||
return der_write_length(s, length) + 1;
|
||||
Stream_Write_UINT8(s,
|
||||
(FREERDP_ER_CLASS_CTXT | FREERDP_ER_PC(pc)) | (FREERDP_ER_TAG_MASK & tag));
|
||||
return freerdp_der_write_length(s, length) + 1;
|
||||
}
|
||||
|
||||
static void der_write_universal_tag(wStream* s, BYTE tag, BOOL pc)
|
||||
static void freerdp_der_write_universal_tag(wStream* s, BYTE tag, BOOL pc)
|
||||
{
|
||||
Stream_Write_UINT8(s, (ER_CLASS_UNIV | ER_PC(pc)) | (ER_TAG_MASK & tag));
|
||||
Stream_Write_UINT8(s,
|
||||
(FREERDP_ER_CLASS_UNIV | FREERDP_ER_PC(pc)) | (FREERDP_ER_TAG_MASK & tag));
|
||||
}
|
||||
|
||||
size_t freerdp_der_skip_octet_string(size_t length)
|
||||
{
|
||||
return 1 + freerdp_der_skip_length(length) + length;
|
||||
}
|
||||
|
||||
void freerdp_der_write_octet_string(wStream* s, const BYTE* oct_str, size_t length)
|
||||
{
|
||||
freerdp_der_write_universal_tag(s, FREERDP_ER_TAG_OCTET_STRING, FALSE);
|
||||
freerdp_der_write_length(s, length);
|
||||
Stream_Write(s, oct_str, length);
|
||||
}
|
||||
|
||||
size_t freerdp_der_skip_sequence_tag(size_t length)
|
||||
{
|
||||
return 1 + freerdp_der_skip_length(length);
|
||||
}
|
||||
|
||||
size_t freerdp_der_write_sequence_tag(wStream* s, size_t length)
|
||||
{
|
||||
Stream_Write_UINT8(s, (FREERDP_ER_CLASS_UNIV | FREERDP_ER_CONSTRUCT) |
|
||||
(FREERDP_ER_TAG_MASK & FREERDP_ER_TAG_SEQUENCE));
|
||||
return freerdp_der_write_length(s, length) + 1;
|
||||
}
|
||||
|
||||
#if defined(WITH_FREERDP_3x_DEPRECATED)
|
||||
int _der_skip_length(int length)
|
||||
{
|
||||
WINPR_ASSERT(length >= 0);
|
||||
const size_t rc = freerdp_der_skip_length((size_t)length);
|
||||
WINPR_ASSERT(rc <= INT32_MAX);
|
||||
return (int)rc;
|
||||
}
|
||||
|
||||
int der_write_length(wStream* s, int length)
|
||||
{
|
||||
WINPR_ASSERT(length >= 0);
|
||||
const size_t rc = freerdp_der_write_length(s, (size_t)length);
|
||||
WINPR_ASSERT(rc <= INT32_MAX);
|
||||
return (int)rc;
|
||||
}
|
||||
|
||||
int der_get_content_length(int length)
|
||||
{
|
||||
WINPR_ASSERT(length >= 0);
|
||||
const size_t rc = freerdp_der_get_content_length((size_t)length);
|
||||
WINPR_ASSERT(rc <= INT32_MAX);
|
||||
return (int)rc;
|
||||
}
|
||||
|
||||
int der_skip_octet_string(int length)
|
||||
{
|
||||
return 1 + _der_skip_length(length) + length;
|
||||
}
|
||||
|
||||
void der_write_octet_string(wStream* s, BYTE* oct_str, int length)
|
||||
{
|
||||
der_write_universal_tag(s, ER_TAG_OCTET_STRING, FALSE);
|
||||
der_write_length(s, length);
|
||||
Stream_Write(s, oct_str, length);
|
||||
WINPR_ASSERT(length >= 0);
|
||||
const size_t rc = freerdp_der_skip_octet_string((size_t)length);
|
||||
WINPR_ASSERT(rc <= INT32_MAX);
|
||||
return (int)rc;
|
||||
}
|
||||
|
||||
int der_skip_sequence_tag(int length)
|
||||
{
|
||||
return 1 + _der_skip_length(length);
|
||||
WINPR_ASSERT(length >= 0);
|
||||
const size_t rc = freerdp_der_skip_sequence_tag((size_t)length);
|
||||
WINPR_ASSERT(rc <= INT32_MAX);
|
||||
return (int)rc;
|
||||
}
|
||||
|
||||
int der_write_sequence_tag(wStream* s, int length)
|
||||
{
|
||||
Stream_Write_UINT8(s, (ER_CLASS_UNIV | ER_CONSTRUCT) | (ER_TAG_MASK & ER_TAG_SEQUENCE));
|
||||
return der_write_length(s, length) + 1;
|
||||
WINPR_ASSERT(length >= 0);
|
||||
const size_t rc = freerdp_der_write_sequence_tag(s, (size_t)length);
|
||||
WINPR_ASSERT(rc <= INT32_MAX);
|
||||
return (int)rc;
|
||||
}
|
||||
|
||||
int der_skip_contextual_tag(int length)
|
||||
{
|
||||
WINPR_ASSERT(length >= 0);
|
||||
const size_t rc = freerdp_der_skip_contextual_tag((size_t)length);
|
||||
WINPR_ASSERT(rc <= INT32_MAX);
|
||||
return (int)rc;
|
||||
}
|
||||
|
||||
int der_write_contextual_tag(wStream* s, BYTE tag, int length, BOOL pc)
|
||||
{
|
||||
WINPR_ASSERT(length >= 0);
|
||||
const size_t rc = freerdp_der_write_contextual_tag(s, tag, (size_t)length, pc);
|
||||
WINPR_ASSERT(rc <= INT32_MAX);
|
||||
return (int)rc;
|
||||
}
|
||||
|
||||
void der_write_octet_string(wStream* s, const BYTE* oct_str, int length)
|
||||
{
|
||||
WINPR_ASSERT(length >= 0);
|
||||
freerdp_der_write_octet_string(s, oct_str, (size_t)length);
|
||||
}
|
||||
#endif
|
||||
|
@ -18,6 +18,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <freerdp/config.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
@ -26,7 +28,7 @@
|
||||
#include <freerdp/crypto/ber.h>
|
||||
#include <freerdp/crypto/der.h>
|
||||
|
||||
void er_read_length(wStream* s, int* length)
|
||||
void freerdp_er_read_length(wStream* s, size_t* length)
|
||||
{
|
||||
BYTE byte = 0;
|
||||
|
||||
@ -54,21 +56,15 @@ void er_read_length(wStream* s, int* length)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write er length.
|
||||
* @param s stream
|
||||
* @param length length
|
||||
*/
|
||||
|
||||
int er_write_length(wStream* s, int length, BOOL flag)
|
||||
size_t freerdp_er_write_length(wStream* s, size_t length, BOOL flag)
|
||||
{
|
||||
if (flag)
|
||||
return der_write_length(s, length);
|
||||
return freerdp_der_write_length(s, length);
|
||||
else
|
||||
return ber_write_length(s, length);
|
||||
return freerdp_ber_write_length(s, length);
|
||||
}
|
||||
|
||||
int _er_skip_length(int length)
|
||||
size_t freerdp_er_skip_length(size_t length)
|
||||
{
|
||||
if (length > 0x7F)
|
||||
return 3;
|
||||
@ -76,7 +72,7 @@ int _er_skip_length(int length)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int er_get_content_length(int length)
|
||||
size_t freerdp_er_get_content_length(size_t length)
|
||||
{
|
||||
if (length - 1 > 0x7F)
|
||||
return length - 4;
|
||||
@ -84,45 +80,25 @@ int er_get_content_length(int length)
|
||||
return length - 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read er Universal tag.
|
||||
* @param s A pointer to the stream to write to
|
||||
* @param tag er universally-defined tag
|
||||
* @return \b TRUE for success
|
||||
*/
|
||||
|
||||
BOOL er_read_universal_tag(wStream* s, BYTE tag, BOOL pc)
|
||||
BOOL freerdp_er_read_universal_tag(wStream* s, BYTE tag, BOOL pc)
|
||||
{
|
||||
BYTE byte = 0;
|
||||
|
||||
Stream_Read_UINT8(s, byte);
|
||||
|
||||
if (byte != (ER_CLASS_UNIV | ER_PC(pc) | (ER_TAG_MASK & tag)))
|
||||
if (byte != (FREERDP_ER_CLASS_UNIV | FREERDP_ER_PC(pc) | (FREERDP_ER_TAG_MASK & tag)))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write er Universal tag.
|
||||
* @param s stream
|
||||
* @param tag er universally-defined tag
|
||||
* @param pc primitive (FALSE) or constructed (TRUE)
|
||||
*/
|
||||
|
||||
void er_write_universal_tag(wStream* s, BYTE tag, BOOL pc)
|
||||
void freerdp_er_write_universal_tag(wStream* s, BYTE tag, BOOL pc)
|
||||
{
|
||||
Stream_Write_UINT8(s, (ER_CLASS_UNIV | ER_PC(pc)) | (ER_TAG_MASK & tag));
|
||||
Stream_Write_UINT8(s,
|
||||
(FREERDP_ER_CLASS_UNIV | FREERDP_ER_PC(pc)) | (FREERDP_ER_TAG_MASK & tag));
|
||||
}
|
||||
|
||||
/**
|
||||
* Read er Application tag.
|
||||
* @param s stream
|
||||
* @param tag er application-defined tag
|
||||
* @param length length
|
||||
*/
|
||||
|
||||
BOOL er_read_application_tag(wStream* s, BYTE tag, int* length)
|
||||
BOOL freerdp_er_read_application_tag(wStream* s, BYTE tag, size_t* length)
|
||||
{
|
||||
BYTE byte = 0;
|
||||
|
||||
@ -130,7 +106,7 @@ BOOL er_read_application_tag(wStream* s, BYTE tag, int* length)
|
||||
{
|
||||
Stream_Read_UINT8(s, byte);
|
||||
|
||||
if (byte != ((ER_CLASS_APPL | ER_CONSTRUCT) | ER_TAG_MASK))
|
||||
if (byte != ((FREERDP_ER_CLASS_APPL | FREERDP_ER_CONSTRUCT) | FREERDP_ER_TAG_MASK))
|
||||
return FALSE;
|
||||
|
||||
Stream_Read_UINT8(s, byte);
|
||||
@ -138,113 +114,103 @@ BOOL er_read_application_tag(wStream* s, BYTE tag, int* length)
|
||||
if (byte != tag)
|
||||
return FALSE;
|
||||
|
||||
er_read_length(s, length);
|
||||
freerdp_er_read_length(s, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stream_Read_UINT8(s, byte);
|
||||
|
||||
if (byte != ((ER_CLASS_APPL | ER_CONSTRUCT) | (ER_TAG_MASK & tag)))
|
||||
if (byte != ((FREERDP_ER_CLASS_APPL | FREERDP_ER_CONSTRUCT) | (FREERDP_ER_TAG_MASK & tag)))
|
||||
return FALSE;
|
||||
|
||||
er_read_length(s, length);
|
||||
freerdp_er_read_length(s, length);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write er Application tag.
|
||||
* @param s stream
|
||||
* @param tag er application-defined tag
|
||||
* @param length length
|
||||
*/
|
||||
|
||||
void er_write_application_tag(wStream* s, BYTE tag, int length, BOOL flag)
|
||||
void freerdp_er_write_application_tag(wStream* s, BYTE tag, size_t length, BOOL flag)
|
||||
{
|
||||
if (tag > 30)
|
||||
{
|
||||
Stream_Write_UINT8(s, (ER_CLASS_APPL | ER_CONSTRUCT) | ER_TAG_MASK);
|
||||
Stream_Write_UINT8(s, (FREERDP_ER_CLASS_APPL | FREERDP_ER_CONSTRUCT) | FREERDP_ER_TAG_MASK);
|
||||
Stream_Write_UINT8(s, tag);
|
||||
er_write_length(s, length, flag);
|
||||
freerdp_er_write_length(s, length, flag);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stream_Write_UINT8(s, (ER_CLASS_APPL | ER_CONSTRUCT) | (ER_TAG_MASK & tag));
|
||||
er_write_length(s, length, flag);
|
||||
Stream_Write_UINT8(s, (FREERDP_ER_CLASS_APPL | FREERDP_ER_CONSTRUCT) |
|
||||
(FREERDP_ER_TAG_MASK & tag));
|
||||
freerdp_er_write_length(s, length, flag);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL er_read_contextual_tag(wStream* s, BYTE tag, int* length, BOOL pc)
|
||||
BOOL freerdp_er_read_contextual_tag(wStream* s, BYTE tag, size_t* length, BOOL pc)
|
||||
{
|
||||
BYTE byte = 0;
|
||||
|
||||
Stream_Read_UINT8(s, byte);
|
||||
|
||||
if (byte != ((ER_CLASS_CTXT | ER_PC(pc)) | (ER_TAG_MASK & tag)))
|
||||
if (byte != ((FREERDP_ER_CLASS_CTXT | FREERDP_ER_PC(pc)) | (FREERDP_ER_TAG_MASK & tag)))
|
||||
{
|
||||
Stream_Rewind(s, 1);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
er_read_length(s, length);
|
||||
freerdp_er_read_length(s, length);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int er_write_contextual_tag(wStream* s, BYTE tag, int length, BOOL pc, BOOL flag)
|
||||
size_t freerdp_er_write_contextual_tag(wStream* s, BYTE tag, size_t length, BOOL pc, BOOL flag)
|
||||
{
|
||||
Stream_Write_UINT8(s, (ER_CLASS_CTXT | ER_PC(pc)) | (ER_TAG_MASK & tag));
|
||||
return er_write_length(s, length, flag) + 1;
|
||||
Stream_Write_UINT8(s,
|
||||
(FREERDP_ER_CLASS_CTXT | FREERDP_ER_PC(pc)) | (FREERDP_ER_TAG_MASK & tag));
|
||||
return freerdp_er_write_length(s, length, flag) + 1;
|
||||
}
|
||||
|
||||
int er_skip_contextual_tag(int length)
|
||||
size_t freerdp_er_skip_contextual_tag(size_t length)
|
||||
{
|
||||
return _er_skip_length(length) + 1;
|
||||
return freerdp_er_skip_length(length) + 1;
|
||||
}
|
||||
|
||||
BOOL er_read_sequence_tag(wStream* s, int* length)
|
||||
BOOL freerdp_er_read_sequence_tag(wStream* s, size_t* length)
|
||||
{
|
||||
BYTE byte = 0;
|
||||
|
||||
Stream_Read_UINT8(s, byte);
|
||||
|
||||
if (byte != ((ER_CLASS_UNIV | ER_CONSTRUCT) | (ER_TAG_SEQUENCE_OF)))
|
||||
if (byte != ((FREERDP_ER_CLASS_UNIV | FREERDP_ER_CONSTRUCT) | (FREERDP_ER_TAG_SEQUENCE_OF)))
|
||||
return FALSE;
|
||||
|
||||
er_read_length(s, length);
|
||||
freerdp_er_read_length(s, length);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write er SEQUENCE tag.
|
||||
* @param s stream
|
||||
* @param length length
|
||||
*/
|
||||
|
||||
int er_write_sequence_tag(wStream* s, int length, BOOL flag)
|
||||
size_t freerdp_er_write_sequence_tag(wStream* s, size_t length, BOOL flag)
|
||||
{
|
||||
Stream_Write_UINT8(s, (ER_CLASS_UNIV | ER_CONSTRUCT) | (ER_TAG_MASK & ER_TAG_SEQUENCE));
|
||||
return er_write_length(s, length, flag) + 1;
|
||||
Stream_Write_UINT8(s, (FREERDP_ER_CLASS_UNIV | FREERDP_ER_CONSTRUCT) |
|
||||
(FREERDP_ER_TAG_MASK & FREERDP_ER_TAG_SEQUENCE));
|
||||
return freerdp_er_write_length(s, length, flag) + 1;
|
||||
}
|
||||
|
||||
int er_skip_sequence(int length)
|
||||
size_t freerdp_er_skip_sequence(size_t length)
|
||||
{
|
||||
return 1 + _er_skip_length(length) + length;
|
||||
return 1 + freerdp_er_skip_length(length) + length;
|
||||
}
|
||||
|
||||
int er_skip_sequence_tag(int length)
|
||||
size_t freerdp_er_skip_sequence_tag(size_t length)
|
||||
{
|
||||
return 1 + _er_skip_length(length);
|
||||
return 1 + freerdp_er_skip_length(length);
|
||||
}
|
||||
|
||||
BOOL er_read_enumerated(wStream* s, BYTE* enumerated, BYTE count)
|
||||
BOOL freerdp_er_read_enumerated(wStream* s, BYTE* enumerated, BYTE count)
|
||||
{
|
||||
int length = 0;
|
||||
size_t length = 0;
|
||||
|
||||
er_read_universal_tag(s, ER_TAG_ENUMERATED, FALSE);
|
||||
er_read_length(s, &length);
|
||||
freerdp_er_read_universal_tag(s, FREERDP_ER_TAG_ENUMERATED, FALSE);
|
||||
freerdp_er_read_length(s, &length);
|
||||
|
||||
if (length == 1)
|
||||
Stream_Read_UINT8(s, *enumerated);
|
||||
@ -258,79 +224,66 @@ BOOL er_read_enumerated(wStream* s, BYTE* enumerated, BYTE count)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void er_write_enumerated(wStream* s, BYTE enumerated, BYTE count, BOOL flag)
|
||||
void freerdp_er_write_enumerated(wStream* s, BYTE enumerated, BYTE count, BOOL flag)
|
||||
{
|
||||
er_write_universal_tag(s, ER_TAG_ENUMERATED, FALSE);
|
||||
er_write_length(s, 1, flag);
|
||||
freerdp_er_write_universal_tag(s, FREERDP_ER_TAG_ENUMERATED, FALSE);
|
||||
freerdp_er_write_length(s, 1, flag);
|
||||
Stream_Write_UINT8(s, enumerated);
|
||||
}
|
||||
|
||||
BOOL er_read_bit_string(wStream* s, int* length, BYTE* padding)
|
||||
BOOL freerdp_er_read_bit_string(wStream* s, size_t* length, BYTE* padding)
|
||||
{
|
||||
er_read_universal_tag(s, ER_TAG_BIT_STRING, FALSE);
|
||||
er_read_length(s, length);
|
||||
freerdp_er_read_universal_tag(s, FREERDP_ER_TAG_BIT_STRING, FALSE);
|
||||
freerdp_er_read_length(s, length);
|
||||
Stream_Read_UINT8(s, *padding);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL er_write_bit_string_tag(wStream* s, UINT32 length, BYTE padding, BOOL flag)
|
||||
BOOL freerdp_er_write_bit_string_tag(wStream* s, UINT32 length, BYTE padding, BOOL flag)
|
||||
{
|
||||
er_write_universal_tag(s, ER_TAG_BIT_STRING, FALSE);
|
||||
er_write_length(s, length, flag);
|
||||
freerdp_er_write_universal_tag(s, FREERDP_ER_TAG_BIT_STRING, FALSE);
|
||||
freerdp_er_write_length(s, length, flag);
|
||||
Stream_Write_UINT8(s, padding);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL er_read_octet_string(wStream* s, int* length)
|
||||
BOOL freerdp_er_read_octet_string(wStream* s, size_t* length)
|
||||
{
|
||||
if (!er_read_universal_tag(s, ER_TAG_OCTET_STRING, FALSE))
|
||||
if (!freerdp_er_read_universal_tag(s, FREERDP_ER_TAG_OCTET_STRING, FALSE))
|
||||
return FALSE;
|
||||
er_read_length(s, length);
|
||||
freerdp_er_read_length(s, length);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a er OCTET_STRING
|
||||
* @param s stream
|
||||
* @param oct_str octet string
|
||||
* @param length string length
|
||||
*/
|
||||
|
||||
void er_write_octet_string(wStream* s, BYTE* oct_str, int length, BOOL flag)
|
||||
void freerdp_er_write_octet_string(wStream* s, const BYTE* oct_str, size_t length, BOOL flag)
|
||||
{
|
||||
er_write_universal_tag(s, ER_TAG_OCTET_STRING, FALSE);
|
||||
er_write_length(s, length, flag);
|
||||
freerdp_er_write_universal_tag(s, FREERDP_ER_TAG_OCTET_STRING, FALSE);
|
||||
freerdp_er_write_length(s, length, flag);
|
||||
Stream_Write(s, oct_str, length);
|
||||
}
|
||||
|
||||
int er_write_octet_string_tag(wStream* s, int length, BOOL flag)
|
||||
size_t freerdp_er_write_octet_string_tag(wStream* s, size_t length, BOOL flag)
|
||||
{
|
||||
er_write_universal_tag(s, ER_TAG_OCTET_STRING, FALSE);
|
||||
er_write_length(s, length, flag);
|
||||
return 1 + _er_skip_length(length);
|
||||
freerdp_er_write_universal_tag(s, FREERDP_ER_TAG_OCTET_STRING, FALSE);
|
||||
freerdp_er_write_length(s, length, flag);
|
||||
return 1 + freerdp_er_skip_length(length);
|
||||
}
|
||||
|
||||
int er_skip_octet_string(int length)
|
||||
size_t freerdp_er_skip_octet_string(size_t length)
|
||||
{
|
||||
return 1 + _er_skip_length(length) + length;
|
||||
return 1 + freerdp_er_skip_length(length) + length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a er BOOLEAN
|
||||
* @param s A pointer to the stream to read from
|
||||
* @param value A pointer to read the data to
|
||||
*/
|
||||
|
||||
BOOL er_read_BOOL(wStream* s, BOOL* value)
|
||||
BOOL freerdp_er_read_BOOL(wStream* s, BOOL* value)
|
||||
{
|
||||
int length = 0;
|
||||
size_t length = 0;
|
||||
BYTE v = 0;
|
||||
|
||||
if (!er_read_universal_tag(s, ER_TAG_BOOLEAN, FALSE))
|
||||
if (!freerdp_er_read_universal_tag(s, FREERDP_ER_TAG_BOOLEAN, FALSE))
|
||||
return FALSE;
|
||||
er_read_length(s, &length);
|
||||
freerdp_er_read_length(s, &length);
|
||||
if (length != 1)
|
||||
return FALSE;
|
||||
Stream_Read_UINT8(s, v);
|
||||
@ -338,25 +291,19 @@ BOOL er_read_BOOL(wStream* s, BOOL* value)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a er BOOLEAN
|
||||
* @param s A pointer to the stream to write to
|
||||
* @param value The value to write
|
||||
*/
|
||||
|
||||
void er_write_BOOL(wStream* s, BOOL value)
|
||||
void freerdp_er_write_BOOL(wStream* s, BOOL value)
|
||||
{
|
||||
er_write_universal_tag(s, ER_TAG_BOOLEAN, FALSE);
|
||||
er_write_length(s, 1, FALSE);
|
||||
freerdp_er_write_universal_tag(s, FREERDP_ER_TAG_BOOLEAN, FALSE);
|
||||
freerdp_er_write_length(s, 1, FALSE);
|
||||
Stream_Write_UINT8(s, (value == TRUE) ? 0xFF : 0);
|
||||
}
|
||||
|
||||
BOOL er_read_integer(wStream* s, UINT32* value)
|
||||
BOOL freerdp_er_read_integer(wStream* s, INT32* value)
|
||||
{
|
||||
int length = 0;
|
||||
size_t length = 0;
|
||||
|
||||
er_read_universal_tag(s, ER_TAG_INTEGER, FALSE);
|
||||
er_read_length(s, &length);
|
||||
freerdp_er_read_universal_tag(s, FREERDP_ER_TAG_INTEGER, FALSE);
|
||||
freerdp_er_read_length(s, &length);
|
||||
|
||||
if (value == NULL)
|
||||
{
|
||||
@ -391,55 +338,268 @@ BOOL er_read_integer(wStream* s, UINT32* value)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a er INTEGER
|
||||
* @param s A pointer to the stream to write to
|
||||
* @param value the value to write
|
||||
*/
|
||||
|
||||
int er_write_integer(wStream* s, INT32 value)
|
||||
size_t freerdp_er_write_integer(wStream* s, INT32 value)
|
||||
{
|
||||
er_write_universal_tag(s, ER_TAG_INTEGER, FALSE);
|
||||
freerdp_er_write_universal_tag(s, FREERDP_ER_TAG_INTEGER, FALSE);
|
||||
|
||||
if (value <= 127 && value >= -128)
|
||||
{
|
||||
er_write_length(s, 1, FALSE);
|
||||
freerdp_er_write_length(s, 1, FALSE);
|
||||
Stream_Write_UINT8(s, value);
|
||||
return 2;
|
||||
}
|
||||
else if (value <= 32767 && value >= -32768)
|
||||
{
|
||||
er_write_length(s, 2, FALSE);
|
||||
freerdp_er_write_length(s, 2, FALSE);
|
||||
Stream_Write_UINT16_BE(s, value);
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
er_write_length(s, 4, FALSE);
|
||||
freerdp_er_write_length(s, 4, FALSE);
|
||||
Stream_Write_UINT32_BE(s, value);
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
|
||||
int er_skip_integer(INT32 value)
|
||||
size_t freerdp_er_skip_integer(INT32 value)
|
||||
{
|
||||
if (value <= 127 && value >= -128)
|
||||
{
|
||||
return _er_skip_length(1) + 2;
|
||||
return freerdp_er_skip_length(1) + 2;
|
||||
}
|
||||
else if (value <= 32767 && value >= -32768)
|
||||
{
|
||||
return _er_skip_length(2) + 3;
|
||||
return freerdp_er_skip_length(2) + 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _er_skip_length(4) + 5;
|
||||
return freerdp_er_skip_length(4) + 5;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL freerdp_er_read_integer_length(wStream* s, size_t* length)
|
||||
{
|
||||
freerdp_er_read_universal_tag(s, FREERDP_ER_TAG_INTEGER, FALSE);
|
||||
freerdp_er_read_length(s, length);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if defined(WITH_FREERDP_3x_DEPRECATED)
|
||||
|
||||
void er_read_length(wStream* s, int* length)
|
||||
{
|
||||
WINPR_ASSERT(length);
|
||||
size_t len = 0;
|
||||
freerdp_er_read_length(s, &len);
|
||||
WINPR_ASSERT(len <= INT32_MAX);
|
||||
*length = (int)len;
|
||||
}
|
||||
|
||||
int er_write_length(wStream* s, int length, BOOL flag)
|
||||
{
|
||||
WINPR_ASSERT(length >= 0);
|
||||
const size_t rc = freerdp_er_write_length(s, (size_t)length, flag);
|
||||
WINPR_ASSERT(rc <= INT32_MAX);
|
||||
return (int)rc;
|
||||
}
|
||||
|
||||
int _er_skip_length(int length)
|
||||
{
|
||||
WINPR_ASSERT(length >= 0);
|
||||
const size_t rc = freerdp_er_skip_length((size_t)length);
|
||||
WINPR_ASSERT(rc <= INT32_MAX);
|
||||
return (int)rc;
|
||||
}
|
||||
|
||||
int er_get_content_length(int length)
|
||||
{
|
||||
WINPR_ASSERT(length >= 0);
|
||||
const size_t rc = freerdp_er_get_content_length((size_t)length);
|
||||
WINPR_ASSERT(rc <= INT32_MAX);
|
||||
return (int)rc;
|
||||
}
|
||||
|
||||
BOOL er_read_universal_tag(wStream* s, BYTE tag, BOOL pc)
|
||||
{
|
||||
return freerdp_er_read_universal_tag(s, tag, pc);
|
||||
}
|
||||
|
||||
void er_write_universal_tag(wStream* s, BYTE tag, BOOL pc)
|
||||
{
|
||||
freerdp_er_write_universal_tag(s, tag, pc);
|
||||
}
|
||||
|
||||
BOOL er_read_application_tag(wStream* s, BYTE tag, int* length)
|
||||
{
|
||||
WINPR_ASSERT(length);
|
||||
size_t len = 0;
|
||||
return freerdp_er_read_application_tag(s, tag, &len);
|
||||
WINPR_ASSERT(len <= INT32_MAX);
|
||||
*length = (int)len;
|
||||
}
|
||||
|
||||
void er_write_application_tag(wStream* s, BYTE tag, int length, BOOL flag)
|
||||
{
|
||||
WINPR_ASSERT(length >= 0);
|
||||
freerdp_er_write_application_tag(s, tag, (size_t)length, flag);
|
||||
}
|
||||
|
||||
BOOL er_read_enumerated(wStream* s, BYTE* enumerated, BYTE count)
|
||||
{
|
||||
WINPR_ASSERT(enumerated);
|
||||
return freerdp_er_read_enumerated(s, enumerated, count);
|
||||
}
|
||||
|
||||
void er_write_enumerated(wStream* s, BYTE enumerated, BYTE count, BOOL flag)
|
||||
{
|
||||
freerdp_er_write_enumerated(s, enumerated, count, flag);
|
||||
}
|
||||
|
||||
BOOL er_read_contextual_tag(wStream* s, BYTE tag, int* length, BOOL pc)
|
||||
{
|
||||
WINPR_ASSERT(length);
|
||||
size_t len = 0;
|
||||
const BOOL rc = freerdp_er_read_contextual_tag(s, tag, &len, pc);
|
||||
WINPR_ASSERT(len <= INT32_MAX);
|
||||
*length = (int)len;
|
||||
return rc;
|
||||
}
|
||||
|
||||
int er_write_contextual_tag(wStream* s, BYTE tag, int length, BOOL pc, BOOL flag)
|
||||
{
|
||||
WINPR_ASSERT(length >= 0);
|
||||
const size_t rc = freerdp_er_write_contextual_tag(s, tag, (size_t)length, pc, flag);
|
||||
WINPR_ASSERT(rc <= INT32_MAX);
|
||||
return (int)rc;
|
||||
}
|
||||
|
||||
int er_skip_contextual_tag(int length)
|
||||
{
|
||||
WINPR_ASSERT(length >= 0);
|
||||
const size_t rc = freerdp_er_skip_contextual_tag((size_t)length);
|
||||
WINPR_ASSERT(rc <= INT32_MAX);
|
||||
return (int)rc;
|
||||
}
|
||||
|
||||
BOOL er_read_sequence_tag(wStream* s, int* length)
|
||||
{
|
||||
WINPR_ASSERT(length);
|
||||
size_t len = 0;
|
||||
const BOOL rc = freerdp_er_read_sequence_tag(s, &len);
|
||||
WINPR_ASSERT(len <= INT32_MAX);
|
||||
*length = (int)len;
|
||||
return rc;
|
||||
}
|
||||
|
||||
int er_write_sequence_tag(wStream* s, int length, BOOL flag)
|
||||
{
|
||||
WINPR_ASSERT(length >= 0);
|
||||
const size_t rc = freerdp_er_write_sequence_tag(s, (size_t)length, flag);
|
||||
WINPR_ASSERT(rc <= INT32_MAX);
|
||||
return (int)rc;
|
||||
}
|
||||
|
||||
int er_skip_sequence(int length)
|
||||
{
|
||||
WINPR_ASSERT(length >= 0);
|
||||
const size_t rc = freerdp_er_skip_sequence((size_t)length);
|
||||
WINPR_ASSERT(rc <= INT32_MAX);
|
||||
return (int)rc;
|
||||
}
|
||||
|
||||
int er_skip_sequence_tag(int length)
|
||||
{
|
||||
WINPR_ASSERT(length >= 0);
|
||||
const size_t rc = freerdp_er_skip_sequence_tag((size_t)length);
|
||||
WINPR_ASSERT(rc <= INT32_MAX);
|
||||
return (int)rc;
|
||||
}
|
||||
|
||||
BOOL er_read_bit_string(wStream* s, int* length, BYTE* padding)
|
||||
{
|
||||
WINPR_ASSERT(length);
|
||||
size_t len = 0;
|
||||
const BOOL rc = freerdp_er_read_bit_string(s, &len, padding);
|
||||
WINPR_ASSERT(len <= INT32_MAX);
|
||||
*length = (int)len;
|
||||
return rc;
|
||||
}
|
||||
|
||||
BOOL er_write_bit_string_tag(wStream* s, UINT32 length, BYTE padding, BOOL flag)
|
||||
{
|
||||
return freerdp_er_write_bit_string_tag(s, length, padding, flag);
|
||||
}
|
||||
|
||||
BOOL er_read_octet_string(wStream* s, int* length)
|
||||
{
|
||||
WINPR_ASSERT(length);
|
||||
size_t len = 0;
|
||||
const BOOL rc = freerdp_er_read_octet_string(s, &len);
|
||||
WINPR_ASSERT(len <= INT32_MAX);
|
||||
*length = (int)len;
|
||||
return rc;
|
||||
}
|
||||
|
||||
void er_write_octet_string(wStream* s, BYTE* oct_str, int length, BOOL flag)
|
||||
{
|
||||
WINPR_ASSERT(length >= 0);
|
||||
freerdp_er_write_octet_string(s, oct_str, (size_t)length, flag);
|
||||
}
|
||||
|
||||
int er_write_octet_string_tag(wStream* s, int length, BOOL flag)
|
||||
{
|
||||
WINPR_ASSERT(length >= 0);
|
||||
const size_t rc = freerdp_er_write_octet_string_tag(s, (size_t)length, flag);
|
||||
WINPR_ASSERT(rc <= INT32_MAX);
|
||||
return (int)rc;
|
||||
}
|
||||
|
||||
int er_skip_octet_string(int length)
|
||||
{
|
||||
WINPR_ASSERT(length >= 0);
|
||||
const size_t rc = freerdp_er_skip_octet_string((size_t)length);
|
||||
WINPR_ASSERT(rc <= INT32_MAX);
|
||||
return (int)rc;
|
||||
}
|
||||
|
||||
BOOL er_read_BOOL(wStream* s, BOOL* value)
|
||||
{
|
||||
return freerdp_er_read_BOOL(s, value);
|
||||
}
|
||||
|
||||
void er_write_BOOL(wStream* s, BOOL value)
|
||||
{
|
||||
freerdp_er_write_BOOL(s, value);
|
||||
}
|
||||
|
||||
BOOL er_read_integer(wStream* s, INT32* value)
|
||||
{
|
||||
return freerdp_er_read_integer_length(s, value);
|
||||
}
|
||||
|
||||
int er_write_integer(wStream* s, INT32 value)
|
||||
{
|
||||
const size_t rc = freerdp_er_write_integer(s, value);
|
||||
WINPR_ASSERT(rc <= INT32_MAX);
|
||||
return (int)rc;
|
||||
}
|
||||
|
||||
BOOL er_read_integer_length(wStream* s, int* length)
|
||||
{
|
||||
er_read_universal_tag(s, ER_TAG_INTEGER, FALSE);
|
||||
er_read_length(s, length);
|
||||
return TRUE;
|
||||
WINPR_ASSERT(length);
|
||||
size_t len = 0;
|
||||
const BOOL rc = freerdp_er_read_integer_length(s, &len);
|
||||
WINPR_ASSERT(len <= INT32_MAX);
|
||||
*length = (int)len;
|
||||
return rc;
|
||||
}
|
||||
|
||||
int er_skip_integer(INT32 value)
|
||||
{
|
||||
WINPR_ASSERT(value >= 0);
|
||||
const size_t rc = freerdp_er_skip_length(value);
|
||||
WINPR_ASSERT(rc <= INT32_MAX);
|
||||
return (int)rc;
|
||||
}
|
||||
#endif
|
||||
|
@ -26,16 +26,7 @@
|
||||
#include <freerdp/log.h>
|
||||
#define TAG FREERDP_TAG("crypto.per")
|
||||
|
||||
/**
|
||||
* Read PER length.
|
||||
*
|
||||
* @param s stream to read from
|
||||
* @param length A pointer to return the length read, must not be NULL
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise.
|
||||
*/
|
||||
|
||||
BOOL per_read_length(wStream* s, UINT16* length)
|
||||
BOOL freerdp_per_read_length(wStream* s, UINT16* length)
|
||||
{
|
||||
BYTE byte = 0;
|
||||
|
||||
@ -63,15 +54,7 @@ BOOL per_read_length(wStream* s, UINT16* length)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write PER length.
|
||||
* @param s stream
|
||||
* @param length length
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise.
|
||||
*/
|
||||
|
||||
BOOL per_write_length(wStream* s, UINT16 length)
|
||||
BOOL freerdp_per_write_length(wStream* s, UINT16 length)
|
||||
{
|
||||
if (length > 0x7F)
|
||||
{
|
||||
@ -88,15 +71,7 @@ BOOL per_write_length(wStream* s, UINT16 length)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read PER choice.
|
||||
* @param s stream
|
||||
* @param choice choice
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise.
|
||||
*/
|
||||
|
||||
BOOL per_read_choice(wStream* s, BYTE* choice)
|
||||
BOOL freerdp_per_read_choice(wStream* s, BYTE* choice)
|
||||
{
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
||||
return FALSE;
|
||||
@ -105,15 +80,7 @@ BOOL per_read_choice(wStream* s, BYTE* choice)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write PER CHOICE.
|
||||
* @param s stream
|
||||
* @param choice index of chosen field
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise.
|
||||
*/
|
||||
|
||||
BOOL per_write_choice(wStream* s, BYTE choice)
|
||||
BOOL freerdp_per_write_choice(wStream* s, BYTE choice)
|
||||
{
|
||||
if (!Stream_EnsureRemainingCapacity(s, 1))
|
||||
return FALSE;
|
||||
@ -121,15 +88,7 @@ BOOL per_write_choice(wStream* s, BYTE choice)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read PER selection.
|
||||
* @param s stream
|
||||
* @param selection selection
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise.
|
||||
*/
|
||||
|
||||
BOOL per_read_selection(wStream* s, BYTE* selection)
|
||||
BOOL freerdp_per_read_selection(wStream* s, BYTE* selection)
|
||||
{
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
||||
return FALSE;
|
||||
@ -139,15 +98,7 @@ BOOL per_read_selection(wStream* s, BYTE* selection)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write PER selection for OPTIONAL fields.
|
||||
* @param s stream
|
||||
* @param selection bit map of selected fields
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise.
|
||||
*/
|
||||
|
||||
BOOL per_write_selection(wStream* s, BYTE selection)
|
||||
BOOL freerdp_per_write_selection(wStream* s, BYTE selection)
|
||||
{
|
||||
if (!Stream_EnsureRemainingCapacity(s, 1))
|
||||
return FALSE;
|
||||
@ -155,15 +106,7 @@ BOOL per_write_selection(wStream* s, BYTE selection)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read PER number of sets.
|
||||
* @param s stream
|
||||
* @param number number of sets
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise.
|
||||
*/
|
||||
|
||||
BOOL per_read_number_of_sets(wStream* s, BYTE* number)
|
||||
BOOL freerdp_per_read_number_of_sets(wStream* s, BYTE* number)
|
||||
{
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
||||
return FALSE;
|
||||
@ -173,16 +116,7 @@ BOOL per_read_number_of_sets(wStream* s, BYTE* number)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write PER number of sets for SET OF.
|
||||
*
|
||||
* @param s stream
|
||||
* @param number number of sets
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise.
|
||||
*/
|
||||
|
||||
BOOL per_write_number_of_sets(wStream* s, BYTE number)
|
||||
BOOL freerdp_per_write_number_of_sets(wStream* s, BYTE number)
|
||||
{
|
||||
if (!Stream_EnsureRemainingCapacity(s, 1))
|
||||
return FALSE;
|
||||
@ -190,16 +124,7 @@ BOOL per_write_number_of_sets(wStream* s, BYTE number)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read PER padding with zeros.
|
||||
*
|
||||
* @param s A stream to read from
|
||||
* @param length the data to write
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise.
|
||||
*/
|
||||
|
||||
BOOL per_read_padding(wStream* s, UINT16 length)
|
||||
BOOL freerdp_per_read_padding(wStream* s, UINT16 length)
|
||||
{
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, length))
|
||||
return FALSE;
|
||||
@ -208,15 +133,7 @@ BOOL per_read_padding(wStream* s, UINT16 length)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write PER padding with zeros.
|
||||
* @param s A stream to write to
|
||||
* @param length the data to write
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise.
|
||||
*/
|
||||
|
||||
BOOL per_write_padding(wStream* s, UINT16 length)
|
||||
BOOL freerdp_per_write_padding(wStream* s, UINT16 length)
|
||||
{
|
||||
if (!Stream_EnsureRemainingCapacity(s, length))
|
||||
return FALSE;
|
||||
@ -224,21 +141,13 @@ BOOL per_write_padding(wStream* s, UINT16 length)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read PER INTEGER.
|
||||
* @param s stream
|
||||
* @param integer integer
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise.
|
||||
*/
|
||||
|
||||
BOOL per_read_integer(wStream* s, UINT32* integer)
|
||||
BOOL freerdp_per_read_integer(wStream* s, UINT32* integer)
|
||||
{
|
||||
UINT16 length = 0;
|
||||
|
||||
WINPR_ASSERT(integer);
|
||||
|
||||
if (!per_read_length(s, &length))
|
||||
if (!freerdp_per_read_length(s, &length))
|
||||
return FALSE;
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, length))
|
||||
@ -256,19 +165,11 @@ BOOL per_read_integer(wStream* s, UINT32* integer)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write PER INTEGER.
|
||||
* @param s stream
|
||||
* @param integer integer
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise.
|
||||
*/
|
||||
|
||||
BOOL per_write_integer(wStream* s, UINT32 integer)
|
||||
BOOL freerdp_per_write_integer(wStream* s, UINT32 integer)
|
||||
{
|
||||
if (integer <= UINT8_MAX)
|
||||
{
|
||||
if (!per_write_length(s, 1))
|
||||
if (!freerdp_per_write_length(s, 1))
|
||||
return FALSE;
|
||||
if (!Stream_EnsureRemainingCapacity(s, 1))
|
||||
return FALSE;
|
||||
@ -276,7 +177,7 @@ BOOL per_write_integer(wStream* s, UINT32 integer)
|
||||
}
|
||||
else if (integer <= UINT16_MAX)
|
||||
{
|
||||
if (!per_write_length(s, 2))
|
||||
if (!freerdp_per_write_length(s, 2))
|
||||
return FALSE;
|
||||
if (!Stream_EnsureRemainingCapacity(s, 2))
|
||||
return FALSE;
|
||||
@ -284,7 +185,7 @@ BOOL per_write_integer(wStream* s, UINT32 integer)
|
||||
}
|
||||
else if (integer <= UINT32_MAX)
|
||||
{
|
||||
if (!per_write_length(s, 4))
|
||||
if (!freerdp_per_write_length(s, 4))
|
||||
return FALSE;
|
||||
if (!Stream_EnsureRemainingCapacity(s, 4))
|
||||
return FALSE;
|
||||
@ -293,17 +194,7 @@ BOOL per_write_integer(wStream* s, UINT32 integer)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read PER INTEGER (UINT16).
|
||||
*
|
||||
* @param s The stream to read from
|
||||
* @param integer The integer result variable pointer, must not be NULL
|
||||
* @param min minimum value
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*/
|
||||
|
||||
BOOL per_read_integer16(wStream* s, UINT16* integer, UINT16 min)
|
||||
BOOL freerdp_per_read_integer16(wStream* s, UINT16* integer, UINT16 min)
|
||||
{
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
|
||||
return FALSE;
|
||||
@ -322,16 +213,7 @@ BOOL per_read_integer16(wStream* s, UINT16* integer, UINT16 min)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write PER INTEGER (UINT16).
|
||||
* @param s stream
|
||||
* @param integer integer
|
||||
* @param min minimum value
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise.
|
||||
*/
|
||||
|
||||
BOOL per_write_integer16(wStream* s, UINT16 integer, UINT16 min)
|
||||
BOOL freerdp_per_write_integer16(wStream* s, UINT16 integer, UINT16 min)
|
||||
{
|
||||
if (!Stream_EnsureRemainingCapacity(s, 2))
|
||||
return FALSE;
|
||||
@ -339,17 +221,7 @@ BOOL per_write_integer16(wStream* s, UINT16 integer, UINT16 min)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read PER ENUMERATED.
|
||||
*
|
||||
* @param s The stream to read from
|
||||
* @param enumerated enumerated result variable, must not be NULL
|
||||
* @param count enumeration count
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*/
|
||||
|
||||
BOOL per_read_enumerated(wStream* s, BYTE* enumerated, BYTE count)
|
||||
BOOL freerdp_per_read_enumerated(wStream* s, BYTE* enumerated, BYTE count)
|
||||
{
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
||||
return FALSE;
|
||||
@ -367,17 +239,7 @@ BOOL per_read_enumerated(wStream* s, BYTE* enumerated, BYTE count)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write PER ENUMERATED.
|
||||
*
|
||||
* @param s The stream to write to
|
||||
* @param enumerated enumerated
|
||||
* @param count enumeration count
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*/
|
||||
|
||||
BOOL per_write_enumerated(wStream* s, BYTE enumerated, BYTE count)
|
||||
BOOL freerdp_per_write_enumerated(wStream* s, BYTE enumerated, BYTE count)
|
||||
{
|
||||
if (!Stream_EnsureRemainingCapacity(s, 1))
|
||||
return FALSE;
|
||||
@ -385,7 +247,8 @@ BOOL per_write_enumerated(wStream* s, BYTE enumerated, BYTE count)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL per_check_oid_and_log_mismatch(const BYTE* got, const BYTE* expect, size_t length)
|
||||
static BOOL freerdp_per_check_oid_and_log_mismatch(const BYTE* got, const BYTE* expect,
|
||||
size_t length)
|
||||
{
|
||||
if (memcmp(got, expect, length) == 0)
|
||||
{
|
||||
@ -403,23 +266,13 @@ static BOOL per_check_oid_and_log_mismatch(const BYTE* got, const BYTE* expect,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read PER OBJECT_IDENTIFIER (OID).
|
||||
*
|
||||
* @param s The stream to read from
|
||||
* @param oid object identifier (OID)
|
||||
* @warning It works correctly only for limited set of OIDs.
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise
|
||||
*/
|
||||
|
||||
BOOL per_read_object_identifier(wStream* s, const BYTE oid[6])
|
||||
BOOL freerdp_per_read_object_identifier(wStream* s, const BYTE oid[6])
|
||||
{
|
||||
BYTE t12 = 0;
|
||||
UINT16 length = 0;
|
||||
BYTE a_oid[6] = { 0 };
|
||||
|
||||
if (!per_read_length(s, &length))
|
||||
if (!freerdp_per_read_length(s, &length))
|
||||
return FALSE;
|
||||
|
||||
if (length != 5)
|
||||
@ -440,19 +293,10 @@ BOOL per_read_object_identifier(wStream* s, const BYTE oid[6])
|
||||
Stream_Read_UINT8(s, a_oid[4]); /* tuple 5 */
|
||||
Stream_Read_UINT8(s, a_oid[5]); /* tuple 6 */
|
||||
|
||||
return per_check_oid_and_log_mismatch(a_oid, oid, sizeof(a_oid));
|
||||
return freerdp_per_check_oid_and_log_mismatch(a_oid, oid, sizeof(a_oid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Write PER OBJECT_IDENTIFIER (OID)
|
||||
* @param s stream
|
||||
* @param oid object identifier (oid)
|
||||
* @warning It works correctly only for limited set of OIDs.
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise.
|
||||
*/
|
||||
|
||||
BOOL per_write_object_identifier(wStream* s, const BYTE oid[6])
|
||||
BOOL freerdp_per_write_object_identifier(wStream* s, const BYTE oid[6])
|
||||
{
|
||||
BYTE t12 = oid[0] * 40 + oid[1];
|
||||
if (!Stream_EnsureRemainingCapacity(s, 6))
|
||||
@ -466,35 +310,17 @@ BOOL per_write_object_identifier(wStream* s, const BYTE oid[6])
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write PER string.
|
||||
* @param s stream
|
||||
* @param str string
|
||||
* @param length string length
|
||||
*/
|
||||
|
||||
static void per_write_string(wStream* s, BYTE* str, int length)
|
||||
static void freerdp_per_write_string(wStream* s, BYTE* str, int length)
|
||||
{
|
||||
for (int i = 0; i < length; i++)
|
||||
Stream_Write_UINT8(s, str[i]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read PER OCTET_STRING.
|
||||
*
|
||||
* @param s The stream to read from
|
||||
* @param oct_str octet string
|
||||
* @param length string length
|
||||
* @param min minimum length
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise.
|
||||
*/
|
||||
|
||||
BOOL per_read_octet_string(wStream* s, const BYTE* oct_str, UINT16 length, UINT16 min)
|
||||
BOOL freerdp_per_read_octet_string(wStream* s, const BYTE* oct_str, UINT16 length, UINT16 min)
|
||||
{
|
||||
UINT16 mlength = 0;
|
||||
|
||||
if (!per_read_length(s, &mlength))
|
||||
if (!freerdp_per_read_length(s, &mlength))
|
||||
return FALSE;
|
||||
|
||||
if (mlength + min != length)
|
||||
@ -509,26 +335,16 @@ BOOL per_read_octet_string(wStream* s, const BYTE* oct_str, UINT16 length, UINT1
|
||||
const BYTE* a_oct_str = Stream_ConstPointer(s);
|
||||
Stream_Seek(s, length);
|
||||
|
||||
return per_check_oid_and_log_mismatch(a_oct_str, oct_str, length);
|
||||
return freerdp_per_check_oid_and_log_mismatch(a_oct_str, oct_str, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write PER OCTET_STRING
|
||||
* @param s stream
|
||||
* @param oct_str octet string
|
||||
* @param length string length
|
||||
* @param min minimum string length
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise.
|
||||
*/
|
||||
|
||||
BOOL per_write_octet_string(wStream* s, const BYTE* oct_str, UINT16 length, UINT16 min)
|
||||
BOOL freerdp_per_write_octet_string(wStream* s, const BYTE* oct_str, UINT16 length, UINT16 min)
|
||||
{
|
||||
UINT16 mlength = 0;
|
||||
|
||||
mlength = (length >= min) ? length - min : min;
|
||||
|
||||
if (!per_write_length(s, mlength))
|
||||
if (!freerdp_per_write_length(s, mlength))
|
||||
return FALSE;
|
||||
|
||||
if (!Stream_EnsureRemainingCapacity(s, length))
|
||||
@ -538,20 +354,12 @@ BOOL per_write_octet_string(wStream* s, const BYTE* oct_str, UINT16 length, UINT
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read PER NumericString.
|
||||
* @param s stream
|
||||
* @param min minimum string length
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise.
|
||||
*/
|
||||
|
||||
BOOL per_read_numeric_string(wStream* s, UINT16 min)
|
||||
BOOL freerdp_per_read_numeric_string(wStream* s, UINT16 min)
|
||||
{
|
||||
size_t length = 0;
|
||||
UINT16 mlength = 0;
|
||||
|
||||
if (!per_read_length(s, &mlength))
|
||||
if (!freerdp_per_read_length(s, &mlength))
|
||||
return FALSE;
|
||||
|
||||
length = (mlength + min + 1) / 2;
|
||||
@ -563,23 +371,13 @@ BOOL per_read_numeric_string(wStream* s, UINT16 min)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write PER NumericString.
|
||||
* @param s stream
|
||||
* @param num_str numeric string
|
||||
* @param length string length
|
||||
* @param min minimum string length
|
||||
*
|
||||
* @return \b TRUE for success, \b FALSE otherwise.
|
||||
*/
|
||||
|
||||
BOOL per_write_numeric_string(wStream* s, const BYTE* num_str, UINT16 length, UINT16 min)
|
||||
BOOL freerdp_per_write_numeric_string(wStream* s, const BYTE* num_str, UINT16 length, UINT16 min)
|
||||
{
|
||||
WINPR_ASSERT(num_str || (length == 0));
|
||||
|
||||
const UINT16 mlength = (length >= min) ? length - min : min;
|
||||
|
||||
if (!per_write_length(s, mlength))
|
||||
if (!freerdp_per_write_length(s, mlength))
|
||||
return FALSE;
|
||||
|
||||
if (!Stream_EnsureRemainingCapacity(s, length))
|
||||
@ -600,3 +398,115 @@ BOOL per_write_numeric_string(wStream* s, const BYTE* num_str, UINT16 length, UI
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if defined(WITH_FREERDP_3x_DEPRECATED)
|
||||
BOOL per_read_length(wStream* s, UINT16* length)
|
||||
{
|
||||
return freerdp_per_read_length(s, length);
|
||||
}
|
||||
|
||||
BOOL per_write_length(wStream* s, UINT16 length)
|
||||
{
|
||||
return freerdp_per_write_length(s, length);
|
||||
}
|
||||
|
||||
BOOL per_read_choice(wStream* s, BYTE* choice)
|
||||
{
|
||||
return freerdp_per_read_choice(s, choice);
|
||||
}
|
||||
|
||||
BOOL per_write_choice(wStream* s, BYTE choice)
|
||||
{
|
||||
return freerdp_per_write_choice(s, choice);
|
||||
}
|
||||
|
||||
BOOL per_read_selection(wStream* s, BYTE* selection)
|
||||
{
|
||||
return freerdp_per_read_selection(s, selection);
|
||||
}
|
||||
|
||||
BOOL per_write_selection(wStream* s, BYTE selection)
|
||||
{
|
||||
return freerdp_per_write_selection(s, selection);
|
||||
}
|
||||
|
||||
BOOL per_read_number_of_sets(wStream* s, BYTE* number)
|
||||
{
|
||||
return freerdp_per_read_number_of_sets(s, number);
|
||||
}
|
||||
|
||||
BOOL per_write_number_of_sets(wStream* s, BYTE number)
|
||||
{
|
||||
return freerdp_per_write_number_of_sets(s, number);
|
||||
}
|
||||
|
||||
BOOL per_read_padding(wStream* s, UINT16 length)
|
||||
{
|
||||
return freerdp_per_read_padding(s, length);
|
||||
}
|
||||
|
||||
BOOL per_write_padding(wStream* s, UINT16 length)
|
||||
{
|
||||
return freerdp_per_write_padding(s, length);
|
||||
}
|
||||
|
||||
BOOL per_read_integer(wStream* s, UINT32* integer)
|
||||
{
|
||||
return freerdp_per_read_integer(s, integer);
|
||||
}
|
||||
|
||||
BOOL per_read_integer16(wStream* s, UINT16* integer, UINT16 min)
|
||||
{
|
||||
return freerdp_per_read_integer16(s, integer, min);
|
||||
}
|
||||
|
||||
BOOL per_write_integer(wStream* s, UINT32 integer)
|
||||
{
|
||||
return freerdp_per_write_integer(s, integer);
|
||||
}
|
||||
|
||||
BOOL per_write_integer16(wStream* s, UINT16 integer, UINT16 min)
|
||||
{
|
||||
return freerdp_per_write_integer16(s, integer, min);
|
||||
}
|
||||
|
||||
BOOL per_read_enumerated(wStream* s, BYTE* enumerated, BYTE count)
|
||||
{
|
||||
return freerdp_per_read_enumerated(s, enumerated, count);
|
||||
}
|
||||
|
||||
BOOL per_write_enumerated(wStream* s, BYTE enumerated, BYTE count)
|
||||
{
|
||||
return freerdp_per_write_enumerated(s, enumerated, count);
|
||||
}
|
||||
|
||||
BOOL per_write_object_identifier(wStream* s, const BYTE oid[6])
|
||||
{
|
||||
return freerdp_per_write_object_identifier(s, oid);
|
||||
}
|
||||
|
||||
BOOL per_read_object_identifier(wStream* s, const BYTE oid[6])
|
||||
{
|
||||
return freerdp_per_read_object_identifier(s, oid);
|
||||
}
|
||||
|
||||
BOOL per_read_octet_string(wStream* s, const BYTE* oct_str, UINT16 length, UINT16 min)
|
||||
{
|
||||
return freerdp_per_read_octet_string(s, oct_str, length, min);
|
||||
}
|
||||
|
||||
BOOL per_write_octet_string(wStream* s, const BYTE* oct_str, UINT16 length, UINT16 min)
|
||||
{
|
||||
return freerdp_per_write_octet_string(s, oct_str, length, min);
|
||||
}
|
||||
|
||||
BOOL per_read_numeric_string(wStream* s, UINT16 min)
|
||||
{
|
||||
return freerdp_per_read_numeric_string(s, min);
|
||||
}
|
||||
|
||||
BOOL per_write_numeric_string(wStream* s, const BYTE* num_str, UINT16 length, UINT16 min)
|
||||
{
|
||||
return freerdp_per_write_numeric_string(s, num_str, length, min);
|
||||
}
|
||||
#endif
|
||||
|
@ -76,6 +76,7 @@ int shadow_capture_align_clip_rect(RECTANGLE_16* rect, const RECTANGLE_16* clip)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if defined(WITH_FREERDP_3x_DEPRECATED)
|
||||
int shadow_capture_compare(const BYTE* WINPR_RESTRICT pData1, UINT32 nStep1, UINT32 nWidth,
|
||||
UINT32 nHeight, const BYTE* WINPR_RESTRICT pData2, UINT32 nStep2,
|
||||
RECTANGLE_16* WINPR_RESTRICT rect)
|
||||
@ -83,6 +84,7 @@ int shadow_capture_compare(const BYTE* WINPR_RESTRICT pData1, UINT32 nStep1, UIN
|
||||
return shadow_capture_compare_with_format(pData1, PIXEL_FORMAT_BGRX32, nStep1, nWidth, nHeight,
|
||||
pData2, PIXEL_FORMAT_BGRX32, nStep2, rect);
|
||||
}
|
||||
#endif
|
||||
|
||||
static BOOL color_equal(UINT32 colorA, UINT32 formatA, UINT32 colorB, UINT32 formatB)
|
||||
{
|
||||
|
@ -189,6 +189,7 @@ UINT32 shadow_enum_monitors(MONITOR_DEF* monitors, UINT32 maxMonitors)
|
||||
* and andmask data and fill into SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE
|
||||
* Caller should free the andMaskData and xorMaskData later.
|
||||
*/
|
||||
#if defined(WITH_FREERDP_3x_DEPRECATED)
|
||||
int shadow_subsystem_pointer_convert_alpha_pointer_data(
|
||||
const BYTE* WINPR_RESTRICT pixels, BOOL premultiplied, UINT32 width, UINT32 height,
|
||||
SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE* WINPR_RESTRICT pointerColor)
|
||||
@ -196,6 +197,7 @@ int shadow_subsystem_pointer_convert_alpha_pointer_data(
|
||||
return shadow_subsystem_pointer_convert_alpha_pointer_data_to_format(
|
||||
pixels, PIXEL_FORMAT_BGRX32, premultiplied, width, height, pointerColor);
|
||||
}
|
||||
#endif
|
||||
|
||||
int shadow_subsystem_pointer_convert_alpha_pointer_data_to_format(
|
||||
const BYTE* pixels, UINT32 format, BOOL premultiplied, UINT32 width, UINT32 height,
|
||||
|
Loading…
Reference in New Issue
Block a user