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 ProcessNonCriticalErrorMessage(Node messageFrom, MeshworkError error) { if (error is NotTrustedError) { messageFrom.ClearSessionKey(); messageFrom.RemotelyUntrusted = true; } else if (error is FileTransferError) { string id = ((FileTransferError)error).TransferId; foreach (IFileTransfer transfer in Core.FileTransferManager.Transfers) { if (transfer.Id == id) { ((IFileTransferInternal)transfer).ErrorReceived(messageFrom, (FileTransferError)error); break; } } } else { network.RaiseReceivedNonCriticalError(messageFrom, error); } }
internal void ProcessNonCriticalErrorMessage(Node messageFrom, MeshworkError error) { if (error is NotTrustedError) { messageFrom.ClearSessionKey(); messageFrom.RemotelyUntrusted = true; } else if (error is FileTransferError) { string id = ((FileTransferError)error).TransferId; foreach (IFileTransfer transfer in Core.FileTransferManager.Transfers) { if (transfer.Id == id) { ((IFileTransferInternal)transfer).ErrorReceived(messageFrom, (FileTransferError)error); break; } } } else { network.RaiseReceivedNonCriticalError (messageFrom, error); } }
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()); } }