Skip to content

Commit

Permalink
pro: normalize code style in all manifest crypto code
Browse files Browse the repository at this point in the history
  • Loading branch information
ZingBallyhoo committed Dec 2, 2023
1 parent 2ab6dc3 commit e032381
Show file tree
Hide file tree
Showing 169 changed files with 5,120 additions and 4,469 deletions.
3 changes: 2 additions & 1 deletion TACTLib/Core/Product/Tank/CMF/ProCMF_105760.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public byte[] IV(CMFHeader header, byte[] digest, int length)
byte[] buffer = new byte[length];
uint kidx, okidx;
kidx = okidx = Keytable[(digest[7] * Keytable[0]) & 511];
for (int i = 0; i != length; ++i) {
for (int i = 0; i != length; ++i)
{
buffer[i] = Keytable[SignedMod(kidx, 512)];
kidx += ((digest[6] & 1) != 0) ? 37 : (okidx % 61);
buffer[i] ^= digest[SignedMod(kidx - i, SHA1_DIGESTSIZE)];
Expand Down
23 changes: 15 additions & 8 deletions TACTLib/Core/Product/Tank/CMF/ProCMF_35328.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
using static TACTLib.Core.Product.Tank.ManifestCryptoHandler;
using static TACTLib.Core.Product.Tank.ContentManifestFile;

namespace TACTLib.Core.Product.Tank.CMF {
namespace TACTLib.Core.Product.Tank.CMF
{
[ManifestCrypto(AutoDetectVersion = true, Product = TACTProduct.Overwatch)]
public class ProCMF_35328 : ICMFEncryptionProc {
public byte[] Key(CMFHeader header, int length) {
public class ProCMF_35328 : ICMFEncryptionProc
{
public byte[] Key(CMFHeader header, int length)
{
byte[] buffer = new byte[length];

uint kidx = Keytable[header.m_dataCount & 511];
const uint increment = 3;
for (int i = 0; i != length; ++i) {
for (int i = 0; i != length; ++i)
{
buffer[i] = Keytable[kidx % 512];
kidx += increment;
}

return buffer;
}

public byte[] IV(CMFHeader header, byte[] digest, int length) {
public byte[] IV(CMFHeader header, byte[] digest, int length)
{
byte[] buffer = new byte[length];

uint kidx = Constrain(header.m_buildVersion * length);
uint increment = kidx % 61;
for (int i = 0; i != length; ++i) {
for (int i = 0; i != length; ++i)
{
buffer[i] = Keytable[kidx % 512];
kidx += increment;
buffer[i] ^= digest[(kidx - i) % SHA1_DIGESTSIZE];
}

return buffer;
}

private static readonly byte[] Keytable = {

private static readonly byte[] Keytable =
{
0xAB, 0xD1, 0x7A, 0xF5, 0xD8, 0x95, 0x03, 0x95, 0x07, 0xBF, 0xD0, 0x51, 0xA3, 0x8D, 0x54, 0xD2,
0xB7, 0xB9, 0xB3, 0xC7, 0xF3, 0x95, 0x77, 0xB5, 0x86, 0xAB, 0xE0, 0x83, 0xF9, 0x69, 0xD5, 0x05,
0xEF, 0xB6, 0x39, 0xED, 0x3A, 0xEB, 0x35, 0x99, 0x28, 0x59, 0xFE, 0xA9, 0xB4, 0xC2, 0x3A, 0x32,
Expand Down
21 changes: 14 additions & 7 deletions TACTLib/Core/Product/Tank/CMF/ProCMF_35455.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
using static TACTLib.Core.Product.Tank.ManifestCryptoHandler;
using static TACTLib.Core.Product.Tank.ContentManifestFile;

namespace TACTLib.Core.Product.Tank.CMF {
namespace TACTLib.Core.Product.Tank.CMF
{
[ManifestCrypto(AutoDetectVersion = true, Product = TACTProduct.Overwatch)]
public class ProCMF_35455 : ICMFEncryptionProc {
public byte[] Key(CMFHeader header, int length) {
public class ProCMF_35455 : ICMFEncryptionProc
{
public byte[] Key(CMFHeader header, int length)
{
byte[] buffer = new byte[length];

uint kidx = 193;
const uint increment = 319;
for (int i = 0; i != length; ++i) {
for (int i = 0; i != length; ++i)
{
buffer[i] = Keytable[kidx % 512];
kidx -= increment;
}

return buffer;
}

public byte[] IV(CMFHeader header, byte[] digest, int length) {
public byte[] IV(CMFHeader header, byte[] digest, int length)
{
byte[] buffer = new byte[length];

uint kidx = Keytable[header.m_dataCount & 511];
for (int i = 0; i != length; ++i) {
for (int i = 0; i != length; ++i)
{
kidx += (uint)header.m_entryCount + digest[header.m_entryCount % SHA1_DIGESTSIZE];
buffer[i] = digest[kidx % SHA1_DIGESTSIZE];
}

return buffer;
}

private static readonly byte[] Keytable = {
private static readonly byte[] Keytable =
{
0x80, 0x8A, 0x26, 0xFC, 0x2E, 0xCC, 0x67, 0xEC, 0x9D, 0xEC, 0x33, 0xEC, 0xCA, 0xA8, 0x86, 0x38,
0x54, 0x3F, 0x9E, 0xD3, 0x5A, 0xC4, 0xDC, 0x67, 0xA5, 0xE0, 0xB5, 0x06, 0x8D, 0xD7, 0xED, 0x5F,
0x4C, 0xE9, 0xF3, 0x28, 0x05, 0x19, 0x2E, 0xAF, 0x55, 0x15, 0x85, 0x34, 0x82, 0x82, 0xEA, 0xC3,
Expand Down
21 changes: 14 additions & 7 deletions TACTLib/Core/Product/Tank/CMF/ProCMF_35780.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
using static TACTLib.Core.Product.Tank.ManifestCryptoHandler;
using static TACTLib.Core.Product.Tank.ContentManifestFile;

namespace TACTLib.Core.Product.Tank.CMF {
namespace TACTLib.Core.Product.Tank.CMF
{
[ManifestCrypto(AutoDetectVersion = true, Product = TACTProduct.Overwatch)]
public class ProCMF_35780 : ICMFEncryptionProc {
public byte[] Key(CMFHeader header, int length) {
public class ProCMF_35780 : ICMFEncryptionProc
{
public byte[] Key(CMFHeader header, int length)
{
byte[] buffer = new byte[length];

uint kidx = 193;
const uint increment = 319;
for (int i = 0; i != length; ++i) {
for (int i = 0; i != length; ++i)
{
buffer[i] = Keytable[kidx % 512];
kidx -= increment;
}

return buffer;
}

public byte[] IV(CMFHeader header, byte[] digest, int length) {
public byte[] IV(CMFHeader header, byte[] digest, int length)
{
byte[] buffer = new byte[length];

uint kidx = Keytable[header.m_dataCount & 511];
for (int i = 0; i != length; ++i) {
for (int i = 0; i != length; ++i)
{
kidx += (uint)header.m_entryCount + digest[header.m_entryCount % SHA1_DIGESTSIZE];
buffer[i] = digest[kidx % SHA1_DIGESTSIZE];
}

return buffer;
}

private static readonly byte[] Keytable = {
private static readonly byte[] Keytable =
{
0x80, 0x8A, 0x26, 0xFC, 0x2E, 0xCC, 0x67, 0xEC, 0x9D, 0xEC, 0x33, 0xEC, 0xCA, 0xA8, 0x86, 0x38,
0x54, 0x3F, 0x9E, 0xD3, 0x5A, 0xC4, 0xDC, 0x67, 0xA5, 0xE0, 0xB5, 0x06, 0x8D, 0xD7, 0xED, 0x5F,
0x4C, 0xE9, 0xF3, 0x28, 0x05, 0x19, 0x2E, 0xAF, 0x55, 0x15, 0x85, 0x34, 0x82, 0x82, 0xEA, 0xC3,
Expand Down
23 changes: 15 additions & 8 deletions TACTLib/Core/Product/Tank/CMF/ProCMF_36473.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
using static TACTLib.Core.Product.Tank.ManifestCryptoHandler;
using static TACTLib.Core.Product.Tank.ContentManifestFile;

namespace TACTLib.Core.Product.Tank.CMF {
namespace TACTLib.Core.Product.Tank.CMF
{
[ManifestCrypto(AutoDetectVersion = true, Product = TACTProduct.Overwatch)]
public class ProCMF_36473 : ICMFEncryptionProc {
public byte[] Key(CMFHeader header, int length) {
public class ProCMF_36473 : ICMFEncryptionProc
{
public byte[] Key(CMFHeader header, int length)
{
byte[] buffer = new byte[length];

uint kidx = Constrain(header.m_buildVersion * length);
uint increment = header.m_buildVersion;
for (int i = 0; i != length; ++i) {
for (int i = 0; i != length; ++i)
{
buffer[i] = Keytable[kidx % 512];
kidx = increment - kidx;
}

return buffer;
}

public byte[] IV(CMFHeader header, byte[] digest, int length) {
public byte[] IV(CMFHeader header, byte[] digest, int length)
{
byte[] buffer = new byte[length];

uint kidx = Keytable[header.m_buildVersion & 511];
uint increment = kidx % 29;
for (int i = 0; i != length; ++i) {
for (int i = 0; i != length; ++i)
{
buffer[i] = Keytable[kidx % 512];
kidx += increment;
buffer[i] ^= (byte) ((digest[(kidx + header.m_entryCount) % SHA1_DIGESTSIZE] + 1) % 0xFF);
buffer[i] ^= (byte)((digest[(kidx + header.m_entryCount) % SHA1_DIGESTSIZE] + 1) % 0xFF);
}

return buffer;
}

private static readonly byte[] Keytable = {
private static readonly byte[] Keytable =
{
0x9E, 0x8C, 0x4E, 0xAE, 0xE9, 0xC9, 0x80, 0x1C, 0x79, 0x27, 0xCD, 0x28, 0x69, 0xFB, 0x97, 0x73,
0xA2, 0x96, 0x71, 0x74, 0x65, 0x3D, 0xD6, 0x80, 0x24, 0x26, 0xB9, 0x3D, 0xE6, 0x59, 0xFD, 0xE3,
0x98, 0x15, 0x8A, 0x83, 0x06, 0x92, 0x82, 0x01, 0x87, 0x19, 0x19, 0xF9, 0x59, 0xDE, 0xFC, 0x91,
Expand Down
44 changes: 26 additions & 18 deletions TACTLib/Core/Product/Tank/CMF/ProCMF_36859.cs
Original file line number Diff line number Diff line change
@@ -1,47 +1,55 @@
using static TACTLib.Core.Product.Tank.ManifestCryptoHandler;
using static TACTLib.Core.Product.Tank.ContentManifestFile;

namespace TACTLib.Core.Product.Tank.CMF {
namespace TACTLib.Core.Product.Tank.CMF
{
[ManifestCrypto(AutoDetectVersion = true, Product = TACTProduct.Overwatch)]
public class ProCMF_36859 : ICMFEncryptionProc {
public byte[] Key(CMFHeader header, int length) {
public class ProCMF_36859 : ICMFEncryptionProc
{
public byte[] Key(CMFHeader header, int length)
{
byte[] buffer = new byte[length];

uint kidx = 31;
const uint increment = 393;
for (int i = 0; i != length; ++i) {
for (int i = 0; i != length; ++i)
{
buffer[i] = Keytable[kidx % 512];
kidx -= increment;
}

return buffer;
}

public byte[] IV(CMFHeader header, byte[] digest, int length) {
public byte[] IV(CMFHeader header, byte[] digest, int length)
{
byte[] buffer = new byte[length];

uint kidx = Keytable[header.m_dataCount & 511];
for (int i = 0; i != length; ++i) {
for (int i = 0; i != length; ++i)
{
buffer[i] = Keytable[kidx % 512];
switch (kidx % 3) {
case 0:
kidx += 103;
break;
case 1:
kidx = 4 * kidx % header.m_buildVersion;
break;
case 2:
--kidx;
break;
switch (kidx % 3)
{
case 0:
kidx += 103;
break;
case 1:
kidx = 4 * kidx % header.m_buildVersion;
break;
case 2:
--kidx;
break;
}

buffer[i] ^= digest[(kidx + header.m_buildVersion) % SHA1_DIGESTSIZE];
}

return buffer;
}

private static readonly byte[] Keytable = {

private static readonly byte[] Keytable =
{
0xAB, 0x6B, 0xD4, 0xC1, 0x8E, 0xB5, 0xDE, 0xE3, 0xE7, 0xE0, 0x0C, 0x0B, 0x0E, 0xD2, 0x9D, 0x88,
0x6F, 0xD9, 0x6E, 0x7A, 0x0A, 0x17, 0x09, 0x75, 0x35, 0x1C, 0x95, 0x65, 0xDD, 0x02, 0xE2, 0x06,
0x49, 0xBF, 0xE6, 0xAD, 0x68, 0xB2, 0x6E, 0x53, 0x2D, 0x64, 0x68, 0x59, 0x18, 0x98, 0x6E, 0x63,
Expand Down
23 changes: 15 additions & 8 deletions TACTLib/Core/Product/Tank/CMF/ProCMF_37104.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
using static TACTLib.Core.Product.Tank.ManifestCryptoHandler;
using static TACTLib.Core.Product.Tank.ContentManifestFile;

namespace TACTLib.Core.Product.Tank.CMF {
namespace TACTLib.Core.Product.Tank.CMF
{
[ManifestCrypto(AutoDetectVersion = true, Product = TACTProduct.Overwatch)]
public class ProCMF_37104 : ICMFEncryptionProc {
public byte[] Key(CMFHeader header, int length) {
public class ProCMF_37104 : ICMFEncryptionProc
{
public byte[] Key(CMFHeader header, int length)
{
byte[] buffer = new byte[length];

uint kidx = Keytable[length + 256];
uint increment = header.m_buildVersion * (uint)header.m_dataCount % 7;
for (int i = 0; i != length; ++i) {
for (int i = 0; i != length; ++i)
{
buffer[i] = Keytable[kidx % 512];
kidx += increment;
}

return buffer;
}

public byte[] IV(CMFHeader header, byte[] digest, int length) {
public byte[] IV(CMFHeader header, byte[] digest, int length)
{
byte[] buffer = new byte[length];

uint kidx = Keytable[(13 * digest[7]) & 511];
for (int i = 0; i != length; ++i) {
for (int i = 0; i != length; ++i)
{
kidx += (uint)header.m_entryCount + digest[header.m_entryCount % SHA1_DIGESTSIZE];
buffer[i] = digest[kidx % SHA1_DIGESTSIZE];
}

return buffer;
}

private static readonly byte[] Keytable = {

private static readonly byte[] Keytable =
{
0x0D, 0x95, 0x08, 0x0B, 0xF3, 0x80, 0xE1, 0x2E, 0x04, 0x0B, 0xF9, 0x1A, 0x5B, 0x5E, 0xF5, 0x60,
0xB3, 0xC6, 0x2F, 0x91, 0x8F, 0x3B, 0xED, 0x2B, 0x3D, 0xE5, 0xB2, 0x06, 0x76, 0x38, 0x7E, 0xAB,
0xDF, 0x70, 0x95, 0x3A, 0x6D, 0xE5, 0x13, 0x18, 0x3D, 0x54, 0x2B, 0x13, 0x2C, 0x4F, 0x62, 0x1B,
Expand Down
Loading

0 comments on commit e032381

Please sign in to comment.