Esempio n. 1
0
        private void UpdateKeys()
        {
            if (session.SessionId == null)
            {
                session.SessionId = kexProcessor.ExchangeHash;
            }

            var a1             = Cipher.Create(ClientKexInit.EncAlgorithmsClient[0]);
            var a2             = Cipher.Create(ClientKexInit.EncAlgorithmsServer[0]);
            var a3             = MacWriter.Create(ClientKexInit.MacAlgorithmsClient[0]);
            var a4             = MacWriter.Create(ClientKexInit.MacAlgorithmsServer[0]);
            var desiredLengths = new int[] { a1.BlockSize, a2.BlockSize, a1.KeySize,
                                             a2.KeySize, a3.KeySize, a4.KeySize };

            Debug.WriteLine(string.Format("Shared Secret: {0}", kexProcessor.SharedSecret.HexDump()));
            byte[][] keys = new byte[6][];
            using (var hash = HashWriter.Create(ClientKexInit.KexAlgorithms[0]))
            {
                var i = 0;
                for (char c = 'A'; c <= 'F'; c++, i++)
                {
                    hash.WriteString(kexProcessor.SharedSecret);
                    hash.Write(kexProcessor.ExchangeHash);
                    hash.Write(c);
                    hash.Write(session.SessionId);
                    var key = hash.Hash;
                    hash.Reset();
                    while (key.Length < desiredLengths[i])
                    {
                        hash.WriteString(kexProcessor.SharedSecret);
                        hash.Write(kexProcessor.ExchangeHash);
                        hash.Write(key);
                        var h      = hash.Hash;
                        var buffer = new byte[key.Length + h.Length];
                        Buffer.BlockCopy(key, 0, buffer, 0, key.Length);
                        Buffer.BlockCopy(h, 0, buffer, key.Length, h.Length);
                        key = buffer;
                        Extensions.Random.ClearBytes(buffer, 0, buffer.Length);
                        hash.Reset();
                    }

                    keys[i] = new byte[desiredLengths[i]];
                    Buffer.BlockCopy(key, 0, keys[i], 0, desiredLengths[i]);
                    Extensions.Random.ClearBytes(key, 0, key.Length);
                    Debug.WriteLine("Key '{0}': {1}", c, keys[i].HexDump());
                }
            }

            a1.Initialize(Cipher.CipherMode.Encryption, keys[2], keys[0]);
            a2.Initialize(Cipher.CipherMode.Decryption, keys[3], keys[1]);
            session.Socket.Encryptor    = a1;
            session.Socket.Decryptor    = a2;
            session.Socket.EncryptorMac = MacWriter.Create(ClientKexInit.MacAlgorithmsClient[0], keys[4]);
            session.Socket.DecryptorMac = MacWriter.Create(ClientKexInit.MacAlgorithmsServer[0], keys[5]);

            for (var i = 0; i < keys.Length; i++)
            {
                Extensions.Random.ClearBytes(keys[i], 0, keys[i].Length);
            }
        }
Esempio n. 2
0
        public override void Write <TItem>(TItem obj, BinaryWriter writer, HashWriter hashWriter)
        {
            if (!(GetValue(obj) is Material[] materials))
            {
                return;
            }
            using (var stream = new MemoryStream())
                using (var dataWriter = new BinaryWriter(stream)) {
                    foreach (var material in materials)
                    {
                        if (IsPhysics)
                        {
                            material.PhysicsMaterialData.Write(dataWriter);
                        }
                        else
                        {
                            material.UpdateData();
                            material.MaterialData.Write(dataWriter);
                        }
                    }

                    var data = stream.ToArray();
                    WriteStart(writer, data.Length, hashWriter);
                    writer.Write(data);
                    hashWriter?.Write(data);
                }
        }
