def test_serialize_rsa_pub_key(): rsakey = RSAKey(key=import_public_rsa_key_from_file(full_path("rsa.pub"))) assert rsakey.d == '' d_rsakey = rsakey.serialize(private=True) restored_key = RSAKey(**d_rsakey) assert restored_key == rsakey
def test_serialize_rsa_priv_key(): rsakey = RSAKey(key=import_private_rsa_key_from_file(full_path("rsa.key"))) assert rsakey.d d_rsakey = rsakey.serialize(private=True) restored_key = RSAKey(**d_rsakey) assert restored_key == rsakey assert rsakey.is_private_key() assert restored_key.is_private_key()
def test_kspec(): _ckey = import_rsa_key_from_cert_file(CERT) _key = RSAKey() _key.load_key(_ckey) jwk = _key.serialize() assert jwk["kty"] == "RSA" assert jwk["e"] == JWK["keys"][0]["e"] assert jwk["n"] == JWK["keys"][0]["n"] assert not _key.is_private_key()