rework app registry - trust tweaks
This commit is contained in:
@@ -6,10 +6,6 @@ local Crypto = require('crypto')
|
||||
|
||||
local remoteId
|
||||
local args = { ... }
|
||||
local exchange = {
|
||||
base = 11,
|
||||
primeMod = 625210769
|
||||
}
|
||||
|
||||
if #args == 1 then
|
||||
remoteId = tonumber(args[1])
|
||||
@@ -35,25 +31,18 @@ if not socket then
|
||||
error('Unable to connect to ' .. remoteId .. ' on port 19')
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
local secretKey = os.getSecretKey()
|
||||
local publicKey = modexp(exchange.base, secretKey, exchange.primeMod)
|
||||
local publicKey = os.getPublicKey()
|
||||
local password = SHA1.sha1(password)
|
||||
|
||||
socket:write(Crypto.encrypt({ pk = publicKey, dh = os.getComputerID() }, password))
|
||||
|
||||
print(socket:read(2) or 'No response')
|
||||
|
||||
local data = socket:read(2)
|
||||
socket:close()
|
||||
|
||||
if data and data.success then
|
||||
print(data.msg)
|
||||
elseif data then
|
||||
error(data.msg)
|
||||
else
|
||||
error('No response')
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user