def test_dump_load(): _ckey = import_rsa_key_from_cert_file(CERT) _key = jwk_wrap(_ckey, "sig", "kid1") _filename = full_path("tmp_jwk.json") dump_jwk(_filename, _key) key = import_jwk(_filename) assert isinstance(key, RSAKey) assert key.kid == "kid1" assert key.use == "sig"
def test_import_rsa_key(): _ckey = import_private_rsa_key_from_file(full_path(KEY)) assert isinstance(_ckey, rsa.RSAPrivateKey) djwk = jwk_wrap(_ckey).to_dict() assert _eq(djwk.keys(), ["kty", "e", "n", "p", "q", "d"]) assert djwk[ "n"] == '5zbNbHIYIkGGJ3RGdRKkYmF4gOorv5eDuUKTVtuu3VvxrpOWvwnFV' \ '-NY0LgqkQSMMyVzodJE3SUuwQTUHPXXY5784vnkFqzPRx6bHgPxKz7XfwQjEBTafQTMmOeYI8wFIOIHY5i0RWR-gxDbh_D5TXuUqScOOqR47vSpIbUH-nc' assert djwk['e'] == 'AQAB'
def test_key_size(): _ckey = import_rsa_key_from_cert_file(CERT) jwk = jwk_wrap(_ckey) assert jwk.key_len() == 1024
def test_dumps(): _ckey = import_rsa_key_from_cert_file(CERT) jwk = jwk_wrap(_ckey).serialize() assert _eq(list(jwk.keys()), ["kty", "e", "n", "kid"])