protected override bool HandshakePassive(SendCall Send, ReceiveCall Receive) { if (!Receive(out byte[] data, out EndPoint source)) { return(false); } KEXCrypto.FromXmlString(Encoding.ASCII.GetString(data)); byte[] key = new byte[32]; RandomNumberGenerator.Create().GetBytes(key); DataCrypto.Key = key; Send(KEXCrypto.Encrypt(key, RSAEncryptionPadding.OaepSHA256)); if (!Receive(out data, out source)) { return(false); } DataCrypto.IV = data; Send(EncryptData(SECRET)); return(true); }
public bool Handshake(SendCall Send, ReceiveCall Receive) { if (Active) { return(HandshakeActive(Send, Receive)); } else { return(HandshakePassive(Send, Receive)); } }
protected override bool HandshakeActive(SendCall Send, ReceiveCall Receive) { Send(KEXCrypto.GetPublicKey()); if (!Receive(out byte[] data, out EndPoint source)) { return(false); } DataCrypto.Key = KEXCrypto.GetSharedSecret(data); Send(DataCrypto.IV); if (!Receive(out data, out source)) { return(false); } return(DecryptSecret(data)); }
protected override bool HandshakeActive(SendCall Send, ReceiveCall Receive) { Send(Encoding.ASCII.GetBytes(KEXCrypto.ToXmlString(false))); if (!Receive(out byte[] data, out EndPoint source)) { return(false); } DataCrypto.Key = KEXCrypto.Decrypt(data, RSAEncryptionPadding.OaepSHA256); Send(DataCrypto.IV); if (!Receive(out data, out source)) { return(false); } return(DecryptSecret(data)); }
protected override bool HandshakeActive(SendCall Send, ReceiveCall Receive) { Send(KEXCrypto.PublicKey.ToByteArray()); if (!Receive(out byte[] data, out EndPoint source)) { return(false); } DataCrypto.Key = KEXCrypto.DeriveKeyMaterial(CngKey.Import(data, CngKeyBlobFormat.EccPublicBlob)); Send(DataCrypto.IV); if (!Receive(out data, out source)) { return(false); } return(DecryptSecret(data)); }
protected override bool HandshakePassive(SendCall Send, ReceiveCall Receive) { if (!Receive(out byte[] data, out EndPoint source)) { return(false); } DataCrypto.Key = KEXCrypto.GetSharedSecret(data); Send(KEXCrypto.GetPublicKey()); if (!Receive(out data, out source)) { return(false); } DataCrypto.IV = data; Send(EncryptData(SECRET)); return(true); }
protected override bool HandshakePassive(SendCall Send, ReceiveCall Receive) { if (!Receive(out byte[] data, out EndPoint source)) { return(false); } DataCrypto.Key = KEXCrypto.DeriveKeyMaterial(CngKey.Import(data, CngKeyBlobFormat.EccPublicBlob)); Send(KEXCrypto.PublicKey.ToByteArray()); if (!Receive(out data, out source)) { return(false); } DataCrypto.IV = data; Send(EncryptData(SECRET)); return(true); }
protected abstract bool HandshakePassive(SendCall Send, ReceiveCall Receive);
protected override bool HandshakePassive(SendCall Send, ReceiveCall Receive) { return(true); }