mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-31 12:31:45 +01:00
Implement cellSslCertificateLoader
This commit is contained in:
parent
9440e65452
commit
8ad44dd00f
@ -1,11 +1,19 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <bitset>
|
||||
#include <string>
|
||||
|
||||
#include "Emu/Cell/PPUModule.h"
|
||||
#include "Utilities/File.h"
|
||||
#include "Emu/VFS.h"
|
||||
|
||||
logs::channel cellSsl("cellSsl");
|
||||
|
||||
s32 cellSslInit()
|
||||
namespace vm { using namespace ps3; }
|
||||
|
||||
s32 cellSslInit(vm::ptr<void> pool, u32 poolSize)
|
||||
{
|
||||
UNIMPLEMENTED_FUNC(cellSsl);
|
||||
cellSsl.todo("cellSslInit(pool=0x%x, poolSize=%d)", pool, poolSize);
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
@ -15,9 +23,57 @@ s32 cellSslEnd()
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
s32 cellSslCertificateLoader()
|
||||
std::string getCert(const std::string certPath, const int certID)
|
||||
{
|
||||
UNIMPLEMENTED_FUNC(cellSsl);
|
||||
//Stupid cellssl
|
||||
int newID = certID;
|
||||
if (certID == 6)
|
||||
newID = 23;
|
||||
if (certID > 6 && certID < 23)
|
||||
newID = certID - 1;
|
||||
|
||||
std::string filePath = fmt::format("%sCA%02d.cer", certPath, newID);
|
||||
|
||||
if (!fs::exists(filePath))
|
||||
{
|
||||
cellSsl.error("Can't find certificate file %s, do you have the PS3 firmware installed?", filePath);
|
||||
return "";
|
||||
}
|
||||
return fs::file(filePath).to_string();
|
||||
}
|
||||
|
||||
s32 cellSslCertificateLoader(u64 flag, vm::ptr<char> buffer, u32 size, vm::ptr<u32> required)
|
||||
{
|
||||
cellSsl.trace("cellSslCertificateLoader(flag=%llu, buffer=0x%x, size=%zu, required=0x%x)", flag, buffer, size, required);
|
||||
|
||||
const std::bitset<58> flagBits(flag);
|
||||
const std::string certPath = vfs::get("/dev_flash/") + "data/cert/";
|
||||
|
||||
if (required)
|
||||
{
|
||||
*required = (u32)flagBits.count();
|
||||
for (int i = 1; i < flagBits.size(); i++)
|
||||
{
|
||||
if (!flagBits[i-1])
|
||||
continue;
|
||||
*required += (u32)(getCert(certPath, i).size() - 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string final;
|
||||
for (int i = 1; i < flagBits.size(); i++)
|
||||
{
|
||||
if (!flagBits[i-1])
|
||||
continue;
|
||||
final.append(getCert(certPath, i));
|
||||
}
|
||||
|
||||
memset(buffer.get_ptr(), 0, size-1);
|
||||
strncpy(buffer.get_ptr(), final.c_str(), size - 1);
|
||||
buffer.get_ptr()[size - 1] = '\0';
|
||||
}
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user