示例#1
0
    def test_public_key_serializeation(self):
        crypto = Crypto(public_exponent=65537, key_size=2048)
        with open(tempfile.NamedTemporaryFile().name, 'w') as f:
            crypto.public_key_to_file(f.name)
            crypto_client = CryptoClient(f.name)

        self.assertEqual(
            crypto.public_bytes(),
            crypto_client.public_bytes(),
        )
示例#2
0
def make_keys(args):
    for k, v in args.auth_to_key_files_map.items():
        for val in v:
            auth_id, filename = val
            pub_file = '{}.{}'.format(filename, args.public_key_file_extension)
            crypto = Crypto(
                public_exponent=args.public_exponent,
                key_size=args.key_size,
            )
            fullpath = os.path.join(args.basedir, args.key_dir, pub_file)
            os.makedirs(os.path.dirname(fullpath), exist_ok=True)
            crypto.public_key_to_file(fullpath)
            fullpath = os.path.join(args.basedir, args.key_dir, filename)
            crypto.UNSAFE_private_key_to_file(fullpath)