internal static byte[] ComputeSignatureDigest(System.IO.Stream chunksStream
                                                      , long chunksOffset
                                                      , long chunksLength
                                                      , ECF.EcfHeader header)
        {
            Contract.Requires(chunksStream != null);
            Contract.Requires(chunksStream.CanSeek && chunksStream.CanRead);
            Contract.Requires(chunksOffset >= 0);
            Contract.Requires(chunksLength > 0);

            using (var sha = new SHA1CryptoServiceProvider())
            {
                PhxHash.UInt32(sha, kSha1Salt);
                PhxHash.UInt32(sha, (uint)header.HeaderSize);
                PhxHash.UInt32(sha, (uint)header.ChunkCount);
                PhxHash.UInt32(sha, (uint)header.ExtraDataSize);
                PhxHash.UInt32(sha, (uint)header.TotalSize);

                PhxHash.Stream(sha,
                               chunksStream, chunksOffset, chunksLength,
                               isFinal: true);

                return(sha.Hash);
            }
        }
        bool ReadEcfFromStream()
        {
            bool result = true;

            result = EcfHeader.VerifyIsEcf(mEcfStream.Reader);
            if (!result)
            {
                if (VerboseOutput != null)
                {
                    VerboseOutput.WriteLine("\tFailed: File is either not even an ECF-based file, or corrupt");
                }
            }
            else
            {
                mEcfFile = new EcfFile();
                mEcfFile.Serialize(mEcfStream);
            }

            return(result);
        }
Ejemplo n.º 3
0
        public void UpdateHeader(ref EcfHeader header)
        {
            Contract.Requires <InvalidOperationException>(HeaderId != 0);

            header.InitializeChunkInfo(HeaderId, ChunkExtraDataSize);
        }
Ejemplo n.º 4
0
 public void CopyHeaderData(EcfHeader header)
 {
     HeaderId           = header.Id;
     ChunkExtraDataSize = header.ExtraDataSize;
 }