Ejemplo n.º 1
0
 def test_verify_with_other_key(self):
     key1 = self.keys
     key2 = generate_keys()
     random_word = randomword(2 ** 10)
     signature = key1.sign(random_word)
     # now verify that key2 does not verify the signature
     self.assertFalse(key2.verify(random_word, signature))
Ejemplo n.º 2
0
def save_rsa_keys(pub_path, private_path):
    """
    Saves a pair of rsa keys
    """
    myKey = generate_keys()
    public_key    = open(pub_path, "w")
    private_key   = open(private_path, "w")
    public_key.write(str(myKey.get_pub().decode()))
    private_key.write(str(myKey.get_private().decode()))
    public_key.close()
    private_key.close()
Ejemplo n.º 3
0
 def test_key_gen(self):
     key1 = self.keys
     key2 = generate_keys()
     self.assertNotEqual(key1.e, key1.d)
     self.assertNotEqual(key1.e, key2.e)
     self.assertNotEqual(key1.d, key2.d)