contiki-ng / tinydtls

A version of tinyDTLS that is refactored to be more easy to use "standalone" (e.g. without bindings to a specific IP-stack).
Other
8 stars 25 forks source link

dtls-client adds newline in preshared key #3

Open aodanne opened 6 years ago

aodanne commented 6 years ago

dtls-client concatenates the key from the key file (using -k) with a newline.

nfi commented 6 years ago

Just tested under OSX and there I do not get an ending newline. Which operating system are you testing with?

aodanne commented 6 years ago

Ubuntu

nfi commented 6 years ago

I added a print of the key data read from file in dtls-client.c and tested with a key file with 9 characters under Linux Ubuntu 14.04:

> ll default-key 
-rw-rw-r-- 1 user user 9 Feb 21 00:14 default-key
> ./dtls-client -k default-key 127.0.0.1
READ PSK (9 bytes): 73656372657450534b

It does not look like any newline is added for me. Could it be that your key file actually contains a newline?

If that is the case, one option would be to forbid ending whitespace in PSK and make dtls-client remove any ending whitespace when reading data from file. Since it is a test application, I do not think it would be a big limitation.