Esempio n. 1
0
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
Esempio n. 2
0
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()
Esempio n. 3
0
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()