public Server(EndPoint localEndPoint, List <TCipherSuite> supportedCipherSuites) { _LocalEndPoint = localEndPoint; _Sessions = new Sessions(); _PSKIdentities = new PSKIdentities(); _SupportedCipherSuites = supportedCipherSuites; }
public Client(EndPoint localEndPoint, List <TCipherSuite> supportedCipherSuites) { _LocalEndPoint = localEndPoint; _PSKIdentities = new PSKIdentities(); _SupportedCipherSuites = supportedCipherSuites; _HandshakeInfo.ClientRandom = new RandomData(); _HandshakeInfo.ClientRandom.Generate(); }
public ServerHandshake(Socket socket, int maxPacketSize, PSKIdentities pskIdentities, List <TCipherSuite> supportedCipherSuites, bool requireClientCertificate, DTLS.Server.ValidatePSKEventHandler validatePSK) { this._Socket = socket; _ValidatePSK = validatePSK; _MaxPacketSize = maxPacketSize; _PSKIdentities = pskIdentities; _SupportedCipherSuites = new Dictionary <TCipherSuite, object>(); _RequireClientCertificate = requireClientCertificate; foreach (TCipherSuite item in supportedCipherSuites) { _SupportedCipherSuites.Add(item, null); } ServerVersion = new Version(1, 2); }
public ServerHandshake(Socket socket, int maxPacketSize, PSKIdentities pskIdentities, List <TCipherSuite> supportedCipherSuites, bool requireClientCertificate, ValidatePSKEventHandler validatePSK) { if (supportedCipherSuites == null) { throw new ArgumentNullException(nameof(supportedCipherSuites)); } this._Socket = socket ?? throw new ArgumentNullException(nameof(socket)); this._PSKIdentities = pskIdentities ?? throw new ArgumentNullException(nameof(pskIdentities)); this._ValidatePSK = validatePSK; this._MaxPacketSize = maxPacketSize; this._RequireClientCertificate = requireClientCertificate; this.ServerVersion = new Version(1, 2); this._SupportedCipherSuites = new Dictionary <TCipherSuite, object>(); foreach (var item in supportedCipherSuites) { this._SupportedCipherSuites.Add(item, null); } }
public static bool SuiteUsable(TCipherSuite cipherSuite, Org.BouncyCastle.Crypto.AsymmetricKeyParameter privateKey, PSKIdentities pskIdentities, bool haveValidatePSKCallback) { bool result = false; TKeyExchangeAlgorithm keyExchangeAlgorithm = GetKeyExchangeAlgorithm(cipherSuite); switch (keyExchangeAlgorithm) { case TKeyExchangeAlgorithm.NotSet: break; case TKeyExchangeAlgorithm.PSK: case TKeyExchangeAlgorithm.ECDHE_PSK: result = haveValidatePSKCallback || ((pskIdentities != null) && (pskIdentities.Count > 0)); break; case TKeyExchangeAlgorithm.ECDH_ECDSA: case TKeyExchangeAlgorithm.ECDHE_ECDSA: result = (privateKey != null); break; default: break; } return(result); }