SMT: Secure Modem Transit for ComputerCraft

Started by steamport, Aug 12, 2018, 05:10 pm

Previous topic - Next topic

steamport

it's like ringnet but better

INTRODUCING, SMT!

Secure, easy to use modem transit!

Download:
Code Select
wget https://gist.githubusercontent.com/steamp0rt/080de776670a778d3e612e1a05d2de77/raw/smt.min.lua smt.lua
Github: https://github.com/steamp0rt/SMT
Docs: https://steamp0rt.github.io/SMT/

Server Example:
Code Select
local smt = require("/smt")
local t = smt("smt.main.transit")
t.openChannel(100)
parallel.waitForAll(t.listener, function()
while true do
  local ev, cid, data = os.pullEvent("RLWE-Receive")
  print("Received data! "..tostring(data))
end
end)

Client Example:
Code Select
local smt = require("/smt")
local t = smt("smt.main.transit")
t.openChannel(100)
parallel.waitForAll(t.listener, function()
    t.openTunnel("f463820793", 100)
    local _,cid = os.pullEvent("RLWE-Finish")
    sleep(0.15)
    t.sendData(cid, "hai")
end)

FAQ:
Q: So wait, what's this "f463820793" in the client example?
A: That's the server's UUID. The server can get it by either reading the ".rlwe_uuid" file, or reading "t.uuid", assuming t is smt("smt.main.transit").
Q: How does this work?
A: Basically, math shenanigans is used to exchange a key in a way that can't be intercepted. And yes, there IS forward secrecy!
Q: Can't I just pretend to have a UUID and intercept the handshake?
A: Not really! The server's static public-private keypair is used during the key exchange. Provided the client already has the public key (it does if you have already handshaked with it once), an attempt to spoof the server will fail the handshake.

HydroNitrogen

Looks nice! What's performance like? Also, aside from a tutorial on how to use it, could you add a brief description of what it is and how it works?
Please do collaborate on the ComputerCraft Wiki! Thanks!
Also like my post if you found it informative or helpful. This gets me to know what I should do more of. Thanks again!

steamport

Quote from: HydroNitrogen on Aug 12, 2018, 05:27 pmLooks nice! What's performance like? Also, aside from a tutorial on how to use it, could you add a brief description of what it is and how it works?

Performance is: good, but expect latency and lag with real-time stuff.

Also, it works via RLWE key exchange, to make a key used to encrypt stuff with ChaCha20

osmarks

Please make this able to either use all modems (get them via [icode]{peripheral.find "modem"}[/icode]) or allow you to pass in a modem object.