public BootstrapServer() { _PSKIdentities = new PSKIdentities(); _Port = Spec.Default.DefaultPort; _CoapServer.MessageDeliverer = this; SecureOnly = true; }
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 IActionResult GetPSKIdentities() { IActionResult result = null; string rootUrl = Request.GetRootUrl(); PSKIdentities response = new PSKIdentities(); response.AddLink("add", string.Concat(rootUrl, "/identities/psk"), null); int organisationID = User.GetOrganisationID(); List <Model.PSKIdentity> pskIdentities = BusinessLogicFactory.Identities.GetPSKIdentities(organisationID); response.PageInfo = Request.GetPageInfo(pskIdentities.Count); int endIndex = response.PageInfo.StartIndex + response.PageInfo.ItemsCount; for (int index = response.PageInfo.StartIndex; index < endIndex; index++) { ServiceModels.PSKIdentity pskIdentity = new ServiceModels.PSKIdentity(pskIdentities[index]); pskIdentity.AddSelfLink(string.Concat(rootUrl, "/identities/psk/", pskIdentity.Identity), false, true); response.Add(pskIdentity); } result = Request.GetObjectResult(response); return(result); }
public Client(EndPoint localEndPoint, List<TCipherSuite> supportedCipherSuites) { _LocalEndPoint = localEndPoint; _PSKIdentities = new PSKIdentities(); _SupportedCipherSuites = supportedCipherSuites; _HandshakeInfo.ClientRandom = new RandomData(); _HandshakeInfo.ClientRandom.Generate(); }
public Server(EndPoint localEndPoint, List<TCipherSuite> supportedCipherSuites) { _LocalEndPoint = localEndPoint; _Sessions = new Sessions(); _PSKIdentities = new PSKIdentities(); _SupportedCipherSuites = supportedCipherSuites; }
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; }
public IActionResult GetPSKIdentities() { IActionResult result = null; string rootUrl = Request.GetRootUrl(); PSKIdentities response = new PSKIdentities(); response.AddLink("add", string.Concat(rootUrl, "/identities/psk"), null); int organisationID = User.GetOrganisationID(); List<Model.PSKIdentity> pskIdentities = BusinessLogicFactory.Identities.GetPSKIdentities(organisationID); response.PageInfo = Request.GetPageInfo(pskIdentities.Count); int endIndex = response.PageInfo.StartIndex + response.PageInfo.ItemsCount; for (int index = response.PageInfo.StartIndex; index < endIndex; index++) { ServiceModels.PSKIdentity pskIdentity = new ServiceModels.PSKIdentity(pskIdentities[index]); pskIdentity.AddSelfLink(string.Concat(rootUrl, "/identities/psk/", pskIdentity.Identity), false, true); response.Add(pskIdentity); } result = Request.GetObjectResult(response); return result; }