internal HttpCryptoClientSession(RSACryptoServiceProvider publicKey, string website) { if (publicKey == null || !publicKey.PublicOnly) throw new ArgumentException("There have to be an public asymmetric key!", nameof(publicKey)); if (string.IsNullOrEmpty(website)) throw new ArgumentException("The website must be specified and cannot be null or empty."); Website = website; _clientCipher = CipherBlock.ClientCipher(publicKey); }
internal HttpCryptoServerSession(CipherBlock.PrivateKeyByPublicKeyHash privateKeySelector, HttpRequestBase httpRequest) { if (privateKeySelector == null) throw new ArgumentException("The parameter cannot be null", nameof(privateKeySelector)); if (httpRequest == null) throw new ArgumentException("The parameter cannot be null", nameof(httpRequest)); var request = httpRequest; var rawData = CsGlobal.Transmission.ReadFromStream(request.InputStream, request.ContentLength); using (var rd = new BinaryReader(new MemoryStream(rawData))) { _serverCipher = CipherBlock.ServerCipher(rd, privateKeySelector); DecryptData(rd); } }
/// <summary> /// Creates a <see cref="HttpCryptoServerSession" />, which can perform asymmetric/symmetric hybrid encryption operations. It is used with the /// <see cref="HttpCryptoClientSession" /> on the other side of the transmission. /// </summary> public HttpCryptoServerSession ServerSession(CipherBlock.PrivateKeyByPublicKeyHash privateKeySelector, HttpRequestBase request) { return new HttpCryptoServerSession(privateKeySelector, request); }