Esempio n. 1
0
 def test_key_serialization(self):
     tmpdir = tempfile.mkdtemp()
     try:
         filename = os.path.join(tmpdir, '.keyinfo')
         crypto.write_keyinfo(self.keyinfo, filename)
         keyinfo2 = crypto.read_keyinfo(filename)
         for name, keydata in self.keyinfo.items():
             self.assertEqual(keydata, keyinfo2[name])
     finally:
         shutil.rmtree(tmpdir)
Esempio n. 2
0
 def test_keyfile(self):
     keyinfo = crypto.generate_keyinfo(Client.KEY_SCHEMA)
     tmpdir = tempfile.mkdtemp()
     try:
         filename = os.path.join(tmpdir, '.keyinfo')
         crypto.write_keyinfo(keyinfo, filename)
         client = Client(filename)
         ptxt = b"test"
         ctxt = client.encrypt(ptxt)
         self.assertEqual(ptxt, client.decrypt(ctxt))
     finally:
         shutil.rmtree(tmpdir)
Esempio n. 3
0
def keygen(context, filename):
    """Generate client keys."""
    keyinfo = crypto.generate_keyinfo(EDBClient.KEY_SCHEMA)
    crypto.write_keyinfo(keyinfo, filename)
    print('Created keyfile at {}'.format(os.path.abspath(filename)))
Esempio n. 4
0
def keygen(context, filename):
    """Generate client keys."""
    keyinfo = crypto.generate_keyinfo(EDBClient.KEY_SCHEMA)
    crypto.write_keyinfo(keyinfo, filename)
    print("Created keyfile at {}".format(os.path.abspath(filename)))