Esempio n. 3
0
        public void Partial()
        {
            var     data = "Some random stuff for testing purposes.".AsciiToBytes();
            UInt256 h1;

            UInt256 refOnce;
            UInt256 refTwice;

            using (var alg = new SHA256Managed()) {
                alg.TransformFinalBlock(data, 0, data.Length);
                refOnce = h1 = (UInt256)alg.Hash;
                alg.TransformFinalBlock(data, 0, data.Length);
                UInt256 h2 = (UInt256)alg.Hash;
                Assert.Equal(h1, h2);

                alg.TransformFinalBlock(h1, 0, 32);
                refTwice = (UInt256)alg.Hash;
            }

            using (var alg = new SHA256Managed()) {
                alg.TransformBlock(data, 0, data.Length - 12, null, 0);
                alg.TransformFinalBlock(data, data.Length - 12, 12);
                h1 = (UInt256)alg.Hash;
                Assert.Equal(refOnce, h1);
            }

            using (var alg = new SHA256Managed()) {
                alg.TransformBlock(data, 0, data.Length, null, 0);
                alg.TransformFinalBlock(data, 0, 0);
                h1 = (UInt256)alg.Hash;
                Assert.Equal(refOnce, h1);
            }

            using var hw = new HashWriter();
            hw.Add(data[..12]);
Esempio n. 4
0
        public override void Write(BinaryWriter writer, HashWriter hashWriter)
        {
            writer.Write(Encoding.Default.GetBytes(Name).Length);
            writer.Write(Encoding.Default.GetBytes(Name));

            writer.Write(Encoding.Default.GetBytes(Path).Length);
            writer.Write(Encoding.Default.GetBytes(Path));

            writer.Write(Encoding.Default.GetBytes(InternalName).Length);
            writer.Write(Encoding.Default.GetBytes(InternalName));

            if (IsWav)
            {
                Wfx.Write(writer);
            }

            writer.Write(Data.Length);
            writer.Write(Data);

            writer.Write(OutputTarget);
            writer.Write(Volume);
            writer.Write(Balance);
            writer.Write(Fade);
            writer.Write(Volume);
        }
        public override void Write <TItem>(TItem obj, BinaryWriter writer, HashWriter hashWriter)
        {
            if (obj is PrimitiveData primitiveData)
            {
                if (!primitiveData.Use3DMesh)
                {
                    // don't write animation if not using 3d mesh
                    return;
                }

                for (var i = 0; i < primitiveData.Mesh.AnimationFrames.Count; i++)
                {
                    var animationData = SerializeAnimation(primitiveData.Mesh.AnimationFrames[i]);
                    var data          = IsCompressed ? BiffZlib.Compress(animationData) : animationData;
                    WriteStart(writer, 4, hashWriter, "M3AY");
                    writer.Write(data.Length);
                    WriteStart(writer, data.Length, hashWriter);
                    writer.Write(data);
                    hashWriter?.Write(data);
                }
            }
            else
            {
                throw new InvalidOperationException("Unknown type for [" + GetType().Name + "] on field \"" + Name + "\".");
            }
        }
Esempio n. 6
0
        public void ClientProxy_Dispose_DisposeWhenWriting()
        {
            const int distrServer1  = 22370;
            const int distrServer12 = 22371;
            const int storageServer = 22372;

            #region hell

            var writer = new HashWriter(new HashMapConfiguration("TestProxyDispose", HashMapCreationMode.CreateNew, 1, 1, HashFileType.Distributor));
            writer.CreateMap();
            writer.SetServer(0, "localhost", storageServer, 157);
            writer.Save();

            var common = new CommonConfiguration(1, 100);

            var distr =
                new DistributorApi(
                    new DistributorNetConfiguration("localhost", distrServer1, distrServer12, "testService"),
                    new DistributorConfiguration(1, "TestProxyDispose"), common);


            var storage = new WriterApi(
                new StorageNetConfiguration("localhost", storageServer, 157, "testService"),
                new StorageConfiguration(1, "TestProxyDispose"),
                new CommonConfiguration());

            #endregion

            distr.Build();
            distr.Start();

            var result = _proxy.Int.SayIAmHere("localhost", distrServer1);
            Assert.AreEqual(RequestState.Complete, result.State, result.ToString());

            storage.Build();
            storage.AddDbModule(new TestInMemoryDbFactory());
            storage.Start();

            const int count = 500;

            for (int i = 0; i < count; i++)
            {
                if (i == count / 4)
                {
                    Task.Run(() => _proxy.Dispose());
                }

                var state = _proxy.Int.CreateSync(i, i);

                if (!(state.State == RequestState.Complete || state.State == RequestState.Error &&
                      state.ErrorDescription == "System disposed" || i == count / 4))
                {
                    Assert.Fail(state + " " + i);
                }
            }

            distr.Dispose();
            storage.Dispose();
        }
Esempio n. 7
0
        public void Writer_ProcessDataFromDistributor_SendResultBack()
        {
            const int distrServer1   = 22180;
            const int distrServer12  = 23180;
            const int storageServer1 = 22181;

            var writer =
                new HashWriter(new HashMapConfiguration("TestTransaction1D1S", HashMapCreationMode.CreateNew, 1, 1,
                                                        HashFileType.Distributor));

            writer.CreateMap();
            writer.SetServer(0, "localhost", storageServer1, 157);
            writer.Save();

            _distributor1.Build(1, distrServer1, distrServer12, "TestTransaction1D1S");
            _writer1.Build(storageServer1, "TestTransaction1D1S", 1);

            _distributor1.Start();
            _writer1.Start();

            var       list  = new List <InnerData>();
            const int count = 100;

            for (int i = 1; i < count + 1; i++)
            {
                var ev =
                    new InnerData(new Transaction(HashConvertor.GetString(i.ToString(CultureInfo.InvariantCulture)), "")
                {
                    OperationName = OperationName.Create,
                    OperationType = OperationType.Async
                })
                {
                    Data        = CommonDataSerializer.Serialize(i),
                    Key         = CommonDataSerializer.Serialize(i),
                    Transaction = { TableName = "Int" }
                };
                list.Add(ev);
            }

            foreach (var data in list)
            {
                _distributor1.Input.ProcessAsync(data);
            }

            Thread.Sleep(TimeSpan.FromMilliseconds(1000));

            foreach (var data in list)
            {
                var transaction = _distributor1.Main.GetTransactionState(data.Transaction.UserTransaction);
                Assert.AreEqual(TransactionState.Complete, transaction.State);
            }

            var mem = _writer1.Db.GetDbModules.First() as TestDbInMemory;

            Assert.AreEqual(count, mem.Local);

            _writer1.Dispose();
            _distributor1.Dispose();
        }
Esempio n. 8
0
        protected static void WriteEnd(BinaryWriter writer, HashWriter hashWriter)
        {
            var endTag = Encoding.Default.GetBytes("ENDB");

            writer.Write(4);
            writer.Write(endTag);
            hashWriter?.Write(endTag);
        }
Esempio n. 9
0
 private byte[] GetBytes(HashWriter hashWriter)
 {
     using (var stream = new MemoryStream())
         using (var writer = new BinaryWriter(stream)) {
             Write(writer, hashWriter);
             return(stream.ToArray());
         }
 }
Esempio n. 10
0
 public void Write(BinaryWriter writer, HashWriter hashWriter)
 {
     writer.Write(new byte[] { 0x01, 0x0, 0x0 });
     writer.Write((byte)(Italic ? 0x02 : 0x0));
     writer.Write(Weight);
     writer.Write(Size);
     writer.Write((byte)Name.Length);
     writer.Write(Encoding.Default.GetBytes(Name));
 }
Esempio n. 11
0
        public void Writer_Restore_TwoServersWhenOneServerNotAvailable()
        {
            #region hell

            var writer =
                new HashWriter(new HashMapConfiguration("TestRestore", HashMapCreationMode.CreateNew, 2, 1,
                                                        HashFileType.Distributor));
            writer.CreateMap();
            writer.SetServer(0, "localhost", storageServer1, 157);
            writer.SetServer(1, "localhost", storageServer2, 157);
            writer.Save();

            var common = new CommonConfiguration(1, 100);

            var storageNet1   = new StorageNetConfiguration("localhost", storageServer1, 157, "testService", 10);
            var storageConfig = new StorageConfiguration("TestRestore", 1, 10,
                                                         TimeSpan.FromMilliseconds(10000),
                                                         TimeSpan.FromMilliseconds(200), TimeSpan.FromHours(1), TimeSpan.FromHours(1), false);

            var storage1    = new WriterApi(storageNet1, storageConfig, common);
            var storageNet2 = new StorageNetConfiguration("localhost", storageServer2, 157, "testService", 10);
            var storage2    = new WriterApi(storageNet2, storageConfig, common);

            #endregion

            _proxy.Start();
            _distr.Start();

            storage1.Build();
            storage1.AddDbModule(new TestInMemoryDbFactory());
            storage1.Start();

            storage1.Api.Restore(new ServerAddress("localhost", distrServer12), false);

            Thread.Sleep(4000);
            Assert.IsTrue(storage1.Api.IsRestoreCompleted());

            var list = storage1.Api.FailedServers();
            Assert.AreEqual(1, list.Count);

            storage2.Build();
            storage2.AddDbModule(new TestInMemoryDbFactory());
            storage2.Start();

            storage1.Api.Restore(new ServerAddress("localhost", distrServer12), list, false);

            Thread.Sleep(1000);
            Assert.IsTrue(storage1.Api.IsRestoreCompleted());

            Thread.Sleep(1000);

            _proxy.Dispose();
            _distr.Dispose();
            storage1.Dispose();
            storage2.Dispose();
        }
Esempio n. 12
0
        private static UInt256 GetSequenceHash(Transaction txTo)
        {
            using var hw = new HashWriter();
            foreach (var i in txTo.Inputs)
            {
                hw.Add(i.Sequence);
            }

            return(hw.GetHashFinal());
        }
Esempio n. 13
0
        private static UInt256 GetOutputsHash(Transaction txTo)
        {
            using var hw = new HashWriter();
            foreach (var o in txTo.Outputs)
            {
                hw.Add(o);
            }

            return(hw.GetHashFinal());
        }
Esempio n. 14
0
        public long GetHash()
        {
            HashWriter ss = new HashWriter(nType, nVersion);

            ss << obj;
            return(ss.GetHash());


            return(SerializeHash(this));
        }
Esempio n. 15
0
        public static UInt256 GetPrevOutHash(Transaction txTo)
        {
            using var hw = new HashWriter();
            foreach (var i in txTo.Inputs)
            {
                hw.Add(i.PrevOut);
            }

            return(hw.GetHashFinal());
        }
Esempio n. 16
0
        public void DbModule_LocalAndRemoteData_Count()
        {
            var provider = new IntHashConvertor();

            var writer =
                new HashWriter(new HashMapConfiguration("TestLocalAndRemote", HashMapCreationMode.CreateNew, 2, 3,
                                                        HashFileType.Collector));

            writer.CreateMap();
            writer.SetServer(0, "localhost", 157, 157);
            writer.SetServer(1, "localhost", 11011, 157);
            writer.Save();

            _writer1.Build(157, "TestLocalAndRemote", 1);

            var       list  = new List <InnerData>();
            const int count = 100;

            for (int i = 0; i < count; i++)
            {
                var ev =
                    new InnerData(new Transaction(provider.CalculateHashFromKey(i), "")
                {
                    OperationName = OperationName.Create
                })
                {
                    Data        = CommonDataSerializer.Serialize(i),
                    Key         = CommonDataSerializer.Serialize(i),
                    Transaction = { Distributor = new ServerId("localhost", 22188) }
                };
                ev.Transaction.TableName = "Int";

                list.Add(ev);
            }

            TestHelper.OpenDistributorHostForDb(new ServerId("localhost", 22188), new ConnectionConfiguration("testService", 10));

            _writer1.Start();

            foreach (var data in list)
            {
                _writer1.Input.Process(data);
            }

            Thread.Sleep(1000);

            var mem = _writer1.Db.GetDbModules.First() as TestDbInMemory;

            Assert.AreNotEqual(count, mem.Local);
            Assert.AreNotEqual(count, mem.Remote);
            Assert.AreEqual(count, mem.Local + mem.Remote);

            _writer1.Dispose();
        }
Esempio n. 17
0
 public override void Write <TItem>(TItem obj, BinaryWriter writer, HashWriter hashWriter)
 {
     if (!AsInt)
     {
         WriteValue <TItem, float>(obj, writer, WriteFloat, hashWriter);
     }
     else
     {
         WriteValue <TItem, int>(obj, writer, WriteFloat, hashWriter);
     }
 }
Esempio n. 18
0
 static void Main(string[] args)
 {
     HashWriter.ArgonParams argonParams = new HashWriter.ArgonParams(2, 8192, 4);
     Console.WriteLine("hash test 1, salt = C560325F-6617-4FE9-BF30-04E67D591637");
     Console.WriteLine(HashWriter.Hash("hash test 1", "C560325F-6617-4FE9-BF30-04E67D591637", argonParams));
     Console.WriteLine("hash test 2, salt = C560325F-6617-4FE9-BF30-04E67D591637");
     Console.WriteLine(HashWriter.Hash("hash test 2", "C560325F-6617-4FE9-BF30-04E67D591637", argonParams));
     Console.WriteLine("hash test 1, salt = dsdadasd25F-6s17-4FE9-BF30-04E67D591637");
     Console.WriteLine(HashWriter.Hash("hash test 1", "dsdadasd25F-6s17-4FE9-BF30-04E67D591637", argonParams));
     Console.ReadKey();
 }
Esempio n. 19
0
        private byte[] HashExchangeHash()
        {
            var h = new byte[0];

            using (var pw = HashWriter.Create(session.Algorithms.KeyAlgorithmsServer[0]))
            {
                pw.Write(ExchangeHash, 0, ExchangeHash.Length);
                h = pw.Hash;
            }
            return(h);
        }
Esempio n. 20
0
        public override byte[] Sign(byte[] data)
        {
            Decrypt();
            byte[] H;
            using (var hw = HashWriter.Create(AlgorithmName))
            {
                hw.Write(data);
                H = hw.Hash;
            }

            return(((ECDSAManaged)Algorithm).SignHash(H));
        }
 public override void Write <TItem>(TItem obj, BinaryWriter writer, HashWriter hashWriter)
 {
     if (GetValue(obj) is Font font)
     {
         WriteStart(writer, 0, hashWriter);
         font.Write(writer, hashWriter);
     }
     else
     {
         throw new InvalidOperationException("Unknown type for [" + GetType().Name + "] on field \"" + Name + "\".");
     }
 }
Esempio n. 22
0
        private static byte[] GenerateJsonHashImpl(
            object obj,
            IHashFunction hashFunction,
            JsonWriterOptions writerOptions,
            JsonSerializerOptions?serializerOptions)
        {
            var hashWriter = new HashWriter(hashFunction);

            JsonSerializer.Serialize(new Utf8JsonWriter(hashWriter, writerOptions), obj, serializerOptions);

            return(hashWriter.GetResult());
        }
        protected void WriteStart(BinaryWriter writer, int dataLength, HashWriter hashWriter)
        {
            var tag = Encoding.Default.GetBytes(Name);

            if (Name.Length < 4)
            {
                tag = tag.Concat(new byte[4 - Name.Length]).ToArray();
            }
            writer.Write(dataLength + 4);
            writer.Write(tag);
            hashWriter?.Write(tag);             // only write tag
        }
 private void WriteVertex3D(BinaryWriter writer, Vertex3D value, HashWriter hashWriter)
 {
     writer.Write(value.X);
     writer.Write(value.Y);
     if (!WriteAsVertex2D)
     {
         writer.Write(value.Z);
         if (IsPadded)
         {
             writer.Write(0f);
         }
     }
 }
Esempio n. 25
0
 public override void Write <TItem>(TItem obj, BinaryWriter writer, HashWriter hashWriter)
 {
     if (Type == typeof(byte[]))
     {
         var bytes = GetValue(obj) as byte[];
         WriteStart(writer, bytes.Length, WriteHash(obj) ? hashWriter : null);
         writer.Write(bytes);
         if (WriteHash(obj))
         {
             hashWriter?.Write(bytes);
         }
     }
 }
Esempio n. 26
0
        public void ProxyAndDistributor_Read_DirectReadFromOneServerMock()
        {
            const int storageServer = 22261;

            var writer = new HashWriter(new HashMapConfiguration("TestProxyAndDistributorRead1Servers", HashMapCreationMode.CreateNew, 1, 3, HashFileType.Distributor));

            writer.CreateMap();
            writer.SetServer(0, "localhost", storageServer, 157);
            writer.Save();

            var dhc        = new DistributorHashConfiguration(1);
            var queue      = new QueueConfiguration(1, 100);
            var connection = new ConnectionConfiguration("testService", 10);
            var dcc        = new DistributorCacheConfiguration(TimeSpan.FromMilliseconds(600), TimeSpan.FromMilliseconds(1000));
            var ndrc       = new NetReceiverConfiguration(22260, "localhost", "testService");
            var ndrc12     = new NetReceiverConfiguration(23260, "localhost", "testService");

            var distr = new DistributorSystem(new ServerId("localhost", 22260),
                                              new ServerId("localhost", 23260),
                                              dhc, queue, connection, dcc, ndrc, ndrc12,
                                              new TransactionConfiguration(1),
                                              new HashMapConfiguration("TestProxyAndDistributorRead1Servers",
                                                                       HashMapCreationMode.ReadFromFile, 1, 1, HashFileType.Distributor),
                                              new AsyncTasksConfiguration(TimeSpan.FromMinutes(5)),
                                              new AsyncTasksConfiguration(TimeSpan.FromMinutes(5)),
                                              new ConnectionTimeoutConfiguration(Consts.OpenTimeout, Consts.SendTimeout));

            var server = new ServerId("localhost", 23260);

            distr.Build();

            _proxy.Start();
            distr.Start();

            GlobalQueue.Queue.Start();

            _proxy.Distributor.SayIAmHere(server);

            var s = TestHelper.OpenWriterHost(new ServerId("localhost", storageServer), connection);

            s.retData = TestHelper.CreateEvent(new StoredDataHashCalculator(), 10);

            var api = _proxy.CreateApi("Event", false, new StoredDataHashCalculator());

            UserTransaction transaction;
            var             read = (StoredData)api.Read(10, out transaction);

            Assert.AreEqual(10, read.Id);
            _proxy.Dispose();
            distr.Dispose();
        }
Esempio n. 27
0
        public void Writer_ProcessData_SendResultToDistributerMock()
        {
            const int distributorServer1 = 22171;
            const int storageServer1     = 22172;

            var writer =
                new HashWriter(new HashMapConfiguration("TestDbTransaction", HashMapCreationMode.CreateNew, 1, 1,
                                                        HashFileType.Distributor));

            writer.CreateMap();
            writer.SetServer(0, "localhost", storageServer1, 157);
            writer.Save();

            _writer1.Build(storageServer1, "TestDbTransaction", 1);
            _writer1.Start();

            var s = TestHelper.OpenDistributorHostForDb(new ServerId("localhost", distributorServer1),
                                                        new ConnectionConfiguration("testService", 10));

            var       list  = new List <InnerData>();
            const int count = 100;

            for (int i = 1; i < count + 1; i++)
            {
                var ev =
                    new InnerData(new Transaction(HashConvertor.GetString(i.ToString(CultureInfo.InvariantCulture)), "")
                {
                    OperationName = OperationName.Create
                })
                {
                    Data        = CommonDataSerializer.Serialize(i),
                    Key         = CommonDataSerializer.Serialize(i),
                    Transaction = { Distributor = new ServerId("localhost", distributorServer1) }
                };
                ev.Transaction.TableName = "Int";

                list.Add(ev);
            }

            foreach (var data in list)
            {
                _writer1.Q.DbInputProcessQueue.Add(data);
            }

            Thread.Sleep(TimeSpan.FromMilliseconds(1000));

            Assert.AreEqual(count, s.SendValue);
            _writer1.Dispose();
        }
Esempio n. 28
0
 private byte[] CalculateExchangeHash()
 {
     using (var pw = HashWriter.Create(session.Algorithms.KexAlgorithms[0]))
     {
         pw.WriteString(session.ClientIdentifier.ToSshMessage());
         pw.WriteString(session.ServerIdentifier.ToSshMessage());
         pw.WriteString(session.KexProcessor.ClientKexInit.ToSshMessage());
         pw.WriteString(session.KexProcessor.ServerKexInit.ToSshMessage());
         pw.WriteString(ServerHostKey);
         pw.WriteString(ClientPublicKey);
         pw.WriteString(ServerPublicKey);
         pw.WriteString(SharedSecret);
         return(pw.Hash);
     }
 }
Esempio n. 29
0
        public void Write <TItem>(TItem obj, BinaryWriter writer, HashWriter hashWriter) where TItem : BiffData
        {
            var tag = Encoding.Default.GetBytes(Name);

            if (Name.Length < 4)
            {
                tag = tag.Concat(new byte[4 - Name.Length]).ToArray();
            }
            writer.Write(Data.Length + 4);
            writer.Write(tag);
            writer.Write(Data);

            hashWriter?.Write(tag);
            hashWriter?.Write(Data);
        }
Esempio n. 30
0
 public override void Write <TItem>(TItem obj, BinaryWriter writer, HashWriter hashWriter)
 {
     if (Type == typeof(int))
     {
         WriteValue <TItem, int>(obj, writer, WriteInt, hashWriter);
     }
     else if (Type == typeof(uint))
     {
         WriteValue <TItem, uint>(obj, writer, WriteUInt, hashWriter);
     }
     else
     {
         throw new InvalidOperationException("Unknown type for [BiffInt] on field \"" + Name + "\".");
     }
 }