Ejemplo n.º 1
0
import sm_py

if __name__ == '__main__':
    aliceKeys = sm_py.key_init()["keys"]
    bobKeys = sm_py.key_init()["keys"]
    secret = "test"
    step1 = sm_py.step_1(secret, aliceKeys)
    aliceKeys = step1["keys"]
    print(step1["message"])
    step2 = sm_py.step_2(step1["message"], bobKeys)
    bobKeys = step2["keys"]
    step3 = sm_py.step_3("test", bobKeys)
    bobKeys = step3["keys"]
    print(step3["message"])
    step4 = sm_py.step_4(step3["message"], aliceKeys)
    aliceKeys = step4["keys"]
    print(step4["message"])
    step5 = sm_py.step_5(step4["message"], bobKeys)
    bobKeys = step5["keys"]
    print(step5["success"])
    print(step5["message"])
    step6 = sm_py.step_6(step5["message"], aliceKeys)
    print(step6["success"])
Ejemplo n.º 2
0
 while smWait:
     smUrl = "https://lab3key.herokuapp.com/messages"
     smRecvUrl = "https://lab3key.herokuapp.com/messages?demail=" + NICK
     smRecvReq = urllib2.Request(smRecvUrl, headers={"content-type": "application/json"})
     smRecvResp = urllib2.urlopen(smRecvReq)
     try:
         responseVal = smRecvResp.read().decode("utf8")
         if responseVal != "none":
             valstr = str(responseVal)
             jsonval = json.loads(valstr)
             for message in jsonval:
                 if message["isSMP"]:
                     step = message["typeSMP"]
                     payload = message["payload"]
                     if step == 2:
                         step2 = sm_py.step_2(payload, smKeys)
                         smKeys = step2["keys"]
                         step3 = sm_py.step_3(secret, smKeys)
                         smKeys = step3["keys"]
                         smPayload = {
                             "message": {
                                 "source": NICK,
                                 "destination": OTHER_NICK,
                                 "isSMP": True,
                                 "typeSMP": 4,
                                 "payload": step3["message"],
                             }
                         }
                         smParams = json.dumps(smPayload)
                         smReq = urllib2.Request(
                             smUrl, data=smParams, headers={"content-type": "application/json"}