mirror of
https://github.com/jakcron/nstool
synced 2024-12-27 15:11:12 +00:00
[es] Change handling of ticket property flags.
This commit is contained in:
parent
16041c2d65
commit
38eb0391b3
2 changed files with 20 additions and 50 deletions
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <fnd/ISerialisable.h>
|
||||
#include <fnd/List.h>
|
||||
#include <es/ticket.h>
|
||||
|
||||
namespace es
|
||||
|
@ -42,14 +43,8 @@ namespace es
|
|||
byte_t getCommonKeyId() const;
|
||||
void setCommonKeyId(byte_t id);
|
||||
|
||||
bool isPreInstall() const;
|
||||
void setIsPreInstall(bool isPreInstall);
|
||||
|
||||
bool isSharedTitle() const;
|
||||
void setIsSharedTitle(bool isSharedTitle);
|
||||
|
||||
bool allowAllContent() const;
|
||||
void setAllowAllContent(bool allowAllContent);
|
||||
const fnd::List<es::ticket::PropertyMaskFlags>& getPropertyFlags() const;
|
||||
void setPropertyFlags(const fnd::List<es::ticket::PropertyMaskFlags>& flags);
|
||||
|
||||
const byte_t* getReservedRegion() const;
|
||||
void setReservedRegion(const byte_t* data, size_t len);
|
||||
|
@ -91,9 +86,7 @@ namespace es
|
|||
uint16_t mTicketVersion;
|
||||
ticket::LicenseType mLicenseType;
|
||||
byte_t mCommonKeyId;
|
||||
bool mPreInstall;
|
||||
bool mSharedTitle;
|
||||
bool mAllowAllContent;
|
||||
fnd::List<es::ticket::PropertyMaskFlags> mPropertyFlags;
|
||||
byte_t mReservedRegion[ticket::kReservedRegionSize]; // explicitly reserved
|
||||
uint64_t mTicketId;
|
||||
uint64_t mDeviceId;
|
||||
|
|
|
@ -27,9 +27,7 @@ void es::TicketBody_V2::operator=(const TicketBody_V2 & other)
|
|||
mTicketVersion = other.mTicketVersion;
|
||||
mLicenseType = other.mLicenseType;
|
||||
mCommonKeyId = other.mCommonKeyId;
|
||||
mPreInstall = other.mPreInstall;
|
||||
mSharedTitle = other.mSharedTitle;
|
||||
mAllowAllContent = other.mAllowAllContent;
|
||||
mPropertyFlags = other.mPropertyFlags;
|
||||
memcpy(mReservedRegion, other.mReservedRegion, ticket::kReservedRegionSize);
|
||||
mTicketId = other.mTicketId;
|
||||
mDeviceId = other.mDeviceId;
|
||||
|
@ -49,9 +47,7 @@ bool es::TicketBody_V2::operator==(const TicketBody_V2 & other) const
|
|||
&& (mEncType == other.mEncType) \
|
||||
&& (mTicketVersion == other.mTicketVersion) \
|
||||
&& (mLicenseType == other.mLicenseType) \
|
||||
&& (mPreInstall == other.mPreInstall) \
|
||||
&& (mSharedTitle == other.mSharedTitle) \
|
||||
&& (mAllowAllContent == other.mAllowAllContent) \
|
||||
&& (mPropertyFlags == other.mPropertyFlags) \
|
||||
&& (memcmp(mReservedRegion, other.mReservedRegion, ticket::kReservedRegionSize) == 0) \
|
||||
&& (mTicketId == other.mTicketId) \
|
||||
&& (mDeviceId == other.mDeviceId) \
|
||||
|
@ -82,9 +78,10 @@ void es::TicketBody_V2::toBytes()
|
|||
body->license_type = mLicenseType;
|
||||
body->common_key_id = mCommonKeyId;
|
||||
byte_t property_mask = 0;
|
||||
property_mask |= mPreInstall ? _BIT(ticket::FLAG_PRE_INSTALL) : 0;
|
||||
property_mask |= mSharedTitle ? _BIT(ticket::FLAG_SHARED_TITLE) : 0;
|
||||
property_mask |= mAllowAllContent ? _BIT(ticket::FLAG_ALLOW_ALL_CONTENT) : 0;
|
||||
for (size_t i = 0; i < mPropertyFlags.size(); i++)
|
||||
{
|
||||
property_mask |= _BIT(mPropertyFlags[i]);
|
||||
}
|
||||
body->property_mask = (property_mask);
|
||||
memcpy(body->reserved_region, mReservedRegion, ticket::kReservedRegionSize);
|
||||
body->ticket_id = (mTicketId);
|
||||
|
@ -121,9 +118,11 @@ void es::TicketBody_V2::fromBytes(const byte_t * bytes, size_t len)
|
|||
mTicketVersion = body->ticket_version.get();
|
||||
mLicenseType = (ticket::LicenseType)body->license_type;
|
||||
mCommonKeyId = body->common_key_id;
|
||||
mPreInstall = _HAS_BIT(body->property_mask, ticket::FLAG_PRE_INSTALL);
|
||||
mSharedTitle = _HAS_BIT(body->property_mask, ticket::FLAG_SHARED_TITLE);
|
||||
mAllowAllContent = _HAS_BIT(body->property_mask, ticket::FLAG_ALLOW_ALL_CONTENT);
|
||||
for (size_t i = 0; i < mPropertyFlags.size(); i++)
|
||||
{
|
||||
if (_HAS_BIT(body->property_mask, i))
|
||||
mPropertyFlags.addElement((ticket::PropertyMaskFlags)i);
|
||||
}
|
||||
memcpy(mReservedRegion, body->reserved_region, ticket::kReservedRegionSize);
|
||||
mTicketId = body->ticket_id.get();
|
||||
mDeviceId = body->device_id.get();
|
||||
|
@ -149,9 +148,7 @@ void es::TicketBody_V2::clear()
|
|||
mTicketVersion = 0;
|
||||
mLicenseType = ticket::LICENSE_PERMANENT;
|
||||
mCommonKeyId = 0;
|
||||
mPreInstall = false;
|
||||
mSharedTitle = false;
|
||||
mAllowAllContent = false;
|
||||
mPropertyFlags.clear();
|
||||
memset(mReservedRegion, 0, ticket::kReservedRegionSize);
|
||||
mTicketId = 0;
|
||||
mDeviceId = 0;
|
||||
|
@ -229,34 +226,14 @@ void es::TicketBody_V2::setCommonKeyId(byte_t id)
|
|||
mCommonKeyId = id;
|
||||
}
|
||||
|
||||
bool es::TicketBody_V2::isPreInstall() const
|
||||
const fnd::List<es::ticket::PropertyMaskFlags>& es::TicketBody_V2::getPropertyFlags() const
|
||||
{
|
||||
return mPreInstall;
|
||||
return mPropertyFlags;
|
||||
}
|
||||
|
||||
void es::TicketBody_V2::setIsPreInstall(bool isPreInstall)
|
||||
void es::TicketBody_V2::setPropertyFlags(const fnd::List<es::ticket::PropertyMaskFlags>& flags)
|
||||
{
|
||||
mPreInstall = isPreInstall;
|
||||
}
|
||||
|
||||
bool es::TicketBody_V2::isSharedTitle() const
|
||||
{
|
||||
return mSharedTitle;
|
||||
}
|
||||
|
||||
void es::TicketBody_V2::setIsSharedTitle(bool isSharedTitle)
|
||||
{
|
||||
mSharedTitle = isSharedTitle;
|
||||
}
|
||||
|
||||
bool es::TicketBody_V2::allowAllContent() const
|
||||
{
|
||||
return mAllowAllContent;
|
||||
}
|
||||
|
||||
void es::TicketBody_V2::setAllowAllContent(bool allowAllContent)
|
||||
{
|
||||
mAllowAllContent = allowAllContent;
|
||||
mPropertyFlags = flags;
|
||||
}
|
||||
|
||||
const byte_t * es::TicketBody_V2::getReservedRegion() const
|
||||
|
|
Loading…
Reference in a new issue