mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-12 13:13:43 +00:00
unify line endings to shut up VS
This commit is contained in:
parent
c8d8428275
commit
d65968b41d
1724
rpcs3/Crypto/aes.cpp
1724
rpcs3/Crypto/aes.cpp
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "utils.h"
|
||||
|
||||
#pragma once
|
||||
#include "utils.h"
|
||||
|
||||
enum SELF_KEY_TYPE {
|
||||
KEY_LV0 = 1,
|
||||
KEY_LV1,
|
||||
@ -22,7 +22,7 @@ struct SELF_KEY {
|
||||
u8 priv[0x15];
|
||||
u32 curve_type;
|
||||
|
||||
SELF_KEY(u64 ver, u16 rev, u32 type, const std::string& e, const std::string& r, const std::string& pb, const std::string& pr, u32 ct)
|
||||
SELF_KEY(u64 ver, u16 rev, u32 type, const std::string& e, const std::string& r, const std::string& pb, const std::string& pr, u32 ct)
|
||||
{
|
||||
version = ver;
|
||||
revision = rev;
|
||||
@ -35,12 +35,12 @@ struct SELF_KEY {
|
||||
}
|
||||
};
|
||||
|
||||
static u8 PKG_AES_KEY[0x10] = {
|
||||
0x2e, 0x7b, 0x71, 0xd7, 0xc9, 0xc9, 0xa1, 0x4e, 0xa3, 0x22, 0x1f, 0x18, 0x88, 0x28, 0xb8, 0xf8
|
||||
static u8 PKG_AES_KEY[0x10] = {
|
||||
0x2e, 0x7b, 0x71, 0xd7, 0xc9, 0xc9, 0xa1, 0x4e, 0xa3, 0x22, 0x1f, 0x18, 0x88, 0x28, 0xb8, 0xf8
|
||||
};
|
||||
|
||||
static u8 NP_IDPS[0x10] = {
|
||||
0x5E, 0x06, 0xE0, 0x4F, 0xD9, 0x4A, 0x71, 0xBF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
|
||||
static u8 NP_IDPS[0x10] = {
|
||||
0x5E, 0x06, 0xE0, 0x4F, 0xD9, 0x4A, 0x71, 0xBF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
|
||||
};
|
||||
|
||||
static u8 NP_KLIC_FREE[0x10] = {
|
||||
@ -114,43 +114,43 @@ static u8 EDAT_HASH_1[0x10] = {
|
||||
static u8 EDAT_IV[0x10] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
class KeyVault
|
||||
{
|
||||
Array<SELF_KEY> sk_LV0_arr;
|
||||
Array<SELF_KEY> sk_LV1_arr;
|
||||
Array<SELF_KEY> sk_LV2_arr;
|
||||
Array<SELF_KEY> sk_APP_arr;
|
||||
Array<SELF_KEY> sk_ISO_arr;
|
||||
Array<SELF_KEY> sk_LDR_arr;
|
||||
Array<SELF_KEY> sk_UNK7_arr;
|
||||
Array<SELF_KEY> sk_NPDRM_arr;
|
||||
u8 klicensee_key[0x10];
|
||||
|
||||
public:
|
||||
KeyVault();
|
||||
SELF_KEY FindSelfKey(u32 type, u16 revision, u64 version);
|
||||
void SetKlicenseeKey(u8 *key);
|
||||
u8 *GetKlicenseeKey();
|
||||
|
||||
private:
|
||||
void LoadSelfLV0Keys();
|
||||
void LoadSelfLDRKeys();
|
||||
void LoadSelfLV1Keys();
|
||||
void LoadSelfLV2Keys();
|
||||
void LoadSelfISOKeys();
|
||||
void LoadSelfAPPKeys();
|
||||
void LoadSelfUNK7Keys();
|
||||
void LoadSelfNPDRMKeys();
|
||||
SELF_KEY GetSelfLV0Key();
|
||||
SELF_KEY GetSelfLDRKey();
|
||||
SELF_KEY GetSelfLV1Key(u64 version);
|
||||
SELF_KEY GetSelfLV2Key(u64 version);
|
||||
SELF_KEY GetSelfISOKey(u16 revision, u64 version);
|
||||
SELF_KEY GetSelfAPPKey(u16 revision);
|
||||
SELF_KEY GetSelfUNK7Key(u64 version);
|
||||
SELF_KEY GetSelfNPDRMKey(u16 revision);
|
||||
};
|
||||
|
||||
|
||||
class KeyVault
|
||||
{
|
||||
Array<SELF_KEY> sk_LV0_arr;
|
||||
Array<SELF_KEY> sk_LV1_arr;
|
||||
Array<SELF_KEY> sk_LV2_arr;
|
||||
Array<SELF_KEY> sk_APP_arr;
|
||||
Array<SELF_KEY> sk_ISO_arr;
|
||||
Array<SELF_KEY> sk_LDR_arr;
|
||||
Array<SELF_KEY> sk_UNK7_arr;
|
||||
Array<SELF_KEY> sk_NPDRM_arr;
|
||||
u8 klicensee_key[0x10];
|
||||
|
||||
public:
|
||||
KeyVault();
|
||||
SELF_KEY FindSelfKey(u32 type, u16 revision, u64 version);
|
||||
void SetKlicenseeKey(u8 *key);
|
||||
u8 *GetKlicenseeKey();
|
||||
|
||||
private:
|
||||
void LoadSelfLV0Keys();
|
||||
void LoadSelfLDRKeys();
|
||||
void LoadSelfLV1Keys();
|
||||
void LoadSelfLV2Keys();
|
||||
void LoadSelfISOKeys();
|
||||
void LoadSelfAPPKeys();
|
||||
void LoadSelfUNK7Keys();
|
||||
void LoadSelfNPDRMKeys();
|
||||
SELF_KEY GetSelfLV0Key();
|
||||
SELF_KEY GetSelfLDRKey();
|
||||
SELF_KEY GetSelfLV1Key(u64 version);
|
||||
SELF_KEY GetSelfLV2Key(u64 version);
|
||||
SELF_KEY GetSelfISOKey(u16 revision, u64 version);
|
||||
SELF_KEY GetSelfAPPKey(u16 revision);
|
||||
SELF_KEY GetSelfUNK7Key(u64 version);
|
||||
SELF_KEY GetSelfNPDRMKey(u16 revision);
|
||||
};
|
||||
|
||||
// RAP to RIF function.
|
||||
void rap_to_rif(unsigned char* rap, unsigned char* rif);
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
#include "utils.h"
|
||||
#include "key_vault.h"
|
||||
#include "Loader/ELF.h"
|
||||
#include "Loader/SELF.h"
|
||||
#include <wx/mstream.h>
|
||||
#include <wx/zstream.h>
|
||||
|
||||
#pragma once
|
||||
#include "utils.h"
|
||||
#include "key_vault.h"
|
||||
#include "Loader/ELF.h"
|
||||
#include "Loader/SELF.h"
|
||||
#include <wx/mstream.h>
|
||||
#include <wx/zstream.h>
|
||||
|
||||
struct AppInfo
|
||||
{
|
||||
u64 authid;
|
||||
@ -14,20 +14,20 @@ struct AppInfo
|
||||
u64 version;
|
||||
u64 padding;
|
||||
|
||||
void Load(vfsStream& f)
|
||||
{
|
||||
authid = Read64(f);
|
||||
vendor_id = Read32(f);
|
||||
self_type = Read32(f);
|
||||
version = Read64(f);
|
||||
void Load(vfsStream& f)
|
||||
{
|
||||
authid = Read64(f);
|
||||
vendor_id = Read32(f);
|
||||
self_type = Read32(f);
|
||||
version = Read64(f);
|
||||
padding = Read64(f);
|
||||
}
|
||||
|
||||
void Show()
|
||||
{
|
||||
ConLog.Write("AuthID: 0x%llx", authid);
|
||||
ConLog.Write("VendorID: 0x%08x", vendor_id);
|
||||
ConLog.Write("SELF type: 0x%08x", self_type);
|
||||
void Show()
|
||||
{
|
||||
ConLog.Write("AuthID: 0x%llx", authid);
|
||||
ConLog.Write("VendorID: 0x%08x", vendor_id);
|
||||
ConLog.Write("SELF type: 0x%08x", self_type);
|
||||
ConLog.Write("Version: 0x%llx", version);
|
||||
}
|
||||
};
|
||||
@ -41,21 +41,21 @@ struct SectionInfo
|
||||
u32 unknown2;
|
||||
u32 encrypted;
|
||||
|
||||
void Load(vfsStream& f)
|
||||
{
|
||||
offset = Read64(f);
|
||||
size = Read64(f);
|
||||
compressed = Read32(f);
|
||||
unknown1 = Read32(f);
|
||||
void Load(vfsStream& f)
|
||||
{
|
||||
offset = Read64(f);
|
||||
size = Read64(f);
|
||||
compressed = Read32(f);
|
||||
unknown1 = Read32(f);
|
||||
unknown2 = Read32(f);
|
||||
encrypted = Read32(f);
|
||||
}
|
||||
|
||||
void Show()
|
||||
{
|
||||
ConLog.Write("Offset: 0x%llx", offset);
|
||||
ConLog.Write("Size: 0x%llx", size);
|
||||
ConLog.Write("Compressed: 0x%08x", compressed);
|
||||
void Show()
|
||||
{
|
||||
ConLog.Write("Offset: 0x%llx", offset);
|
||||
ConLog.Write("Size: 0x%llx", size);
|
||||
ConLog.Write("Compressed: 0x%08x", compressed);
|
||||
ConLog.Write("Unknown1: 0x%08x", unknown1);
|
||||
ConLog.Write("Unknown2: 0x%08x", unknown2);
|
||||
ConLog.Write("Encrypted: 0x%08x", encrypted);
|
||||
@ -69,19 +69,19 @@ struct SCEVersionInfo
|
||||
u32 size;
|
||||
u32 unknown;
|
||||
|
||||
void Load(vfsStream& f)
|
||||
{
|
||||
subheader_type = Read32(f);
|
||||
present = Read32(f);
|
||||
size = Read32(f);
|
||||
void Load(vfsStream& f)
|
||||
{
|
||||
subheader_type = Read32(f);
|
||||
present = Read32(f);
|
||||
size = Read32(f);
|
||||
unknown = Read32(f);
|
||||
}
|
||||
|
||||
void Show()
|
||||
{
|
||||
ConLog.Write("Sub-header type: 0x%08x", subheader_type);
|
||||
ConLog.Write("Present: 0x%08x", present);
|
||||
ConLog.Write("Size: 0x%08x", size);
|
||||
void Show()
|
||||
{
|
||||
ConLog.Write("Sub-header type: 0x%08x", subheader_type);
|
||||
ConLog.Write("Present: 0x%08x", present);
|
||||
ConLog.Write("Size: 0x%08x", size);
|
||||
ConLog.Write("Unknown: 0x%08x", unknown);
|
||||
}
|
||||
};
|
||||
@ -133,9 +133,9 @@ struct ControlInfo
|
||||
} npdrm;
|
||||
};
|
||||
|
||||
void Load(vfsStream& f)
|
||||
{
|
||||
type = Read32(f);
|
||||
void Load(vfsStream& f)
|
||||
{
|
||||
type = Read32(f);
|
||||
size = Read32(f);
|
||||
next = Read64(f);
|
||||
|
||||
@ -179,10 +179,10 @@ struct ControlInfo
|
||||
}
|
||||
}
|
||||
|
||||
void Show()
|
||||
{
|
||||
ConLog.Write("Type: 0x%08x", type);
|
||||
ConLog.Write("Size: 0x%08x", size);
|
||||
void Show()
|
||||
{
|
||||
ConLog.Write("Type: 0x%08x", type);
|
||||
ConLog.Write("Size: 0x%08x", size);
|
||||
ConLog.Write("Next: 0x%llx", next);
|
||||
|
||||
if (type == 1)
|
||||
@ -259,11 +259,11 @@ struct MetadataInfo
|
||||
u8 iv[0x10];
|
||||
u8 iv_pad[0x10];
|
||||
|
||||
void Load(u8* in)
|
||||
{
|
||||
memcpy(key, in, 0x10);
|
||||
memcpy(key_pad, in + 0x10, 0x10);
|
||||
memcpy(iv, in + 0x20, 0x10);
|
||||
void Load(u8* in)
|
||||
{
|
||||
memcpy(key, in, 0x10);
|
||||
memcpy(key_pad, in + 0x10, 0x10);
|
||||
memcpy(iv, in + 0x20, 0x10);
|
||||
memcpy(iv_pad, in + 0x30, 0x10);
|
||||
}
|
||||
|
||||
@ -298,11 +298,11 @@ struct MetadataHeader
|
||||
u32 unknown2;
|
||||
u32 unknown3;
|
||||
|
||||
void Load(u8* in)
|
||||
{
|
||||
memcpy(&signature_input_length, in, 8);
|
||||
memcpy(&unknown1, in + 8, 4);
|
||||
memcpy(§ion_count, in + 12, 4);
|
||||
void Load(u8* in)
|
||||
{
|
||||
memcpy(&signature_input_length, in, 8);
|
||||
memcpy(&unknown1, in + 8, 4);
|
||||
memcpy(§ion_count, in + 12, 4);
|
||||
memcpy(&key_count, in + 16, 4);
|
||||
memcpy(&opt_header_size, in + 20, 4);
|
||||
memcpy(&unknown2, in + 24, 4);
|
||||
@ -318,11 +318,11 @@ struct MetadataHeader
|
||||
unknown3 = swap32(unknown3);
|
||||
}
|
||||
|
||||
void Show()
|
||||
{
|
||||
ConLog.Write("Signature input length: 0x%llx", signature_input_length);
|
||||
ConLog.Write("Unknown1: 0x%08x", unknown1);
|
||||
ConLog.Write("Section count: 0x%08x", section_count);
|
||||
void Show()
|
||||
{
|
||||
ConLog.Write("Signature input length: 0x%llx", signature_input_length);
|
||||
ConLog.Write("Unknown1: 0x%08x", unknown1);
|
||||
ConLog.Write("Section count: 0x%08x", section_count);
|
||||
ConLog.Write("Key count: 0x%08x", key_count);
|
||||
ConLog.Write("Optional header size: 0x%08x", opt_header_size);
|
||||
ConLog.Write("Unknown2: 0x%08x", unknown2);
|
||||
@ -343,17 +343,17 @@ struct MetadataSectionHeader
|
||||
u32 iv_idx;
|
||||
u32 compressed;
|
||||
|
||||
void Load(u8* in)
|
||||
{
|
||||
memcpy(&data_offset, in, 8);
|
||||
memcpy(&data_size, in + 8, 8);
|
||||
memcpy(&type, in + 16, 4);
|
||||
memcpy(&program_idx, in + 20, 4);
|
||||
memcpy(&hashed, in + 24, 4);
|
||||
memcpy(&sha1_idx, in + 28, 4);
|
||||
memcpy(&encrypted, in + 32, 4);
|
||||
memcpy(&key_idx, in + 36, 4);
|
||||
memcpy(&iv_idx, in + 40, 4);
|
||||
void Load(u8* in)
|
||||
{
|
||||
memcpy(&data_offset, in, 8);
|
||||
memcpy(&data_size, in + 8, 8);
|
||||
memcpy(&type, in + 16, 4);
|
||||
memcpy(&program_idx, in + 20, 4);
|
||||
memcpy(&hashed, in + 24, 4);
|
||||
memcpy(&sha1_idx, in + 28, 4);
|
||||
memcpy(&encrypted, in + 32, 4);
|
||||
memcpy(&key_idx, in + 36, 4);
|
||||
memcpy(&iv_idx, in + 40, 4);
|
||||
memcpy(&compressed, in + 44, 4);
|
||||
|
||||
// Endian swap.
|
||||
@ -369,11 +369,11 @@ struct MetadataSectionHeader
|
||||
compressed = swap32(compressed);
|
||||
}
|
||||
|
||||
void Show()
|
||||
{
|
||||
ConLog.Write("Data offset: 0x%llx", data_offset);
|
||||
ConLog.Write("Data size: 0x%llx", data_size);
|
||||
ConLog.Write("Type: 0x%08x", type);
|
||||
void Show()
|
||||
{
|
||||
ConLog.Write("Data offset: 0x%llx", data_offset);
|
||||
ConLog.Write("Data size: 0x%llx", data_size);
|
||||
ConLog.Write("Type: 0x%08x", type);
|
||||
ConLog.Write("Program index: 0x%08x", program_idx);
|
||||
ConLog.Write("Hashed: 0x%08x", hashed);
|
||||
ConLog.Write("SHA1 index: 0x%08x", sha1_idx);
|
||||
@ -389,10 +389,10 @@ struct SectionHash {
|
||||
u8 padding[12];
|
||||
u8 hmac_key[64];
|
||||
|
||||
void Load(vfsStream& f)
|
||||
{
|
||||
void Load(vfsStream& f)
|
||||
{
|
||||
f.Read(sha1, 20);
|
||||
f.Read(padding, 12);
|
||||
f.Read(padding, 12);
|
||||
f.Read(hmac_key, 64);
|
||||
}
|
||||
};
|
||||
@ -409,12 +409,12 @@ struct CapabilitiesInfo
|
||||
u32 unknown4;
|
||||
u32 unknown5;
|
||||
|
||||
void Load(vfsStream& f)
|
||||
{
|
||||
type = Read32(f);
|
||||
capabilities_size = Read32(f);
|
||||
next = Read32(f);
|
||||
unknown1 = Read32(f);
|
||||
void Load(vfsStream& f)
|
||||
{
|
||||
type = Read32(f);
|
||||
capabilities_size = Read32(f);
|
||||
next = Read32(f);
|
||||
unknown1 = Read32(f);
|
||||
unknown2 = Read64(f);
|
||||
unknown3 = Read64(f);
|
||||
flags = Read64(f);
|
||||
@ -429,10 +429,10 @@ struct Signature
|
||||
u8 s[21];
|
||||
u8 padding[6];
|
||||
|
||||
void Load(vfsStream& f)
|
||||
{
|
||||
void Load(vfsStream& f)
|
||||
{
|
||||
f.Read(r, 21);
|
||||
f.Read(s, 21);
|
||||
f.Read(s, 21);
|
||||
f.Read(padding, 6);
|
||||
}
|
||||
};
|
||||
@ -443,65 +443,65 @@ struct SelfSection
|
||||
u64 size;
|
||||
u64 offset;
|
||||
|
||||
void Load(vfsStream& f)
|
||||
{
|
||||
*data = Read32(f);
|
||||
size = Read64(f);
|
||||
void Load(vfsStream& f)
|
||||
{
|
||||
*data = Read32(f);
|
||||
size = Read64(f);
|
||||
offset = Read64(f);
|
||||
}
|
||||
};
|
||||
|
||||
class SELFDecrypter
|
||||
{
|
||||
// Main SELF file stream.
|
||||
vfsStream& self_f;
|
||||
|
||||
// SCE, SELF and APP headers.
|
||||
SceHeader sce_hdr;
|
||||
SelfHeader self_hdr;
|
||||
AppInfo app_info;
|
||||
|
||||
// ELF64 header and program header/section header arrays.
|
||||
Elf64_Ehdr elf64_hdr;
|
||||
Array<Elf64_Shdr> shdr64_arr;
|
||||
Array<Elf64_Phdr> phdr64_arr;
|
||||
|
||||
// ELF32 header and program header/section header arrays.
|
||||
Elf32_Ehdr elf32_hdr;
|
||||
Array<Elf32_Shdr> shdr32_arr;
|
||||
Array<Elf32_Phdr> phdr32_arr;
|
||||
|
||||
// Decryption info structs.
|
||||
Array<SectionInfo> secinfo_arr;
|
||||
SCEVersionInfo scev_info;
|
||||
Array<ControlInfo> ctrlinfo_arr;
|
||||
|
||||
// Metadata structs.
|
||||
MetadataInfo meta_info;
|
||||
MetadataHeader meta_hdr;
|
||||
Array<MetadataSectionHeader> meta_shdr;
|
||||
|
||||
// Internal data buffers.
|
||||
u8 *data_keys;
|
||||
u32 data_keys_length;
|
||||
u8 *data_buf;
|
||||
u32 data_buf_length;
|
||||
|
||||
// Main key vault instance.
|
||||
KeyVault key_v;
|
||||
|
||||
public:
|
||||
SELFDecrypter(vfsStream& s);
|
||||
bool MakeElf(const std::string& elf, bool isElf32);
|
||||
bool LoadHeaders(bool isElf32);
|
||||
void ShowHeaders(bool isElf32);
|
||||
bool LoadMetadata();
|
||||
bool DecryptData();
|
||||
bool DecryptNPDRM(u8 *metadata, u32 metadata_size);
|
||||
bool GetKeyFromRap(u8 *content_id, u8 *npdrm_key);
|
||||
};
|
||||
|
||||
extern bool IsSelf(const std::string& path);
|
||||
extern bool IsSelfElf32(const std::string& path);
|
||||
extern bool CheckDebugSelf(const std::string& self, const std::string& elf);
|
||||
extern bool DecryptSelf(const std::string& elf, const std::string& self);
|
||||
};
|
||||
|
||||
class SELFDecrypter
|
||||
{
|
||||
// Main SELF file stream.
|
||||
vfsStream& self_f;
|
||||
|
||||
// SCE, SELF and APP headers.
|
||||
SceHeader sce_hdr;
|
||||
SelfHeader self_hdr;
|
||||
AppInfo app_info;
|
||||
|
||||
// ELF64 header and program header/section header arrays.
|
||||
Elf64_Ehdr elf64_hdr;
|
||||
Array<Elf64_Shdr> shdr64_arr;
|
||||
Array<Elf64_Phdr> phdr64_arr;
|
||||
|
||||
// ELF32 header and program header/section header arrays.
|
||||
Elf32_Ehdr elf32_hdr;
|
||||
Array<Elf32_Shdr> shdr32_arr;
|
||||
Array<Elf32_Phdr> phdr32_arr;
|
||||
|
||||
// Decryption info structs.
|
||||
Array<SectionInfo> secinfo_arr;
|
||||
SCEVersionInfo scev_info;
|
||||
Array<ControlInfo> ctrlinfo_arr;
|
||||
|
||||
// Metadata structs.
|
||||
MetadataInfo meta_info;
|
||||
MetadataHeader meta_hdr;
|
||||
Array<MetadataSectionHeader> meta_shdr;
|
||||
|
||||
// Internal data buffers.
|
||||
u8 *data_keys;
|
||||
u32 data_keys_length;
|
||||
u8 *data_buf;
|
||||
u32 data_buf_length;
|
||||
|
||||
// Main key vault instance.
|
||||
KeyVault key_v;
|
||||
|
||||
public:
|
||||
SELFDecrypter(vfsStream& s);
|
||||
bool MakeElf(const std::string& elf, bool isElf32);
|
||||
bool LoadHeaders(bool isElf32);
|
||||
void ShowHeaders(bool isElf32);
|
||||
bool LoadMetadata();
|
||||
bool DecryptData();
|
||||
bool DecryptNPDRM(u8 *metadata, u32 metadata_size);
|
||||
bool GetKeyFromRap(u8 *content_id, u8 *npdrm_key);
|
||||
};
|
||||
|
||||
extern bool IsSelf(const std::string& path);
|
||||
extern bool IsSelfElf32(const std::string& path);
|
||||
extern bool CheckDebugSelf(const std::string& self, const std::string& elf);
|
||||
extern bool DecryptSelf(const std::string& elf, const std::string& self);
|
||||
|
@ -1,12 +1,12 @@
|
||||
#include "stdafx.h"
|
||||
#include "utils.h"
|
||||
|
||||
// Endian swap auxiliary functions.
|
||||
#include "stdafx.h"
|
||||
#include "utils.h"
|
||||
|
||||
// Endian swap auxiliary functions.
|
||||
u16 swap16(u16 i)
|
||||
{
|
||||
return ((i & 0xFF00) >> 8) | ((i & 0xFF) << 8);
|
||||
}
|
||||
|
||||
{
|
||||
return ((i & 0xFF00) >> 8) | ((i & 0xFF) << 8);
|
||||
}
|
||||
|
||||
u32 swap32(u32 i)
|
||||
{
|
||||
return ((i & 0xFF000000) >> 24) | ((i & 0xFF0000) >> 8) | ((i & 0xFF00) << 8) | ((i & 0xFF) << 24);
|
||||
@ -28,32 +28,32 @@ void xor_(unsigned char *dest, unsigned char *src1, unsigned char *src2, int siz
|
||||
dest[i] = src1[i] ^ src2[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Hex string conversion auxiliary functions.
|
||||
u64 hex_to_u64(const char* hex_str)
|
||||
{
|
||||
u32 length = strlen(hex_str);
|
||||
u64 tmp = 0;
|
||||
u64 result = 0;
|
||||
char c;
|
||||
|
||||
while (length--)
|
||||
{
|
||||
c = *hex_str++;
|
||||
if((c >= '0') && (c <= '9'))
|
||||
tmp = c - '0';
|
||||
else if((c >= 'a') && (c <= 'f'))
|
||||
tmp = c - 'a' + 10;
|
||||
else if((c >= 'A') && (c <= 'F'))
|
||||
tmp = c - 'A' + 10;
|
||||
else
|
||||
tmp = 0;
|
||||
result |= (tmp << (length * 4));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Hex string conversion auxiliary functions.
|
||||
u64 hex_to_u64(const char* hex_str)
|
||||
{
|
||||
u32 length = strlen(hex_str);
|
||||
u64 tmp = 0;
|
||||
u64 result = 0;
|
||||
char c;
|
||||
|
||||
while (length--)
|
||||
{
|
||||
c = *hex_str++;
|
||||
if((c >= '0') && (c <= '9'))
|
||||
tmp = c - '0';
|
||||
else if((c >= 'a') && (c <= 'f'))
|
||||
tmp = c - 'a' + 10;
|
||||
else if((c >= 'A') && (c <= 'F'))
|
||||
tmp = c - 'A' + 10;
|
||||
else
|
||||
tmp = 0;
|
||||
result |= (tmp << (length * 4));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void hex_to_bytes(unsigned char *data, const char *hex_str)
|
||||
{
|
||||
u32 str_length = strlen(hex_str);
|
||||
@ -101,19 +101,19 @@ bool hmac_hash_compare(unsigned char *key, int key_len, unsigned char *in, int i
|
||||
{
|
||||
unsigned char *out = new unsigned char[key_len];
|
||||
|
||||
sha1_hmac(key, key_len, in, in_len, out);
|
||||
|
||||
for (int i = 0; i < 0x10; i++)
|
||||
{
|
||||
if (out[i] != hash[i])
|
||||
sha1_hmac(key, key_len, in, in_len, out);
|
||||
|
||||
for (int i = 0; i < 0x10; i++)
|
||||
{
|
||||
if (out[i] != hash[i])
|
||||
{
|
||||
delete[] out;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
delete[] out;
|
||||
|
||||
delete[] out;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
delete[] out;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -123,19 +123,19 @@ bool cmac_hash_compare(unsigned char *key, int key_len, unsigned char *in, int i
|
||||
|
||||
aes_context ctx;
|
||||
aes_setkey_enc(&ctx, key, 128);
|
||||
aes_cmac(&ctx, in_len, in, out);
|
||||
|
||||
for (int i = 0; i < key_len; i++)
|
||||
{
|
||||
if (out[i] != hash[i])
|
||||
aes_cmac(&ctx, in_len, in, out);
|
||||
|
||||
for (int i = 0; i < key_len; i++)
|
||||
{
|
||||
if (out[i] != hash[i])
|
||||
{
|
||||
delete[] out;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
delete[] out;
|
||||
|
||||
delete[] out;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
delete[] out;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -744,4 +744,4 @@ int lz_decompress(unsigned char *out, unsigned char *in, unsigned int size)
|
||||
delete[] tmp;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
#include "aes.h"
|
||||
#include "sha1.h"
|
||||
|
||||
// Auxiliary functions (endian swap and xor).
|
||||
u16 swap16(u16 i);
|
||||
u32 swap32(u32 i);
|
||||
u64 swap64(u64 i);
|
||||
#include "sha1.h"
|
||||
|
||||
// Auxiliary functions (endian swap and xor).
|
||||
u16 swap16(u16 i);
|
||||
u32 swap32(u32 i);
|
||||
u64 swap64(u64 i);
|
||||
void xor_(unsigned char *dest, unsigned char *src1, unsigned char *src2, int size);
|
||||
|
||||
// Hex string conversion auxiliary functions.
|
||||
u64 hex_to_u64(const char* hex_str);
|
||||
void hex_to_bytes(unsigned char *data, const char *hex_str);
|
||||
|
||||
// Hex string conversion auxiliary functions.
|
||||
u64 hex_to_u64(const char* hex_str);
|
||||
void hex_to_bytes(unsigned char *data, const char *hex_str);
|
||||
|
||||
// Crypto functions (AES128-CBC, AES128-ECB, SHA1-HMAC and AES-CMAC).
|
||||
void aescbc128_decrypt(unsigned char *key, unsigned char *iv, unsigned char *in, unsigned char *out, int len);
|
||||
@ -19,4 +19,4 @@ bool hmac_hash_compare(unsigned char *key, int key_len, unsigned char *in, int i
|
||||
bool cmac_hash_compare(unsigned char *key, int key_len, unsigned char *in, int in_len, unsigned char *hash);
|
||||
|
||||
// Reverse-engineered custom Lempel–Ziv–Markov based compression (unknown variant of LZRC).
|
||||
int lz_decompress(unsigned char *out, unsigned char *in, unsigned int size);
|
||||
int lz_decompress(unsigned char *out, unsigned char *in, unsigned int size);
|
||||
|
Loading…
x
Reference in New Issue
Block a user