internal void ProcessNewSessionKeyMessage(Node messageFrom, byte[] key) { string keyHash = FileFind.Common.SHA512Str(key); // This lets us create a brand new session key // if someone wants that for whatever reason. if (messageFrom.SessionKeyDataHash != String.Empty && keyHash != messageFrom.SessionKeyDataHash) { Core.LoggingService.LogInfo("MessageProcessor: Re-keying with: {0}.", messageFrom.ToString()); messageFrom.ClearSessionKey(); } if (messageFrom.FinishedKeyExchange == false) { Core.LoggingService.LogInfo("Received secure channel key from: {0}.", messageFrom.ToString()); messageFrom.SessionKeyDataHash = keyHash; messageFrom.DecryptKeyExchange(key); if (messageFrom.RemoteHasKey == true) { Core.LoggingService.LogInfo("Secure communication channel to {0} now avaliable.", messageFrom.ToString()); network.SendInfoToTrustedNode(messageFrom); } else { messageFrom.CreateNewSessionKey(); } } else { Core.LoggingService.LogWarning("Received secure communication key from: {0}, but key exchange was already finished!", messageFrom.ToString()); } }
internal void ProcessNewSessionKeyMessage(Node messageFrom, byte[] key) { string keyHash = FileFind.Common.SHA512Str(key); // This lets us create a brand new session key // if someone wants that for whatever reason. if (messageFrom.SessionKeyDataHash != String.Empty && keyHash != messageFrom.SessionKeyDataHash) { LoggingService.LogInfo("MessageProcessor: Re-keying with: {0}.", messageFrom.ToString()); messageFrom.ClearSessionKey(); } if (messageFrom.FinishedKeyExchange == false) { LoggingService.LogInfo("Received secure channel key from: {0}.", messageFrom.ToString()); messageFrom.SessionKeyDataHash = keyHash; messageFrom.DecryptKeyExchange(key); if (messageFrom.RemoteHasKey == true) { LoggingService.LogInfo("Secure communication channel to {0} now avaliable.", messageFrom.ToString()); network.SendInfoToTrustedNode(messageFrom); } else { messageFrom.CreateNewSessionKey(); } } else { LoggingService.LogWarning("Received secure communication key from: {0}, but key exchange was already finished!", messageFrom.ToString()); } }