Skip to content

Commit

Permalink
Merge pull request #112 from Parlane/fix_ssl_init
Browse files Browse the repository at this point in the history
Initialise entropy correctly for ssl.
  • Loading branch information
delroth committed Feb 27, 2014
2 parents 1f5b3c9 + e1ec472 commit a350882
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_net_ssl.cpp
Expand Up @@ -148,7 +148,21 @@ bool CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
}

entropy_init(&_SSL[sslID].entropy);
ssl_set_rng(&_SSL[sslID].ctx, entropy_func, &_SSL[sslID].entropy);
const char* pers = "dolphin-emu";
ret = ctr_drbg_init(&_SSL[sslID].ctr_drbg, entropy_func,
&_SSL[sslID].entropy,
(const unsigned char*)pers,
strlen(pers));
if (ret)
{
ssl_free(&_SSL[sslID].ctx);
// Cleanup possibly dirty ctx
memset(&_SSL[sslID].ctx, 0, sizeof(ssl_context));
entropy_free(&_SSL[sslID].entropy);
goto _SSL_NEW_ERROR;
}

ssl_set_rng(&_SSL[sslID].ctx, ctr_drbg_random, &_SSL[sslID].ctr_drbg);

// For some reason we can't use TLSv1.2, v1.1 and below are fine!
ssl_set_max_version(&_SSL[sslID].ctx, SSL_MAJOR_VERSION_3, SSL_MINOR_VERSION_2);
Expand Down Expand Up @@ -191,6 +205,8 @@ bool CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
ssl_session_free(&_SSL[sslID].session);
ssl_free(&_SSL[sslID].ctx);

entropy_free(&_SSL[sslID].entropy);

x509_crt_free(&_SSL[sslID].cacert);
x509_crt_free(&_SSL[sslID].clicert);

Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h
Expand Up @@ -4,6 +4,7 @@

#pragma once

#include <polarssl/ctr_drbg.h>
#include <polarssl/entropy.h>
#include <polarssl/net.h>
#include <polarssl/ssl.h>
Expand Down Expand Up @@ -58,6 +59,7 @@ typedef struct
ssl_context ctx;
ssl_session session;
entropy_context entropy;
ctr_drbg_context ctr_drbg;
x509_crt cacert;
x509_crt clicert;
pk_context pk;
Expand Down

0 comments on commit a350882

Please sign in to comment.