public Package2(Keyset keyset, IStorage storage) { Storage = storage; IStorage headerStorage = Storage.Slice(0, 0x200); KeyRevision = FindKeyGeneration(keyset, headerStorage); Key = keyset.Package2Keys[KeyRevision]; Header = new Package2Header(headerStorage, keyset, KeyRevision); PackageSize = BitConverter.ToInt32(Header.Counter, 0) ^ BitConverter.ToInt32(Header.Counter, 8) ^ BitConverter.ToInt32(Header.Counter, 12); HeaderVersion = Header.Counter[4] ^ Header.Counter[6] ^ Header.Counter[7]; if (PackageSize != 0x200 + Header.SectionSizes[0] + Header.SectionSizes[1] + Header.SectionSizes[2]) { throw new InvalidDataException("Package2 Header is corrupt!"); } }
public Package2(Keyset keyset, Stream stream) { StreamSource = new SharedStreamSource(stream); SharedStream headerStream = StreamSource.CreateStream(0, 0x200); KeyRevision = FindKeyGeneration(keyset, headerStream); Key = keyset.Package2Keys[KeyRevision]; Header = new Package2Header(headerStream, Key); PackageSize = BitConverter.ToInt32(Header.Counter, 0) ^ BitConverter.ToInt32(Header.Counter, 8) ^ BitConverter.ToInt32(Header.Counter, 12); HeaderVersion = Header.Counter[4] ^ Header.Counter[6] ^ Header.Counter[7]; if (PackageSize != 0x200 + Header.SectionSizes[0] + Header.SectionSizes[1] + Header.SectionSizes[2]) { throw new InvalidDataException("Package2 Header is corrupt!"); } }