Beispiel #1
0
        private static void TryDecrypt(ABNDFileEntry entry, List <ABNDChunk> chunks)
        {
            Debug.Assert(entry.EncryptionType == EncryptionType.ChaCha);

            uint totalLen = 0;

            foreach (var chunk in chunks)
            {
                totalLen += chunk.Length;
            }

            var encrypted = GetConcatenatedEncryptedChunks(totalLen, chunks);

            var IV        = entry.IV;
            var xor       = IV.Xor(12);
            var decrypted = ChaCha.Decrypt(encrypted, xor, entry.MAC);

            if (decrypted == null)
            {
                throw new Exception();
            }

            // rechunk data
            GetDecryptedChunks(chunks, decrypted);
        }
Beispiel #2
0
        public ABND(byte[] data)
        {
            Data   = data;
            Header = Util.GetSlice(data, 0, ABNDHeader.SIZE).ByteArrayToStructure <ABNDHeader>();
            Debug.Assert(Header.Magic == MAGIC);
            Debug.Assert(Header.ExtHeaderOffset == ABNDHeader.SIZE);
            Debug.Assert(Header.ExtHeaderSize == ABNDExtHeader.SIZE);
            ExtHeader = Util.GetSlice(data, Header.ExtHeaderOffset, Header.ExtHeaderSize).ByteArrayToStructure <ABNDExtHeader>();

            Debug.Assert(ExtHeader.EncryptionType == EncryptionType.ChaCha);
            var payload = Util.GetSlice(data, ExtHeader.EStringTableOffset, ExtHeader.EStringTableLength);

            FileNameTable = ChaCha.Decrypt(payload, ExtHeader.IV, ExtHeader.MAC);
        }