def test_ec_alg(): kb = KeyBundle(source=os.path.join(BASE_PATH, "ec-p256.json"), keyusage="sig") issuer = KeyIssuer() issuer.add_kb(kb) k = issuer.get(key_use="sig", key_type="ec", alg="P-384") assert k == [] k = issuer.get(key_use="sig", key_type="ec", alg="P-256") assert len(k) == 1
def test_get_signing_key_use_undefined(): issuer = KeyIssuer() issuer.import_jwks(JWK1) keys = issuer.get("sig", kid="rsa1") assert len(keys) == 1 keys = issuer.get("sig", key_type="rsa") assert len(keys) == 1 keys = issuer.get("sig", key_type="rsa", kid="rsa1") assert len(keys) == 1
def test_get_enc_not_mine(self): issuer = KeyIssuer() issuer.add_kb( KeyBundle([ { "kty": "oct", "key": "a1b2c3d4e5f6g7h8", "use": "sig" }, { "kty": "oct", "key": "a1b2c3d4e5f6g7h8", "use": "enc" }, ])) issuer.add_kb( KeyBundle([ { "kty": "oct", "key": "1a2b3c4d5e6f7g8h", "use": "sig" }, { "kty": "oct", "key": "1a2b3c4d5e6f7g8h", "use": "ver" }, ])) issuer.add_kb(keybundle_from_local_file(RSAKEY, "der", ["ver", "sig"])) assert issuer.get("enc", "oct")
def test_dump(): issuer = KeyIssuer() issuer.add_kb(KeyBundle(JWK2["keys"])) res = issuer.dump() nkj = KeyIssuer().load(res) assert nkj.get("sig", "rsa", kid="kriMPdmBvx68skT8-mPAB3BseeA") assert nkj.get("sig", "rsa", kid="MnC_VZcATfM5pOYiJHMba9goEKY")
def test_get_ec_wrong_alg(): issuer = KeyIssuer() issuer.import_jwks(JWKS_SPO) k = issuer.get("sig", "EC", alg="ES512") assert k == []
def test_get_ec(): issuer = KeyIssuer() issuer.import_jwks(JWKS_SPO) k = issuer.get("sig", "EC", alg="ES256") assert k
def test_no_use(self): kb = KeyBundle(JWK0["keys"]) issuer = KeyIssuer() issuer.add_kb(kb) enc_key = issuer.get("enc", "RSA") assert enc_key != []
def test_add_symmetric(self): issuer = KeyIssuer() issuer.add_symmetric("abcdefghijklmnop", ["sig"]) assert len(issuer.get("sig", "oct")) == 1