From 97a442e99974356e313fd9c9d0bcb5723737f69c Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Thu, 27 Jun 2019 16:29:12 -0400 Subject: [PATCH] socket update --- sys/apis/socket.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/apis/socket.lua b/sys/apis/socket.lua index fd73abd..726b4d3 100644 --- a/sys/apis/socket.lua +++ b/sys/apis/socket.lua @@ -115,7 +115,7 @@ function Socket.connect(host, port) type = 'OPEN', shost = socket.shost, dhost = socket.dhost, - t = Crypto.encrypt({ ts = os.time(), seq = socket.seq }, Security.getPublicKey()), + t = Crypto.encrypt({ ts = os.time(), seq = socket.seq, nts = os.epoch('utc') }, Security.getPublicKey()), rseq = socket.wseq, wseq = socket.rseq, }) @@ -170,6 +170,10 @@ local function trusted(msg, port) if pubKey then local data = Crypto.decrypt(msg.t or '', pubKey) + if data.nts then -- upgraded security + return data.nts and tonumber(data.nts) and math.abs(os.epoch('utc') - data.nts) < 1024 + end + --local sharedKey = modexp(pubKey, exchange.secretKey, public.primeMod) return data.ts and tonumber(data.ts) and math.abs(os.time() - data.ts) < 24 end