Exemplo n.º 1
0
 def test_key_differences(self):
     """Test if the generated keys are different"""
     key1 = KeyOperation.generate_new_pair()
     key2 = KeyOperation.generate_new_pair()
     pub1 = key1.publickey()
     pub2 = key2.publickey()
     self.assertNotEqual(key1.exportKey(), key2.exportKey())
     self.assertNotEqual(pub1.exportKey(), pub2.exportKey())
Exemplo n.º 2
0
 def test_import_public_key(self):
     """ Test for public key import"""
     new_key = KeyOperation.generate_new_pair()
     public_key = KeyOperation.import_key(new_key.publickey().exportKey())
     self.assertFalse(public_key.has_private())
     self.assertEqual(public_key.exportKey(),
                      new_key.publickey().exportKey())
Exemplo n.º 3
0
 def add_new_encrypted_key():
     user = DatabasePrepare.create_new_user()
     user = User.query.filter_by(email=user.email).first()
     public_key = KeyOperation.generate_new_pair().publickey()
     device = DeviceList(user,
                         mac_address=DatabasePrepare.SUCCESS_MAC_ADDR,
                         os=DatabasePrepare.SUCCESS_OS,
                         backup_key='asdfasdf',
                         main_key='main key',
                         otp_modulus=int(public_key.n),
                         otp_exponent=int(public_key.e),
                         is_root=True)
     db.session.add(device)
     db.session.commit()
     return device
Exemplo n.º 4
0
 def test_generate_key_pair(self):
     """ Test for key pairs generation """
     private_key = KeyOperation.generate_new_pair()
     self.assertTrue(private_key.has_private())
     self.assertTrue(isinstance(private_key.exportKey(), bytes))