def load_my_key(self, tup=None): if self.replay.can_replay("dsa_private_key") and self.replay.can_replay("dsa_public_key"): self.my_private_key = self.replay.load_dsa_key() else: if tup is None: self.my_private_key = OtrDSA.make_key() else: self.my_private_key = DSA.construct(tup) self.my_public_key = self.my_private_key.publickey() self.my_q_len = OtrDSA.calc_q_len(self.my_private_key)
def load_dsa_key(self): assert self.can_replay('dsa_public_key') assert self.can_replay('dsa_private_key') key = self.data['dsa_public_key'] priv_key = self.data['dsa_private_key'] key_reader = ByteStreamReader(key) p = _OT.mpi_to_int(key_reader.get_mpi()) q = _OT.mpi_to_int(key_reader.get_mpi()) g = _OT.mpi_to_int(key_reader.get_mpi()) y = _OT.mpi_to_int(key_reader.get_mpi()) assert (key_reader.consumed_all()) priv_key_reader = ByteStreamReader(priv_key) x = _OT.mpi_to_int(priv_key_reader.get_mpi()) assert (priv_key_reader.consumed_all()) return DSA.construct((y,g,p,q,x))
def make_key(): rp = RandomPool() return DSA.generate(OtrDSA.dsa_len, rp.get_bytes)
def load_their_key(self, tup): self.their_public_key = DSA.construct(tup) self.their_q_len = OtrDSA.calc_q_len(self.their_public_key)