public void EnableEncryption(ServerAuthority serverAuthority, byte[] encodedPublicKey) { encryptionEnabled = true; this.serverAuthority = serverAuthority; this.remotePublicKey = new DHPublicKeyParameters( ((DHPublicKeyParameters)PublicKeyFactory.CreateKey(encodedPublicKey)).Y, serverAuthority.Parameters); }
private new void OnValidate() { if (!serverAuthority) { serverAuthority = Resources.Load <ServerAuthority>("Server/DefaultServerAuthority"); } base.OnValidate(); //TODO: Does this make it Validate twice? - TESTERS: place debug statements in the base method to find out...I expect it will not, but please verify }
private bool NegotiateKeys() { SendRequest <NegotiateKeysRequest>(RequestTypes.NegotiateKeysRequest, new NegotiateKeysRequest(), false); NegotiateKeysResponse response = WaitForResponse <NegotiateKeysResponse>(); if (response == null) { return(false); } // we have a response, let's copy the server key and create the serverauthority _serverAuthority = new ServerAuthority(new BigInteger(response.Prime, 16), new BigInteger(response.G, 16)); _serverPublicKey = response.ServerPublicKey; return(true); }
/// <summary> /// Processes the request. /// </summary> /// <param name="header">The header.</param> /// <param name="publicKeyEncoded">The public key encoded.</param> /// <param name="response">The response.</param> /// <returns></returns> public static String ProcessRequest(ServerAuthority serverAuthority, byte[] publicKeyEncoded, RequestHeader header, String request) { if (header.MessageHeader.EncryptionHeader.EncryptionType != EncryptionTypes.None) { //byte[] publicKeyEncoded = client.RequestHeader.MessageHeader.EncryptionHeader.PublicKey; DHPublicKeyParameters publicKey = new DHPublicKeyParameters( ((DHPublicKeyParameters)PublicKeyFactory.CreateKey(publicKeyEncoded)).Y, serverAuthority.Parameters); BigInteger agreementValue = serverAuthority.GenerateAgreementValue(publicKey); RijndaelCrypto crypto = new RijndaelCrypto(); return(crypto.Encrypt(request, agreementValue.ToString(16))); } else { return(request); } }
public void DisableEncryption() { encryptionEnabled = false; this.serverAuthority = null; this.remotePublicKey = null; }