/luadtls

Binding Lua for tinydtls library (http://tinydtls.sourceforge.net), a tiny implementation of DTLS.

Primary LanguageC

luadtls

luadtls is a lua binding for tinydtls library .

luadtls contains 2 modules :

A dtls/luasocket sample :

local dtls = require 'dtls'
local socket = require 'socket'

-- create UDP socket
local udp = socket.udp();
udp:setsockname('*', 5683)

-- change UDP socket in DTLS socket
dtls.wrap(udp, {security = "PSK", identity = "Client_identity", key = "secretPSK"})

-- DTLS handshake in automaticaly do at first sendto
udp:sendto("my clear data","127.0.0.1", 5684)
repeat
  local data, host, port, msg = udp:receivefrom()
  -- receive clear data
  print ("receive clear data",data, host, port)
until false

More samples available in sample folder.

Compile & Test

Get the code : (--recursive is need because of use of git submodule.)

git clone --recursive git@github.com:sbernard31/luadtls.git luadtls

Compile it : (You need lua header files from package liblua5.1-0-dev and the tools cmake and autoconf -_-! ...)

mkdir [builddir]
cd [builddir]
cmake [luadtls source directory]
make

Test it : (Lua 5.1 and luasocket is needed, you can use californium.sandium server implementation to test.)

lua -e "package.path = './?/init.lua;' .. package.path" sample.lua

Limitation

luadtls binding is still in development. For now, it is only compatible with Lua 5.1 and linux.