예제 #1
0
 public DTLSClientChannel(CWT cwt, OneKey userKey, KeySet cwtTrustKeys, int port)
 {
     _port          = port;
     _userKey       = userKey;
     _userCwt       = cwt;
     CwtTrustKeySet = cwtTrustKeys;
 }
예제 #2
0
        public static void ClassSetup(TestContext ctx)
        {
            byte[]     cert   = Base64.Decode("MIIBHDCBz6ADAgECAhRzRMjlxi8nPr0B6DoN7e4sxwyb6jAFBgMrZXAwGDEWMBQGA1UEAwwNQ09TRSBDQSBUaHJlZTAeFw0xOTA3MDgwMTAyMjBaFw0yNzA5MjQwMTAyMjBaMBYxFDASBgNVBAMMC0NPU0UgRUUgU2l4MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEo0gYfGOYqcwGVra0OEiE0XXST/W4pTJ/HdTXZ7Ek/ycJZZn0jkHNQ9UCP7NJ16LOcZLUofev7OMHxct5DvuaPjAFBgMrZXADQQAqm5No83WC9W7tOkicP9wGu1HSdGCOR0CVjjzHfCfzRQkuSW2tRLBlstxzpqY6yrIuccMifhcrCdMe3fsPPS8G");
            CBORObject objKey = CBORObject.NewMap();

            objKey[CoseKeyKeys.KeyType]           = GeneralValues.KeyType_EC;
            objKey[CoseKeyKeys.Algorithm]         = AlgorithmValues.ECDSA_256;
            objKey[CoseKeyParameterKeys.EC_Curve] = GeneralValues.P256;
            objKey[CoseKeyParameterKeys.EC_D]     = CBORObject.FromObject(Hex.Decode("7D29C4C7CDCBB2209CAD01F3BB4C9009782F66C2E1A6C592DF838A0795A6D87B"));
            objKey[CoseKeyParameterKeys.EC_X]     = CBORObject.FromObject(Hex.Decode("A348187C6398A9CC0656B6B4384884D175D24FF5B8A5327F1DD4D767B124FF27"));
            objKey[CoseKeyParameterKeys.EC_Y]     = CBORObject.FromObject(Hex.Decode("096599F48E41CD43D5023FB349D7A2CE7192D4A1F7AFECE307C5CB790EFB9A3E"));

            OneKey key = new OneKey(objKey);

            X509Key = new TlsKeyPair(cert, key);

            cert   = Hex.Decode("3082011D3081D0A00302010202147344C8E5C62F273EBD01E83A0DEDEE2CC70C9BE9300506032B657030183116301406035504030C0D434F5345204341205468726565301E170D3139303730383031303231395A170D3237303932343031303231395A30173115301306035504030C0C434F534520454520466976653059301306072A8648CE3D020106082A8648CE3D03010703420004E8D9873804129C0A11238675C144CF00A7AF0E1A8ACF54A87BE76B9A0F2DBADF5384966EFD9C05B3DCEB3C074CF32410F033D962620C41F3892C0B94E3955D77300506032B65700341007BB0A5201998E6FC120364B96DD88211DD1FC907888C380E5A186BCD2F6A4CB238853EC22E5537CBCE5C157E59B4AEE71383372345932D0D40260857053FA608");
            objKey = CBORObject.NewMap();
            objKey[CoseKeyKeys.KeyType]           = GeneralValues.KeyType_EC;
            objKey[CoseKeyKeys.Algorithm]         = AlgorithmValues.ECDSA_256;
            objKey[CoseKeyParameterKeys.EC_Curve] = GeneralValues.P256;
            objKey[CoseKeyParameterKeys.EC_D]     = CBORObject.FromObject(Hex.Decode("019F4FD19429DE078B2A013F5218CD64C24FABA1F6F0BE924E628E63BC67A8AC"));
            objKey[CoseKeyParameterKeys.EC_X]     = CBORObject.FromObject(Hex.Decode("E8D9873804129C0A11238675C144CF00A7AF0E1A8ACF54A87BE76B9A0F2DBADF"));
            objKey[CoseKeyParameterKeys.EC_Y]     = CBORObject.FromObject(Hex.Decode("5384966EFD9C05B3DCEB3C074CF32410F033D962620C41F3892C0B94E3955D77"));

            X509Client = new TlsKeyPair(cert, new OneKey(objKey));
        }
예제 #3
0
 public bool Compare(TlsKeyPair other)
 {
     if (this == other)
     {
         return(true);
     }
     return(false);
 }
