Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --
- -- encrypt( securekey(hash) - keyhere, securesalt(hash) - salthere)
- --
- -- 1. Recieve on random stonefruit channel (gained from ecnrypted server request encrypted then appended with encrypted salt)
- -- 2. Retreived channel will be send back encrypted with retrievers id
- -- 3. unencrypted the client uses this new channel to communicate with the server
- -- 3. the client requests a session, a random id is generated if it isnt in use (session table)
- -- 4. ID is then encrypted with clients id, then sent to the client
- -- 5. clients new requests must be met with a session id as the clients id is stored in a table
- --
- function setupModem()
- return peripheral.find("modem")
- end
- function getSession(modem,key)
- -- Send rednet signal to server
- local sessionid = 0
- rednet.broadcast("stone-freq",{type="auth",data.encrypt(key,os.getComputerID())})
- local sid, mes = rednet.receive("3")
- local mes = data.decrypt(mes,os.getComputerID())
- if(type(mes)=="table")then
- if(mes.auth == true)then
- -- Get random channel from server
- modem.open(auth.channel)
- local _, _, senderChannel, replyChannel, message, _ = os.pullEvent("modem_message")
- if(senderChannel == auth.channnel and replyChannel == auth.channel)then
- local sessionid = message.session
- end
- end
- elseif(mes ~= nil)then
- error("Possible Rednet interference detected, please contact StoneFruit! ".."\nInterference ID: " .. sid)
- else
- return 0
- end
- end
- -- Generate keys based on unique id's then store those ID's in a file to be compared,
- -- Send the key out encrypted, then have the server decrypt the key,
- -- Compare the decrypted ID with the register ID's if it matches then GG.
- function decryptKey(key,cid,securekey,securesalt)
- return data.decrypt(data.decrypt(data.decrypt(key,securekey),securesalt),cid)
- end
- function generateKey(cid,uid,securekey,securesalt)
- return data.encrypt(data.encrypt(data.encrypt(uid,securekey),securesalt),cid)
- end
- function generateSession(uid,cid,auth,securekey,securesalt)
- -- Check key based on decoded security key
- local compses = {
- [cid] = {
- sesid = uid,
- ses = data.encrypt(data.encrypt(data.encrypt(cid, securekey),uid),securesalt),
- }
- }
- return compses
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement