Test of tinydtls over cellular

Dependencies:   VodafoneUSBModem mbed-rtos mbed tinydtls

Files at this revision

API Documentation at this revision

Comitter:
ashleymills
Date:
Fri Oct 18 14:08:05 2013 +0000
Parent:
1:1dd9b8218515
Commit message:
Updated to tinydtls v0.5.0

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
tinydtls.lib Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Oct 11 14:01:57 2013 +0000
+++ b/main.cpp	Fri Oct 18 14:08:05 2013 +0000
@@ -23,24 +23,24 @@
    }
 }
 
+static const dtls_psk_key_t client_psk = {
+    .id = (unsigned char *)"Client_identity",
+    .id_length = 15,
+    .key = (unsigned char *)"secretPSK",
+    .key_length = 9
+};
+
 /* This function is the "key store" for tinyDTLS. It is called to
  * retrieve a key for the given identiy within this particular
  * session. */
-int get_key(struct dtls_context_t *ctx, 
-    const session_t *session, 
-    const unsigned char *id, size_t id_len, 
-    const dtls_key_t **result) {
-    DBG("get_key called");
+int
+get_psk_key(struct dtls_context_t *ctx,
+        const session_t *session,
+        const unsigned char *id, size_t id_len,
+        const dtls_psk_key_t **result) {
+  DBG("id: %d, len: %d",id,id_len);
+  *result = &client_psk;
 
-  static const dtls_key_t psk = {
-    .type = DTLS_KEY_PSK,
-    .key.psk.id = (unsigned char *)"Client_identity", 
-    .key.psk.id_length = 15,
-    .key.psk.key = (unsigned char *)"secretPSK", 
-    .key.psk.key_length = 9
-  };
-   
-  *result = &psk;
   return 0;
 }
 
@@ -171,12 +171,14 @@
    return 0;
 }
 
-// structure for required tinydtls callbacks
+// structure for required DTLS callbacks
 static dtls_handler_t cb = {
   .write = send_to_peer,
   .read  = read_from_peer,
   .event = event_handler,
-  .get_key = get_key
+  .get_psk_key = get_psk_key,
+  .get_ecdsa_key = NULL,// get_ecdsa_key,
+  .verify_ecdsa_key = NULL//verify_ecdsa_key
 };
 
 int main() {
--- a/tinydtls.lib	Fri Oct 11 14:01:57 2013 +0000
+++ b/tinydtls.lib	Fri Oct 18 14:08:05 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/ashleymills/code/tinydtls/#bc8a649bad13
+http://mbed.org/users/ashleymills/code/tinydtls/#ff9ebe0cf0e9