mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
Replace OpenSSL with PolarSSL
Works on windows, not yet cmake.
This commit is contained in:
@ -33,7 +33,7 @@ public:
|
||||
|
||||
void Log(LogTypes::LOG_LEVELS, const char *msg);
|
||||
|
||||
bool IsValid() { return (bool)m_logfile; }
|
||||
bool IsValid() { return !m_logfile.fail(); }
|
||||
bool IsEnabled() const { return m_enable; }
|
||||
void SetEnable(bool enable) { m_enable = enable; }
|
||||
|
||||
|
@ -115,7 +115,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|x64'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\portaudio\include;..\..\..\Externals\zlib;..\..\..\Externals\openssl;..\..\..\Externals\openssl\$(PlatformName);..\..\..\Externals\libusb\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\portaudio\include;..\..\..\Externals\zlib;..\..\..\Externals\polarssl\include;..\..\..\Externals\libusb\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@ -123,11 +123,12 @@
|
||||
<Lib>
|
||||
<AdditionalLibraryDirectories>
|
||||
</AdditionalLibraryDirectories>
|
||||
<LinkTimeCodeGeneration>true</LinkTimeCodeGeneration>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\portaudio\include;..\..\..\Externals\zlib;..\..\..\Externals\openssl;..\..\..\Externals\openssl\$(PlatformName);..\..\..\Externals\libusb\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\portaudio\include;..\..\..\Externals\zlib;..\..\..\Externals\polarssl\include;..\..\..\Externals\libusb\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@ -135,11 +136,12 @@
|
||||
<Lib>
|
||||
<AdditionalLibraryDirectories>
|
||||
</AdditionalLibraryDirectories>
|
||||
<LinkTimeCodeGeneration>true</LinkTimeCodeGeneration>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\portaudio\include;..\..\..\Externals\zlib;..\..\..\Externals\openssl;..\..\..\Externals\openssl\$(PlatformName);..\..\..\Externals\libusb\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\portaudio\include;..\..\..\Externals\zlib;..\..\..\Externals\polarssl\include;..\..\..\Externals\libusb\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@ -149,11 +151,12 @@
|
||||
<Lib>
|
||||
<AdditionalLibraryDirectories>
|
||||
</AdditionalLibraryDirectories>
|
||||
<LinkTimeCodeGeneration>true</LinkTimeCodeGeneration>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\portaudio\include;..\..\..\Externals\zlib;..\..\..\Externals\openssl;..\..\..\Externals\openssl\$(PlatformName);..\..\..\Externals\libusb\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\portaudio\include;..\..\..\Externals\zlib;..\..\..\Externals\polarssl\include;..\..\..\Externals\libusb\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@ -163,11 +166,12 @@
|
||||
<Lib>
|
||||
<AdditionalLibraryDirectories>
|
||||
</AdditionalLibraryDirectories>
|
||||
<LinkTimeCodeGeneration>true</LinkTimeCodeGeneration>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\portaudio\include;..\..\..\Externals\zlib;..\..\..\Externals\openssl;..\..\..\Externals\openssl\$(PlatformName);..\..\..\Externals\libusb\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\portaudio\include;..\..\..\Externals\zlib;..\..\..\Externals\polarssl\include;..\..\..\Externals\libusb\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@ -177,11 +181,12 @@
|
||||
<Lib>
|
||||
<AdditionalLibraryDirectories>
|
||||
</AdditionalLibraryDirectories>
|
||||
<LinkTimeCodeGeneration>true</LinkTimeCodeGeneration>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|x64'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\portaudio\include;..\..\..\Externals\zlib;..\..\..\Externals\openssl;..\..\..\Externals\openssl\$(PlatformName);..\..\..\Externals\libusb\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>.\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\portaudio\include;..\..\..\Externals\zlib;..\..\..\Externals\polarssl\include;..\..\..\Externals\libusb\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
@ -191,6 +196,7 @@
|
||||
<Lib>
|
||||
<AdditionalLibraryDirectories>
|
||||
</AdditionalLibraryDirectories>
|
||||
<LinkTimeCodeGeneration>true</LinkTimeCodeGeneration>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
@ -340,8 +346,8 @@
|
||||
<ClCompile Include="Src\NetPlayClient.cpp" />
|
||||
<ClCompile Include="Src\NetPlayServer.cpp" />
|
||||
<ClCompile Include="Src\PatchEngine.cpp" />
|
||||
<ClCompile Include="Src\DSPEmulator.cpp" />
|
||||
<ClCompile Include="Src\ec_wii.cpp" />
|
||||
<ClCompile Include="Src\DSPEmulator.cpp" />
|
||||
<ClCompile Include="Src\ec_wii.cpp" />
|
||||
<ClCompile Include="Src\PowerPC\Interpreter\Interpreter.cpp" />
|
||||
<ClCompile Include="Src\PowerPC\Interpreter\Interpreter_Branch.cpp" />
|
||||
<ClCompile Include="Src\PowerPC\Interpreter\Interpreter_FloatingPoint.cpp" />
|
||||
@ -606,4 +612,4 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
@ -529,9 +529,6 @@
|
||||
<ClCompile Include="Src\NetPlay.cpp">
|
||||
<Filter>NetPlay</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Src\ec_wii.cpp">
|
||||
<Filter>ec_wii</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Src\NetPlayServer.cpp">
|
||||
<Filter>NetPlay</Filter>
|
||||
</ClCompile>
|
||||
@ -566,12 +563,14 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="Src\PowerPC\JitInterface.cpp">
|
||||
<Filter>PowerPC</Filter>
|
||||
</ClCompile> <ClCompile Include="Src\IPC_HLE\ICMPWin.cpp">
|
||||
<Filter>IPC HLE %28IOS/Starlet%29\Net</Filter>
|
||||
</ClCompile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Src\IPC_HLE\ICMPWin.cpp">
|
||||
<Filter>IPC HLE %28IOS/Starlet%29\Net</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Src\IPC_HLE\WII_IPC_HLE_Device_hid.cpp">
|
||||
<Filter>IPC HLE %28IOS/Starlet%29\USB</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Src\ec_wii.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Src\ConfigManager.h" />
|
||||
@ -1022,9 +1021,6 @@
|
||||
<ClInclude Include="Src\NetPlay.h">
|
||||
<Filter>NetPlay</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Src\ec_wii.h">
|
||||
<Filter>ec_wii</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Src\BootManager.h" />
|
||||
<ClInclude Include="Src\FifoPlayer\FifoDataFile.h">
|
||||
<Filter>FifoPlayer</Filter>
|
||||
@ -1053,7 +1049,8 @@
|
||||
</ClInclude>
|
||||
<ClInclude Include="Src\PowerPC\JitInterface.h">
|
||||
<Filter>PowerPC</Filter>
|
||||
</ClInclude> <ClInclude Include="Src\IPC_HLE\WII_IPC_HLE_Device_net_ssl.h">
|
||||
</ClInclude>
|
||||
<ClInclude Include="Src\IPC_HLE\WII_IPC_HLE_Device_net_ssl.h">
|
||||
<Filter>IPC HLE %28IOS/Starlet%29\Net</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Src\IPC_HLE\fakepoll.h">
|
||||
@ -1065,6 +1062,7 @@
|
||||
<ClInclude Include="Src\IPC_HLE\WII_IPC_HLE_Device_hid.h">
|
||||
<Filter>IPC HLE %28IOS/Starlet%29\USB</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Src\ec_wii.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="CMakeLists.txt" />
|
||||
@ -1209,4 +1207,4 @@
|
||||
<UniqueIdentifier>{321a9af5-9b3d-4620-888c-fe9d02e9559e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
@ -198,17 +198,17 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress)
|
||||
}
|
||||
else
|
||||
{
|
||||
Memory::Write_U32(nwc24_err_t::WC24_ERR_FATAL, BufferOut);
|
||||
Memory::Write_U32(WC24_ERR_FATAL, BufferOut);
|
||||
}
|
||||
|
||||
}
|
||||
else if(config.CreationStage() == nwc24_config_t::NWC24_IDCS_GENERATED)
|
||||
{
|
||||
Memory::Write_U32(nwc24_err_t::WC24_ERR_ID_GENERATED, BufferOut);
|
||||
Memory::Write_U32(WC24_ERR_ID_GENERATED, BufferOut);
|
||||
}
|
||||
else if(config.CreationStage() == nwc24_config_t::NWC24_IDCS_REGISTERED)
|
||||
{
|
||||
Memory::Write_U32(nwc24_err_t::WC24_ERR_ID_REGISTERED, BufferOut);
|
||||
Memory::Write_U32(WC24_ERR_ID_REGISTERED, BufferOut);
|
||||
}
|
||||
Memory::Write_U64(config.Id(), BufferOut + 4);
|
||||
Memory::Write_U32(config.CreationStage(), BufferOut + 0xC);
|
||||
@ -334,9 +334,9 @@ s32 CWII_IPC_HLE_Device_net_kd_request::NWC24MakeUserID(u64* nwc24_id, u32 holly
|
||||
*nwc24_id = mix_id;
|
||||
|
||||
if (mix_id > 9999999999999999ULL)
|
||||
return nwc24_err_t::WC24_ERR_FATAL;
|
||||
return WC24_ERR_FATAL;
|
||||
|
||||
return nwc24_err_t::WC24_OK;
|
||||
return WC24_OK;
|
||||
}
|
||||
// **********************************************************************************
|
||||
// Handle /dev/net/ncd/manage requests
|
||||
|
@ -24,17 +24,12 @@
|
||||
#include "WII_IPC_HLE_Device_net_ssl.h"
|
||||
#include "../Debugger/Debugger_SymbolMap.h"
|
||||
|
||||
|
||||
|
||||
CWII_IPC_HLE_Device_net_ssl::CWII_IPC_HLE_Device_net_ssl(u32 _DeviceID, const std::string& _rDeviceName)
|
||||
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
|
||||
{
|
||||
gnutls_global_init();
|
||||
{
|
||||
for(int i = 0; i < NET_SSL_MAXINSTANCES; ++i)
|
||||
{
|
||||
_SSL[i].session = NULL;
|
||||
_SSL[i].xcred = NULL;
|
||||
memset(_SSL[i].hostname, 0, MAX_HOSTNAME_LEN);
|
||||
memset(&_SSL[i], 0, sizeof(struct _SSL));
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,27 +38,35 @@ CWII_IPC_HLE_Device_net_ssl::~CWII_IPC_HLE_Device_net_ssl()
|
||||
// Cleanup sessions
|
||||
for (int i = 0; i < NET_SSL_MAXINSTANCES; i++)
|
||||
{
|
||||
gnutls_session_t session = _SSL[i].session;
|
||||
if(session)
|
||||
if(_SSL[i].active)
|
||||
{
|
||||
gnutls_bye (session, GNUTLS_SHUT_RDWR);
|
||||
gnutls_deinit(session);
|
||||
gnutls_certificate_free_credentials (_SSL[i].xcred);
|
||||
ssl_close_notify(&_SSL[i].ctx);
|
||||
ssl_session_free(&_SSL[i].session);
|
||||
ssl_free(&_SSL[i].ctx);
|
||||
|
||||
x509_free(&_SSL[i].cacert);
|
||||
x509_free(&_SSL[i].clicert);
|
||||
|
||||
memset(&_SSL[i].ctx, 0, sizeof(ssl_context));
|
||||
memset(&_SSL[i].session, 0, sizeof(ssl_session));
|
||||
memset(&_SSL[i].hs, 0, sizeof(havege_state));
|
||||
memset(_SSL[i].hostname, 0, MAX_HOSTNAME_LEN);
|
||||
|
||||
_SSL[i].active = false;
|
||||
}
|
||||
}
|
||||
|
||||
gnutls_global_deinit();
|
||||
}
|
||||
|
||||
int CWII_IPC_HLE_Device_net_ssl::getSSLFreeID()
|
||||
{
|
||||
for (int i = 0; i < NET_SSL_MAXINSTANCES; i++)
|
||||
{
|
||||
if (_SSL[i].session == NULL)
|
||||
if (!_SSL[i].active)
|
||||
return i + 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CWII_IPC_HLE_Device_net_ssl::Open(u32 _CommandAddress, u32 _Mode)
|
||||
{
|
||||
Memory::Write_U32(GetDeviceID(), _CommandAddress+4);
|
||||
@ -104,49 +107,45 @@ bool CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
|
||||
}
|
||||
|
||||
static int
|
||||
_verify_certificate_callback (gnutls_session_t session)
|
||||
_verify_certificate_callback (void *data, x509_cert *crt, int depth, int *flags)
|
||||
{
|
||||
unsigned int status;
|
||||
int ret;
|
||||
gnutls_certificate_type_t type;
|
||||
const char *hostname;
|
||||
gnutls_datum_t out;
|
||||
char buf[1024];
|
||||
((void) data);
|
||||
std::string verify_info = "Verify requested for (Depth ";
|
||||
sprintf(buf, "%d", depth);
|
||||
verify_info += buf;
|
||||
verify_info += "):\n";
|
||||
|
||||
x509parse_cert_info( buf, sizeof( buf ) - 1, "", crt );
|
||||
verify_info += buf;
|
||||
|
||||
if( ( (*flags) & BADCERT_EXPIRED ) != 0 )
|
||||
verify_info += " ! server certificate has expired";
|
||||
|
||||
if( ( (*flags) & BADCERT_REVOKED ) != 0 )
|
||||
verify_info += " ! server certificate has been revoked";
|
||||
|
||||
if( ( (*flags) & BADCERT_CN_MISMATCH ) != 0 )
|
||||
verify_info += " ! CN mismatch\n";
|
||||
|
||||
if( ( (*flags) & BADCERT_NOT_TRUSTED ) != 0 )
|
||||
verify_info += " ! self-signed or not signed by a trusted CA\n";
|
||||
|
||||
if( ( (*flags) & BADCRL_NOT_TRUSTED ) != 0 )
|
||||
verify_info += " ! CRL not trusted\n";
|
||||
|
||||
if( ( (*flags) & BADCRL_EXPIRED ) != 0 )
|
||||
verify_info += " ! CRL expired\n";
|
||||
|
||||
if( ( (*flags) & BADCERT_OTHER ) != 0 )
|
||||
verify_info += " ! other (unknown) flag\n";
|
||||
|
||||
if ( ( *flags ) == 0 )
|
||||
verify_info += " This certificate has no flags\n";
|
||||
|
||||
/* Read hostname. */
|
||||
hostname = (const char *)gnutls_session_get_ptr (session);
|
||||
WARN_LOG(WII_IPC_SSL, "_verify_certificate_callback: Verifying certificate for %s\n", hostname);
|
||||
|
||||
/* This verification function uses the trusted CAs in the credentials
|
||||
* structure.
|
||||
*/
|
||||
ret = gnutls_certificate_verify_peers3 (session, hostname, &status);
|
||||
if (ret < 0)
|
||||
{
|
||||
WARN_LOG(WII_IPC_SSL, "gnutls_certificate_verify_peers3 error %d", ret);
|
||||
return GNUTLS_E_CERTIFICATE_ERROR;
|
||||
}
|
||||
|
||||
type = gnutls_certificate_type_get (session);
|
||||
|
||||
ret = gnutls_certificate_verification_status_print( status, type, &out, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
WARN_LOG(WII_IPC_SSL, "gnutls_certificate_verification_status_print error %d", ret);
|
||||
return GNUTLS_E_CERTIFICATE_ERROR;
|
||||
}
|
||||
|
||||
WARN_LOG(WII_IPC_SSL, "_verify_certificate_callback: %s", out.data);
|
||||
|
||||
gnutls_free(out.data);
|
||||
|
||||
if (status != 0)
|
||||
{
|
||||
/* Certificate is not trusted */
|
||||
WARN_LOG(WII_IPC_SSL, "_verify_certificate_callback: status = %d", status);
|
||||
return GNUTLS_E_CERTIFICATE_ERROR;
|
||||
}
|
||||
/* Certificate verified successfully. */
|
||||
return 0;
|
||||
WARN_LOG(WII_IPC_SSL, verify_info.c_str() );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
u32 CWII_IPC_HLE_Device_net_ssl::ExecuteCommandV(u32 _Parameter, SIOCtlVBuffer CommandBuffer)
|
||||
@ -190,7 +189,7 @@ u32 CWII_IPC_HLE_Device_net_ssl::ExecuteCommandV(u32 _Parameter, SIOCtlVBuffer C
|
||||
_BufferOut3 = CommandBuffer.PayloadBuffer.at(2).m_Address;
|
||||
BufferOutSize3 = CommandBuffer.PayloadBuffer.at(2).m_Size;
|
||||
}
|
||||
|
||||
|
||||
switch (_Parameter)
|
||||
{
|
||||
case IOCTLV_NET_SSL_NEW:
|
||||
@ -202,53 +201,34 @@ u32 CWII_IPC_HLE_Device_net_ssl::ExecuteCommandV(u32 _Parameter, SIOCtlVBuffer C
|
||||
if (freeSSL)
|
||||
{
|
||||
int sslID = freeSSL - 1;
|
||||
|
||||
int ret = gnutls_init (&_SSL[sslID].session, GNUTLS_CLIENT);
|
||||
int ret = ssl_init(&_SSL[sslID].ctx);
|
||||
if(ret)
|
||||
{
|
||||
_SSL[sslID].session = NULL;
|
||||
goto _SSL_NEW_ERROR;
|
||||
}
|
||||
|
||||
gnutls_session_t session = _SSL[sslID].session;
|
||||
|
||||
const char *err = NULL;
|
||||
ret = gnutls_priority_set_direct (session, "NORMAL", &err);
|
||||
if(ret)
|
||||
{
|
||||
_SSL[sslID].session = NULL;
|
||||
goto _SSL_NEW_ERROR;
|
||||
}
|
||||
|
||||
/* X509 stuff */
|
||||
ret = gnutls_certificate_allocate_credentials (&_SSL[sslID].xcred);
|
||||
if(ret)
|
||||
{
|
||||
_SSL[sslID].session = NULL;
|
||||
_SSL[sslID].xcred = NULL;
|
||||
goto _SSL_NEW_ERROR;
|
||||
}
|
||||
|
||||
gnutls_certificate_set_verify_function (_SSL[sslID].xcred, _verify_certificate_callback);
|
||||
|
||||
/* put the x509 credentials to the current session
|
||||
*/
|
||||
ret = gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, _SSL[sslID].xcred);
|
||||
if(ret)
|
||||
{
|
||||
_SSL[sslID].session = NULL;
|
||||
_SSL[sslID].xcred = NULL;
|
||||
// Cleanup possibly dirty ctx
|
||||
memset(&_SSL[sslID].ctx, 0, sizeof(ssl_context));
|
||||
goto _SSL_NEW_ERROR;
|
||||
}
|
||||
|
||||
havege_init(&_SSL[sslID].hs);
|
||||
ssl_set_rng(&_SSL[sslID].ctx, havege_random, &_SSL[sslID].hs);
|
||||
|
||||
// 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);
|
||||
|
||||
ssl_set_ciphersuites(&_SSL[sslID].ctx, ssl_default_ciphersuites);
|
||||
ssl_set_session(&_SSL[sslID].ctx, &_SSL[sslID].session);
|
||||
|
||||
ssl_set_verify(&_SSL[sslID].ctx, _verify_certificate_callback, NULL);
|
||||
|
||||
ssl_set_endpoint(&_SSL[sslID].ctx, SSL_IS_CLIENT);
|
||||
ssl_set_authmode(&_SSL[sslID].ctx, SSL_VERIFY_OPTIONAL);
|
||||
ssl_set_renegotiation(&_SSL[sslID].ctx, SSL_RENEGOTIATION_ENABLED);
|
||||
|
||||
memcpy(_SSL[sslID].hostname, hostname, min((int)BufferOutSize2, MAX_HOSTNAME_LEN));
|
||||
_SSL[sslID].hostname[MAX_HOSTNAME_LEN-1] = '\0';
|
||||
|
||||
gnutls_session_set_ptr (session, (void *) _SSL[sslID].hostname);
|
||||
gnutls_server_name_set (session, GNUTLS_NAME_DNS, _SSL[sslID].hostname,
|
||||
strnlen(_SSL[sslID].hostname, MAX_HOSTNAME_LEN));
|
||||
|
||||
ssl_set_hostname(&_SSL[sslID].ctx, _SSL[sslID].hostname);
|
||||
|
||||
_SSL[sslID].active = true;
|
||||
Memory::Write_U32(freeSSL, _BufferIn);
|
||||
}
|
||||
else
|
||||
@ -267,21 +247,25 @@ _SSL_NEW_ERROR:
|
||||
_BufferOut2, BufferOutSize2, _BufferOut3, BufferOutSize3);
|
||||
break;
|
||||
}
|
||||
|
||||
case IOCTLV_NET_SSL_SHUTDOWN:
|
||||
{
|
||||
int sslID = Memory::Read_U32(_BufferOut) - 1;
|
||||
if (SSLID_VALID(sslID))
|
||||
{
|
||||
gnutls_session_t session = _SSL[sslID].session;
|
||||
gnutls_bye (session, GNUTLS_SHUT_RDWR);
|
||||
gnutls_deinit(session);
|
||||
gnutls_certificate_free_credentials (_SSL[sslID].xcred);
|
||||
|
||||
_SSL[sslID].session = NULL;
|
||||
_SSL[sslID].xcred = NULL;
|
||||
ssl_close_notify(&_SSL[sslID].ctx);
|
||||
ssl_session_free(&_SSL[sslID].session);
|
||||
ssl_free(&_SSL[sslID].ctx);
|
||||
|
||||
x509_free(&_SSL[sslID].cacert);
|
||||
x509_free(&_SSL[sslID].clicert);
|
||||
|
||||
memset(&_SSL[sslID].ctx, 0, sizeof(ssl_context));
|
||||
memset(&_SSL[sslID].session, 0, sizeof(ssl_session));
|
||||
memset(&_SSL[sslID].hs, 0, sizeof(havege_state));
|
||||
memset(_SSL[sslID].hostname, 0, MAX_HOSTNAME_LEN);
|
||||
|
||||
_SSL[sslID].active = false;
|
||||
|
||||
Memory::Write_U32(SSL_OK, _BufferIn);
|
||||
}
|
||||
else
|
||||
@ -311,21 +295,21 @@ _SSL_NEW_ERROR:
|
||||
int sslID = Memory::Read_U32(_BufferOut) - 1;
|
||||
if (SSLID_VALID(sslID))
|
||||
{
|
||||
gnutls_datum_t rootca = {
|
||||
int ret = x509parse_crt_der(
|
||||
&_SSL[sslID].cacert,
|
||||
Memory::GetPointer(_BufferOut2),
|
||||
BufferOutSize2
|
||||
};
|
||||
|
||||
int ret = gnutls_certificate_set_x509_trust_mem (
|
||||
_SSL[sslID].xcred,
|
||||
&rootca,
|
||||
GNUTLS_X509_FMT_DER
|
||||
);
|
||||
|
||||
if(ret < 1)
|
||||
BufferOutSize2);
|
||||
|
||||
if(ret)
|
||||
{
|
||||
Memory::Write_U32(SSL_ERR_FAILED, _BufferIn);
|
||||
}
|
||||
else
|
||||
Memory::Write_U32(SSL_OK, _BufferIn);
|
||||
{
|
||||
ssl_set_ca_chain(&_SSL[sslID].ctx, &_SSL[sslID].cacert, NULL, _SSL[sslID].hostname);
|
||||
Memory::Write_U32(SSL_OK, _BufferIn);
|
||||
}
|
||||
|
||||
WARN_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETROOTCA = %d", ret);
|
||||
}
|
||||
else
|
||||
@ -334,8 +318,6 @@ _SSL_NEW_ERROR:
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case IOCTLV_NET_SSL_SETBUILTINCLIENTCERT:
|
||||
{
|
||||
WARN_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT "
|
||||
@ -350,28 +332,59 @@ _SSL_NEW_ERROR:
|
||||
if (SSLID_VALID(sslID))
|
||||
{
|
||||
std::string cert_base_path(File::GetUserPath(D_WIIUSER_IDX));
|
||||
|
||||
int ret = gnutls_certificate_set_x509_key_file (
|
||||
_SSL[sslID].xcred,
|
||||
(cert_base_path + "clientca.pem").c_str(),
|
||||
(cert_base_path + "clientcakey.pem").c_str(),
|
||||
GNUTLS_X509_FMT_PEM
|
||||
);
|
||||
|
||||
if(ret)
|
||||
int ret = x509parse_crtfile(&_SSL[sslID].clicert, (cert_base_path + "clientca.pem").c_str());
|
||||
int rsa_ret = x509parse_keyfile(&_SSL[sslID].rsa, (cert_base_path + "clientcakey.pem").c_str(), NULL);
|
||||
if(ret || rsa_ret)
|
||||
{
|
||||
x509_free(&_SSL[sslID].clicert);
|
||||
rsa_free(&_SSL[sslID].rsa);
|
||||
memset(&_SSL[sslID].clicert, 0, sizeof(x509_cert));
|
||||
memset(&_SSL[sslID].rsa, 0, sizeof(rsa_context));
|
||||
Memory::Write_U32(SSL_ERR_FAILED, _BufferIn);
|
||||
}
|
||||
else
|
||||
Memory::Write_U32(SSL_OK, _BufferIn);
|
||||
{
|
||||
ssl_set_own_cert(&_SSL[sslID].ctx, &_SSL[sslID].clicert, &_SSL[sslID].rsa);
|
||||
Memory::Write_U32(SSL_OK, _BufferIn);
|
||||
}
|
||||
|
||||
WARN_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT = %d", ret);
|
||||
WARN_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT = (%d, %d)", ret, rsa_ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
Memory::Write_U32(SSL_ERR_ID, _BufferIn);
|
||||
WARN_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT invalid sslID = %d", sslID);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IOCTLV_NET_SSL_REMOVECLIENTCERT:
|
||||
{
|
||||
WARN_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_REMOVECLIENTCERT "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
_BufferIn, BufferInSize, _BufferIn2, BufferInSize2,
|
||||
_BufferIn3, BufferInSize3, _BufferOut, BufferOutSize,
|
||||
_BufferOut2, BufferOutSize2, _BufferOut3, BufferOutSize3);
|
||||
|
||||
int sslID = Memory::Read_U32(_BufferOut) - 1;
|
||||
if (SSLID_VALID(sslID))
|
||||
{
|
||||
x509_free(&_SSL[sslID].clicert);
|
||||
rsa_free(&_SSL[sslID].rsa);
|
||||
memset(&_SSL[sslID].clicert, 0, sizeof(x509_cert));
|
||||
memset(&_SSL[sslID].rsa, 0, sizeof(rsa_context));
|
||||
|
||||
ssl_set_own_cert(&_SSL[sslID].ctx, NULL, NULL);
|
||||
Memory::Write_U32(SSL_OK, _BufferIn);
|
||||
}
|
||||
else
|
||||
{
|
||||
Memory::Write_U32(SSL_ERR_ID, _BufferIn);
|
||||
WARN_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT invalid sslID = %d", sslID);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IOCTLV_NET_SSL_SETBUILTINROOTCA:
|
||||
{
|
||||
int sslID = Memory::Read_U32(_BufferOut) - 1;
|
||||
@ -379,16 +392,17 @@ _SSL_NEW_ERROR:
|
||||
{
|
||||
std::string cert_base_path(File::GetUserPath(D_WIIUSER_IDX));
|
||||
|
||||
int ret = gnutls_certificate_set_x509_trust_file (
|
||||
_SSL[sslID].xcred,
|
||||
(cert_base_path + "rootca.pem").c_str(),
|
||||
GNUTLS_X509_FMT_PEM
|
||||
);
|
||||
|
||||
if(ret < 1)
|
||||
int ret = x509parse_crtfile(&_SSL[sslID].cacert, (cert_base_path + "rootca.pem").c_str());
|
||||
if(ret)
|
||||
{
|
||||
x509_free(&_SSL[sslID].clicert);
|
||||
Memory::Write_U32(SSL_ERR_FAILED, _BufferIn);
|
||||
}
|
||||
else
|
||||
Memory::Write_U32(SSL_OK, _BufferIn);
|
||||
{
|
||||
ssl_set_ca_chain(&_SSL[sslID].ctx, &_SSL[sslID].cacert, NULL, _SSL[sslID].hostname);
|
||||
Memory::Write_U32(SSL_OK, _BufferIn);
|
||||
}
|
||||
WARN_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINROOTCA = %d", ret);
|
||||
}
|
||||
else
|
||||
@ -404,27 +418,20 @@ _SSL_NEW_ERROR:
|
||||
_BufferOut2, BufferOutSize2, _BufferOut3, BufferOutSize3);
|
||||
break;
|
||||
}
|
||||
|
||||
case IOCTLV_NET_SSL_CONNECT:
|
||||
{
|
||||
int sslID = Memory::Read_U32(_BufferOut) - 1;
|
||||
if (SSLID_VALID(sslID))
|
||||
{
|
||||
int sock = Memory::Read_U32(_BufferOut2);
|
||||
gnutls_session_t session = _SSL[sslID].session;
|
||||
|
||||
gnutls_transport_set_int (session, sock);
|
||||
gnutls_handshake_set_timeout (
|
||||
session,
|
||||
GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT
|
||||
);
|
||||
_SSL[sslID].sockfd = Memory::Read_U32(_BufferOut2);
|
||||
WARN_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_CONNECT socket = %d", _SSL[sslID].sockfd);
|
||||
ssl_set_bio(&_SSL[sslID].ctx, net_recv, &_SSL[sslID].sockfd, net_send, &_SSL[sslID].sockfd);
|
||||
Memory::Write_U32(SSL_OK, _BufferIn);
|
||||
}
|
||||
else
|
||||
{
|
||||
Memory::Write_U32(SSL_ERR_ID, _BufferIn);
|
||||
}
|
||||
|
||||
WARN_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_CONNECT "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
@ -434,71 +441,71 @@ _SSL_NEW_ERROR:
|
||||
_BufferOut2, BufferOutSize2, _BufferOut3, BufferOutSize3);
|
||||
break;
|
||||
}
|
||||
|
||||
case IOCTLV_NET_SSL_DOHANDSHAKE:
|
||||
{
|
||||
int ret = 0;
|
||||
int sslID = Memory::Read_U32(_BufferOut) - 1;
|
||||
if (SSLID_VALID(sslID))
|
||||
{
|
||||
gnutls_session_t session = _SSL[sslID].session;
|
||||
int ret = 0;
|
||||
do
|
||||
ret = ssl_handshake(&_SSL[sslID].ctx);
|
||||
switch (ret)
|
||||
{
|
||||
ret = gnutls_handshake (session);
|
||||
case 0:
|
||||
Memory::Write_U32(SSL_OK, _BufferIn);
|
||||
break;
|
||||
case POLARSSL_ERR_NET_WANT_READ:
|
||||
Memory::Write_U32(SSL_ERR_RAGAIN, _BufferIn);
|
||||
break;
|
||||
case POLARSSL_ERR_NET_WANT_WRITE:
|
||||
Memory::Write_U32(SSL_ERR_WAGAIN, _BufferIn);
|
||||
break;
|
||||
default:
|
||||
Memory::Write_U32(SSL_ERR_FAILED, _BufferIn);
|
||||
break;
|
||||
}
|
||||
while (ret < 0 && gnutls_error_is_fatal (ret) == 0);
|
||||
|
||||
WARN_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_DOHANDSHAKE = %d", ret);
|
||||
|
||||
ret = ret == GNUTLS_E_SUCCESS;
|
||||
if (ret)
|
||||
Memory::Write_U32(SSL_OK, _BufferIn);
|
||||
else
|
||||
Memory::Write_U32(SSL_ERR_FAILED, _BufferIn);
|
||||
}
|
||||
else
|
||||
{
|
||||
Memory::Write_U32(SSL_ERR_ID, _BufferIn);
|
||||
}
|
||||
WARN_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_DOHANDSHAKE "
|
||||
WARN_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_DOHANDSHAKE = (%d) "
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
"BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)",
|
||||
ret,
|
||||
_BufferIn, BufferInSize, _BufferIn2, BufferInSize2,
|
||||
_BufferIn3, BufferInSize3, _BufferOut, BufferOutSize,
|
||||
_BufferOut2, BufferOutSize2, _BufferOut3, BufferOutSize3);
|
||||
break;
|
||||
}
|
||||
|
||||
case IOCTLV_NET_SSL_WRITE:
|
||||
{
|
||||
|
||||
int sslID = Memory::Read_U32(_BufferOut) - 1;
|
||||
if (SSLID_VALID(sslID))
|
||||
{
|
||||
gnutls_session_t session = _SSL[sslID].session;
|
||||
|
||||
int ret = gnutls_record_send(session, Memory::GetPointer(_BufferOut2), BufferOutSize2);
|
||||
int ret = ssl_write( &_SSL[sslID].ctx, Memory::GetPointer(_BufferOut2), BufferOutSize2);
|
||||
|
||||
File::IOFile("ssl_write.bin", "ab").WriteBytes(Memory::GetPointer(_BufferOut2), BufferOutSize2);
|
||||
|
||||
switch(ret)
|
||||
if(ret >= 0)
|
||||
{
|
||||
case 0:
|
||||
ret = SSL_ERR_ZERO;
|
||||
break;
|
||||
case GNUTLS_E_LARGE_PACKET:
|
||||
case GNUTLS_E_INTERRUPTED:
|
||||
ret = SSL_ERR_FAILED;
|
||||
break;
|
||||
case GNUTLS_E_AGAIN:
|
||||
ret = SSL_ERR_WAGAIN;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
// Return bytes written or SSL_ERR_ZERO if none
|
||||
Memory::Write_U32((ret == 0) ? SSL_ERR_ZERO : ret, _BufferIn);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (ret)
|
||||
{
|
||||
case POLARSSL_ERR_NET_WANT_READ:
|
||||
Memory::Write_U32(SSL_ERR_RAGAIN, _BufferIn);
|
||||
break;
|
||||
case POLARSSL_ERR_NET_WANT_WRITE:
|
||||
Memory::Write_U32(SSL_ERR_WAGAIN, _BufferIn);
|
||||
break;
|
||||
default:
|
||||
Memory::Write_U32(SSL_ERR_FAILED, _BufferIn);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Memory::Write_U32(ret, _BufferIn);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -514,43 +521,45 @@ _SSL_NEW_ERROR:
|
||||
WARN_LOG(WII_IPC_SSL, "%s", Memory::GetPointer(_BufferOut2));
|
||||
break;
|
||||
}
|
||||
|
||||
case IOCTLV_NET_SSL_READ:
|
||||
{
|
||||
int sslID = Memory::Read_U32(_BufferOut) - 1;
|
||||
|
||||
int ret = 0;
|
||||
int sslID = Memory::Read_U32(_BufferOut) - 1;
|
||||
if (SSLID_VALID(sslID))
|
||||
{
|
||||
gnutls_session_t session = _SSL[sslID].session;
|
||||
ret = gnutls_record_recv(session, Memory::GetPointer(_BufferIn2), BufferInSize2);
|
||||
ret = ssl_read( &_SSL[sslID].ctx, Memory::GetPointer(_BufferIn2), BufferInSize2);
|
||||
if (ret > 0)
|
||||
{
|
||||
File::IOFile("ssl_read.bin", "ab").WriteBytes(Memory::GetPointer(_BufferIn2), ret);
|
||||
}
|
||||
|
||||
switch(ret)
|
||||
|
||||
if(ret >= 0)
|
||||
{
|
||||
case 0:
|
||||
ret = SSL_ERR_ZERO;
|
||||
break;
|
||||
case GNUTLS_E_LARGE_PACKET:
|
||||
case GNUTLS_E_INTERRUPTED:
|
||||
ret = SSL_ERR_FAILED;
|
||||
break;
|
||||
case GNUTLS_E_AGAIN:
|
||||
ret = SSL_ERR_RAGAIN;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
// Return bytes read or SSL_ERR_ZERO if none
|
||||
Memory::Write_U32((ret == 0) ? SSL_ERR_ZERO : ret, _BufferIn);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (ret)
|
||||
{
|
||||
case POLARSSL_ERR_NET_WANT_READ:
|
||||
Memory::Write_U32(SSL_ERR_RAGAIN, _BufferIn);
|
||||
break;
|
||||
case POLARSSL_ERR_NET_WANT_WRITE:
|
||||
Memory::Write_U32(SSL_ERR_WAGAIN, _BufferIn);
|
||||
break;
|
||||
default:
|
||||
Memory::Write_U32(SSL_ERR_FAILED, _BufferIn);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Memory::Write_U32(ret, _BufferIn);
|
||||
}
|
||||
else
|
||||
{
|
||||
Memory::Write_U32(SSL_ERR_ID, _BufferIn);
|
||||
}
|
||||
|
||||
|
||||
WARN_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_READ(%d)"
|
||||
"BufferIn: (%08x, %i), BufferIn2: (%08x, %i), "
|
||||
"BufferIn3: (%08x, %i), BufferOut: (%08x, %i), "
|
||||
@ -566,7 +575,6 @@ _SSL_NEW_ERROR:
|
||||
int sslID = Memory::Read_U32(_BufferOut) - 1;
|
||||
if (SSLID_VALID(sslID))
|
||||
{
|
||||
//gnutls_session_t session = _SSL[sslID].session;
|
||||
Memory::Write_U32(SSL_OK, _BufferIn);
|
||||
}
|
||||
else
|
||||
@ -582,7 +590,6 @@ _SSL_NEW_ERROR:
|
||||
_BufferOut2, BufferOutSize2, _BufferOut3, BufferOutSize3);
|
||||
break;
|
||||
}
|
||||
|
||||
case IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT:
|
||||
{
|
||||
WARN_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT "
|
||||
@ -596,7 +603,6 @@ _SSL_NEW_ERROR:
|
||||
int sslID = Memory::Read_U32(_BufferOut) - 1;
|
||||
if (SSLID_VALID(sslID))
|
||||
{
|
||||
//gnutls_session_t session = _SSL[sslID].session;
|
||||
Memory::Write_U32(SSL_OK, _BufferIn);
|
||||
}
|
||||
else
|
||||
@ -605,7 +611,6 @@ _SSL_NEW_ERROR:
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
ERROR_LOG(WII_IPC_SSL, "%i "
|
||||
@ -626,17 +631,10 @@ u32 CWII_IPC_HLE_Device_net_ssl::ExecuteCommand(u32 _Command,
|
||||
u32 _BufferIn, u32 BufferInSize,
|
||||
u32 _BufferOut, u32 BufferOutSize)
|
||||
{
|
||||
switch (_Command)
|
||||
{
|
||||
default:
|
||||
{
|
||||
WARN_LOG(WII_IPC_SSL, "%s unknown %i "
|
||||
"(BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
|
||||
GetDeviceName().c_str(), _Command,
|
||||
_BufferIn, BufferInSize, _BufferOut, BufferOutSize);
|
||||
break;
|
||||
}
|
||||
}
|
||||
WARN_LOG(WII_IPC_SSL, "%s unknown %i "
|
||||
"(BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
|
||||
GetDeviceName().c_str(), _Command,
|
||||
_BufferIn, BufferInSize, _BufferOut, BufferOutSize);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -25,13 +25,14 @@
|
||||
|
||||
#include "WII_IPC_HLE_Device.h"
|
||||
|
||||
#include <gnutls/gnutls.h>
|
||||
#include <gnutls/x509.h>
|
||||
#include <polarssl/net.h>
|
||||
#include <polarssl/ssl.h>
|
||||
#include <polarssl/havege.h>
|
||||
|
||||
#define MAX_HOSTNAME_LEN 256
|
||||
#define NET_SSL_MAXINSTANCES 4
|
||||
|
||||
#define SSLID_VALID(x) (x >= 0 && x < NET_SSL_MAXINSTANCES && _SSL[x].session != NULL)
|
||||
#define SSLID_VALID(x) (x >= 0 && x < NET_SSL_MAXINSTANCES && _SSL[x].active)
|
||||
|
||||
class CWII_IPC_HLE_Device_net_ssl : public IWII_IPC_HLE_Device
|
||||
{
|
||||
@ -50,10 +51,17 @@ public:
|
||||
int getSSLFreeID();
|
||||
|
||||
private:
|
||||
|
||||
struct _SSL{
|
||||
gnutls_session_t session;
|
||||
gnutls_certificate_credentials_t xcred;
|
||||
ssl_context ctx;
|
||||
ssl_session session;
|
||||
havege_state hs;
|
||||
x509_cert cacert;
|
||||
x509_cert clicert;
|
||||
rsa_context rsa;
|
||||
int sockfd;
|
||||
char hostname[MAX_HOSTNAME_LEN];
|
||||
bool active;
|
||||
} _SSL[NET_SSL_MAXINSTANCES];
|
||||
|
||||
enum
|
||||
|
@ -141,6 +141,7 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /
|
||||
</Command>
|
||||
<Message>Copying Data\* to $(TargetDir)</Message>
|
||||
</PostBuildEvent>
|
||||
<Link />
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
@ -155,6 +156,7 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /
|
||||
</Command>
|
||||
<Message>Copying Data\* to $(TargetDir)</Message>
|
||||
</PostBuildEvent>
|
||||
<Link />
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
@ -171,10 +173,11 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /
|
||||
</Command>
|
||||
<Message>Copying Data\* to $(TargetDir)</Message>
|
||||
</PostBuildEvent>
|
||||
<Link />
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\..\..\Externals\GLew\include;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\Core\Src;..\Core\Src\PowerPC\JitCommon;..\DebuggerWX\Src;..\..\..\Externals\Bochs_disasm;..\InputCommon\Src;..\InputUICommon\Src;..\DiscIO\Src;..\..\..\Externals\SFML\include;..\..\..\Externals\wxWidgets3;..\..\..\Externals\wxWidgets3\include;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\..\Externals\GLew\include;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\Core\Src;..\Core\Src\PowerPC\JitCommon;..\DebuggerWX\Src;..\..\..\Externals\Bochs_disasm;..\InputCommon\Src;..\DiscIO\Src;..\..\..\Externals\SFML\include;..\..\..\Externals\wxWidgets3;..\..\..\Externals\wxWidgets3\include;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link />
|
||||
<PostBuildEvent>
|
||||
@ -185,6 +188,7 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /
|
||||
</Command>
|
||||
<Message>Copying Data\* to $(TargetDir)</Message>
|
||||
</PostBuildEvent>
|
||||
<Link />
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
@ -203,10 +207,12 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /
|
||||
</PostBuildEvent>
|
||||
<ResourceCompile>
|
||||
</ResourceCompile>
|
||||
<Link />
|
||||
<Link />
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DebugFast|x64'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\..\..\Externals\GLew\include;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\Core\Src;..\Core\Src\PowerPC\JitCommon;..\DebuggerWX\Src;..\..\..\Externals\Bochs_disasm;..\InputCommon\Src;..\InputUICommon\Src;..\DiscIO\Src;..\..\..\Externals\SFML\include;..\..\..\Externals\wxWidgets3;..\..\..\Externals\wxWidgets3\include;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\..\Externals\GLew\include;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\Core\Src;..\Core\Src\PowerPC\JitCommon;..\DebuggerWX\Src;..\..\..\Externals\Bochs_disasm;..\InputCommon\Src;..\DiscIO\Src;..\..\..\Externals\SFML\include;..\..\..\Externals\wxWidgets3;..\..\..\Externals\wxWidgets3\include;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link />
|
||||
<PostBuildEvent>
|
||||
@ -217,6 +223,7 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /
|
||||
</Command>
|
||||
<Message>Copying Data\* to $(TargetDir)</Message>
|
||||
</PostBuildEvent>
|
||||
<Link />
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Src\AboutDolphin.cpp" />
|
||||
@ -267,7 +274,7 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /
|
||||
<ClCompile Include="Src\PHackSettings.cpp" />
|
||||
<ClCompile Include="Src\Debugger\RegisterView.cpp" />
|
||||
<ClCompile Include="Src\Debugger\RegisterWindow.cpp" />
|
||||
<ClCompile Include="Src\GLInterface\WGL.cpp" />
|
||||
<ClCompile Include="Src\GLInterface\WGL.cpp" />
|
||||
<ClCompile Include="Src\stdafx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='DebugFast|Win32'">Create</PrecompiledHeader>
|
||||
@ -393,4 +400,4 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e /
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
@ -135,6 +135,7 @@
|
||||
<ClCompile Include="Src\GCMicDlg.cpp">
|
||||
<Filter>GUI</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Src\GLInterface\WGL.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Src\Main.h" />
|
||||
@ -264,6 +265,9 @@
|
||||
<ClInclude Include="Src\GCMicDlg.h">
|
||||
<Filter>GUI</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Src\GLInterface.h" />
|
||||
<ClInclude Include="Src\GLInterface\InterfaceBase.h" />
|
||||
<ClInclude Include="Src\GLInterface\WGL.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="CMakeLists.txt" />
|
||||
|
Reference in New Issue
Block a user