1
0
mirror of https://github.com/kepler155c/opus synced 2025-10-22 11:17:40 +00:00

rework app registry - trust tweaks

This commit is contained in:
kepler155c@gmail.com
2017-05-19 19:00:23 -04:00
parent fbe2c9e909
commit 8ecfea1524
33 changed files with 282 additions and 68 deletions

View File

@@ -3,27 +3,6 @@ local Crypto = require('crypto')
local socketClass = { }
local exchange = {
base = 11,
primeMod = 625210769
}
local function modexp(base, exponent, modulo)
local remainder = base
for i = 1, exponent-1 do
remainder = remainder * remainder
if remainder >= modulo then
remainder = remainder % modulo
end
end
return remainder
end
exchange.secretKey = os.getSecretKey()
exchange.publicKey = modexp(exchange.base, exchange.secretKey, exchange.primeMod)
function socketClass:read(timeout)
local data, distance = transport.read(self)
@@ -131,7 +110,7 @@ function Socket.connect(host, port)
type = 'OPEN',
shost = socket.shost,
dhost = socket.dhost,
t = Crypto.encrypt({ ts = os.time(), seq = socket.seq }, exchange.publicKey),
t = Crypto.encrypt({ ts = os.time(), seq = socket.seq }, os.getPublicKey()),
rseq = socket.wseq,
wseq = socket.rseq,
})