mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-22 09:09:18 +01:00
Fix inconsistency with int types
This commit is contained in:
parent
eb1983daa6
commit
a115921b43
@ -71,9 +71,9 @@ namespace iosu
|
||||
return CCR_NFC_ERROR;
|
||||
}
|
||||
|
||||
sint32 CCRNFCAESCTRCrypt(const uint8* key, const void* ivNonce, const void* inData, uint32_t inSize, void* outData, uint32_t outSize)
|
||||
sint32 CCRNFCAESCTRCrypt(const uint8* key, const void* ivNonce, const void* inData, uint32 inSize, void* outData, uint32 outSize)
|
||||
{
|
||||
uint8_t tmpIv[0x10];
|
||||
uint8 tmpIv[0x10];
|
||||
memcpy(tmpIv, ivNonce, sizeof(tmpIv));
|
||||
|
||||
memcpy(outData, inData, inSize);
|
||||
@ -81,7 +81,7 @@ namespace iosu
|
||||
return 0;
|
||||
}
|
||||
|
||||
sint32 __CCRNFCGenerateKey(const uint8* hmacKey, uint32 hmacKeySize, const uint8* name, uint32_t nameSize, const uint8* inData, uint32_t inSize, uint8* outData, uint32_t outSize)
|
||||
sint32 __CCRNFCGenerateKey(const uint8* hmacKey, uint32 hmacKeySize, const uint8* name, uint32 nameSize, const uint8* inData, uint32 inSize, uint8* outData, uint32 outSize)
|
||||
{
|
||||
if (nameSize != 0xe || outSize != 0x40)
|
||||
{
|
||||
@ -89,13 +89,13 @@ namespace iosu
|
||||
}
|
||||
|
||||
// Create a buffer containing 2 counter bytes, the key name, and the key data
|
||||
uint8_t buffer[0x50];
|
||||
uint8 buffer[0x50];
|
||||
buffer[0] = 0;
|
||||
buffer[1] = 0;
|
||||
memcpy(buffer + 2, name, nameSize);
|
||||
memcpy(buffer + nameSize + 2, inData, inSize);
|
||||
|
||||
uint16_t counter = 0;
|
||||
uint16 counter = 0;
|
||||
while (outSize > 0)
|
||||
{
|
||||
// Set counter bytes and increment counter
|
||||
@ -118,9 +118,9 @@ namespace iosu
|
||||
|
||||
sint32 __CCRNFCGenerateInternalKeys(const CCRNFCCryptData* in, const uint8* keyGenSalt)
|
||||
{
|
||||
uint8_t lockedSecretBuffer[0x40] = { 0 };
|
||||
uint8_t unfixedInfosBuffer[0x40] = { 0 };
|
||||
uint8_t outBuffer[0x40] = { 0 };
|
||||
uint8 lockedSecretBuffer[0x40] = { 0 };
|
||||
uint8 unfixedInfosBuffer[0x40] = { 0 };
|
||||
uint8 outBuffer[0x40] = { 0 };
|
||||
|
||||
// Fill the locked secret buffer
|
||||
memcpy(lockedSecretBuffer, sLockedSecretMagicBytes, sizeof(sLockedSecretMagicBytes));
|
||||
@ -193,7 +193,7 @@ namespace iosu
|
||||
sint32 __CCRNFCCryptData(const CCRNFCCryptData* in, CCRNFCCryptData* out, bool decrypt)
|
||||
{
|
||||
// Decrypt key generation salt
|
||||
uint8_t keyGenSalt[0x20];
|
||||
uint8 keyGenSalt[0x20];
|
||||
sint32 res = CCRNFCAESCTRCrypt(sNfcKey, sNfcKeyIV, in->data + in->keyGenSaltOffset, 0x20, keyGenSalt, sizeof(keyGenSalt));
|
||||
if (res != 0)
|
||||
{
|
||||
@ -227,7 +227,7 @@ namespace iosu
|
||||
}
|
||||
|
||||
// Verify HMACs
|
||||
uint8_t hmacBuffer[0x20];
|
||||
uint8 hmacBuffer[0x20];
|
||||
uint32 hmacLen = sizeof(hmacBuffer);
|
||||
|
||||
if (!HMAC(EVP_sha256(), sLockedSecretInternalHmacKey, sizeof(sLockedSecretInternalHmacKey), out->data + in->lockedSecretHmacOffset + 0x20, (in->dataSize - in->lockedSecretHmacOffset) - 0x20, hmacBuffer, &hmacLen))
|
||||
@ -258,7 +258,7 @@ namespace iosu
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t hmacBuffer[0x20];
|
||||
uint8 hmacBuffer[0x20];
|
||||
uint32 hmacLen = sizeof(hmacBuffer);
|
||||
|
||||
if (!HMAC(EVP_sha256(), sLockedSecretInternalHmacKey, sizeof(sLockedSecretInternalHmacKey), out->data + in->lockedSecretHmacOffset + 0x20, (in->dataSize - in->lockedSecretHmacOffset) - 0x20, hmacBuffer, &hmacLen))
|
||||
|
@ -25,7 +25,7 @@ std::vector<TLV> TLV::FromBytes(const std::span<std::byte>& data)
|
||||
while (stream.GetRemaining() > 0 && !hasTerminator)
|
||||
{
|
||||
// Read the tag
|
||||
uint8_t byte;
|
||||
uint8 byte;
|
||||
stream >> byte;
|
||||
Tag tag = static_cast<Tag>(byte);
|
||||
|
||||
@ -43,7 +43,7 @@ std::vector<TLV> TLV::FromBytes(const std::span<std::byte>& data)
|
||||
default:
|
||||
{
|
||||
// Read the length
|
||||
uint16_t length;
|
||||
uint16 length;
|
||||
stream >> byte;
|
||||
length = byte;
|
||||
|
||||
@ -85,7 +85,7 @@ std::vector<std::byte> TLV::ToBytes() const
|
||||
VectorStream stream(bytes, std::endian::big);
|
||||
|
||||
// Write tag
|
||||
stream << std::uint8_t(mTag);
|
||||
stream << uint8(mTag);
|
||||
|
||||
switch (mTag)
|
||||
{
|
||||
@ -99,12 +99,12 @@ std::vector<std::byte> TLV::ToBytes() const
|
||||
// Write length (decide if as a 8-bit or 16-bit value)
|
||||
if (mValue.size() >= 0xff)
|
||||
{
|
||||
stream << std::uint8_t(0xff);
|
||||
stream << std::uint16_t(mValue.size());
|
||||
stream << uint8(0xff);
|
||||
stream << uint16(mValue.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
stream << std::uint8_t(mValue.size());
|
||||
stream << uint8(mValue.size());
|
||||
}
|
||||
|
||||
// Write value
|
||||
|
@ -9,17 +9,17 @@ namespace
|
||||
constexpr std::size_t kTagSize = 512u;
|
||||
constexpr std::size_t kMaxBlockCount = kTagSize / sizeof(TagV0::Block);
|
||||
|
||||
constexpr std::uint8_t kLockbyteBlock0 = 0xe;
|
||||
constexpr std::uint8_t kLockbytesStart0 = 0x0;
|
||||
constexpr std::uint8_t kLockbytesEnd0 = 0x2;
|
||||
constexpr std::uint8_t kLockbyteBlock1 = 0xf;
|
||||
constexpr std::uint8_t kLockbytesStart1 = 0x2;
|
||||
constexpr std::uint8_t kLockbytesEnd1 = 0x8;
|
||||
constexpr uint8 kLockbyteBlock0 = 0xe;
|
||||
constexpr uint8 kLockbytesStart0 = 0x0;
|
||||
constexpr uint8 kLockbytesEnd0 = 0x2;
|
||||
constexpr uint8 kLockbyteBlock1 = 0xf;
|
||||
constexpr uint8 kLockbytesStart1 = 0x2;
|
||||
constexpr uint8 kLockbytesEnd1 = 0x8;
|
||||
|
||||
constexpr std::uint8_t kNDEFMagicNumber = 0xe1;
|
||||
constexpr uint8 kNDEFMagicNumber = 0xe1;
|
||||
|
||||
// These blocks are not part of the locked area
|
||||
constexpr bool IsBlockLockedOrReserved(std::uint8_t blockIdx)
|
||||
constexpr bool IsBlockLockedOrReserved(uint8 blockIdx)
|
||||
{
|
||||
// Block 0 is the UID
|
||||
if (blockIdx == 0x0)
|
||||
@ -153,7 +153,7 @@ std::vector<std::byte> TagV0::ToBytes() const
|
||||
|
||||
// The rest will be the data area
|
||||
auto dataIterator = dataArea.begin();
|
||||
for (std::uint8_t currentBlock = 0; currentBlock < kMaxBlockCount; currentBlock++)
|
||||
for (uint8 currentBlock = 0; currentBlock < kMaxBlockCount; currentBlock++)
|
||||
{
|
||||
// All blocks which aren't locked make up the dataArea
|
||||
if (!IsBlockLocked(currentBlock))
|
||||
@ -189,15 +189,15 @@ void TagV0::SetNDEFData(const std::span<const std::byte>& data)
|
||||
|
||||
bool TagV0::ParseLockedArea(const std::span<const std::byte>& data)
|
||||
{
|
||||
std::uint8_t currentBlock = 0;
|
||||
uint8 currentBlock = 0;
|
||||
|
||||
// Start by parsing the first set of lock bytes
|
||||
for (std::uint8_t i = kLockbytesStart0; i < kLockbytesEnd0; i++)
|
||||
for (uint8 i = kLockbytesStart0; i < kLockbytesEnd0; i++)
|
||||
{
|
||||
std::uint8_t lockByte = std::uint8_t(data[kLockbyteBlock0 * sizeof(Block) + i]);
|
||||
uint8 lockByte = uint8(data[kLockbyteBlock0 * sizeof(Block) + i]);
|
||||
|
||||
// Iterate over the individual bits in the lock byte
|
||||
for (std::uint8_t j = 0; j < 8; j++)
|
||||
for (uint8 j = 0; j < 8; j++)
|
||||
{
|
||||
// Is block locked?
|
||||
if (lockByte & (1u << j))
|
||||
@ -221,11 +221,11 @@ bool TagV0::ParseLockedArea(const std::span<const std::byte>& data)
|
||||
}
|
||||
|
||||
// Parse the second set of lock bytes
|
||||
for (std::uint8_t i = kLockbytesStart1; i < kLockbytesEnd1; i++) {
|
||||
std::uint8_t lockByte = std::uint8_t(data[kLockbyteBlock1 * sizeof(Block) + i]);
|
||||
for (uint8 i = kLockbytesStart1; i < kLockbytesEnd1; i++) {
|
||||
uint8 lockByte = uint8(data[kLockbyteBlock1 * sizeof(Block) + i]);
|
||||
|
||||
// Iterate over the individual bits in the lock byte
|
||||
for (std::uint8_t j = 0; j < 8; j++)
|
||||
for (uint8 j = 0; j < 8; j++)
|
||||
{
|
||||
// Is block locked?
|
||||
if (lockByte & (1u << j))
|
||||
@ -251,14 +251,14 @@ bool TagV0::ParseLockedArea(const std::span<const std::byte>& data)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TagV0::IsBlockLocked(std::uint8_t blockIdx) const
|
||||
bool TagV0::IsBlockLocked(uint8 blockIdx) const
|
||||
{
|
||||
return mLockedBlocks.contains(blockIdx) || IsBlockLockedOrReserved(blockIdx);
|
||||
}
|
||||
|
||||
bool TagV0::ParseDataArea(const std::span<const std::byte>& data, std::vector<std::byte>& dataArea)
|
||||
{
|
||||
for (std::uint8_t currentBlock = 0; currentBlock < kMaxBlockCount; currentBlock++)
|
||||
for (uint8 currentBlock = 0; currentBlock < kMaxBlockCount; currentBlock++)
|
||||
{
|
||||
// All blocks which aren't locked make up the dataArea
|
||||
if (!IsBlockLocked(currentBlock))
|
||||
@ -274,7 +274,7 @@ bool TagV0::ParseDataArea(const std::span<const std::byte>& data, std::vector<st
|
||||
bool TagV0::ValidateCapabilityContainer()
|
||||
{
|
||||
// NDEF Magic Number
|
||||
std::uint8_t nmn = mCapabilityContainer[0];
|
||||
uint8 nmn = mCapabilityContainer[0];
|
||||
if (nmn != kNDEFMagicNumber)
|
||||
{
|
||||
cemuLog_log(LogType::Force, "Error: CC: Invalid NDEF Magic Number");
|
||||
@ -282,7 +282,7 @@ bool TagV0::ValidateCapabilityContainer()
|
||||
}
|
||||
|
||||
// Version Number
|
||||
std::uint8_t vno = mCapabilityContainer[1];
|
||||
uint8 vno = mCapabilityContainer[1];
|
||||
if (vno >> 4 != 1)
|
||||
{
|
||||
cemuLog_log(LogType::Force, "Error: CC: Invalid Version Number");
|
||||
@ -290,7 +290,7 @@ bool TagV0::ValidateCapabilityContainer()
|
||||
}
|
||||
|
||||
// Tag memory size
|
||||
std::uint8_t tms = mCapabilityContainer[2];
|
||||
uint8 tms = mCapabilityContainer[2];
|
||||
if (8u * (tms + 1) < kTagSize)
|
||||
{
|
||||
cemuLog_log(LogType::Force, "Error: CC: Incomplete tag memory size");
|
||||
|
@ -26,13 +26,13 @@ public:
|
||||
|
||||
private:
|
||||
bool ParseLockedArea(const std::span<const std::byte>& data);
|
||||
bool IsBlockLocked(std::uint8_t blockIdx) const;
|
||||
bool IsBlockLocked(uint8 blockIdx) const;
|
||||
bool ParseDataArea(const std::span<const std::byte>& data, std::vector<std::byte>& dataArea);
|
||||
bool ValidateCapabilityContainer();
|
||||
|
||||
std::map<std::uint8_t, Block> mLockedOrReservedBlocks;
|
||||
std::map<std::uint8_t, Block> mLockedBlocks;
|
||||
std::array<std::uint8_t, 0x4> mCapabilityContainer;
|
||||
std::map<uint8, Block> mLockedOrReservedBlocks;
|
||||
std::map<uint8, Block> mLockedBlocks;
|
||||
std::array<uint8, 0x4> mCapabilityContainer;
|
||||
std::vector<TLV> mTLVs;
|
||||
std::size_t mNdefTlvIdx;
|
||||
std::vector<std::byte> mLockedArea;
|
||||
|
@ -19,20 +19,20 @@ namespace ndef
|
||||
Record rec;
|
||||
|
||||
// Read record header
|
||||
uint8_t recHdr;
|
||||
uint8 recHdr;
|
||||
stream >> recHdr;
|
||||
rec.mFlags = recHdr & ~NDEF_TNF_MASK;
|
||||
rec.mTNF = static_cast<TypeNameFormat>(recHdr & NDEF_TNF_MASK);
|
||||
|
||||
// Type length
|
||||
uint8_t typeLen;
|
||||
uint8 typeLen;
|
||||
stream >> typeLen;
|
||||
|
||||
// Payload length;
|
||||
uint32_t payloadLen;
|
||||
uint32 payloadLen;
|
||||
if (recHdr & NDEF_SR)
|
||||
{
|
||||
uint8_t len;
|
||||
uint8 len;
|
||||
stream >> len;
|
||||
payloadLen = len;
|
||||
}
|
||||
@ -48,7 +48,7 @@ namespace ndef
|
||||
}
|
||||
|
||||
// ID length
|
||||
uint8_t idLen = 0;
|
||||
uint8 idLen = 0;
|
||||
if (recHdr & NDEF_IL)
|
||||
{
|
||||
stream >> idLen;
|
||||
@ -81,35 +81,35 @@ namespace ndef
|
||||
return rec;
|
||||
}
|
||||
|
||||
std::vector<std::byte> Record::ToBytes(uint8_t flags) const
|
||||
std::vector<std::byte> Record::ToBytes(uint8 flags) const
|
||||
{
|
||||
std::vector<std::byte> bytes;
|
||||
VectorStream stream(bytes, std::endian::big);
|
||||
|
||||
// Combine flags (clear message begin and end flags)
|
||||
std::uint8_t finalFlags = mFlags & ~(NDEF_MB | NDEF_ME);
|
||||
uint8 finalFlags = mFlags & ~(NDEF_MB | NDEF_ME);
|
||||
finalFlags |= flags;
|
||||
|
||||
// Write flags + tnf
|
||||
stream << std::uint8_t(finalFlags | std::uint8_t(mTNF));
|
||||
stream << uint8(finalFlags | uint8(mTNF));
|
||||
|
||||
// Type length
|
||||
stream << std::uint8_t(mType.size());
|
||||
stream << uint8(mType.size());
|
||||
|
||||
// Payload length
|
||||
if (IsShort())
|
||||
{
|
||||
stream << std::uint8_t(mPayload.size());
|
||||
stream << uint8(mPayload.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
stream << std::uint32_t(mPayload.size());
|
||||
stream << uint32(mPayload.size());
|
||||
}
|
||||
|
||||
// ID length
|
||||
if (mFlags & NDEF_IL)
|
||||
{
|
||||
stream << std::uint8_t(mID.size());
|
||||
stream << uint8(mID.size());
|
||||
}
|
||||
|
||||
// Type
|
||||
@ -249,7 +249,7 @@ namespace ndef
|
||||
|
||||
for (std::size_t i = 0; i < mRecords.size(); i++)
|
||||
{
|
||||
std::uint8_t flags = 0;
|
||||
uint8 flags = 0;
|
||||
|
||||
// Add message begin flag to first record
|
||||
if (i == 0)
|
||||
|
@ -39,7 +39,7 @@ namespace ndef
|
||||
virtual ~Record();
|
||||
|
||||
static std::optional<Record> FromStream(Stream& stream);
|
||||
std::vector<std::byte> ToBytes(uint8_t flags = 0) const;
|
||||
std::vector<std::byte> ToBytes(uint8 flags = 0) const;
|
||||
|
||||
TypeNameFormat GetTNF() const;
|
||||
const std::vector<std::byte>& GetID() const;
|
||||
@ -55,7 +55,7 @@ namespace ndef
|
||||
bool IsShort() const;
|
||||
|
||||
private:
|
||||
uint8_t mFlags;
|
||||
uint8 mFlags;
|
||||
TypeNameFormat mTNF;
|
||||
std::vector<std::byte> mID;
|
||||
std::vector<std::byte> mType;
|
||||
|
@ -149,9 +149,9 @@ namespace nfc
|
||||
StackAllocator<NFCUid> uid;
|
||||
bool readOnly = false;
|
||||
uint32 dataSize = 0;
|
||||
StackAllocator<uint8_t, 0x200> data;
|
||||
StackAllocator<uint8, 0x200> data;
|
||||
uint32 lockedDataSize = 0;
|
||||
StackAllocator<uint8_t, 0x200> lockedData;
|
||||
StackAllocator<uint8, 0x200> lockedData;
|
||||
|
||||
if (ctx->tag)
|
||||
{
|
||||
|
@ -28,7 +28,7 @@ std::endian Stream::GetEndianness() const
|
||||
|
||||
Stream& Stream::operator>>(bool& val)
|
||||
{
|
||||
std::uint8_t i;
|
||||
uint8 i;
|
||||
*this >> i;
|
||||
val = !!i;
|
||||
|
||||
@ -37,7 +37,7 @@ Stream& Stream::operator>>(bool& val)
|
||||
|
||||
Stream& Stream::operator>>(float& val)
|
||||
{
|
||||
std::uint32_t i;
|
||||
uint32 i;
|
||||
*this >> i;
|
||||
val = std::bit_cast<float>(i);
|
||||
|
||||
@ -46,7 +46,7 @@ Stream& Stream::operator>>(float& val)
|
||||
|
||||
Stream& Stream::operator>>(double& val)
|
||||
{
|
||||
std::uint64_t i;
|
||||
uint64 i;
|
||||
*this >> i;
|
||||
val = std::bit_cast<double>(i);
|
||||
|
||||
@ -55,7 +55,7 @@ Stream& Stream::operator>>(double& val)
|
||||
|
||||
Stream& Stream::operator<<(bool val)
|
||||
{
|
||||
std::uint8_t i = val;
|
||||
uint8 i = val;
|
||||
*this >> i;
|
||||
|
||||
return *this;
|
||||
@ -63,7 +63,7 @@ Stream& Stream::operator<<(bool val)
|
||||
|
||||
Stream& Stream::operator<<(float val)
|
||||
{
|
||||
std::uint32_t i = std::bit_cast<std::uint32_t>(val);
|
||||
uint32 i = std::bit_cast<uint32>(val);
|
||||
*this >> i;
|
||||
|
||||
return *this;
|
||||
@ -71,7 +71,7 @@ Stream& Stream::operator<<(float val)
|
||||
|
||||
Stream& Stream::operator<<(double val)
|
||||
{
|
||||
std::uint64_t i = std::bit_cast<std::uint64_t>(val);
|
||||
uint64 i = std::bit_cast<uint64>(val);
|
||||
*this >> i;
|
||||
|
||||
return *this;
|
||||
|
Loading…
Reference in New Issue
Block a user