public bool CommitHeader(Keyset keyset) { SharedStream headerStream = SavefileSource.CreateStream(); var hashData = new byte[0x3d00]; headerStream.Position = 0x300; headerStream.Read(hashData, 0, hashData.Length); byte[] hash = Crypto.ComputeSha256(hashData, 0, hashData.Length); headerStream.Position = 0x108; headerStream.Write(hash, 0, hash.Length); if (keyset.SaveMacKey.IsEmpty()) { return(false); } var cmacData = new byte[0x200]; var cmac = new byte[0x10]; headerStream.Position = 0x100; headerStream.Read(cmacData, 0, 0x200); Crypto.CalculateAesCmac(keyset.SaveMacKey, cmacData, 0, cmac, 0, 0x200); headerStream.Position = 0; headerStream.Write(cmac, 0, 0x10); headerStream.Flush(); return(true); }
public bool SignHeader(Keyset keyset) { if (keyset.SaveMacKey.IsEmpty()) { return(false); } var data = new byte[0x200]; var cmac = new byte[0x10]; SharedStream headerStream = SavefileSource.CreateStream(); headerStream.Position = 0x100; headerStream.Read(data, 0, 0x200); Crypto.CalculateAesCmac(keyset.SaveMacKey, data, 0, cmac, 0, 0x200); headerStream.Position = 0; headerStream.Write(cmac, 0, 0x10); return(true); }