public BitChatNetwork(MailAddress peerEmailAddress, string sharedSecret, BinaryID networkID, Certificate[] knownPeerCerts, IBitChatNetworkManager networkManager, ISecureChannelSecurityManager securityManager)
        {
            _type = BitChatNetworkType.PrivateChat;
            _peerEmailAddress = peerEmailAddress;
            _sharedSecret = sharedSecret;
            _networkManager = networkManager;
            _securityManager = securityManager;

            LoadPeers(knownPeerCerts);

            if (knownPeerCerts.Length > 0)
                _peerName = knownPeerCerts[0].IssuedTo.Name;

            if (networkID == null)
            {
                //compute network id
                HashAlgorithm hash = HashAlgorithm.Create("SHA1");

                byte[] peerEmailAddressHash = hash.ComputeHash(Encoding.UTF8.GetBytes(_peerEmailAddress.Address.ToLower()));
                byte[] selfEmailAddressHash = hash.ComputeHash(Encoding.UTF8.GetBytes(networkManager.GetLocalCredentials().Certificate.IssuedTo.EmailAddress.Address.ToLower()));
                byte[] salt = new byte[20];

                for (int i = 0; i < 20; i++)
                {
                    salt[i] = (byte)(peerEmailAddressHash[i] ^ selfEmailAddressHash[i]);
                }

                _networkID = new BinaryID(PBKDF2.CreateHMACSHA1(_sharedSecret, salt, 200000).GetBytes(20));
            }
            else
            {
                _networkID = networkID;
            }
        }
Beispiel #2
0
        public BitChatNetwork(string networkName, string sharedSecret, BinaryID networkID, Certificate[] knownPeerCerts, IBitChatNetworkManager networkManager, ISecureChannelSecurityManager securityManager)
        {
            _type            = BitChatNetworkType.GroupChat;
            _networkName     = networkName;
            _sharedSecret    = sharedSecret;
            _networkManager  = networkManager;
            _securityManager = securityManager;

            LoadPeers(knownPeerCerts);

            if (networkID == null)
            {
                //compute network id
                _networkID = new BinaryID(PBKDF2.CreateHMACSHA1(_sharedSecret, Encoding.UTF8.GetBytes(_networkName.ToLower()), 200000).GetBytes(20));
            }
            else
            {
                _networkID = networkID;
            }
        }
Beispiel #3
0
        public BitChatNetwork(MailAddress peerEmailAddress, string sharedSecret, BinaryID networkID, Certificate[] knownPeerCerts, IBitChatNetworkManager networkManager, ISecureChannelSecurityManager securityManager)
        {
            _type             = BitChatNetworkType.PrivateChat;
            _peerEmailAddress = peerEmailAddress;
            _sharedSecret     = sharedSecret;
            _networkManager   = networkManager;
            _securityManager  = securityManager;

            LoadPeers(knownPeerCerts);

            if (knownPeerCerts.Length > 0)
            {
                _peerName = knownPeerCerts[0].IssuedTo.Name;
            }

            if (networkID == null)
            {
                //compute network id
                HashAlgorithm hash = HashAlgorithm.Create("SHA1");

                byte[] peerEmailAddressHash = hash.ComputeHash(Encoding.UTF8.GetBytes(_peerEmailAddress.Address.ToLower()));
                byte[] selfEmailAddressHash = hash.ComputeHash(Encoding.UTF8.GetBytes(networkManager.GetLocalCredentials().Certificate.IssuedTo.EmailAddress.Address.ToLower()));
                byte[] salt = new byte[20];

                for (int i = 0; i < 20; i++)
                {
                    salt[i] = (byte)(peerEmailAddressHash[i] ^ selfEmailAddressHash[i]);
                }

                _networkID = new BinaryID(PBKDF2.CreateHMACSHA1(_sharedSecret, salt, 200000).GetBytes(20));
            }
            else
            {
                _networkID = networkID;
            }
        }
        public BitChatNetwork(string networkName, string sharedSecret, BinaryID networkID, Certificate[] knownPeerCerts, IBitChatNetworkManager networkManager, ISecureChannelSecurityManager securityManager)
        {
            _type = BitChatNetworkType.GroupChat;
            _networkName = networkName;
            _sharedSecret = sharedSecret;
            _networkManager = networkManager;
            _securityManager = securityManager;

            LoadPeers(knownPeerCerts);

            if (networkID == null)
            {
                //compute network id
                _networkID = new BinaryID(PBKDF2.CreateHMACSHA1(_sharedSecret, Encoding.UTF8.GetBytes(_networkName.ToLower()), 200000).GetBytes(20));
            }
            else
            {
                _networkID = networkID;
            }
        }