コード例 #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
 public void UpdateHash(SHA1CryptoServiceProvider sha)
 {
     PhxHash.UInt8(sha, kVersion);
     PhxHash.UInt64(sha, Id);
     PhxHash.Unicode(sha, Name, kNameStorage.FixedLength - 1);
     PhxHash.Unicode(sha, Description, kDescStorage.FixedLength - 1);
     PhxHash.Ascii(sha, Author, kAuthorStorage.FixedLength);
     DateTime.UpdateHash(sha);
     PhxHash.UInt64(sha, AuthorXuid);
     PhxHash.UInt32(sha, Bitwise.ByteSwap.SingleToUInt32(Length));
     PhxHash.UInt16(sha, (uint)SessionId);
     PhxHash.UInt32(sha, (uint)GameType);
     PhxHash.UInt64(sha, DataCryptKey);
     sha.TransformBlock(DataHash, 0, DataHash.Length, null, 0);
     PhxHash.UInt64(sha, DataSize, isFinal: true);
 }