Пример #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)
Пример #2
0
    def __init__(self, keyfile=None, _keyinfo=None):
        """Create a client.

        Parameters:

        keyfile (optional)
          path to file containing client keys

        If keyfile is not supplied, fresh keys will be generated.

        """
        if _keyinfo is not None:
            self.keys = _keyinfo
        elif keyfile is not None:
            self.keys = crypto.read_keyinfo(keyfile)
        else:
            self.keys = crypto.generate_keyinfo(self.KEY_SCHEMA)
Пример #3
0
    def __init__(self, keyfile=None, _keyinfo=None):
        """Create a client.

        Parameters:

        keyfile (optional)
          path to file containing client keys

        If keyfile is not supplied, fresh keys will be generated.

        """
        if _keyinfo is not None:
            self.keys = _keyinfo
        elif keyfile is not None:
            self.keys = crypto.read_keyinfo(keyfile)
        else:
            self.keys = crypto.generate_keyinfo(self.KEY_SCHEMA)