From 002dcd61b68b9ff361ffa47e72b293abbcd26dbe Mon Sep 17 00:00:00 2001 From: zingballyhoo Date: Wed, 22 Nov 2023 14:26:59 +0000 Subject: [PATCH] [pro]: cmf for 118879 --- .../Core/Product/Tank/CMF/ProCMF_118879.cs | 83 +++++++++++++++++++ .../Core/Product/Tank/TRG/ProTRG_118879.cs | 83 +++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 TACTLib/Core/Product/Tank/CMF/ProCMF_118879.cs create mode 100644 TACTLib/Core/Product/Tank/TRG/ProTRG_118879.cs diff --git a/TACTLib/Core/Product/Tank/CMF/ProCMF_118879.cs b/TACTLib/Core/Product/Tank/CMF/ProCMF_118879.cs new file mode 100644 index 0000000..888928a --- /dev/null +++ b/TACTLib/Core/Product/Tank/CMF/ProCMF_118879.cs @@ -0,0 +1,83 @@ +using static TACTLib.Core.Product.Tank.ManifestCryptoHandler; +using static TACTLib.Core.Product.Tank.ContentManifestFile; + +namespace TACTLib.Core.Product.Tank.CMF +{ + [ManifestCrypto(AutoDetectVersion = true, Product = TACTProduct.Overwatch)] + public class ProCMF_118879 : ICMFEncryptionProc + { + public byte[] Key(CMFHeader header, int length) + { + byte[] buffer = new byte[length]; + uint kidx, okidx; + kidx = okidx = Keytable[length + 256]; + for (uint i = 0; i != length; ++i) + { + buffer[i] = Keytable[SignedMod(kidx, 512)]; + switch (SignedMod(kidx, 3)) + { + case 0: + kidx += 103; + break; + case 1: + kidx = (uint)SignedMod(kidx * 4, header.m_buildVersion); + break; + case 2: + --kidx; + break; + } + } + return buffer; + } + + public byte[] IV(CMFHeader header, byte[] digest, int length) + { + byte[] buffer = new byte[length]; + uint kidx, okidx; + kidx = okidx = (uint)(2 * digest[5]); + for (int i = 0; i != length; ++i) + { + buffer[i] = Keytable[SignedMod(kidx, 512)]; + kidx -= header.m_buildVersion & 511; + buffer[i] ^= digest[SignedMod(kidx + header.m_buildVersion, SHA1_DIGESTSIZE)]; + } + return buffer; + } + + private static readonly byte[] Keytable =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, 0xAF, 0xDC, 0xC4, 0xEB, 0xE4, 0xAD, 0xE6, + 0x76, 0xAD, 0x55, 0xC7, 0x5F, 0x41, 0x3F, 0xA4, 0xB4, 0xA8, 0x54, 0x4B, 0xEE, 0x16, 0x67, 0x7E, + 0x1E, 0xD3, 0xA2, 0xB9, 0x1F, 0xEE, 0x3D, 0x98, 0xDD, 0x45, 0x04, 0x41, 0x58, 0xE5, 0x7D, 0x9A, + 0x9A, 0xA0, 0x0E, 0x76, 0x0A, 0x6C, 0x4F, 0xBD, 0xEC, 0x47, 0x4D, 0xF6, 0x78, 0x81, 0xE9, 0x38, + 0xB4, 0x08, 0xEF, 0xB6, 0x3B, 0x53, 0x38, 0x73, 0x60, 0x02, 0x28, 0x6E, 0x8B, 0x7D, 0x86, 0x81, + 0xBB, 0xCB, 0x13, 0xBD, 0x05, 0xF2, 0x7E, 0x4D, 0x34, 0x74, 0xB7, 0xCC, 0xD6, 0x78, 0x11, 0x85, + 0xCF, 0x17, 0x97, 0x99, 0x4B, 0x0D, 0x6E, 0x97, 0xF5, 0xB7, 0x86, 0x52, 0xB9, 0xE7, 0xDB, 0x3E, + 0x88, 0xC3, 0xC2, 0xF0, 0x78, 0x43, 0xBB, 0x6E, 0xAF, 0x81, 0xE2, 0x79, 0xAA, 0x03, 0xD5, 0xB2, + 0xAA, 0xF8, 0x12, 0xBA, 0x21, 0xBC, 0x81, 0x86, 0x15, 0x04, 0x50, 0xFB, 0xEF, 0xB0, 0x88, 0x5A, + 0xCA, 0xCE, 0x05, 0xCD, 0x79, 0xDE, 0x89, 0xA9, 0x5F, 0x2B, 0x05, 0x01, 0xC2, 0x1E, 0x28, 0x4D + }; + } +} \ No newline at end of file diff --git a/TACTLib/Core/Product/Tank/TRG/ProTRG_118879.cs b/TACTLib/Core/Product/Tank/TRG/ProTRG_118879.cs new file mode 100644 index 0000000..803b772 --- /dev/null +++ b/TACTLib/Core/Product/Tank/TRG/ProTRG_118879.cs @@ -0,0 +1,83 @@ +using static TACTLib.Core.Product.Tank.ManifestCryptoHandler; +using static TACTLib.Core.Product.Tank.ResourceGraph; + +namespace TACTLib.Core.Product.Tank.TRG +{ + [ManifestCrypto(AutoDetectVersion = true, Product = TACTProduct.Overwatch)] + public class ProTRG_118879 : ITRGEncryptionProc + { + public byte[] Key(TRGHeader header, int length) + { + byte[] buffer = new byte[length]; + uint kidx, okidx; + kidx = okidx = Keytable[length + 256]; + for (uint i = 0; i != length; ++i) + { + buffer[i] = Keytable[SignedMod(kidx, 512)]; + switch (SignedMod(kidx, 3)) + { + case 0: + kidx += 1273; + break; + case 1: + kidx = (uint)SignedMod(kidx * 4, header.m_buildVersion); + break; + case 2: + kidx -= 17; + break; + } + } + return buffer; + } + + public byte[] IV(TRGHeader header, byte[] digest, int length) + { + byte[] buffer = new byte[length]; + uint kidx, okidx; + kidx = okidx = (uint)(2 * digest[7]); + for (int i = 0; i != length; ++i) + { + buffer[i] = Keytable[SignedMod(kidx, 512)]; + kidx -= header.m_buildVersion & 511; + buffer[i] ^= digest[SignedMod(kidx + header.m_buildVersion, SHA1_DIGESTSIZE)]; + } + return buffer; + } + + private static readonly byte[] Keytable = + { + 0x47, 0xA6, 0x9E, 0x97, 0xED, 0xB9, 0x56, 0xB9, 0x14, 0x20, 0xA7, 0xEB, 0xE0, 0x09, 0x41, 0x17, + 0x11, 0x7A, 0x97, 0xC8, 0x72, 0x0D, 0x8B, 0xEB, 0xF3, 0xA9, 0x93, 0x6E, 0xB7, 0x3D, 0x29, 0xFF, + 0x6C, 0x34, 0x40, 0x49, 0x18, 0xF7, 0x1E, 0xDC, 0xF2, 0x1D, 0x7E, 0x5C, 0xBB, 0xE2, 0x7F, 0x01, + 0x56, 0x8A, 0xC0, 0x7F, 0xE7, 0x6B, 0x15, 0xC0, 0x68, 0x22, 0x95, 0x01, 0xCF, 0xFF, 0x65, 0x42, + 0xCE, 0xCA, 0xD9, 0xE5, 0x59, 0xA2, 0xE7, 0x23, 0xC1, 0xBC, 0x37, 0xD1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x05, 0xF2, 0x7E, 0x4D, 0x34, 0x74, 0xB7, 0xCC, 0xD6, 0x78, 0x11, 0x85, + 0xCF, 0x17, 0x97, 0x99, 0x4B, 0x0D, 0x6E, 0x97, 0xF5, 0xB7, 0x86, 0x52, 0xB9, 0xE7, 0xDB, 0x3E, + 0x88, 0xC3, 0xC2, 0xF0, 0x78, 0x43, 0xBB, 0x6E, 0xAF, 0x81, 0xE2, 0x79, 0xAA, 0x03, 0xD5, 0xB2, + 0xAA, 0xF8, 0x12, 0xBA, 0x21, 0xBC, 0x81, 0x86, 0x15, 0x04, 0x50, 0xFB, 0xEF, 0xB0, 0x88, 0x5A, + 0xCA, 0xCE, 0x05, 0xCD, 0x79, 0xDE, 0x89, 0xA9, 0x5F, 0x2B, 0x05, 0x01, 0xC2, 0x1E, 0x28, 0x4D + }; + } +} \ No newline at end of file