예제 #4
0
        /// <summary>
        /// Create a session for initiating a session.
        /// </summary>
        /// <param name="ipEndPoint">Where to talk from</param>
        /// <param name="dataReceived">Where to send receive events</param>
        /// <param name="privKey">user authentication key</param>
        /// <param name="cwtTrustKeys">Authentication keys for CWTs</param>
        public DTLSSession(IPEndPoint ipEndPoint, EventHandler <DataReceivedEventArgs> dataReceived, TlsKeyPair privKey, KeySet cwtTrustKeys = null)
        {
            EndPoint      = ipEndPoint;
            _dataReceived = dataReceived;
            _userKey      = privKey ?? throw new ArgumentNullException(nameof(privKey));
#if SUPPORT_TLS_CWT
            CwtTrustKeySet = cwtTrustKeys;
#endif
            _transport = new OurTransport(ipEndPoint);
        }
예제 #5
0
 /// <summary>
 /// Add a key to the key set.  The function will do a minimal check for equality to existing keys in the set.
 /// </summary>
 /// <param name="key">OneKey: key to be added</param>
 public void AddKey(TlsKeyPair key)
 {
     foreach (TlsKeyPair k in _keyList)
     {
         if (key.Compare(k))
         {
             return;
         }
     }
     _keyList.Add(key);
 }
예제 #6
0
 /// <summary>
 /// Create a client only channel and use a given point
 /// </summary>
 /// <param name="userKey">Authentication Key</param>
 /// <param name="port">client side UDP port</param>
 public DTLSClientChannel(OneKey userKey, Intint32 port)
 {
     _port    = port;
     _userKey = userKey;
 }
예제 #7
0
 internal MyTlsAuthentication(TlsContext context, TlsKeyPair cwt, KeySet trustKeys)
 {
     this._mContext = context;
     TlsKey         = cwt;
     CwtTrustKeySet = trustKeys;
 }
예제 #8
0
 public DtlsClient(TlsSession session, TlsKeyPair tlsKey, KeySet cwtTrustKeys)
 {
     _mSession      = session;
     _tlsKeyPair    = tlsKey ?? throw new ArgumentNullException(nameof(tlsKey));
     CwtTrustKeySet = cwtTrustKeys;
 }
예제 #9
0
 internal MyTlsAuthentication(TlsContext context, TlsKeyPair rawPublicKey)
 {
     this._mContext = context;
     TlsKey         = rawPublicKey;
 }
예제 #10
0
 public DtlsClient(TlsSession session, TlsKeyPair userKey)
 {
     _mSession   = session;
     _tlsKeyPair = userKey ?? throw new ArgumentNullException(nameof(userKey));
 }
예제 #11
0
 /// <summary>
 /// Create a client only channel and use a given endpoint
 /// </summary>
 /// <param name="userKey">Authentication Key</param>
 /// <param name="ep">client side endpoint</param>
 public DTLSClientChannel(OneKey userKey, System.Net.EndPoint ep)
 {
     _localEndPoint = ep;
     _userKey       = userKey;
 }
예제 #12
0
 /// <summary>
 /// Create a client only channel and use a given endpoint
 /// </summary>
 /// <param name="userKey">Authentication Key</param>
 /// <param name="ep">client side endpoint</param>
 public DTLSClientChannel(TlsKeyPair userKey, System.Net.EndPoint ep)
 {
     _localEndPoint = ep;
     _userKey       = userKey ?? throw new ArgumentNullException(nameof(userKey));
 }
예제 #13
0
 public DTLSClientChannel(TlsKeyPair userKey, int port)
 {
     _port    = port;
     _userKey = userKey ?? throw new ArgumentNullException(nameof(userKey));
 }
예제 #14
0
 public DTLSClientEndPoint(TlsKeyPair userKey, int port = 0) : this(userKey, port, CoapConfig.Default)
 {
 }
예제 #15
0
 public DTLSClientEndPoint(TlsKeyPair userKey, ICoapConfig config) : this(userKey, 0, config)
 {
 }
예제 #16
0
 public DTLSClientEndPoint(TlsKeyPair userKey, int port, ICoapConfig config) : this(new DTLSClientChannel(userKey, port), config)
 {
 }
예제 #17
0
 public void TestRpk()
 {
     TlsKeyPair         tlsKey = new TlsKeyPair(RpkOneKey.PublicKey(), RpkOneKey);
     DTLSClientEndPoint ep     = new DTLSClientEndPoint(RpkOneKey);
 }
예제 #18
0
 public DTLSClientEndPoint(TlsKeyPair userKey, System.Net.EndPoint localEndPoint, ICoapConfig config) : this(new DTLSClientChannel(userKey, localEndPoint), config)
 {
 }
예제 #19
0
 public DTLSClientEndPoint(TlsKeyPair userKey, System.Net.EndPoint localEndPoint) : this(userKey, localEndPoint, CoapConfig.Default)
 {
 }