private async Task HandshakeAsync() { var encryptedServerKey = rsaCryptography.Encrypt(clientSettings.PublicRsaKey, desCryptography.Key); var signature = rsaCryptography.Sign(clientSettings.PrivateRsaKey, encryptedServerKey); var rawEncryptedServerKeyLength = BitConverter.GetBytes(encryptedServerKey.Length); Array.Reverse(rawEncryptedServerKeyLength); var requestDataLength = encryptedServerKey.Length + signature.Length + rawEncryptedServerKeyLength.Length; var requestData = new Byte[requestDataLength]; Array.Copy(rawEncryptedServerKeyLength, 0, requestData, 0, 4); Array.Copy(encryptedServerKey, 0, requestData, 4, encryptedServerKey.Length); Array.Copy(signature, 0, requestData, 4 + encryptedServerKey.Length, signature.Length); var rawResponse = await SendRequestAsync(requestData, ConnectionMode.Assymmetric); var response = Convert.ToBase64String(rawResponse); }