def __init__(self, outbox=None): Thread.__init__(self) self.inbox = SimpleQueue() self.outbox = outbox self.p = dhlib._p self.g = dhlib._g self.Ka, self.KA = dhlib.gen_key(self.p, self.g)
def __init__(self, outbox=None): Thread.__init__(self) self.inbox = SimpleQueue() self.outbox = outbox self.N = _N self.g = _G self.Ka, self.KA = dhlib.gen_key(self.N, self.g) # client DH key self.mel, self.pwd = random.choice(IDS) print(f'Client: {self.mel.decode()}:{self.pwd.decode()}')
def __init__(self, outbox=None): Thread.__init__(self) self.inbox = SimpleQueue() self.outbox = outbox self.N = _N self.g = _G self.Ka, self.KA = dhlib.gen_key(self.N, self.g) # client DH key self.k = _K self.mel = b'*****@*****.**' self.pwd = b's3cr3t_p4ssw0rd'
def run(self): assert self.outbox is not None p, g, KA = self.inbox.get() Kb, KB = dhlib.gen_key(p, g) self.outbox.put(KB) s = pow(KA, Kb, p) key = SHA1.new(int_to_bytes(s)).digest()[:BS] ciph, iv = self.inbox.get() msg = unpad(AES.new(key, AES.MODE_CBC, iv).decrypt(ciph), BS) print('Bob: ', msg) iv = get_random_bytes(BS) ciph = AES.new(key, AES.MODE_CBC, iv).encrypt(pad(msg, BS)) self.outbox.put((ciph, iv)) print('Bob: done')
def __init__(self, outbox=None): Thread.__init__(self) self.inbox = SimpleQueue() self.outbox = outbox self.N = _N self.g = _G self.Kb, self.KB = dhlib.gen_key(self.N, self.g) # server DH key # precomp. server db self.DB = {} for mel, pwd in IDS: salt = get_random_bytes(BS) Kx = int.from_bytes(SHA256.new(salt + pwd).digest(), 'big') KX = pow(self.g, Kx, self.N) self.DB[mel] = (salt, KX) # salt & pwd DH "public" key
def __init__(self, outbox=None): Thread.__init__(self) self.inbox = SimpleQueue() self.outbox = outbox self.N = _N self.g = _G self.Kb, self.KB = dhlib.gen_key(self.N, self.g) # server DH key self.k = _K # precomp. server db self.DB = {} mel = b'*****@*****.**' pwd = b's3cr3t_p4ssw0rd' salt = get_random_bytes(BS) Kx = int.from_bytes(SHA256.new(salt+pwd).digest(), 'big') KX = pow(self.g, Kx, self.N) self.DB[mel] = (salt, KX) # salt & pwd DH "public" key
def __init__(self, outbox=None): Thread.__init__(self) self.inbox = SimpleQueue() self.outbox = outbox self.p, self.g = dhlib._groups[randint(0, 2)] self.Ka, self.KA = dhlib.gen_key(self.p, self.g)