コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public void UpdateHeader(ref EcfHeader header)
        {
            Contract.Requires <InvalidOperationException>(HeaderId != 0);

            header.InitializeChunkInfo(HeaderId, ChunkExtraDataSize);
        }
コード例 #4
0
 public void CopyHeaderData(EcfHeader header)
 {
     HeaderId           = header.Id;
     ChunkExtraDataSize = header.ExtraDataSize;
 }