#ifndef __BITMAP_H
#define __BITMAP_H
+#include <freerdp/api.h>
#include <freerdp/types.h>
FREERDP_API boolean bitmap_decompress(uint8* srcData, uint8* dstData, int width, int height, int size, int srcBpp, int dstBpp);
#ifndef __MPPC_H
#define __MPPC_H
+#include <freerdp/api.h>
#include <freerdp/types.h>
/* Compression Types */
-#define PACKET_COMPRESSED 0x20
-#define PACKET_AT_FRONT 0x40
-#define PACKET_FLUSHED 0x80
-#define PACKET_COMPR_TYPE_8K 0x00
-#define PACKET_COMPR_TYPE_64K 0x01
-#define PACKET_COMPR_TYPE_RDP6 0x02
-#define PACKET_COMPR_TYPE_RDP61 0x03
-#define CompressionTypeMask 0x0F
+#define PACKET_COMPRESSED 0x20
+#define PACKET_AT_FRONT 0x40
+#define PACKET_FLUSHED 0x80
+#define PACKET_COMPR_TYPE_8K 0x00
+#define PACKET_COMPR_TYPE_64K 0x01
+#define PACKET_COMPR_TYPE_RDP6 0x02
+#define PACKET_COMPR_TYPE_RDP61 0x03
+#define CompressionTypeMask 0x0F
-#define RDP6_HISTORY_BUF_SIZE 65536
-#define RDP6_OFFSET_CACHE_SIZE 8
+#define RDP6_HISTORY_BUF_SIZE 65536
+#define RDP6_OFFSET_CACHE_SIZE 8
struct rdp_mppc_dec
{
#ifndef __MPPC_ENC_H
#define __MPPC_ENC_H
+#include <freerdp/api.h>
#include <freerdp/types.h>
#define PROTO_RDP_40 1
#include <freerdp/api.h>
#include <freerdp/settings.h>
-#include <freerdp/utils/blob.h>
#include <freerdp/utils/stream.h>
#include <freerdp/utils/hexdump.h>
#include <freerdp/api.h>
#include <freerdp/freerdp.h>
-#include <freerdp/utils/blob.h>
#include <freerdp/utils/memory.h>
struct crypto_sha1_struct
FREERDP_API boolean x509_verify_certificate(CryptoCert cert, char* certificate_store_path);
FREERDP_API rdpCertificateData* crypto_get_certificate_data(X509* xcert, char* hostname);
-FREERDP_API boolean crypto_cert_get_public_key(CryptoCert cert, rdpBlob* public_key);
+FREERDP_API boolean crypto_cert_get_public_key(CryptoCert cert, BYTE** PublicKey, DWORD* PublicKeyLength);
#define TSSK_KEY_LENGTH 64
extern const uint8 tssk_modulus[];
SSL* ssl;
int sockfd;
SSL_CTX* ctx;
- rdpBlob public_key;
+ BYTE* PublicKey;
+ DWORD PublicKeyLength;
rdpSettings* settings;
rdpCertificateStore* certificate_store;
};
#define __RDP_SETTINGS_H
#include <freerdp/types.h>
-#include <freerdp/utils/blob.h>
/* Performance Flags */
#define PERF_FLAG_NONE 0x00000000
struct rdp_CertInfo
{
- rdpBlob modulus;
+ BYTE* Modulus;
+ DWORD ModulusLength;
uint8 exponent[4];
};
typedef struct rdp_CertInfo rdpCertInfo;
struct rdp_key
{
- rdpBlob modulus;
- rdpBlob private_exponent;
+ BYTE* Modulus;
+ DWORD ModulusLength;
+ BYTE* PrivateExponent;
+ DWORD PrivateExponentLength;
uint8 exponent[4];
};
typedef struct rdp_key rdpKey;
ALIGN64 boolean autologon; /* 58 */
ALIGN64 boolean compression; /* 59 */
ALIGN64 uint32 performance_flags; /* 60 */
- ALIGN64 rdpBlob* password_cookie; /* 61 */
- ALIGN64 char* kerberos_kdc; /* 62 */
- ALIGN64 char* kerberos_realm; /* 63 */
- ALIGN64 boolean ts_gateway; /* 64 */
- ALIGN64 char* tsg_hostname; /* 65 */
- ALIGN64 char* tsg_username; /* 66 */
- ALIGN64 char* tsg_password; /* 67 */
- ALIGN64 boolean local; /* 68 */
- ALIGN64 boolean authentication_only; /* 69 */
- ALIGN64 boolean from_stdin; /* 70 */
- ALIGN64 boolean send_preconnection_pdu; /* 71 */
- ALIGN64 uint32 preconnection_id; /* 72 */
- ALIGN64 char* preconnection_blob; /* 73 */
- uint64 paddingC[80 - 74]; /* 74 */
+ ALIGN64 BYTE* password_cookie; /* 61 */
+ ALIGN64 DWORD password_cookie_length; /* 62 */
+ ALIGN64 char* kerberos_kdc; /* 63 */
+ ALIGN64 char* kerberos_realm; /* 64 */
+ ALIGN64 boolean ts_gateway; /* 65 */
+ ALIGN64 char* tsg_hostname; /* 66 */
+ ALIGN64 char* tsg_username; /* 67 */
+ ALIGN64 char* tsg_password; /* 68 */
+ ALIGN64 boolean local; /* 69 */
+ ALIGN64 boolean authentication_only; /* 70 */
+ ALIGN64 boolean from_stdin; /* 71 */
+ ALIGN64 boolean send_preconnection_pdu; /* 72 */
+ ALIGN64 uint32 preconnection_id; /* 73 */
+ ALIGN64 char* preconnection_blob; /* 74 */
+ uint64 paddingC[80 - 75]; /* 75 */
/* User Interface Parameters */
ALIGN64 boolean sw_gdi; /* 80 */
ALIGN64 char* privatekey_file; /* 249 */
ALIGN64 char* client_hostname; /* 250 */
ALIGN64 char* client_product_id; /* 251 */
- ALIGN64 rdpBlob* server_random; /* 252 */
- ALIGN64 rdpBlob* server_certificate; /* 253 */
- ALIGN64 boolean ignore_certificate; /* 254 */
- ALIGN64 rdpCertificate* server_cert; /* 255 */
- ALIGN64 char* rdp_key_file; /* 256 */
- ALIGN64 rdpKey* server_key; /* 257 */
- ALIGN64 char* certificate_name; /* 258 */
- uint64 paddingL[280 - 259]; /* 259 */
+ ALIGN64 BYTE* server_random; /* 252 */
+ ALIGN64 DWORD server_random_length; /* 253 */
+ ALIGN64 BYTE* server_certificate; /* 254 */
+ ALIGN64 DWORD server_certificate_length; /* 255 */
+ ALIGN64 boolean ignore_certificate; /* 256 */
+ ALIGN64 rdpCertificate* server_cert; /* 257 */
+ ALIGN64 char* rdp_key_file; /* 258 */
+ ALIGN64 rdpKey* server_key; /* 259 */
+ ALIGN64 char* certificate_name; /* 260 */
+ uint64 paddingL[280 - 261]; /* 261 */
/* Codecs */
ALIGN64 boolean rfx_codec; /* 280 */
+++ /dev/null
-/**
- * FreeRDP: A Remote Desktop Protocol Client
- * BLOB Utils
- *
- * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __BLOB_UTILS_H
-#define __BLOB_UTILS_H
-
-#include <string.h>
-#include <freerdp/api.h>
-
-struct rdp_blob
-{
- void* data;
- int length;
-};
-typedef struct rdp_blob rdpBlob;
-
-FREERDP_API void freerdp_blob_alloc(rdpBlob* blob, int length);
-FREERDP_API void freerdp_blob_free(rdpBlob* blob);
-FREERDP_API void freerdp_blob_copy(rdpBlob* dstblob, rdpBlob* srcblob);
-
-#endif /* __BLOB_UTILS_H */
#endif
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <freerdp/utils/memory.h>
#include "config.h"
#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <freerdp/utils/memory.h>
#include <freerdp/codec/mppc_dec.h>
#include <freerdp/codec/mppc_enc.h>
-#include <freerdp/utils/memory.h>
#define MPPC_ENC_DEBUG 0
}
while (padding == 0);
- freerdp_blob_alloc(&info->modulus, modulus_length);
- stream_read(s, info->modulus.data, modulus_length);
+ info->ModulusLength = modulus_length;
+ info->Modulus = (BYTE*) malloc(info->ModulusLength);
+ stream_read(s, info->Modulus, info->ModulusLength);
ber_read_integer_length(s, &exponent_length); /* publicExponent (INTEGER) */
stream_read(s, &info->exponent[4 - exponent_length], exponent_length);
- crypto_reverse(info->modulus.data, modulus_length);
+ crypto_reverse(info->Modulus, info->ModulusLength);
crypto_reverse(info->exponent, 4);
stream_detach(s);
uint32 modlen;
stream_read(s, magic, 4);
+
if (memcmp(magic, "RSA1", 4) != 0)
{
printf("gcc_process_server_public_key: magic error\n");
stream_read_uint32(s, datalen);
stream_read(s, certificate->cert_info.exponent, 4);
modlen = keylen - 8;
- freerdp_blob_alloc(&(certificate->cert_info.modulus), modlen);
- stream_read(s, certificate->cert_info.modulus.data, modlen);
+
+ certificate->cert_info.ModulusLength = modlen;
+ certificate->cert_info.Modulus = malloc(certificate->cert_info.ModulusLength);
+ stream_read(s, certificate->cert_info.Modulus, certificate->cert_info.ModulusLength);
/* 8 bytes of zero padding */
stream_seek(s, 8);
static boolean certificate_process_server_public_signature(rdpCertificate* certificate, uint8* sigdata, int sigdatalen, STREAM* s, uint32 siglen)
{
- uint8 md5hash[CRYPTO_MD5_DIGEST_LENGTH];
- uint8 encsig[TSSK_KEY_LENGTH + 8];
- uint8 sig[TSSK_KEY_LENGTH];
- CryptoMd5 md5ctx;
int i, sum;
+ CryptoMd5 md5ctx;
+ uint8 sig[TSSK_KEY_LENGTH];
+ uint8 encsig[TSSK_KEY_LENGTH + 8];
+ uint8 md5hash[CRYPTO_MD5_DIGEST_LENGTH];
md5ctx = crypto_md5_init();
crypto_md5_update(md5ctx, sigdata, sigdatalen);
sigdata = stream_get_tail(s) - 4;
stream_read_uint32(s, dwSigAlgId);
stream_read_uint32(s, dwKeyAlgId);
+
if (!(dwSigAlgId == SIGNATURE_ALG_RSA && dwKeyAlgId == KEY_EXCHANGE_ALG_RSA))
{
printf("certificate_read_server_proprietary_certificate: parse error 1\n");
return false;
}
+
stream_read_uint16(s, wPublicKeyBlobType);
+
if (wPublicKeyBlobType != BB_RSA_KEY_BLOB)
{
printf("certificate_read_server_proprietary_certificate: parse error 2\n");
return false;
}
+
stream_read_uint16(s, wPublicKeyBlobLen);
+
if (!certificate_process_server_public_key(certificate, s, wPublicKeyBlobLen))
{
printf("certificate_read_server_proprietary_certificate: parse error 3\n");
return false;
}
+
sigdatalen = stream_get_tail(s) - sigdata;
stream_read_uint16(s, wSignatureBlobType);
+
if (wSignatureBlobType != BB_RSA_SIGNATURE_BLOB)
{
printf("certificate_read_server_proprietary_certificate: parse error 4\n");
return false;
}
+
stream_read_uint16(s, wSignatureBlobLen);
+
if (wSignatureBlobLen != 72)
{
printf("certificate_process_server_public_signature: invalid signature length (got %d, expected %d)\n", wSignatureBlobLen, 64);
return false;
}
+
if (!certificate_process_server_public_signature(certificate, sigdata, sigdatalen, s, wSignatureBlobLen))
{
printf("certificate_read_server_proprietary_certificate: parse error 5\n");
rdpCertInfo cert_info;
DEBUG_CERTIFICATE("License Server Certificate");
certificate_read_x509_certificate(&certificate->x509_cert_chain->array[i], &cert_info);
- DEBUG_LICENSE("modulus length:%d", cert_info.modulus.length);
- freerdp_blob_free(&cert_info.modulus);
+ DEBUG_LICENSE("modulus length:%d", cert_info.ModulusLength);
+ free(cert_info.Modulus);
}
else if (numCertBlobs - i == 1)
{
rdpKey* key_new(const char* keyfile)
{
+ FILE* fp;
+ RSA* rsa;
rdpKey* key;
- RSA *rsa;
- FILE *fp;
key = (rdpKey*) xzalloc(sizeof(rdpKey));
return NULL;
}
- freerdp_blob_alloc(&key->modulus, BN_num_bytes(rsa->n));
- BN_bn2bin(rsa->n, key->modulus.data);
- crypto_reverse(key->modulus.data, key->modulus.length);
- freerdp_blob_alloc(&key->private_exponent, BN_num_bytes(rsa->d));
- BN_bn2bin(rsa->d, key->private_exponent.data);
- crypto_reverse(key->private_exponent.data, key->private_exponent.length);
+ key->ModulusLength = BN_num_bytes(rsa->n);
+ key->Modulus = (BYTE*) malloc(key->ModulusLength);
+ BN_bn2bin(rsa->n, key->Modulus);
+ crypto_reverse(key->Modulus, key->ModulusLength);
+
+ key->PrivateExponentLength = BN_num_bytes(rsa->d);
+ key->PrivateExponent = (BYTE*) malloc(key->PrivateExponentLength);
+ BN_bn2bin(rsa->d, key->PrivateExponent);
+ crypto_reverse(key->PrivateExponent, key->PrivateExponentLength);
+
memset(key->exponent, 0, sizeof(key->exponent));
BN_bn2bin(rsa->e, key->exponent + sizeof(key->exponent) - BN_num_bytes(rsa->e));
crypto_reverse(key->exponent, sizeof(key->exponent));
{
if (key != NULL)
{
- freerdp_blob_free(&key->modulus);
- freerdp_blob_free(&key->private_exponent);
+ free(key->Modulus);
+ free(key->PrivateExponent);
xfree(key);
}
}
{
certificate_free_x509_certificate_chain(certificate->x509_cert_chain);
- if (certificate->cert_info.modulus.data != NULL)
- freerdp_blob_free(&(certificate->cert_info.modulus));
+ if (certificate->cert_info.Modulus != NULL)
+ free(certificate->cert_info.Modulus);
xfree(certificate);
}
#include <freerdp/crypto/crypto.h>
#include <freerdp/settings.h>
-#include <freerdp/utils/blob.h>
#include <freerdp/utils/stream.h>
#include <freerdp/utils/hexdump.h>
if ((rdp->nego->selected_protocol & PROTOCOL_TLS) || (rdp->nego->selected_protocol == PROTOCOL_RDP))
{
- if ((settings->username != NULL) && ((settings->password != NULL) || (settings->password_cookie != NULL && settings->password_cookie->length > 0)))
+ if ((settings->username != NULL) && ((settings->password != NULL) ||
+ (settings->password_cookie != NULL && settings->password_cookie_length > 0)))
settings->autologon = true;
}
license_free(rdp->license);
transport_free(rdp->transport);
- /* FIXME: this is a subset of settings_free */
- freerdp_blob_free(settings->server_random);
- freerdp_blob_free(settings->server_certificate);
+ free(settings->server_random);
+ free(settings->server_certificate);
xfree(settings->ip_address);
rdp->transport = transport_new(settings);
if (redirection->flags & LB_LOAD_BALANCE_INFO)
{
- nego_set_routing_token(rdp->nego, &redirection->loadBalanceInfo);
+ nego_set_routing_token(rdp->nego, redirection->LoadBalanceInfo, redirection->LoadBalanceInfoLength);
}
else
{
if (redirection->flags & LB_PASSWORD)
{
- settings->password_cookie = &redirection->password_cookie;
+ settings->password_cookie = redirection->PasswordCookie;
+ settings->password_cookie_length = redirection->PasswordCookieLength;
}
return rdp_client_connect(rdp);
/* encrypt client random */
memset(crypt_client_random, 0, sizeof(crypt_client_random));
crypto_nonce(client_random, sizeof(client_random));
- key_len = rdp->settings->server_cert->cert_info.modulus.length;
- mod = rdp->settings->server_cert->cert_info.modulus.data;
+ key_len = rdp->settings->server_cert->cert_info.ModulusLength;
+ mod = rdp->settings->server_cert->cert_info.Modulus;
exp = rdp->settings->server_cert->cert_info.exponent;
crypto_rsa_public_encrypt(client_random, sizeof(client_random), key_len, mod, exp, crypt_client_random);
static boolean rdp_server_establish_keys(rdpRdp* rdp, STREAM* s)
{
- uint8 client_random[64]; /* Should be only 32 after successfull decryption, but on failure might take up to 64 bytes. */
+ uint8 client_random[64]; /* Should be only 32 after successful decryption, but on failure might take up to 64 bytes. */
uint8 crypt_client_random[256 + 8];
uint32 rand_len, key_len;
uint16 channel_id, length, sec_flags;
printf("rdp_server_establish_keys: invalid RDP header\n");
return false;
}
+
rdp_read_security_header(s, &sec_flags);
+
if ((sec_flags & SEC_EXCHANGE_PKT) == 0)
{
printf("rdp_server_establish_keys: missing SEC_EXCHANGE_PKT in security header\n");
return false;
}
+
stream_read_uint32(s, rand_len);
- key_len = rdp->settings->server_key->modulus.length;
+ key_len = rdp->settings->server_key->ModulusLength;
+
if (rand_len != key_len + 8)
{
printf("rdp_server_establish_keys: invalid encrypted client random length\n");
return false;
}
+
memset(crypt_client_random, 0, sizeof(crypt_client_random));
stream_read(s, crypt_client_random, rand_len);
/* 8 zero bytes of padding */
stream_seek(s, 8);
- mod = rdp->settings->server_key->modulus.data;
- priv_exp = rdp->settings->server_key->private_exponent.data;
+ mod = rdp->settings->server_key->Modulus;
+ priv_exp = rdp->settings->server_key->PrivateExponent;
crypto_rsa_private_decrypt(crypt_client_random, rand_len - 8, key_len, mod, priv_exp, client_random);
/* now calculate encrypt / decrypt and update keys */
printf("rdp_client_connect_mcs_connect_response: mcs_recv_connect_response failed\n");
return false;
}
+
if (!mcs_send_erect_domain_request(rdp->mcs))
return false;
+
if (!mcs_send_attach_user_request(rdp->mcs))
return false;
{
uint8* data;
uint32 length;
- uint32 serverRandomLen;
- uint32 serverCertLen;
stream_read_uint32(s, settings->encryption_method); /* encryptionMethod */
stream_read_uint32(s, settings->encryption_level); /* encryptionLevel */
return true;
}
- stream_read_uint32(s, serverRandomLen); /* serverRandomLen */
- stream_read_uint32(s, serverCertLen); /* serverCertLen */
+ stream_read_uint32(s, settings->server_random_length); /* serverRandomLen */
+ stream_read_uint32(s, settings->server_certificate_length); /* serverCertLen */
- if (serverRandomLen > 0)
+ if (settings->server_random_length > 0)
{
/* serverRandom */
- freerdp_blob_alloc(settings->server_random, serverRandomLen);
- stream_read(s, settings->server_random->data, serverRandomLen);
+ settings->server_random = (BYTE*) malloc(settings->server_random_length);
+ stream_read(s, settings->server_random, settings->server_random_length);
}
else
{
return false;
}
- if (serverCertLen > 0)
+ if (settings->server_certificate_length > 0)
{
/* serverCertificate */
- freerdp_blob_alloc(settings->server_certificate, serverCertLen);
- stream_read(s, settings->server_certificate->data, serverCertLen);
+ settings->server_certificate = (BYTE*) malloc(settings->server_certificate_length);
+ stream_read(s, settings->server_certificate, settings->server_certificate_length);
+
certificate_free(settings->server_cert);
settings->server_cert = certificate_new();
- data = settings->server_certificate->data;
- length = settings->server_certificate->length;
+ data = settings->server_certificate;
+ length = settings->server_certificate_length;
if (!certificate_read_server_certificate(settings->server_cert, data, length))
return false;
{
serverRandomLen = 32;
- keyLen = settings->server_key->modulus.length;
+ keyLen = settings->server_key->ModulusLength;
expLen = sizeof(settings->server_key->exponent);
wPublicKeyBlobLen = 4; /* magic (RSA1) */
wPublicKeyBlobLen += 4; /* keylen */
stream_write_uint32(s, serverRandomLen); /* serverRandomLen */
stream_write_uint32(s, serverCertLen); /* serverCertLen */
- freerdp_blob_alloc(settings->server_random, serverRandomLen);
- crypto_nonce(settings->server_random->data, serverRandomLen);
- stream_write(s, settings->server_random->data, serverRandomLen);
+ settings->server_random_length = serverRandomLen;
+ settings->server_random = (BYTE*) malloc(serverRandomLen);
+ crypto_nonce(settings->server_random, serverRandomLen);
+ stream_write(s, settings->server_random, serverRandomLen);
sigData = stream_get_tail(s);
stream_write_uint32(s, keyLen - 1); /* datalen */
stream_write(s, settings->server_key->exponent, expLen);
- stream_write(s, settings->server_key->modulus.data, keyLen);
+ stream_write(s, settings->server_key->Modulus, keyLen);
stream_write_zero(s, 8);
sigDataLen = stream_get_tail(s) - sigData;
cbUserName = freerdp_AsciiToUnicodeAlloc(settings->username, &userName, 0) * 2;
- if (settings->password_cookie && settings->password_cookie->length > 0)
+ if (settings->password_cookie && settings->password_cookie_length > 0)
{
usedPasswordCookie = true;
- password = (WCHAR*) settings->password_cookie->data;
- cbPassword = settings->password_cookie->length - 2; /* Strip double zero termination */
+ password = (WCHAR*) settings->password_cookie;
+ cbPassword = settings->password_cookie_length - 2; /* Strip double zero termination */
}
else
{
stream_get_mark(s, bm);
stream_seek(s, length);
- if (nego->routing_token != NULL)
+ if (nego->RoutingToken != NULL)
{
- stream_write(s, nego->routing_token->data, nego->routing_token->length);
- length += nego->routing_token->length;
+ stream_write(s, nego->RoutingToken, nego->RoutingTokenLength);
+ length += nego->RoutingTokenLength;
}
else if (nego->cookie != NULL)
{
/**
* Set routing token.
* @param nego
- * @param routing_token
+ * @param RoutingToken
+ * @param RoutingTokenLength
*/
-void nego_set_routing_token(rdpNego* nego, rdpBlob* routing_token)
+void nego_set_routing_token(rdpNego* nego, BYTE* RoutingToken, DWORD RoutingTokenLength)
{
- nego->routing_token = routing_token;
+ nego->RoutingToken = RoutingToken;
+ nego->RoutingTokenLength = RoutingTokenLength;
}
/**
#include "transport.h"
#include <freerdp/types.h>
#include <freerdp/settings.h>
-#include <freerdp/utils/blob.h>
#include <freerdp/utils/debug.h>
#include <freerdp/utils/stream.h>
uint32 flags;
char* hostname;
char* cookie;
- rdpBlob* routing_token;
+ BYTE* RoutingToken;
+ DWORD RoutingTokenLength;
boolean send_preconnection_pdu;
uint32 preconnection_id;
char* preconnection_blob;
rdpNego* nego_new(struct rdp_transport * transport);
void nego_free(rdpNego* nego);
+
void nego_init(rdpNego* nego);
void nego_set_target(rdpNego* nego, char* hostname, int port);
void nego_set_negotiation_enabled(rdpNego* nego, boolean security_layer_negotiation_enabled);
void nego_enable_rdp(rdpNego* nego, boolean enable_rdp);
void nego_enable_nla(rdpNego* nego, boolean enable_nla);
void nego_enable_tls(rdpNego* nego, boolean enable_tls);
-void nego_set_routing_token(rdpNego* nego, rdpBlob* routing_token);
+void nego_set_routing_token(rdpNego* nego, BYTE* RoutingToken, DWORD RoutingTokenLength);
void nego_set_cookie(rdpNego* nego, char* cookie);
void nego_set_send_preconnection_pdu(rdpNego* nego, boolean send_pcpdu);
void nego_set_preconnection_id(rdpNego* nego, uint32 id);
if (redirection->flags & LB_LOAD_BALANCE_INFO)
{
- uint32 loadBalanceInfoLength;
- stream_read_uint32(s, loadBalanceInfoLength);
- freerdp_blob_alloc(&redirection->loadBalanceInfo, loadBalanceInfoLength);
- stream_read(s, redirection->loadBalanceInfo.data, loadBalanceInfoLength);
+ stream_read_uint32(s, redirection->LoadBalanceInfoLength);
+ redirection->LoadBalanceInfo = (BYTE*) malloc(redirection->LoadBalanceInfoLength);
+ stream_read(s, redirection->LoadBalanceInfo, redirection->LoadBalanceInfoLength);
#ifdef WITH_DEBUG_REDIR
DEBUG_REDIR("loadBalanceInfo:");
freerdp_hexdump(redirection->loadBalanceInfo.data, redirection->loadBalanceInfo.length);
if (redirection->flags & LB_PASSWORD)
{
- uint32 passwordLength;
- stream_read_uint32(s, passwordLength); /* Note: length (hopefully) includes double zero termination */
- freerdp_blob_alloc(&redirection->password_cookie, passwordLength);
- stream_read(s, redirection->password_cookie.data, passwordLength);
+ /* Note: length (hopefully) includes double zero termination */
+ stream_read_uint32(s, redirection->PasswordCookieLength);
+ redirection->PasswordCookie = (BYTE*) malloc(redirection->PasswordCookieLength);
+ stream_read(s, redirection->PasswordCookie, redirection->PasswordCookieLength);
#ifdef WITH_DEBUG_REDIR
DEBUG_REDIR("password_cookie:");
- freerdp_hexdump(redirection->password_cookie.data, redirection->password_cookie.length);
+ freerdp_hexdump(redirection->PasswordCookie, redirection->PasswordCookieLength);
#endif
}
freerdp_string_free(&redirection->tsvUrl);
freerdp_string_free(&redirection->username);
freerdp_string_free(&redirection->domain);
- freerdp_blob_free(&redirection->password_cookie);
freerdp_string_free(&redirection->targetFQDN);
freerdp_string_free(&redirection->targetNetBiosName);
freerdp_string_free(&redirection->targetNetAddress);
- freerdp_blob_free(&redirection->loadBalanceInfo);
+
+ if (redirection->LoadBalanceInfo)
+ free(redirection->LoadBalanceInfo);
+
+ if (redirection->PasswordCookie)
+ free(redirection->PasswordCookie);
if (redirection->targetNetAddresses != NULL)
{
#include "rdp.h"
#include <freerdp/freerdp.h>
-#include <freerdp/utils/blob.h>
#include <freerdp/utils/debug.h>
#include <freerdp/utils/stream.h>
#include <freerdp/utils/string.h>
rdpString tsvUrl;
rdpString username;
rdpString domain;
- rdpBlob password_cookie;
+ BYTE* PasswordCookie;
+ DWORD PasswordCookieLength;
rdpString targetFQDN;
- rdpBlob loadBalanceInfo;
+ BYTE* LoadBalanceInfo;
+ DWORD LoadBalanceInfoLength;
rdpString targetNetBiosName;
rdpString targetNetAddress;
uint32 targetNetAddressesCount;
rdpSettings* settings;
settings = rdp->settings;
- server_random = settings->server_random->data;
+ server_random = settings->server_random;
if (settings->encryption_method == ENCRYPTION_METHOD_FIPS)
{
memcpy(rdp->sign_key, session_key_blob, 16);
- if (rdp->settings->server_mode) {
+ if (rdp->settings->server_mode)
+ {
security_md5_16_32_32(&session_key_blob[16], client_random,
server_random, rdp->encrypt_key);
security_md5_16_32_32(&session_key_blob[32], client_random,
server_random, rdp->decrypt_key);
- } else {
+ }
+ else
+ {
security_md5_16_32_32(&session_key_blob[16], client_random,
server_random, rdp->decrypt_key);
security_md5_16_32_32(&session_key_blob[32], client_random,
settings->server_auto_reconnect_cookie = xnew(ARC_SC_PRIVATE_PACKET);
settings->client_time_zone = xnew(TIME_ZONE_INFO);
- settings->server_random = xnew(rdpBlob);
- settings->server_certificate = xnew(rdpBlob);
freerdp_detect_paths(settings);
xfree(settings->order_support);
xfree(settings->client_hostname);
xfree(settings->client_product_id);
- freerdp_blob_free(settings->server_random);
- freerdp_blob_free(settings->server_certificate);
xfree(settings->server_random);
xfree(settings->server_certificate);
xfree(settings->rdp_key_file);
{
if (cert == NULL)
return;
+
X509_free(cert->px509);
+
xfree(cert);
}
-boolean crypto_cert_get_public_key(CryptoCert cert, rdpBlob* public_key)
+boolean crypto_cert_get_public_key(CryptoCert cert, BYTE** PublicKey, DWORD* PublicKeyLength)
{
- uint8* p;
+ BYTE* ptr;
int length;
boolean status = true;
EVP_PKEY* pkey = NULL;
goto exit;
}
- freerdp_blob_alloc(public_key, length);
- p = (uint8*) public_key->data;
- i2d_PublicKey(pkey, &p);
+ *PublicKeyLength = (DWORD) length;
+ *PublicKey = (BYTE*) malloc(length);
+ ptr = (BYTE*) (*PublicKey);
+
+ i2d_PublicKey(pkey, &ptr);
exit:
if (pkey)
(char*) credssp->identity.User, (char*) credssp->identity.Domain, (char*) credssp->identity.Password);
#endif
- sspi_SecBufferAlloc(&credssp->PublicKey, credssp->tls->public_key.length);
- CopyMemory(credssp->PublicKey.pvBuffer, credssp->tls->public_key.data, credssp->tls->public_key.length);
+ sspi_SecBufferAlloc(&credssp->PublicKey, credssp->tls->PublicKeyLength);
+ CopyMemory(credssp->PublicKey.pvBuffer, credssp->tls->PublicKey, credssp->tls->PublicKeyLength);
length = sizeof(TERMSRV_SPN_PREFIX) + strlen(settings->hostname);
rdpSettings* settings = credssp->settings;
instance = (freerdp*) settings->instance;
- sspi_SecBufferAlloc(&credssp->PublicKey, credssp->tls->public_key.length);
- CopyMemory(credssp->PublicKey.pvBuffer, credssp->tls->public_key.data, credssp->tls->public_key.length);
+ sspi_SecBufferAlloc(&credssp->PublicKey, credssp->tls->PublicKeyLength);
+ CopyMemory(credssp->PublicKey.pvBuffer, credssp->tls->PublicKey, credssp->tls->PublicKeyLength);
return 1;
}
return false;
}
- if (!crypto_cert_get_public_key(cert, &tls->public_key))
+ if (!crypto_cert_get_public_key(cert, &tls->PublicKey, &tls->PublicKeyLength))
{
printf("tls_connect: crypto_cert_get_public_key failed to return the server public key.\n");
- tls_free_certificate(cert) ;
+ tls_free_certificate(cert);
return false;
}
return false;
}
- if (!crypto_cert_get_public_key(cert, &tls->public_key))
+ if (!crypto_cert_get_public_key(cert, &tls->PublicKey, &tls->PublicKeyLength))
{
printf("tls_connect: crypto_cert_get_public_key failed to return the server public key.\n");
tls_free_certificate(cert);
if (tls->ctx)
SSL_CTX_free(tls->ctx);
- freerdp_blob_free(&tls->public_key);
+ if (tls->PublicKey)
+ free(tls->PublicKey);
certificate_store_free(tls->certificate_store);
#include "keyboard_xkbfile.h"
+#include <string.h>
+
#include <freerdp/locale/keyboard.h>
#include <freerdp/utils/memory.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "liblocale.h"
#include "config.h"
#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
#include <freerdp/locale/vkcodes.h>
#include <freerdp/utils/memory.h>
#include "xkb_layout_ids.h"
+#include <string.h>
+
#include <freerdp/utils/memory.h>
#include <freerdp/locale/keyboard.h>
set(FREERDP_UTILS_SRCS
args.c
- blob.c
dsp.c
event.c
bitmap.c
+++ /dev/null
-/**
- * FreeRDP: A Remote Desktop Protocol Client
- * BLOB Utils
- *
- * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <freerdp/utils/memory.h>
-
-#include <freerdp/utils/blob.h>
-
-/**
- * Allocate memory for data blob.
- * @param blob blob structure
- * @param length memory length
- */
-
-void freerdp_blob_alloc(rdpBlob* blob, int length)
-{
- blob->data = xmalloc(length);
- blob->length = length;
-}
-
-/**
- * Free memory allocated for data blob.
- * @param blob
- */
-
-void freerdp_blob_free(rdpBlob* blob)
-{
- if (blob->data)
- xfree(blob->data);
-
- blob->length = 0;
-}
-
-void freerdp_blob_copy(rdpBlob* dstblob, rdpBlob* srcblob)
-{
- freerdp_blob_alloc(dstblob, srcblob->length);
- memcpy(dstblob->data, srcblob->data, dstblob->length);
-}
#endif
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
#include <winpr/windows.h>
#include <freerdp/utils/time.h>