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