cscg24-guacamole

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

license.h (4208B)


      1/**
      2 * FreeRDP: A Remote Desktop Protocol Implementation
      3 * Licensing API
      4 *
      5 * Copyright 2018 David Fort <contact@hardening-consulting.com>
      6 *
      7 * Licensed under the Apache License, Version 2.0 (the "License");
      8 * you may not use this file except in compliance with the License.
      9 * You may obtain a copy of the License at
     10 *
     11 *     http://www.apache.org/licenses/LICENSE-2.0
     12 *
     13 * Unless required by applicable law or agreed to in writing, software
     14 * distributed under the License is distributed on an "AS IS" BASIS,
     15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16 * See the License for the specific language governing permissions and
     17 * limitations under the License.
     18 */
     19
     20#ifndef FREERDP_LICENSE_H
     21#define FREERDP_LICENSE_H
     22
     23#include <freerdp/api.h>
     24
     25typedef struct rdp_license rdpLicense;
     26
     27/** @brief Licensing Packet Types */
     28enum
     29{
     30	LICENSE_REQUEST = 0x01,
     31	PLATFORM_CHALLENGE = 0x02,
     32	NEW_LICENSE = 0x03,
     33	UPGRADE_LICENSE = 0x04,
     34	LICENSE_INFO = 0x12,
     35	NEW_LICENSE_REQUEST = 0x13,
     36	PLATFORM_CHALLENGE_RESPONSE = 0x15,
     37	ERROR_ALERT = 0xFF
     38};
     39
     40#define LICENSE_PKT_CS_MASK \
     41	(LICENSE_INFO | NEW_LICENSE_REQUEST | PLATFORM_CHALLENGE_RESPONSE | ERROR_ALERT)
     42#define LICENSE_PKT_SC_MASK \
     43	(LICENSE_REQUEST | PLATFORM_CHALLENGE | NEW_LICENSE | UPGRADE_LICENSE | ERROR_ALERT)
     44#define LICENSE_PKT_MASK (LICENSE_PKT_CS_MASK | LICENSE_PKT_SC_MASK)
     45
     46#define LICENSE_PREAMBLE_LENGTH 4
     47
     48/* Cryptographic Lengths */
     49
     50#define CLIENT_RANDOM_LENGTH 32
     51#define SERVER_RANDOM_LENGTH 32
     52#define MASTER_SECRET_LENGTH 48
     53#define PREMASTER_SECRET_LENGTH 48
     54#define SESSION_KEY_BLOB_LENGTH 48
     55#define MAC_SALT_KEY_LENGTH 16
     56#define LICENSING_ENCRYPTION_KEY_LENGTH 16
     57#define HWID_PLATFORM_ID_LENGTH 4
     58#define HWID_UNIQUE_DATA_LENGTH 16
     59#define HWID_LENGTH 20
     60#define LICENSING_PADDING_SIZE 8
     61
     62/* Preamble Flags */
     63
     64#define PREAMBLE_VERSION_2_0 0x02
     65#define PREAMBLE_VERSION_3_0 0x03
     66#define LicenseProtocolVersionMask 0x0F
     67#define EXTENDED_ERROR_MSG_SUPPORTED 0x80
     68
     69/** @brief binary Blob Types */
     70enum
     71{
     72	BB_ANY_BLOB = 0x0000,
     73	BB_DATA_BLOB = 0x0001,
     74	BB_RANDOM_BLOB = 0x0002,
     75	BB_CERTIFICATE_BLOB = 0x0003,
     76	BB_ERROR_BLOB = 0x0004,
     77	BB_ENCRYPTED_DATA_BLOB = 0x0009,
     78	BB_KEY_EXCHG_ALG_BLOB = 0x000D,
     79	BB_SCOPE_BLOB = 0x000E,
     80	BB_CLIENT_USER_NAME_BLOB = 0x000F,
     81	BB_CLIENT_MACHINE_NAME_BLOB = 0x0010
     82};
     83
     84/* License Key Exchange Algorithms */
     85
     86#define KEY_EXCHANGE_ALG_RSA 0x00000001
     87
     88/** @brief license Error Codes */
     89enum
     90{
     91	ERR_INVALID_SERVER_CERTIFICATE = 0x00000001,
     92	ERR_NO_LICENSE = 0x00000002,
     93	ERR_INVALID_MAC = 0x00000003,
     94	ERR_INVALID_SCOPE = 0x00000004,
     95	ERR_NO_LICENSE_SERVER = 0x00000006,
     96	STATUS_VALID_CLIENT = 0x00000007,
     97	ERR_INVALID_CLIENT = 0x00000008,
     98	ERR_INVALID_PRODUCT_ID = 0x0000000B,
     99	ERR_INVALID_MESSAGE_LENGTH = 0x0000000C
    100};
    101
    102/** @brief state Transition Codes */
    103enum
    104{
    105	ST_TOTAL_ABORT = 0x00000001,
    106	ST_NO_TRANSITION = 0x00000002,
    107	ST_RESET_PHASE_TO_START = 0x00000003,
    108	ST_RESEND_LAST_MESSAGE = 0x00000004
    109};
    110
    111/** @brief Platform Challenge Types */
    112enum
    113{
    114	WIN32_PLATFORM_CHALLENGE_TYPE = 0x0100,
    115	WIN16_PLATFORM_CHALLENGE_TYPE = 0x0200,
    116	WINCE_PLATFORM_CHALLENGE_TYPE = 0x0300,
    117	OTHER_PLATFORM_CHALLENGE_TYPE = 0xFF00
    118};
    119
    120/** @brief License Detail Levels */
    121enum
    122{
    123	LICENSE_DETAIL_SIMPLE = 0x0001,
    124	LICENSE_DETAIL_MODERATE = 0x0002,
    125	LICENSE_DETAIL_DETAIL = 0x0003
    126};
    127
    128/*
    129 * PlatformId:
    130 *
    131 * The most significant byte of the PlatformId field contains the operating system version of the
    132 * client. The second most significant byte of the PlatformId field identifies the ISV that provided
    133 * the client image. The remaining two bytes in the PlatformId field are used by the ISV to identify
    134 * the build number of the operating system.
    135 *
    136 * 0x04010000:
    137 *
    138 * CLIENT_OS_ID_WINNT_POST_52	(0x04000000)
    139 * CLIENT_IMAGE_ID_MICROSOFT	(0x00010000)
    140 */
    141enum
    142{
    143	CLIENT_OS_ID_WINNT_351 = 0x01000000,
    144	CLIENT_OS_ID_WINNT_40 = 0x02000000,
    145	CLIENT_OS_ID_WINNT_50 = 0x03000000,
    146	CLIENT_OS_ID_WINNT_POST_52 = 0x04000000,
    147
    148	CLIENT_IMAGE_ID_MICROSOFT = 0x00010000,
    149	CLIENT_IMAGE_ID_CITRIX = 0x00020000,
    150};
    151
    152#ifdef __cpluscplus
    153extern "C"
    154{
    155#endif
    156
    157	FREERDP_API BOOL license_send_valid_client_error_packet(rdpRdp* rdp);
    158
    159#ifdef __cpluscplus
    160}
    161#endif
    162
    163#endif /* FREERDP_LICENSE_H */