Esempio n. 1
0
 public void TestHashUtilsByteArrayConcat()
 {
     byte[] a1       = new byte[] { 0x10, 0x20, 0x30, 0x40 };
     byte[] a2       = new byte[] { 0x50, 0x60 };
     byte[] expected = new byte[] { 0x10, 0x20, 0x30, 0x40, 0x50, 0x60 };
     byte[] combined = HashUtils.ConcatByteArrays(a1, a2);
     // This makes a deep equal of the length then all of the
     // individual values:
     Assert.That(combined, Is.EqualTo(expected));
 }
Esempio n. 2
0
        public SecureSession CreateSession(IPAddress clientIp)
        {
            var sess = new SecureSession(clientIp);

            // At some point Sessions was a List
            //Sessions.Add(sess);

            // We could, in theory, have a collision of sessions.
            // I'm going to take that risk.
            // We need to hash(hashed_sequence + session_id)
            // Both of these are byte arrays, so we need to build a bigger byte array.
            // Then clear that byte array once we no longer need it.
            byte[] hashedId = HashUtils.HashBytes(HashUtils.ConcatByteArrays(_sequence, sess.SessionId));
            Sessions.TryAdd(HashUtils.ByteArrayToHexString(hashedId), sess);
            HashUtils.ClearByteArray(hashedId);
            return(sess);
        }
Esempio n. 3
0
 private byte[] generateSessionKey(SecureSession session)
 {
     return(HashUtils.ConcatByteArrays(_sequence, session.SessionId));
 }