mirror of
https://github.com/jakcron/nstool.git
synced 2024-12-23 03:05:27 +00:00
[hac] Fixed bug where data was not serialised completely in AccessControlInfoBinary & AccessControlInfoDescBinary.
This commit is contained in:
parent
f21f3f569a
commit
b543b73c66
|
@ -34,14 +34,10 @@ bool nn::hac::AccessControlInfoBinary::operator!=(const AccessControlInfoBinary
|
||||||
|
|
||||||
void nn::hac::AccessControlInfoBinary::toBytes()
|
void nn::hac::AccessControlInfoBinary::toBytes()
|
||||||
{
|
{
|
||||||
if (mFileSystemAccessControl.getBytes().size() == 0)
|
// serialise the sections
|
||||||
mFileSystemAccessControl.toBytes();
|
mFileSystemAccessControl.toBytes();
|
||||||
|
mServiceAccessControl.toBytes();
|
||||||
if (mServiceAccessControl.getBytes().size() == 0)
|
mKernelCapabilities.toBytes();
|
||||||
mServiceAccessControl.toBytes();
|
|
||||||
|
|
||||||
if (mKernelCapabilities.getBytes().size() == 0)
|
|
||||||
mKernelCapabilities.toBytes();
|
|
||||||
|
|
||||||
// determine section layout
|
// determine section layout
|
||||||
struct sLayout {
|
struct sLayout {
|
||||||
|
@ -74,6 +70,11 @@ void nn::hac::AccessControlInfoBinary::toBytes()
|
||||||
hdr->sac.size = sac.size;
|
hdr->sac.size = sac.size;
|
||||||
hdr->kc.offset = kc.offset;
|
hdr->kc.offset = kc.offset;
|
||||||
hdr->kc.size = kc.size;
|
hdr->kc.size = kc.size;
|
||||||
|
|
||||||
|
// write data
|
||||||
|
memcpy(mRawBinary.data() + fac.offset, mFileSystemAccessControl.getBytes().data(), fac.size);
|
||||||
|
memcpy(mRawBinary.data() + sac.offset, mServiceAccessControl.getBytes().data(), sac.size);
|
||||||
|
memcpy(mRawBinary.data() + kc.offset, mKernelCapabilities.getBytes().data(), kc.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nn::hac::AccessControlInfoBinary::fromBytes(const byte_t* data, size_t len)
|
void nn::hac::AccessControlInfoBinary::fromBytes(const byte_t* data, size_t len)
|
||||||
|
|
|
@ -38,14 +38,10 @@ bool nn::hac::AccessControlInfoDescBinary::operator!=(const AccessControlInfoDes
|
||||||
|
|
||||||
void nn::hac::AccessControlInfoDescBinary::toBytes()
|
void nn::hac::AccessControlInfoDescBinary::toBytes()
|
||||||
{
|
{
|
||||||
if (mFileSystemAccessControl.getBytes().size() == 0)
|
// serialise the sections
|
||||||
mFileSystemAccessControl.toBytes();
|
mFileSystemAccessControl.toBytes();
|
||||||
|
mServiceAccessControl.toBytes();
|
||||||
if (mServiceAccessControl.getBytes().size() == 0)
|
mKernelCapabilities.toBytes();
|
||||||
mServiceAccessControl.toBytes();
|
|
||||||
|
|
||||||
if (mKernelCapabilities.getBytes().size() == 0)
|
|
||||||
mKernelCapabilities.toBytes();
|
|
||||||
|
|
||||||
// determine section layout
|
// determine section layout
|
||||||
struct sLayout {
|
struct sLayout {
|
||||||
|
@ -91,6 +87,11 @@ void nn::hac::AccessControlInfoDescBinary::toBytes()
|
||||||
hdr->sac.size = sac.size;
|
hdr->sac.size = sac.size;
|
||||||
hdr->kc.offset = kc.offset;
|
hdr->kc.offset = kc.offset;
|
||||||
hdr->kc.size = kc.size;
|
hdr->kc.size = kc.size;
|
||||||
|
|
||||||
|
// write data
|
||||||
|
memcpy(mRawBinary.data() + fac.offset, mFileSystemAccessControl.getBytes().data(), fac.size);
|
||||||
|
memcpy(mRawBinary.data() + sac.offset, mServiceAccessControl.getBytes().data(), sac.size);
|
||||||
|
memcpy(mRawBinary.data() + kc.offset, mKernelCapabilities.getBytes().data(), kc.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nn::hac::AccessControlInfoDescBinary::fromBytes(const byte_t* data, size_t len)
|
void nn::hac::AccessControlInfoDescBinary::fromBytes(const byte_t* data, size_t len)
|
||||||
|
@ -157,7 +158,7 @@ void nn::hac::AccessControlInfoDescBinary::generateSignature(const fnd::rsa::sRs
|
||||||
byte_t hash[fnd::sha::kSha256HashLen];
|
byte_t hash[fnd::sha::kSha256HashLen];
|
||||||
fnd::sha::Sha256(mRawBinary.data() + fnd::rsa::kRsa2048Size, mRawBinary.size() - fnd::rsa::kRsa2048Size, hash);
|
fnd::sha::Sha256(mRawBinary.data() + fnd::rsa::kRsa2048Size, mRawBinary.size() - fnd::rsa::kRsa2048Size, hash);
|
||||||
|
|
||||||
if (fnd::rsa::pkcs::rsaSign(key, fnd::sha::HASH_SHA256, hash, mRawBinary.data()) != 0)
|
if (fnd::rsa::pss::rsaSign(key, fnd::sha::HASH_SHA256, hash, mRawBinary.data()) != 0)
|
||||||
{
|
{
|
||||||
throw fnd::Exception(kModuleName, "Failed to sign Access Control Info Desc");
|
throw fnd::Exception(kModuleName, "Failed to sign Access Control Info Desc");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue