libfreerdp-core: improving cryptographic module

This commit is contained in:
Marc-André Moreau 2011-07-07 10:33:42 -04:00
parent 0582b26592
commit bbdd6348cc
4 changed files with 32 additions and 1 deletions

View File

@ -135,6 +135,11 @@ stream_extend(STREAM * stream);
#define stream_write_uint16_be(_s, _v) do { \
*_s->p++ = ((_v) >> 8) & 0xFF; \
*_s->p++ = (_v) & 0xFF; } while (0)
#define stream_write_uint32_be(_s, _v) do { \
*_s->p++ = ((_v) >> 8) & 0xFF; \
*_s->p++ = (_v) & 0xFF; \
*_s->p++ = ((_v) >> 24) & 0xFF; \
*_s->p++ = ((_v) >> 16) & 0xFF; } while (0)
#define stream_copy(_dst, _src, _n) do { \
memcpy(_dst->p, _src->p, _n); \

View File

@ -638,7 +638,7 @@ void ntlmssp_output_negotiate_flags(STREAM* s, uint32 flags)
*/
p = s->p;
out_uint32_be(s, flags);
stream_write_uint32_be(s, flags);
tmp = p[0];
p[0] = p[3];

View File

@ -154,6 +154,28 @@ tls_print_error(char *func, SSL *connection, int value)
}
}
CryptoCert
tls_get_certificate(rdpTls * tls)
{
CryptoCert cert;
X509 * server_cert;
server_cert = SSL_get_peer_certificate(tls->ssl);
if (!server_cert)
{
printf("ssl_verify: failed to get the server SSL certificate\n");
cert = NULL;
}
else
{
cert = xmalloc(sizeof(*cert));
cert->px509 = server_cert;
}
return cert;
}
rdpTls*
tls_new()
{

View File

@ -24,6 +24,8 @@
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "crypto.h"
#include <freerdp/types/base.h>
#include <freerdp/utils/stream.h>
@ -49,6 +51,8 @@ int
tls_read(rdpTls * tls, char* data, int length);
int
tls_write(rdpTls * tls, char* data, int length);
CryptoCert
tls_get_certificate(rdpTls * tls);
boolean
tls_print_error(char *func, SSL *connection, int value);