def test_dump_jwks(): kb1 = rsa_init({ 'use': ['enc', 'sig'], 'size': 1024, 'name': 'rsa', 'path': 'keys' }) a = {"kty": "oct", "key": "highestsupersecret", "use": "sig"} b = {"kty": "oct", "key": "highestsupersecret", "use": "enc"} kb2 = KeyBundle([a, b]) dump_jwks([kb1, kb2], 'jwks_combo') # Now read it nkb = KeyBundle(source='file://jwks_combo', fileformat='jwks') assert len(nkb) == 2 # both RSA keys assert len(nkb.get('rsa')) == 2
def test_loads_0(): kb = KeyBundle(JWK0) assert len(kb) == 1 key = kb.get("rsa")[0] assert key.kid == "abc" assert key.kty == "RSA"
def test_with_sym_key(): kc = KeyBundle({"kty": "oct", "key": "highestsupersecret", "use": "sig"}) assert len(kc.get("oct")) == 1 assert len(kc.get("rsa")) == 0 assert kc.remote is False assert kc.source is None
keys.append(RSAKey(key=import_rsa_key(args.rsa_file), kid=_kid)) if args.hmac_key: keys.append(SYMKey(key=args.hmac_key, kid=_kid)) if args.jwk: _key = key_from_jwk_dict(open(args.jwk).read()) keys.append(_key) if args.jwks: _k = KeyJar() _k.import_jwks(open(args.jwks).read(), "") keys.extend(_k.issuer_keys("")) if args.jwks_url: _kb = KeyBundle(source=args.jwks_url) keys.extend(_kb.get()) if not args.msg: # If nothing specified assume stdin message = sys.stdin.read() elif args.msg == "-": message = sys.stdin.read() else: if os.path.isfile(args.msg): message = open(args.msg).read().strip("\n") else: message = args.msg message = message.strip() message = message.strip('"') main(message, keys, args.quiet)