mirror of
https://github.com/jakcron/nstool
synced 2024-11-15 02:06:40 +00:00
[hac] Fixed bug where data was not serialised completely in AccessControlInfoBinary & AccessControlInfoDescBinary.
This commit is contained in:
parent
f21f3f569a
commit
b543b73c66
2 changed files with 19 additions and 17 deletions
|
@ -34,13 +34,9 @@ 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();
|
||||||
|
|
||||||
if (mServiceAccessControl.getBytes().size() == 0)
|
|
||||||
mServiceAccessControl.toBytes();
|
mServiceAccessControl.toBytes();
|
||||||
|
|
||||||
if (mKernelCapabilities.getBytes().size() == 0)
|
|
||||||
mKernelCapabilities.toBytes();
|
mKernelCapabilities.toBytes();
|
||||||
|
|
||||||
// determine section layout
|
// determine section layout
|
||||||
|
@ -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,13 +38,9 @@ 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();
|
||||||
|
|
||||||
if (mServiceAccessControl.getBytes().size() == 0)
|
|
||||||
mServiceAccessControl.toBytes();
|
mServiceAccessControl.toBytes();
|
||||||
|
|
||||||
if (mKernelCapabilities.getBytes().size() == 0)
|
|
||||||
mKernelCapabilities.toBytes();
|
mKernelCapabilities.toBytes();
|
||||||
|
|
||||||
// determine section layout
|
// determine section layout
|
||||||
|
@ -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