repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_documentation_string stringlengths 1 47.2k | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/ec.py | ec_construct_public | def ec_construct_public(num):
"""
Given a set of values on public attributes build a elliptic curve
public key instance.
:param num: A dictionary with public attributes and their values
:return: A
cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey
instance.
"""
... | python | def ec_construct_public(num):
"""
Given a set of values on public attributes build a elliptic curve
public key instance.
:param num: A dictionary with public attributes and their values
:return: A
cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey
instance.
"""
... | Given a set of values on public attributes build a elliptic curve
public key instance.
:param num: A dictionary with public attributes and their values
:return: A
cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey
instance. | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/ec.py#L32-L44 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/ec.py | ec_construct_private | def ec_construct_private(num):
"""
Given a set of values on public and private attributes build a elliptic
curve private key instance.
:param num: A dictionary with public and private attributes and their values
:return: A
cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey... | python | def ec_construct_private(num):
"""
Given a set of values on public and private attributes build a elliptic
curve private key instance.
:param num: A dictionary with public and private attributes and their values
:return: A
cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey... | Given a set of values on public and private attributes build a elliptic
curve private key instance.
:param num: A dictionary with public and private attributes and their values
:return: A
cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey
instance. | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/ec.py#L47-L60 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/ec.py | import_private_key_from_file | def import_private_key_from_file(filename, passphrase=None):
"""
Read a private Elliptic Curve key from a PEM file.
:param filename: The name of the file
:param passphrase: A pass phrase to use to unpack the PEM file.
:return: A
cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePriv... | python | def import_private_key_from_file(filename, passphrase=None):
"""
Read a private Elliptic Curve key from a PEM file.
:param filename: The name of the file
:param passphrase: A pass phrase to use to unpack the PEM file.
:return: A
cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePriv... | Read a private Elliptic Curve key from a PEM file.
:param filename: The name of the file
:param passphrase: A pass phrase to use to unpack the PEM file.
:return: A
cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey
instance | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/ec.py#L63-L79 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/ec.py | ECKey.deserialize | def deserialize(self):
"""
Starting with information gathered from the on-the-wire representation
of an elliptic curve key (a JWK) initiate an
cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey
or EllipticCurvePrivateKey instance. So we have to get from having::
... | python | def deserialize(self):
"""
Starting with information gathered from the on-the-wire representation
of an elliptic curve key (a JWK) initiate an
cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey
or EllipticCurvePrivateKey instance. So we have to get from having::
... | Starting with information gathered from the on-the-wire representation
of an elliptic curve key (a JWK) initiate an
cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey
or EllipticCurvePrivateKey instance. So we have to get from having::
{
"kty":"EC",
... | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/ec.py#L142-L188 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/ec.py | ECKey.serialize | def serialize(self, private=False):
"""
Go from a
cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey
or EllipticCurvePublicKey instance to a JWK representation.
:param private: Whether we should include the private attributes or not.
:return: A JWK as a... | python | def serialize(self, private=False):
"""
Go from a
cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey
or EllipticCurvePublicKey instance to a JWK representation.
:param private: Whether we should include the private attributes or not.
:return: A JWK as a... | Go from a
cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey
or EllipticCurvePublicKey instance to a JWK representation.
:param private: Whether we should include the private attributes or not.
:return: A JWK as a dictionary | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/ec.py#L203-L228 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/ec.py | ECKey.load_key | def load_key(self, key):
"""
Load an Elliptic curve key
:param key: An elliptic curve key instance, private or public.
:return: Reference to this instance
"""
self._serialize(key)
if isinstance(key, ec.EllipticCurvePrivateKey):
self.priv_key = key
... | python | def load_key(self, key):
"""
Load an Elliptic curve key
:param key: An elliptic curve key instance, private or public.
:return: Reference to this instance
"""
self._serialize(key)
if isinstance(key, ec.EllipticCurvePrivateKey):
self.priv_key = key
... | Load an Elliptic curve key
:param key: An elliptic curve key instance, private or public.
:return: Reference to this instance | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/ec.py#L230-L244 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | rsa_init | def rsa_init(spec):
"""
Initiates a :py:class:`oidcmsg.keybundle.KeyBundle` instance
containing newly minted RSA keys according to a spec.
Example of specification::
{'size':2048, 'use': ['enc', 'sig'] }
Using the spec above 2 RSA keys would be minted, one for
encryption ... | python | def rsa_init(spec):
"""
Initiates a :py:class:`oidcmsg.keybundle.KeyBundle` instance
containing newly minted RSA keys according to a spec.
Example of specification::
{'size':2048, 'use': ['enc', 'sig'] }
Using the spec above 2 RSA keys would be minted, one for
encryption ... | Initiates a :py:class:`oidcmsg.keybundle.KeyBundle` instance
containing newly minted RSA keys according to a spec.
Example of specification::
{'size':2048, 'use': ['enc', 'sig'] }
Using the spec above 2 RSA keys would be minted, one for
encryption and one for signing.
... | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L56-L85 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | ec_init | def ec_init(spec):
"""
Initiate a key bundle with an elliptic curve key.
:param spec: Key specifics of the form::
{"type": "EC", "crv": "P-256", "use": ["sig"]}
:return: A KeyBundle instance
"""
kb = KeyBundle(keytype="EC")
if 'use' in spec:
for use in spec["use"]:
... | python | def ec_init(spec):
"""
Initiate a key bundle with an elliptic curve key.
:param spec: Key specifics of the form::
{"type": "EC", "crv": "P-256", "use": ["sig"]}
:return: A KeyBundle instance
"""
kb = KeyBundle(keytype="EC")
if 'use' in spec:
for use in spec["use"]:
... | Initiate a key bundle with an elliptic curve key.
:param spec: Key specifics of the form::
{"type": "EC", "crv": "P-256", "use": ["sig"]}
:return: A KeyBundle instance | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L88-L107 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | keybundle_from_local_file | def keybundle_from_local_file(filename, typ, usage):
"""
Create a KeyBundle based on the content in a local file
:param filename: Name of the file
:param typ: Type of content
:param usage: What the key should be used for
:return: The created KeyBundle
"""
usage = harmonize_usage(us... | python | def keybundle_from_local_file(filename, typ, usage):
"""
Create a KeyBundle based on the content in a local file
:param filename: Name of the file
:param typ: Type of content
:param usage: What the key should be used for
:return: The created KeyBundle
"""
usage = harmonize_usage(us... | Create a KeyBundle based on the content in a local file
:param filename: Name of the file
:param typ: Type of content
:param usage: What the key should be used for
:return: The created KeyBundle | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L573-L591 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | dump_jwks | def dump_jwks(kbl, target, private=False):
"""
Write a JWK to a file. Will ignore symmetric keys !!
:param kbl: List of KeyBundles
:param target: Name of the file to which everything should be written
:param private: Should also the private parts be exported
"""
keys = []
for kb in kbl... | python | def dump_jwks(kbl, target, private=False):
"""
Write a JWK to a file. Will ignore symmetric keys !!
:param kbl: List of KeyBundles
:param target: Name of the file to which everything should be written
:param private: Should also the private parts be exported
"""
keys = []
for kb in kbl... | Write a JWK to a file. Will ignore symmetric keys !!
:param kbl: List of KeyBundles
:param target: Name of the file to which everything should be written
:param private: Should also the private parts be exported | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L594-L618 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | build_key_bundle | def build_key_bundle(key_conf, kid_template=""):
"""
Builds a :py:class:`oidcmsg.key_bundle.KeyBundle` instance based on a key
specification.
An example of such a specification::
keys = [
{"type": "RSA", "key": "cp_keys/key.pem", "use": ["enc", "sig"]},
{"type": "EC", "... | python | def build_key_bundle(key_conf, kid_template=""):
"""
Builds a :py:class:`oidcmsg.key_bundle.KeyBundle` instance based on a key
specification.
An example of such a specification::
keys = [
{"type": "RSA", "key": "cp_keys/key.pem", "use": ["enc", "sig"]},
{"type": "EC", "... | Builds a :py:class:`oidcmsg.key_bundle.KeyBundle` instance based on a key
specification.
An example of such a specification::
keys = [
{"type": "RSA", "key": "cp_keys/key.pem", "use": ["enc", "sig"]},
{"type": "EC", "crv": "P-256", "use": ["sig"], "kid": "ec.1"},
{"... | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L621-L698 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | sort_func | def sort_func(kd1, kd2):
"""
Compares 2 key descriptions
:param kd1: First key description
:param kd2: Second key description
:return: -1,0,1 depending on whether kd1 le,eq or gt then kd2
"""
_l = _cmp(kd1['type'], kd2['type'])
if _l:
return _l
if kd1['type'] == 'EC':
... | python | def sort_func(kd1, kd2):
"""
Compares 2 key descriptions
:param kd1: First key description
:param kd2: Second key description
:return: -1,0,1 depending on whether kd1 le,eq or gt then kd2
"""
_l = _cmp(kd1['type'], kd2['type'])
if _l:
return _l
if kd1['type'] == 'EC':
... | Compares 2 key descriptions
:param kd1: First key description
:param kd2: Second key description
:return: -1,0,1 depending on whether kd1 le,eq or gt then kd2 | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L717-L758 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | order_key_defs | def order_key_defs(key_def):
"""
Sort a set of key definitions. A key definition that defines more then
one usage type are splitted into as many definitions as the number of
usage types specified. One key definition per usage type.
:param key_def: A set of key definitions
:return: The set of de... | python | def order_key_defs(key_def):
"""
Sort a set of key definitions. A key definition that defines more then
one usage type are splitted into as many definitions as the number of
usage types specified. One key definition per usage type.
:param key_def: A set of key definitions
:return: The set of de... | Sort a set of key definitions. A key definition that defines more then
one usage type are splitted into as many definitions as the number of
usage types specified. One key definition per usage type.
:param key_def: A set of key definitions
:return: The set of definitions as a sorted list | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L761-L783 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | key_diff | def key_diff(key_bundle, key_defs):
"""
Creates a difference dictionary with keys that should added and keys that
should be deleted from a Key Bundle to get it updated to a state that
mirrors What is in the key_defs specification.
:param key_bundle: The original KeyBundle
:param key_defs: A set... | python | def key_diff(key_bundle, key_defs):
"""
Creates a difference dictionary with keys that should added and keys that
should be deleted from a Key Bundle to get it updated to a state that
mirrors What is in the key_defs specification.
:param key_bundle: The original KeyBundle
:param key_defs: A set... | Creates a difference dictionary with keys that should added and keys that
should be deleted from a Key Bundle to get it updated to a state that
mirrors What is in the key_defs specification.
:param key_bundle: The original KeyBundle
:param key_defs: A set of key definitions
:return: A dictionary wi... | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L786-L842 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | update_key_bundle | def update_key_bundle(key_bundle, diff):
"""
Apply a diff specification to a KeyBundle.
The keys that are to be added are added.
The keys that should be deleted are marked as inactive.
:param key_bundle: The original KeyBundle
:param diff: The difference specification
:return: An updated ke... | python | def update_key_bundle(key_bundle, diff):
"""
Apply a diff specification to a KeyBundle.
The keys that are to be added are added.
The keys that should be deleted are marked as inactive.
:param key_bundle: The original KeyBundle
:param diff: The difference specification
:return: An updated ke... | Apply a diff specification to a KeyBundle.
The keys that are to be added are added.
The keys that should be deleted are marked as inactive.
:param key_bundle: The original KeyBundle
:param diff: The difference specification
:return: An updated key_bundle | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L845-L869 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | key_rollover | def key_rollover(kb):
"""
A nifty function that lets you do a key rollover that encompasses creating
a completely new set of keys. One new per every old one. With the same
specifications as the old one.
All the old ones are marked as inactive.
:param kb:
:return:
"""
key_spec = []
... | python | def key_rollover(kb):
"""
A nifty function that lets you do a key rollover that encompasses creating
a completely new set of keys. One new per every old one. With the same
specifications as the old one.
All the old ones are marked as inactive.
:param kb:
:return:
"""
key_spec = []
... | A nifty function that lets you do a key rollover that encompasses creating
a completely new set of keys. One new per every old one. With the same
specifications as the old one.
All the old ones are marked as inactive.
:param kb:
:return: | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L872-L895 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | KeyBundle.do_keys | def do_keys(self, keys):
"""
Go from JWK description to binary keys
:param keys:
:return:
"""
for inst in keys:
typ = inst["kty"]
try:
_usage = harmonize_usage(inst['use'])
except KeyError:
_usage = ['']... | python | def do_keys(self, keys):
"""
Go from JWK description to binary keys
:param keys:
:return:
"""
for inst in keys:
typ = inst["kty"]
try:
_usage = harmonize_usage(inst['use'])
except KeyError:
_usage = ['']... | Go from JWK description to binary keys
:param keys:
:return: | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L185-L217 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | KeyBundle.do_local_jwk | def do_local_jwk(self, filename):
"""
Load a JWKS from a local file
:param filename:
"""
_info = json.loads(open(filename).read())
if 'keys' in _info:
self.do_keys(_info["keys"])
else:
self.do_keys([_info])
self.last_upd... | python | def do_local_jwk(self, filename):
"""
Load a JWKS from a local file
:param filename:
"""
_info = json.loads(open(filename).read())
if 'keys' in _info:
self.do_keys(_info["keys"])
else:
self.do_keys([_info])
self.last_upd... | Load a JWKS from a local file
:param filename: | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L219-L231 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | KeyBundle.do_local_der | def do_local_der(self, filename, keytype, keyusage=None, kid=''):
"""
Load a DER encoded file amd create a key from it.
:param filename:
:param keytype: Presently only 'rsa' supported
:param keyusage: encryption ('enc') or signing ('sig') or both
"""
_b... | python | def do_local_der(self, filename, keytype, keyusage=None, kid=''):
"""
Load a DER encoded file amd create a key from it.
:param filename:
:param keytype: Presently only 'rsa' supported
:param keyusage: encryption ('enc') or signing ('sig') or both
"""
_b... | Load a DER encoded file amd create a key from it.
:param filename:
:param keytype: Presently only 'rsa' supported
:param keyusage: encryption ('enc') or signing ('sig') or both | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L233-L258 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | KeyBundle.do_remote | def do_remote(self):
"""
Load a JWKS from a webpage
:return: True or False if load was successful
"""
if self.verify_ssl:
args = {"verify": self.verify_ssl}
else:
args = {}
try:
logging.debug('KeyBundle fetch keys from... | python | def do_remote(self):
"""
Load a JWKS from a webpage
:return: True or False if load was successful
"""
if self.verify_ssl:
args = {"verify": self.verify_ssl}
else:
args = {}
try:
logging.debug('KeyBundle fetch keys from... | Load a JWKS from a webpage
:return: True or False if load was successful | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L260-L298 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | KeyBundle._parse_remote_response | def _parse_remote_response(self, response):
"""
Parse JWKS from the HTTP response.
Should be overriden by subclasses for adding support of e.g. signed
JWKS.
:param response: HTTP response from the 'jwks_uri' endpoint
:return: response parsed as JSON
"""
#... | python | def _parse_remote_response(self, response):
"""
Parse JWKS from the HTTP response.
Should be overriden by subclasses for adding support of e.g. signed
JWKS.
:param response: HTTP response from the 'jwks_uri' endpoint
:return: response parsed as JSON
"""
#... | Parse JWKS from the HTTP response.
Should be overriden by subclasses for adding support of e.g. signed
JWKS.
:param response: HTTP response from the 'jwks_uri' endpoint
:return: response parsed as JSON | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L300-L321 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | KeyBundle.update | def update(self):
"""
Reload the keys if necessary
This is a forced update, will happen even if cache time has not elapsed.
Replaced keys will be marked as inactive and not removed.
"""
res = True # An update was successful
if self.source:
_k... | python | def update(self):
"""
Reload the keys if necessary
This is a forced update, will happen even if cache time has not elapsed.
Replaced keys will be marked as inactive and not removed.
"""
res = True # An update was successful
if self.source:
_k... | Reload the keys if necessary
This is a forced update, will happen even if cache time has not elapsed.
Replaced keys will be marked as inactive and not removed. | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L335-L370 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | KeyBundle.get | def get(self, typ="", only_active=True):
"""
Return a list of keys. Either all keys or only keys of a specific type
:param typ: Type of key (rsa, ec, oct, ..)
:return: If typ is undefined all the keys as a dictionary
otherwise the appropriate keys in a list
"... | python | def get(self, typ="", only_active=True):
"""
Return a list of keys. Either all keys or only keys of a specific type
:param typ: Type of key (rsa, ec, oct, ..)
:return: If typ is undefined all the keys as a dictionary
otherwise the appropriate keys in a list
"... | Return a list of keys. Either all keys or only keys of a specific type
:param typ: Type of key (rsa, ec, oct, ..)
:return: If typ is undefined all the keys as a dictionary
otherwise the appropriate keys in a list | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L372-L391 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | KeyBundle.remove_keys_by_type | def remove_keys_by_type(self, typ):
"""
Remove keys that are of a specific type.
:param typ: Type of key (rsa, ec, oct, ..)
"""
_typs = [typ.lower(), typ.upper()]
self._keys = [k for k in self._keys if not k.kty in _typs] | python | def remove_keys_by_type(self, typ):
"""
Remove keys that are of a specific type.
:param typ: Type of key (rsa, ec, oct, ..)
"""
_typs = [typ.lower(), typ.upper()]
self._keys = [k for k in self._keys if not k.kty in _typs] | Remove keys that are of a specific type.
:param typ: Type of key (rsa, ec, oct, ..) | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L415-L422 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | KeyBundle.jwks | def jwks(self, private=False):
"""
Create a JWKS as a JSON document
:param private: Whether private key information should be included.
:return: A JWKS JSON representation of the keys in this bundle
"""
self._uptodate()
keys = list()
for k in self... | python | def jwks(self, private=False):
"""
Create a JWKS as a JSON document
:param private: Whether private key information should be included.
:return: A JWKS JSON representation of the keys in this bundle
"""
self._uptodate()
keys = list()
for k in self... | Create a JWKS as a JSON document
:param private: Whether private key information should be included.
:return: A JWKS JSON representation of the keys in this bundle | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L427-L444 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | KeyBundle.get_key_with_kid | def get_key_with_kid(self, kid):
"""
Return the key that has a specific key ID (kid)
:param kid: The Key ID
:return: The key or None
"""
for key in self._keys:
if key.kid == kid:
return key
# Try updating since there might ha... | python | def get_key_with_kid(self, kid):
"""
Return the key that has a specific key ID (kid)
:param kid: The Key ID
:return: The key or None
"""
for key in self._keys:
if key.kid == kid:
return key
# Try updating since there might ha... | Return the key that has a specific key ID (kid)
:param kid: The Key ID
:return: The key or None | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L476-L494 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | KeyBundle.kids | def kids(self):
"""
Return a list of key IDs. Note that this list may be shorter then
the list of keys. The reason might be that there are some keys with
no key ID.
:return: A list of all the key IDs that exists in this bundle
"""
self._uptodate()
... | python | def kids(self):
"""
Return a list of key IDs. Note that this list may be shorter then
the list of keys. The reason might be that there are some keys with
no key ID.
:return: A list of all the key IDs that exists in this bundle
"""
self._uptodate()
... | Return a list of key IDs. Note that this list may be shorter then
the list of keys. The reason might be that there are some keys with
no key ID.
:return: A list of all the key IDs that exists in this bundle | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L496-L505 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | KeyBundle.mark_as_inactive | def mark_as_inactive(self, kid):
"""
Mark a specific key as inactive based on the keys KeyID
:param kid: The Key Identifier
"""
k = self.get_key_with_kid(kid)
k.inactive_since = time.time() | python | def mark_as_inactive(self, kid):
"""
Mark a specific key as inactive based on the keys KeyID
:param kid: The Key Identifier
"""
k = self.get_key_with_kid(kid)
k.inactive_since = time.time() | Mark a specific key as inactive based on the keys KeyID
:param kid: The Key Identifier | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L507-L514 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | KeyBundle.remove_outdated | def remove_outdated(self, after, when=0):
"""
Remove keys that should not be available any more.
Outdated means that the key was marked as inactive at a time
that was longer ago then what is given in 'after'.
:param after: The length of time the key will remain in the KeyBundle
... | python | def remove_outdated(self, after, when=0):
"""
Remove keys that should not be available any more.
Outdated means that the key was marked as inactive at a time
that was longer ago then what is given in 'after'.
:param after: The length of time the key will remain in the KeyBundle
... | Remove keys that should not be available any more.
Outdated means that the key was marked as inactive at a time
that was longer ago then what is given in 'after'.
:param after: The length of time the key will remain in the KeyBundle
before it should be removed.
:param when: ... | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L516-L544 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_bundle.py | KeyBundle.copy | def copy(self):
"""
Make deep copy of this KeyBundle
:return: The copy
"""
kb = KeyBundle()
kb._keys = self._keys[:]
kb.cache_time = self.cache_time
kb.verify_ssl = self.verify_ssl
if self.source:
kb.source = self.source
k... | python | def copy(self):
"""
Make deep copy of this KeyBundle
:return: The copy
"""
kb = KeyBundle()
kb._keys = self._keys[:]
kb.cache_time = self.cache_time
kb.verify_ssl = self.verify_ssl
if self.source:
kb.source = self.source
k... | Make deep copy of this KeyBundle
:return: The copy | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_bundle.py#L549-L567 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/simple_jwt.py | SimpleJWT.unpack | def unpack(self, token, **kwargs):
"""
Unpacks a JWT into its parts and base64 decodes the parts
individually
:param token: The JWT
:param kwargs: A possible empty set of claims to verify the header
against.
"""
if isinstance(token, str):
... | python | def unpack(self, token, **kwargs):
"""
Unpacks a JWT into its parts and base64 decodes the parts
individually
:param token: The JWT
:param kwargs: A possible empty set of claims to verify the header
against.
"""
if isinstance(token, str):
... | Unpacks a JWT into its parts and base64 decodes the parts
individually
:param token: The JWT
:param kwargs: A possible empty set of claims to verify the header
against. | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/simple_jwt.py#L27-L60 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/simple_jwt.py | SimpleJWT.pack | def pack(self, parts=None, headers=None):
"""
Packs components into a JWT
:param parts: List of parts to pack
:param headers: The JWT headers
:return:
"""
if not headers:
if self.headers:
headers = self.headers
else:
... | python | def pack(self, parts=None, headers=None):
"""
Packs components into a JWT
:param parts: List of parts to pack
:param headers: The JWT headers
:return:
"""
if not headers:
if self.headers:
headers = self.headers
else:
... | Packs components into a JWT
:param parts: List of parts to pack
:param headers: The JWT headers
:return: | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/simple_jwt.py#L62-L85 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/simple_jwt.py | SimpleJWT.payload | def payload(self):
"""
Picks out the payload from the different parts of the signed/encrypted
JSON Web Token. If the content type is said to be 'jwt' deserialize the
payload into a Python object otherwise return as-is.
:return: The payload
"""
_msg = as_unicode(s... | python | def payload(self):
"""
Picks out the payload from the different parts of the signed/encrypted
JSON Web Token. If the content type is said to be 'jwt' deserialize the
payload into a Python object otherwise return as-is.
:return: The payload
"""
_msg = as_unicode(s... | Picks out the payload from the different parts of the signed/encrypted
JSON Web Token. If the content type is said to be 'jwt' deserialize the
payload into a Python object otherwise return as-is.
:return: The payload | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/simple_jwt.py#L87-L106 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/simple_jwt.py | SimpleJWT.verify_header | def verify_header(self, key, val):
"""
Check that a particular header claim is present and has a specific value
:param key: The claim
:param val: The value of the claim
:raises: KeyError if the claim is not present in the header
:return: True if the claim exists in the h... | python | def verify_header(self, key, val):
"""
Check that a particular header claim is present and has a specific value
:param key: The claim
:param val: The value of the claim
:raises: KeyError if the claim is not present in the header
:return: True if the claim exists in the h... | Check that a particular header claim is present and has a specific value
:param key: The claim
:param val: The value of the claim
:raises: KeyError if the claim is not present in the header
:return: True if the claim exists in the header and has the prescribed
value | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/simple_jwt.py#L108-L128 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/simple_jwt.py | SimpleJWT.verify_headers | def verify_headers(self, check_presence=True, **kwargs):
"""
Check that a set of particular header claim are present and has
specific values
:param kwargs: The claim/value sets as a dictionary
:return: True if the claim that appears in the header has the
prescribed v... | python | def verify_headers(self, check_presence=True, **kwargs):
"""
Check that a set of particular header claim are present and has
specific values
:param kwargs: The claim/value sets as a dictionary
:return: True if the claim that appears in the header has the
prescribed v... | Check that a set of particular header claim are present and has
specific values
:param kwargs: The claim/value sets as a dictionary
:return: True if the claim that appears in the header has the
prescribed values. If a claim is not present in the header and
check_presence... | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/simple_jwt.py#L130-L151 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jws/hmac.py | HMACSigner.sign | def sign(self, msg, key):
"""
Create a signature over a message as defined in RFC7515 using a
symmetric key
:param msg: The message
:param key: The key
:return: A signature
"""
h = hmac.HMAC(key, self.algorithm(), default_backend())
h.update(msg)
... | python | def sign(self, msg, key):
"""
Create a signature over a message as defined in RFC7515 using a
symmetric key
:param msg: The message
:param key: The key
:return: A signature
"""
h = hmac.HMAC(key, self.algorithm(), default_backend())
h.update(msg)
... | Create a signature over a message as defined in RFC7515 using a
symmetric key
:param msg: The message
:param key: The key
:return: A signature | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jws/hmac.py#L23-L34 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jws/hmac.py | HMACSigner.verify | def verify(self, msg, sig, key):
"""
Verifies whether sig is the correct message authentication code of data.
:param msg: The data
:param sig: The message authentication code to verify against data.
:param key: The key to use
:return: Returns true if the mac was valid ot... | python | def verify(self, msg, sig, key):
"""
Verifies whether sig is the correct message authentication code of data.
:param msg: The data
:param sig: The message authentication code to verify against data.
:param key: The key to use
:return: Returns true if the mac was valid ot... | Verifies whether sig is the correct message authentication code of data.
:param msg: The data
:param sig: The message authentication code to verify against data.
:param key: The key to use
:return: Returns true if the mac was valid otherwise it will raise an
Exception. | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jws/hmac.py#L36-L52 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/tools/keygen.py | main | def main():
""" Main function"""
parser = argparse.ArgumentParser(description='JSON Web Key (JWK) Generator')
parser.add_argument('--kty',
dest='kty',
metavar='type',
help='Key type',
required=True)
parser.a... | python | def main():
""" Main function"""
parser = argparse.ArgumentParser(description='JSON Web Key (JWK) Generator')
parser.add_argument('--kty',
dest='kty',
metavar='type',
help='Key type',
required=True)
parser.a... | Main function | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/tools/keygen.py#L22-L74 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/jwk.py | ensure_ec_params | def ensure_ec_params(jwk_dict, private):
"""Ensure all required EC parameters are present in dictionary"""
provided = frozenset(jwk_dict.keys())
if private is not None and private:
required = EC_PUBLIC_REQUIRED | EC_PRIVATE_REQUIRED
else:
required = EC_PUBLIC_REQUIRED
return ensure_p... | python | def ensure_ec_params(jwk_dict, private):
"""Ensure all required EC parameters are present in dictionary"""
provided = frozenset(jwk_dict.keys())
if private is not None and private:
required = EC_PUBLIC_REQUIRED | EC_PRIVATE_REQUIRED
else:
required = EC_PUBLIC_REQUIRED
return ensure_p... | Ensure all required EC parameters are present in dictionary | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/jwk.py#L35-L42 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/jwk.py | ensure_rsa_params | def ensure_rsa_params(jwk_dict, private):
"""Ensure all required RSA parameters are present in dictionary"""
provided = frozenset(jwk_dict.keys())
if private is not None and private:
required = RSA_PUBLIC_REQUIRED | RSA_PRIVATE_REQUIRED
else:
required = RSA_PUBLIC_REQUIRED
return ens... | python | def ensure_rsa_params(jwk_dict, private):
"""Ensure all required RSA parameters are present in dictionary"""
provided = frozenset(jwk_dict.keys())
if private is not None and private:
required = RSA_PUBLIC_REQUIRED | RSA_PRIVATE_REQUIRED
else:
required = RSA_PUBLIC_REQUIRED
return ens... | Ensure all required RSA parameters are present in dictionary | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/jwk.py#L45-L52 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/jwk.py | ensure_params | def ensure_params(kty, provided, required):
"""Ensure all required parameters are present in dictionary"""
if not required <= provided:
missing = required - provided
raise MissingValue('Missing properties for kty={}, {}'.format(kty, str(list(missing)))) | python | def ensure_params(kty, provided, required):
"""Ensure all required parameters are present in dictionary"""
if not required <= provided:
missing = required - provided
raise MissingValue('Missing properties for kty={}, {}'.format(kty, str(list(missing)))) | Ensure all required parameters are present in dictionary | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/jwk.py#L55-L59 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/jwk.py | key_from_jwk_dict | def key_from_jwk_dict(jwk_dict, private=None):
"""Load JWK from dictionary
:param jwk_dict: Dictionary representing a JWK
"""
# uncouple from the original item
_jwk_dict = copy.copy(jwk_dict)
if 'kty' not in _jwk_dict:
raise MissingValue('kty missing')
if _jwk_dict['kty'] == 'EC'... | python | def key_from_jwk_dict(jwk_dict, private=None):
"""Load JWK from dictionary
:param jwk_dict: Dictionary representing a JWK
"""
# uncouple from the original item
_jwk_dict = copy.copy(jwk_dict)
if 'kty' not in _jwk_dict:
raise MissingValue('kty missing')
if _jwk_dict['kty'] == 'EC'... | Load JWK from dictionary
:param jwk_dict: Dictionary representing a JWK | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/jwk.py#L62-L153 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/jwk.py | jwk_wrap | def jwk_wrap(key, use="", kid=""):
"""
Instantiate a Key instance with the given key
:param key: The keys to wrap
:param use: What the key are expected to be use for
:param kid: A key id
:return: The Key instance
"""
if isinstance(key, rsa.RSAPublicKey) or isinstance(key, rsa.RSAPrivate... | python | def jwk_wrap(key, use="", kid=""):
"""
Instantiate a Key instance with the given key
:param key: The keys to wrap
:param use: What the key are expected to be use for
:param kid: A key id
:return: The Key instance
"""
if isinstance(key, rsa.RSAPublicKey) or isinstance(key, rsa.RSAPrivate... | Instantiate a Key instance with the given key
:param key: The keys to wrap
:param use: What the key are expected to be use for
:param kid: A key id
:return: The Key instance | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/jwk.py#L156-L175 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_jar.py | build_keyjar | def build_keyjar(key_conf, kid_template="", keyjar=None, owner=''):
"""
Builds a :py:class:`oidcmsg.key_jar.KeyJar` instance or adds keys to
an existing KeyJar based on a key specification.
An example of such a specification::
keys = [
{"type": "RSA", "key": "cp_keys/key.pem", ... | python | def build_keyjar(key_conf, kid_template="", keyjar=None, owner=''):
"""
Builds a :py:class:`oidcmsg.key_jar.KeyJar` instance or adds keys to
an existing KeyJar based on a key specification.
An example of such a specification::
keys = [
{"type": "RSA", "key": "cp_keys/key.pem", ... | Builds a :py:class:`oidcmsg.key_jar.KeyJar` instance or adds keys to
an existing KeyJar based on a key specification.
An example of such a specification::
keys = [
{"type": "RSA", "key": "cp_keys/key.pem", "use": ["enc", "sig"]},
{"type": "EC", "crv": "P-256", "use": ["sig"... | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_jar.py#L647-L695 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_jar.py | update_keyjar | def update_keyjar(keyjar):
"""
Go through the whole key jar, key bundle by key bundle and update them one
by one.
:param keyjar: The key jar to update
"""
for iss, kbl in keyjar.items():
for kb in kbl:
kb.update() | python | def update_keyjar(keyjar):
"""
Go through the whole key jar, key bundle by key bundle and update them one
by one.
:param keyjar: The key jar to update
"""
for iss, kbl in keyjar.items():
for kb in kbl:
kb.update() | Go through the whole key jar, key bundle by key bundle and update them one
by one.
:param keyjar: The key jar to update | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_jar.py#L698-L707 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_jar.py | key_summary | def key_summary(keyjar, issuer):
"""
Return a text representation of the keyjar.
:param keyjar: A :py:class:`oidcmsg.key_jar.KeyJar` instance
:param issuer: Which key owner that we are looking at
:return: A text representation of the keys
"""
try:
kbl = keyjar[issuer]
except Key... | python | def key_summary(keyjar, issuer):
"""
Return a text representation of the keyjar.
:param keyjar: A :py:class:`oidcmsg.key_jar.KeyJar` instance
:param issuer: Which key owner that we are looking at
:return: A text representation of the keys
"""
try:
kbl = keyjar[issuer]
except Key... | Return a text representation of the keyjar.
:param keyjar: A :py:class:`oidcmsg.key_jar.KeyJar` instance
:param issuer: Which key owner that we are looking at
:return: A text representation of the keys | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_jar.py#L710-L732 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_jar.py | init_key_jar | def init_key_jar(public_path='', private_path='', key_defs='', owner='',
read_only=True):
"""
A number of cases here:
1. A private path is given
a. The file exists and a JWKS is found there.
From that JWKS a KeyJar instance is built.
b.
If the private pat... | python | def init_key_jar(public_path='', private_path='', key_defs='', owner='',
read_only=True):
"""
A number of cases here:
1. A private path is given
a. The file exists and a JWKS is found there.
From that JWKS a KeyJar instance is built.
b.
If the private pat... | A number of cases here:
1. A private path is given
a. The file exists and a JWKS is found there.
From that JWKS a KeyJar instance is built.
b.
If the private path file doesn't exit the key definitions are
used to build a KeyJar instance. A JWKS with the private keys are... | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_jar.py#L735-L848 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_jar.py | KeyJar.add_url | def add_url(self, issuer, url, **kwargs):
"""
Add a set of keys by url. This method will create a
:py:class:`oidcmsg.key_bundle.KeyBundle` instance with the
url as source specification. If no file format is given it's assumed
that what's on the other side is a JWKS.
... | python | def add_url(self, issuer, url, **kwargs):
"""
Add a set of keys by url. This method will create a
:py:class:`oidcmsg.key_bundle.KeyBundle` instance with the
url as source specification. If no file format is given it's assumed
that what's on the other side is a JWKS.
... | Add a set of keys by url. This method will create a
:py:class:`oidcmsg.key_bundle.KeyBundle` instance with the
url as source specification. If no file format is given it's assumed
that what's on the other side is a JWKS.
:param issuer: Who issued the keys
:param url: Wh... | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_jar.py#L59-L85 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_jar.py | KeyJar.add_symmetric | def add_symmetric(self, issuer, key, usage=None):
"""
Add a symmetric key. This is done by wrapping it in a key bundle
cloak since KeyJar does not handle keys directly but only through
key bundles.
:param issuer: Owner of the key
:param key: The key
:pa... | python | def add_symmetric(self, issuer, key, usage=None):
"""
Add a symmetric key. This is done by wrapping it in a key bundle
cloak since KeyJar does not handle keys directly but only through
key bundles.
:param issuer: Owner of the key
:param key: The key
:pa... | Add a symmetric key. This is done by wrapping it in a key bundle
cloak since KeyJar does not handle keys directly but only through
key bundles.
:param issuer: Owner of the key
:param key: The key
:param usage: What the key can be used for signing/signature
... | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_jar.py#L87-L109 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_jar.py | KeyJar.add_kb | def add_kb(self, issuer, kb):
"""
Add a key bundle and bind it to an identifier
:param issuer: Owner of the keys in the key bundle
:param kb: A :py:class:`oidcmsg.key_bundle.KeyBundle` instance
"""
try:
self.issuer_keys[issuer].append(kb)
exce... | python | def add_kb(self, issuer, kb):
"""
Add a key bundle and bind it to an identifier
:param issuer: Owner of the keys in the key bundle
:param kb: A :py:class:`oidcmsg.key_bundle.KeyBundle` instance
"""
try:
self.issuer_keys[issuer].append(kb)
exce... | Add a key bundle and bind it to an identifier
:param issuer: Owner of the keys in the key bundle
:param kb: A :py:class:`oidcmsg.key_bundle.KeyBundle` instance | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_jar.py#L111-L121 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_jar.py | KeyJar.get | def get(self, key_use, key_type="", owner="", kid=None, **kwargs):
"""
Get all keys that matches a set of search criteria
:param key_use: A key useful for this usage (enc, dec, sig, ver)
:param key_type: Type of key (rsa, ec, oct, ..)
:param owner: Who is the owner of the keys, ... | python | def get(self, key_use, key_type="", owner="", kid=None, **kwargs):
"""
Get all keys that matches a set of search criteria
:param key_use: A key useful for this usage (enc, dec, sig, ver)
:param key_type: Type of key (rsa, ec, oct, ..)
:param owner: Who is the owner of the keys, ... | Get all keys that matches a set of search criteria
:param key_use: A key useful for this usage (enc, dec, sig, ver)
:param key_type: Type of key (rsa, ec, oct, ..)
:param owner: Who is the owner of the keys, "" == me (default)
:param kid: A Key Identifier
:return: A possibly emp... | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_jar.py#L148-L230 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_jar.py | KeyJar.get_signing_key | def get_signing_key(self, key_type="", owner="", kid=None, **kwargs):
"""
Shortcut to use for signing keys only.
:param key_type: Type of key (rsa, ec, oct, ..)
:param owner: Who is the owner of the keys, "" == me (default)
:param kid: A Key Identifier
:param kwargs: Ext... | python | def get_signing_key(self, key_type="", owner="", kid=None, **kwargs):
"""
Shortcut to use for signing keys only.
:param key_type: Type of key (rsa, ec, oct, ..)
:param owner: Who is the owner of the keys, "" == me (default)
:param kid: A Key Identifier
:param kwargs: Ext... | Shortcut to use for signing keys only.
:param key_type: Type of key (rsa, ec, oct, ..)
:param owner: Who is the owner of the keys, "" == me (default)
:param kid: A Key Identifier
:param kwargs: Extra key word arguments
:return: A possibly empty list of keys | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_jar.py#L232-L242 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_jar.py | KeyJar.keys_by_alg_and_usage | def keys_by_alg_and_usage(self, issuer, alg, usage):
"""
Find all keys that can be used for a specific crypto algorithm and
usage by key owner.
:param issuer: Key owner
:param alg: a crypto algorithm
:param usage: What the key should be used for
:return: A possib... | python | def keys_by_alg_and_usage(self, issuer, alg, usage):
"""
Find all keys that can be used for a specific crypto algorithm and
usage by key owner.
:param issuer: Key owner
:param alg: a crypto algorithm
:param usage: What the key should be used for
:return: A possib... | Find all keys that can be used for a specific crypto algorithm and
usage by key owner.
:param issuer: Key owner
:param alg: a crypto algorithm
:param usage: What the key should be used for
:return: A possibly empty list of keys | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_jar.py#L253-L268 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_jar.py | KeyJar.get_issuer_keys | def get_issuer_keys(self, issuer):
"""
Get all the keys that belong to an entity.
:param issuer: The entity ID
:return: A possibly empty list of keys
"""
res = []
for kbl in self.issuer_keys[issuer]:
res.extend(kbl.keys())
return res | python | def get_issuer_keys(self, issuer):
"""
Get all the keys that belong to an entity.
:param issuer: The entity ID
:return: A possibly empty list of keys
"""
res = []
for kbl in self.issuer_keys[issuer]:
res.extend(kbl.keys())
return res | Get all the keys that belong to an entity.
:param issuer: The entity ID
:return: A possibly empty list of keys | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_jar.py#L270-L280 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_jar.py | KeyJar.match_owner | def match_owner(self, url):
"""
Finds the first entity, with keys in the key jar, with an
identifier that matches the given URL. The match is a leading
substring match.
:param url: A URL
:return: An issue entity ID that exists in the Key jar
"""
for owner... | python | def match_owner(self, url):
"""
Finds the first entity, with keys in the key jar, with an
identifier that matches the given URL. The match is a leading
substring match.
:param url: A URL
:return: An issue entity ID that exists in the Key jar
"""
for owner... | Finds the first entity, with keys in the key jar, with an
identifier that matches the given URL. The match is a leading
substring match.
:param url: A URL
:return: An issue entity ID that exists in the Key jar | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_jar.py#L311-L324 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_jar.py | KeyJar.load_keys | def load_keys(self, issuer, jwks_uri='', jwks=None, replace=False):
"""
Fetch keys from another server
:param jwks_uri: A URL pointing to a site that will return a JWKS
:param jwks: A dictionary representation of a JWKS
:param issuer: The provider URL
:param replace: If ... | python | def load_keys(self, issuer, jwks_uri='', jwks=None, replace=False):
"""
Fetch keys from another server
:param jwks_uri: A URL pointing to a site that will return a JWKS
:param jwks: A dictionary representation of a JWKS
:param issuer: The provider URL
:param replace: If ... | Fetch keys from another server
:param jwks_uri: A URL pointing to a site that will return a JWKS
:param jwks: A dictionary representation of a JWKS
:param issuer: The provider URL
:param replace: If all previously gathered keys from this provider
should be replace.
:... | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_jar.py#L335-L357 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_jar.py | KeyJar.find | def find(self, source, issuer):
"""
Find a key bundle based on the source of the keys
:param source: A source url
:param issuer: The issuer of keys
:return: A :py:class:`oidcmsg.key_bundle.KeyBundle` instance or None
"""
try:
for kb in self.issuer_key... | python | def find(self, source, issuer):
"""
Find a key bundle based on the source of the keys
:param source: A source url
:param issuer: The issuer of keys
:return: A :py:class:`oidcmsg.key_bundle.KeyBundle` instance or None
"""
try:
for kb in self.issuer_key... | Find a key bundle based on the source of the keys
:param source: A source url
:param issuer: The issuer of keys
:return: A :py:class:`oidcmsg.key_bundle.KeyBundle` instance or None | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_jar.py#L359-L374 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_jar.py | KeyJar.export_jwks | def export_jwks(self, private=False, issuer=""):
"""
Produces a dictionary that later can be easily mapped into a
JSON string representing a JWKS.
:param private: Whether it should be the private keys or the public
:param issuer: The entity ID.
:return: A dictio... | python | def export_jwks(self, private=False, issuer=""):
"""
Produces a dictionary that later can be easily mapped into a
JSON string representing a JWKS.
:param private: Whether it should be the private keys or the public
:param issuer: The entity ID.
:return: A dictio... | Produces a dictionary that later can be easily mapped into a
JSON string representing a JWKS.
:param private: Whether it should be the private keys or the public
:param issuer: The entity ID.
:return: A dictionary with one key: 'keys' | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_jar.py#L376-L389 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_jar.py | KeyJar.export_jwks_as_json | def export_jwks_as_json(self, private=False, issuer=""):
"""
Export a JWKS as a JSON document.
:param private: Whether it should be the private keys or the public
:param issuer: The entity ID.
:return: A JSON representation of a JWKS
"""
return json.dumps(self.ex... | python | def export_jwks_as_json(self, private=False, issuer=""):
"""
Export a JWKS as a JSON document.
:param private: Whether it should be the private keys or the public
:param issuer: The entity ID.
:return: A JSON representation of a JWKS
"""
return json.dumps(self.ex... | Export a JWKS as a JSON document.
:param private: Whether it should be the private keys or the public
:param issuer: The entity ID.
:return: A JSON representation of a JWKS | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_jar.py#L391-L399 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_jar.py | KeyJar.import_jwks | def import_jwks(self, jwks, issuer):
"""
Imports all the keys that are represented in a JWKS
:param jwks: Dictionary representation of a JWKS
:param issuer: Who 'owns' the JWKS
"""
try:
_keys = jwks["keys"]
except KeyError:
raise ValueErro... | python | def import_jwks(self, jwks, issuer):
"""
Imports all the keys that are represented in a JWKS
:param jwks: Dictionary representation of a JWKS
:param issuer: Who 'owns' the JWKS
"""
try:
_keys = jwks["keys"]
except KeyError:
raise ValueErro... | Imports all the keys that are represented in a JWKS
:param jwks: Dictionary representation of a JWKS
:param issuer: Who 'owns' the JWKS | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_jar.py#L401-L418 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_jar.py | KeyJar.import_jwks_as_json | def import_jwks_as_json(self, jwks, issuer):
"""
Imports all the keys that are represented in a JWKS expressed as a
JSON object
:param jwks: JSON representation of a JWKS
:param issuer: Who 'owns' the JWKS
"""
return self.import_jwks(json.loads(jwks), issuer) | python | def import_jwks_as_json(self, jwks, issuer):
"""
Imports all the keys that are represented in a JWKS expressed as a
JSON object
:param jwks: JSON representation of a JWKS
:param issuer: Who 'owns' the JWKS
"""
return self.import_jwks(json.loads(jwks), issuer) | Imports all the keys that are represented in a JWKS expressed as a
JSON object
:param jwks: JSON representation of a JWKS
:param issuer: Who 'owns' the JWKS | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_jar.py#L420-L428 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_jar.py | KeyJar.remove_outdated | def remove_outdated(self, when=0):
"""
Goes through the complete list of issuers and for each of them removes
outdated keys.
Outdated keys are keys that has been marked as inactive at a time that
is longer ago then some set number of seconds (when). If when=0 the
the base... | python | def remove_outdated(self, when=0):
"""
Goes through the complete list of issuers and for each of them removes
outdated keys.
Outdated keys are keys that has been marked as inactive at a time that
is longer ago then some set number of seconds (when). If when=0 the
the base... | Goes through the complete list of issuers and for each of them removes
outdated keys.
Outdated keys are keys that has been marked as inactive at a time that
is longer ago then some set number of seconds (when). If when=0 the
the base time is set to now.
The number of seconds a ca... | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_jar.py#L454-L475 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_jar.py | KeyJar.get_jwt_decrypt_keys | def get_jwt_decrypt_keys(self, jwt, **kwargs):
"""
Get decryption keys from this keyjar based on information carried
in a JWE. These keys should be usable to decrypt an encrypted JWT.
:param jwt: A cryptojwt.jwt.JWT instance
:param kwargs: Other key word arguments
:retur... | python | def get_jwt_decrypt_keys(self, jwt, **kwargs):
"""
Get decryption keys from this keyjar based on information carried
in a JWE. These keys should be usable to decrypt an encrypted JWT.
:param jwt: A cryptojwt.jwt.JWT instance
:param kwargs: Other key word arguments
:retur... | Get decryption keys from this keyjar based on information carried
in a JWE. These keys should be usable to decrypt an encrypted JWT.
:param jwt: A cryptojwt.jwt.JWT instance
:param kwargs: Other key word arguments
:return: list of usable keys | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_jar.py#L519-L563 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_jar.py | KeyJar.get_jwt_verify_keys | def get_jwt_verify_keys(self, jwt, **kwargs):
"""
Get keys from this key jar based on information in a JWS. These keys
should be usable to verify the signed JWT.
:param jwt: A cryptojwt.jwt.JWT instance
:param kwargs: Other key word arguments
:return: list of usable keys... | python | def get_jwt_verify_keys(self, jwt, **kwargs):
"""
Get keys from this key jar based on information in a JWS. These keys
should be usable to verify the signed JWT.
:param jwt: A cryptojwt.jwt.JWT instance
:param kwargs: Other key word arguments
:return: list of usable keys... | Get keys from this key jar based on information in a JWS. These keys
should be usable to verify the signed JWT.
:param jwt: A cryptojwt.jwt.JWT instance
:param kwargs: Other key word arguments
:return: list of usable keys | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_jar.py#L565-L628 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/key_jar.py | KeyJar.copy | def copy(self):
"""
Make deep copy of this key jar.
:return: A :py:class:`oidcmsg.key_jar.KeyJar` instance
"""
kj = KeyJar()
for issuer in self.owners():
kj[issuer] = [kb.copy() for kb in self[issuer]]
kj.verify_ssl = self.verify_ssl
return k... | python | def copy(self):
"""
Make deep copy of this key jar.
:return: A :py:class:`oidcmsg.key_jar.KeyJar` instance
"""
kj = KeyJar()
for issuer in self.owners():
kj[issuer] = [kb.copy() for kb in self[issuer]]
kj.verify_ssl = self.verify_ssl
return k... | Make deep copy of this key jar.
:return: A :py:class:`oidcmsg.key_jar.KeyJar` instance | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/key_jar.py#L630-L641 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwt.py | pick_key | def pick_key(keys, use, alg='', key_type='', kid=''):
"""
Based on given criteria pick out the keys that fulfill them from a
given set of keys.
:param keys: List of keys. These are :py:class:`cryptojwt.jwk.JWK`
instances.
:param use: What the key is going to be used for 'sig'/'enc'
:par... | python | def pick_key(keys, use, alg='', key_type='', kid=''):
"""
Based on given criteria pick out the keys that fulfill them from a
given set of keys.
:param keys: List of keys. These are :py:class:`cryptojwt.jwk.JWK`
instances.
:param use: What the key is going to be used for 'sig'/'enc'
:par... | Based on given criteria pick out the keys that fulfill them from a
given set of keys.
:param keys: List of keys. These are :py:class:`cryptojwt.jwk.JWK`
instances.
:param use: What the key is going to be used for 'sig'/'enc'
:param alg: crypto algorithm
:param key_type: Type of key 'rsa'/'e... | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwt.py#L33-L75 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwt.py | JWT.pack_init | def pack_init(self, recv, aud):
"""
Gather initial information for the payload.
:return: A dictionary with claims and values
"""
argv = {'iss': self.iss, 'iat': utc_time_sans_frac()}
if self.lifetime:
argv['exp'] = argv['iat'] + self.lifetime
_aud = ... | python | def pack_init(self, recv, aud):
"""
Gather initial information for the payload.
:return: A dictionary with claims and values
"""
argv = {'iss': self.iss, 'iat': utc_time_sans_frac()}
if self.lifetime:
argv['exp'] = argv['iat'] + self.lifetime
_aud = ... | Gather initial information for the payload.
:return: A dictionary with claims and values | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwt.py#L155-L169 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwt.py | JWT.pack_key | def pack_key(self, owner_id='', kid=''):
"""
Find a key to be used for signing the Json Web Token
:param owner_id: Owner of the keys to chose from
:param kid: Key ID
:return: One key
"""
keys = pick_key(self.my_keys(owner_id, 'sig'), 'sig', alg=self.alg,
... | python | def pack_key(self, owner_id='', kid=''):
"""
Find a key to be used for signing the Json Web Token
:param owner_id: Owner of the keys to chose from
:param kid: Key ID
:return: One key
"""
keys = pick_key(self.my_keys(owner_id, 'sig'), 'sig', alg=self.alg,
... | Find a key to be used for signing the Json Web Token
:param owner_id: Owner of the keys to chose from
:param kid: Key ID
:return: One key | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwt.py#L171-L185 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwt.py | JWT._verify | def _verify(self, rj, token):
"""
Verify a signed JSON Web Token
:param rj: A :py:class:`cryptojwt.jws.JWS` instance
:param token: The signed JSON Web Token
:return: A verified message
"""
keys = self.key_jar.get_jwt_verify_keys(rj.jwt)
return rj.verify_c... | python | def _verify(self, rj, token):
"""
Verify a signed JSON Web Token
:param rj: A :py:class:`cryptojwt.jws.JWS` instance
:param token: The signed JSON Web Token
:return: A verified message
"""
keys = self.key_jar.get_jwt_verify_keys(rj.jwt)
return rj.verify_c... | Verify a signed JSON Web Token
:param rj: A :py:class:`cryptojwt.jws.JWS` instance
:param token: The signed JSON Web Token
:return: A verified message | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwt.py#L242-L251 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwt.py | JWT._decrypt | def _decrypt(self, rj, token):
"""
Decrypt an encrypted JsonWebToken
:param rj: :py:class:`cryptojwt.jwe.JWE` instance
:param token: The encrypted JsonWebToken
:return:
"""
if self.iss:
keys = self.key_jar.get_jwt_decrypt_keys(rj.jwt, aud=self.iss)
... | python | def _decrypt(self, rj, token):
"""
Decrypt an encrypted JsonWebToken
:param rj: :py:class:`cryptojwt.jwe.JWE` instance
:param token: The encrypted JsonWebToken
:return:
"""
if self.iss:
keys = self.key_jar.get_jwt_decrypt_keys(rj.jwt, aud=self.iss)
... | Decrypt an encrypted JsonWebToken
:param rj: :py:class:`cryptojwt.jwe.JWE` instance
:param token: The encrypted JsonWebToken
:return: | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwt.py#L253-L265 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwt.py | JWT.verify_profile | def verify_profile(msg_cls, info, **kwargs):
"""
If a message type is known for this JSON document. Verify that the
document complies with the message specifications.
:param msg_cls: The message class. A
:py:class:`oidcmsg.message.Message` instance
:param info: The i... | python | def verify_profile(msg_cls, info, **kwargs):
"""
If a message type is known for this JSON document. Verify that the
document complies with the message specifications.
:param msg_cls: The message class. A
:py:class:`oidcmsg.message.Message` instance
:param info: The i... | If a message type is known for this JSON document. Verify that the
document complies with the message specifications.
:param msg_cls: The message class. A
:py:class:`oidcmsg.message.Message` instance
:param info: The information in the JSON document as a dictionary
:param kw... | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwt.py#L268-L282 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwt.py | JWT.unpack | def unpack(self, token):
"""
Unpack a received signed or signed and encrypted Json Web Token
:param token: The Json Web Token
:return: If decryption and signature verification work the payload
will be returned as a Message instance if possible.
"""
if not tok... | python | def unpack(self, token):
"""
Unpack a received signed or signed and encrypted Json Web Token
:param token: The Json Web Token
:return: If decryption and signature verification work the payload
will be returned as a Message instance if possible.
"""
if not tok... | Unpack a received signed or signed and encrypted Json Web Token
:param token: The Json Web Token
:return: If decryption and signature verification work the payload
will be returned as a Message instance if possible. | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwt.py#L284-L367 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jws/jws.py | factory | def factory(token, alg=''):
"""
Instantiate an JWS instance if the token is a signed JWT.
:param token: The token that might be a signed JWT
:param alg: The expected signature algorithm
:return: A JWS instance if the token was a signed JWT, otherwise None
"""
_jw = JWS(alg=alg)
if _jw.... | python | def factory(token, alg=''):
"""
Instantiate an JWS instance if the token is a signed JWT.
:param token: The token that might be a signed JWT
:param alg: The expected signature algorithm
:return: A JWS instance if the token was a signed JWT, otherwise None
"""
_jw = JWS(alg=alg)
if _jw.... | Instantiate an JWS instance if the token is a signed JWT.
:param token: The token that might be a signed JWT
:param alg: The expected signature algorithm
:return: A JWS instance if the token was a signed JWT, otherwise None | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jws/jws.py#L434-L447 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jws/jws.py | JWS.sign_compact | def sign_compact(self, keys=None, protected=None, **kwargs):
"""
Produce a JWS using the JWS Compact Serialization
:param keys: A dictionary of keys
:param protected: The protected headers (a dictionary)
:param kwargs: claims you want to add to the standard headers
:retu... | python | def sign_compact(self, keys=None, protected=None, **kwargs):
"""
Produce a JWS using the JWS Compact Serialization
:param keys: A dictionary of keys
:param protected: The protected headers (a dictionary)
:param kwargs: claims you want to add to the standard headers
:retu... | Produce a JWS using the JWS Compact Serialization
:param keys: A dictionary of keys
:param protected: The protected headers (a dictionary)
:param kwargs: claims you want to add to the standard headers
:return: A signed JSON Web Token | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jws/jws.py#L106-L143 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jws/jws.py | JWS.verify_compact | def verify_compact(self, jws=None, keys=None, allow_none=False,
sigalg=None):
"""
Verify a JWT signature
:param jws: A signed JSON Web Token
:param keys: A list of keys that can possibly be used to verify the
signature
:param allow_none: If sig... | python | def verify_compact(self, jws=None, keys=None, allow_none=False,
sigalg=None):
"""
Verify a JWT signature
:param jws: A signed JSON Web Token
:param keys: A list of keys that can possibly be used to verify the
signature
:param allow_none: If sig... | Verify a JWT signature
:param jws: A signed JSON Web Token
:param keys: A list of keys that can possibly be used to verify the
signature
:param allow_none: If signature algorithm 'none' is allowed
:param sigalg: Expected sigalg
:return: Dictionary with 2 keys 'msg' r... | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jws/jws.py#L145-L157 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jws/jws.py | JWS.verify_compact_verbose | def verify_compact_verbose(self, jws=None, keys=None, allow_none=False,
sigalg=None):
"""
Verify a JWT signature and return dict with validation results
:param jws: A signed JSON Web Token
:param keys: A list of keys that can possibly be used to verify the... | python | def verify_compact_verbose(self, jws=None, keys=None, allow_none=False,
sigalg=None):
"""
Verify a JWT signature and return dict with validation results
:param jws: A signed JSON Web Token
:param keys: A list of keys that can possibly be used to verify the... | Verify a JWT signature and return dict with validation results
:param jws: A signed JSON Web Token
:param keys: A list of keys that can possibly be used to verify the
signature
:param allow_none: If signature algorithm 'none' is allowed
:param sigalg: Expected sigalg
... | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jws/jws.py#L159-L250 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jws/jws.py | JWS.sign_json | def sign_json(self, keys=None, headers=None, flatten=False):
"""
Produce JWS using the JWS JSON Serialization
:param keys: list of keys to use for signing the JWS
:param headers: list of tuples (protected headers, unprotected
headers) for each signature
:return: A si... | python | def sign_json(self, keys=None, headers=None, flatten=False):
"""
Produce JWS using the JWS JSON Serialization
:param keys: list of keys to use for signing the JWS
:param headers: list of tuples (protected headers, unprotected
headers) for each signature
:return: A si... | Produce JWS using the JWS JSON Serialization
:param keys: list of keys to use for signing the JWS
:param headers: list of tuples (protected headers, unprotected
headers) for each signature
:return: A signed message using the JSON serialization format. | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jws/jws.py#L252-L293 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jws/jws.py | JWS._is_json_serialized_jws | def _is_json_serialized_jws(self, json_jws):
"""
Check if we've got a JSON serialized signed JWT.
:param json_jws: The message
:return: True/False
"""
json_ser_keys = {"payload", "signatures"}
flattened_json_ser_keys = {"payload", "signature"}
if not json... | python | def _is_json_serialized_jws(self, json_jws):
"""
Check if we've got a JSON serialized signed JWT.
:param json_jws: The message
:return: True/False
"""
json_ser_keys = {"payload", "signatures"}
flattened_json_ser_keys = {"payload", "signature"}
if not json... | Check if we've got a JSON serialized signed JWT.
:param json_jws: The message
:return: True/False | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jws/jws.py#L360-L373 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jws/jws.py | JWS._is_compact_jws | def _is_compact_jws(self, jws):
"""
Check if we've got a compact signed JWT
:param jws: The message
:return: True/False
"""
try:
jwt = JWSig().unpack(jws)
except Exception as err:
logger.warning('Could not parse JWS: {}'.format(err))
... | python | def _is_compact_jws(self, jws):
"""
Check if we've got a compact signed JWT
:param jws: The message
:return: True/False
"""
try:
jwt = JWSig().unpack(jws)
except Exception as err:
logger.warning('Could not parse JWS: {}'.format(err))
... | Check if we've got a compact signed JWT
:param jws: The message
:return: True/False | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jws/jws.py#L375-L399 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/hmac.py | SYMKey.appropriate_for | def appropriate_for(self, usage, alg='HS256'):
"""
Make sure there is a key instance present that can be used for
the specified usage.
"""
try:
_use = USE[usage]
except:
raise ValueError('Unknown key usage')
else:
if not self.us... | python | def appropriate_for(self, usage, alg='HS256'):
"""
Make sure there is a key instance present that can be used for
the specified usage.
"""
try:
_use = USE[usage]
except:
raise ValueError('Unknown key usage')
else:
if not self.us... | Make sure there is a key instance present that can be used for
the specified usage. | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/hmac.py#L72-L88 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/hmac.py | SYMKey.encryption_key | def encryption_key(self, alg, **kwargs):
"""
Return an encryption key as per
http://openid.net/specs/openid-connect-core-1_0.html#Encryption
:param alg: encryption algorithm
:param kwargs:
:return: encryption key as byte string
"""
if not self.key:
... | python | def encryption_key(self, alg, **kwargs):
"""
Return an encryption key as per
http://openid.net/specs/openid-connect-core-1_0.html#Encryption
:param alg: encryption algorithm
:param kwargs:
:return: encryption key as byte string
"""
if not self.key:
... | Return an encryption key as per
http://openid.net/specs/openid-connect-core-1_0.html#Encryption
:param alg: encryption algorithm
:param kwargs:
:return: encryption key as byte string | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/hmac.py#L90-L122 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jws/rsa.py | RSASigner.sign | def sign(self, msg, key):
"""
Create a signature over a message as defined in RFC7515 using an
RSA key
:param msg: the message.
:type msg: bytes
:returns: bytes, the signature of data.
:rtype: bytes
"""
if not isinstance(key, rsa.RSAPrivateKey):
... | python | def sign(self, msg, key):
"""
Create a signature over a message as defined in RFC7515 using an
RSA key
:param msg: the message.
:type msg: bytes
:returns: bytes, the signature of data.
:rtype: bytes
"""
if not isinstance(key, rsa.RSAPrivateKey):
... | Create a signature over a message as defined in RFC7515 using an
RSA key
:param msg: the message.
:type msg: bytes
:returns: bytes, the signature of data.
:rtype: bytes | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jws/rsa.py#L14-L29 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jws/rsa.py | RSASigner.verify | def verify(self, msg, signature, key):
"""
Verifies whether signature is a valid signature for message
:param msg: the message
:type msg: bytes
:param signature: The signature to be verified
:type signature: bytes
:param key: The key
:return: True is the ... | python | def verify(self, msg, signature, key):
"""
Verifies whether signature is a valid signature for message
:param msg: the message
:type msg: bytes
:param signature: The signature to be verified
:type signature: bytes
:param key: The key
:return: True is the ... | Verifies whether signature is a valid signature for message
:param msg: the message
:type msg: bytes
:param signature: The signature to be verified
:type signature: bytes
:param key: The key
:return: True is the signature is valid otherwise False | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jws/rsa.py#L31-L53 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/asym.py | AsymmetricKey.appropriate_for | def appropriate_for(self, usage, **kwargs):
"""
Make sure there is a key instance present that can be used for
the specified usage.
:param usage: Usage specification, one of [sign, verify, decrypt,
encrypt]
:param kwargs: Extra keyword arguments
:return: Suit... | python | def appropriate_for(self, usage, **kwargs):
"""
Make sure there is a key instance present that can be used for
the specified usage.
:param usage: Usage specification, one of [sign, verify, decrypt,
encrypt]
:param kwargs: Extra keyword arguments
:return: Suit... | Make sure there is a key instance present that can be used for
the specified usage.
:param usage: Usage specification, one of [sign, verify, decrypt,
encrypt]
:param kwargs: Extra keyword arguments
:return: Suitable key or None | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/asym.py#L16-L40 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/rsa.py | generate_and_store_rsa_key | def generate_and_store_rsa_key(key_size=2048, filename='rsa.key',
passphrase=''):
"""
Generate a private RSA key and store a PEM representation of it in a
file.
:param key_size: The size of the key, default 2048 bytes.
:param filename: The name of the file to which th... | python | def generate_and_store_rsa_key(key_size=2048, filename='rsa.key',
passphrase=''):
"""
Generate a private RSA key and store a PEM representation of it in a
file.
:param key_size: The size of the key, default 2048 bytes.
:param filename: The name of the file to which th... | Generate a private RSA key and store a PEM representation of it in a
file.
:param key_size: The size of the key, default 2048 bytes.
:param filename: The name of the file to which the key should be written
:param passphrase: If the PEM representation should be protected with a
pass phrase.
... | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/rsa.py#L29-L60 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/rsa.py | import_public_rsa_key_from_file | def import_public_rsa_key_from_file(filename):
"""
Read a public RSA key from a PEM file.
:param filename: The name of the file
:param passphrase: A pass phrase to use to unpack the PEM file.
:return: A
cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey instance
"""
with ope... | python | def import_public_rsa_key_from_file(filename):
"""
Read a public RSA key from a PEM file.
:param filename: The name of the file
:param passphrase: A pass phrase to use to unpack the PEM file.
:return: A
cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey instance
"""
with ope... | Read a public RSA key from a PEM file.
:param filename: The name of the file
:param passphrase: A pass phrase to use to unpack the PEM file.
:return: A
cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey instance | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/rsa.py#L80-L93 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/rsa.py | import_rsa_key | def import_rsa_key(pem_data):
"""
Extract an RSA key from a PEM-encoded X.509 certificate
:param pem_data: RSA key encoded in standard form
:return: rsa.RSAPublicKey instance
"""
if not pem_data.startswith(PREFIX):
pem_data = bytes('{}\n{}\n{}'.format(PREFIX, pem_data, POSTFIX),
... | python | def import_rsa_key(pem_data):
"""
Extract an RSA key from a PEM-encoded X.509 certificate
:param pem_data: RSA key encoded in standard form
:return: rsa.RSAPublicKey instance
"""
if not pem_data.startswith(PREFIX):
pem_data = bytes('{}\n{}\n{}'.format(PREFIX, pem_data, POSTFIX),
... | Extract an RSA key from a PEM-encoded X.509 certificate
:param pem_data: RSA key encoded in standard form
:return: rsa.RSAPublicKey instance | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/rsa.py#L96-L109 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/rsa.py | rsa_eq | def rsa_eq(key1, key2):
"""
Only works for RSAPublic Keys
:param key1:
:param key2:
:return:
"""
pn1 = key1.public_numbers()
pn2 = key2.public_numbers()
# Check if two RSA keys are in fact the same
if pn1 == pn2:
return True
else:
return False | python | def rsa_eq(key1, key2):
"""
Only works for RSAPublic Keys
:param key1:
:param key2:
:return:
"""
pn1 = key1.public_numbers()
pn2 = key2.public_numbers()
# Check if two RSA keys are in fact the same
if pn1 == pn2:
return True
else:
return False | Only works for RSAPublic Keys
:param key1:
:param key2:
:return: | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/rsa.py#L117-L131 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/rsa.py | x509_rsa_load | def x509_rsa_load(txt):
""" So I get the same output format as loads produces
:param txt:
:return:
"""
pub_key = import_rsa_key(txt)
if isinstance(pub_key, rsa.RSAPublicKey):
return [("rsa", pub_key)] | python | def x509_rsa_load(txt):
""" So I get the same output format as loads produces
:param txt:
:return:
"""
pub_key = import_rsa_key(txt)
if isinstance(pub_key, rsa.RSAPublicKey):
return [("rsa", pub_key)] | So I get the same output format as loads produces
:param txt:
:return: | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/rsa.py#L134-L141 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/rsa.py | der_cert | def der_cert(der_data):
"""
Load a DER encoded certificate
:param der_data: DER-encoded certificate
:return: A cryptography.x509.certificate instance
"""
if isinstance(der_data, str):
der_data = bytes(der_data, 'utf-8')
return x509.load_der_x509_certificate(der_data, default_backend... | python | def der_cert(der_data):
"""
Load a DER encoded certificate
:param der_data: DER-encoded certificate
:return: A cryptography.x509.certificate instance
"""
if isinstance(der_data, str):
der_data = bytes(der_data, 'utf-8')
return x509.load_der_x509_certificate(der_data, default_backend... | Load a DER encoded certificate
:param der_data: DER-encoded certificate
:return: A cryptography.x509.certificate instance | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/rsa.py#L189-L198 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/rsa.py | load_x509_cert | def load_x509_cert(url, httpc, spec2key, **get_args):
"""
Get and transform a X509 cert into a key.
:param url: Where the X509 cert can be found
:param httpc: HTTP client to use for fetching
:param spec2key: A dictionary over keys already seen
:param get_args: Extra key word arguments to the HT... | python | def load_x509_cert(url, httpc, spec2key, **get_args):
"""
Get and transform a X509 cert into a key.
:param url: Where the X509 cert can be found
:param httpc: HTTP client to use for fetching
:param spec2key: A dictionary over keys already seen
:param get_args: Extra key word arguments to the HT... | Get and transform a X509 cert into a key.
:param url: Where the X509 cert can be found
:param httpc: HTTP client to use for fetching
:param spec2key: A dictionary over keys already seen
:param get_args: Extra key word arguments to the HTTP GET request
:return: List of 2-tuples (keytype, key) | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/rsa.py#L201-L226 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/rsa.py | cmp_public_numbers | def cmp_public_numbers(pn1, pn2):
"""
Compare 2 sets of public numbers. These is a way to compare
2 public RSA keys. If the sets are the same then the keys are the same.
:param pn1: The set of values belonging to the 1st key
:param pn2: The set of values belonging to the 2nd key
:return: True i... | python | def cmp_public_numbers(pn1, pn2):
"""
Compare 2 sets of public numbers. These is a way to compare
2 public RSA keys. If the sets are the same then the keys are the same.
:param pn1: The set of values belonging to the 1st key
:param pn2: The set of values belonging to the 2nd key
:return: True i... | Compare 2 sets of public numbers. These is a way to compare
2 public RSA keys. If the sets are the same then the keys are the same.
:param pn1: The set of values belonging to the 1st key
:param pn2: The set of values belonging to the 2nd key
:return: True is the sets are the same otherwise False. | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/rsa.py#L229-L241 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/rsa.py | cmp_private_numbers | def cmp_private_numbers(pn1, pn2):
"""
Compare 2 sets of private numbers. This is for comparing 2
private RSA keys.
:param pn1: The set of values belonging to the 1st key
:param pn2: The set of values belonging to the 2nd key
:return: True is the sets are the same otherwise False.
"""
i... | python | def cmp_private_numbers(pn1, pn2):
"""
Compare 2 sets of private numbers. This is for comparing 2
private RSA keys.
:param pn1: The set of values belonging to the 1st key
:param pn2: The set of values belonging to the 2nd key
:return: True is the sets are the same otherwise False.
"""
i... | Compare 2 sets of private numbers. This is for comparing 2
private RSA keys.
:param pn1: The set of values belonging to the 1st key
:param pn2: The set of values belonging to the 2nd key
:return: True is the sets are the same otherwise False. | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/rsa.py#L244-L259 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/rsa.py | x5t_calculation | def x5t_calculation(cert):
"""
base64url-encoded SHA-1 thumbprint (a.k.a. digest) of the DER
encoding of an X.509 certificate.
:param cert: DER encoded X.509 certificate
:return: x5t value
"""
if isinstance(cert, str):
der_cert = base64.b64decode(cert.encode('ascii'))
else:
... | python | def x5t_calculation(cert):
"""
base64url-encoded SHA-1 thumbprint (a.k.a. digest) of the DER
encoding of an X.509 certificate.
:param cert: DER encoded X.509 certificate
:return: x5t value
"""
if isinstance(cert, str):
der_cert = base64.b64decode(cert.encode('ascii'))
else:
... | base64url-encoded SHA-1 thumbprint (a.k.a. digest) of the DER
encoding of an X.509 certificate.
:param cert: DER encoded X.509 certificate
:return: x5t value | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/rsa.py#L262-L275 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/rsa.py | new_rsa_key | def new_rsa_key(key_size=2048, kid='', use='', public_exponent=65537):
"""
Creates a new RSA key pair and wraps it in a
:py:class:`cryptojwt.jwk.rsa.RSAKey` instance
:param key_size: The size of the key
:param kid: The key ID
:param use: What the is supposed to be used for. 2 choices 'sig'/'enc... | python | def new_rsa_key(key_size=2048, kid='', use='', public_exponent=65537):
"""
Creates a new RSA key pair and wraps it in a
:py:class:`cryptojwt.jwk.rsa.RSAKey` instance
:param key_size: The size of the key
:param kid: The key ID
:param use: What the is supposed to be used for. 2 choices 'sig'/'enc... | Creates a new RSA key pair and wraps it in a
:py:class:`cryptojwt.jwk.rsa.RSAKey` instance
:param key_size: The size of the key
:param kid: The key ID
:param use: What the is supposed to be used for. 2 choices 'sig'/'enc'
:param public_exponent: The value of the public exponent.
:return: A :py:... | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/rsa.py#L503-L523 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/rsa.py | RSAKey.deserialize | def deserialize(self):
"""
Based on a text based representation of an RSA key this method
instantiates a
cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey or
RSAPublicKey instance
"""
# first look for the public parts of a RSA key
if self.n and... | python | def deserialize(self):
"""
Based on a text based representation of an RSA key this method
instantiates a
cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey or
RSAPublicKey instance
"""
# first look for the public parts of a RSA key
if self.n and... | Based on a text based representation of an RSA key this method
instantiates a
cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey or
RSAPublicKey instance | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/rsa.py#L340-L400 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/rsa.py | RSAKey.serialize | def serialize(self, private=False):
"""
Given a cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey or
RSAPublicKey instance construct the JWK representation.
:param private: Should I do the private part or not
:return: A JWK as a dictionary
"""
if not se... | python | def serialize(self, private=False):
"""
Given a cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey or
RSAPublicKey instance construct the JWK representation.
:param private: Should I do the private part or not
:return: A JWK as a dictionary
"""
if not se... | Given a cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey or
RSAPublicKey instance construct the JWK representation.
:param private: Should I do the private part or not
:return: A JWK as a dictionary | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/rsa.py#L402-L432 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwk/rsa.py | RSAKey.load_key | def load_key(self, key):
"""
Load a RSA key. Try to serialize the key before binding it to this
instance.
:param key: An RSA key instance
"""
self._serialize(key)
if isinstance(key, rsa.RSAPrivateKey):
self.priv_key = key
self.pub_key = k... | python | def load_key(self, key):
"""
Load a RSA key. Try to serialize the key before binding it to this
instance.
:param key: An RSA key instance
"""
self._serialize(key)
if isinstance(key, rsa.RSAPrivateKey):
self.priv_key = key
self.pub_key = k... | Load a RSA key. Try to serialize the key before binding it to this
instance.
:param key: An RSA key instance | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/rsa.py#L449-L464 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jws/dsa.py | ECDSASigner.sign | def sign(self, msg, key):
"""
Create a signature over a message as defined in RFC7515 using an
Elliptic curve key
:param msg: The message
:param key: An ec.EllipticCurvePrivateKey instance
:return:
"""
if not isinstance(key, ec.EllipticCurvePrivateKey):
... | python | def sign(self, msg, key):
"""
Create a signature over a message as defined in RFC7515 using an
Elliptic curve key
:param msg: The message
:param key: An ec.EllipticCurvePrivateKey instance
:return:
"""
if not isinstance(key, ec.EllipticCurvePrivateKey):
... | Create a signature over a message as defined in RFC7515 using an
Elliptic curve key
:param msg: The message
:param key: An ec.EllipticCurvePrivateKey instance
:return: | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jws/dsa.py#L31-L53 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jws/dsa.py | ECDSASigner.verify | def verify(self, msg, sig, key):
"""
Verify a message signature
:param msg: The message
:param sig: A signature
:param key: A ec.EllipticCurvePublicKey to use for the verification.
:raises: BadSignature if the signature can't be verified.
:return: True
""... | python | def verify(self, msg, sig, key):
"""
Verify a message signature
:param msg: The message
:param sig: A signature
:param key: A ec.EllipticCurvePublicKey to use for the verification.
:raises: BadSignature if the signature can't be verified.
:return: True
""... | Verify a message signature
:param msg: The message
:param sig: A signature
:param key: A ec.EllipticCurvePublicKey to use for the verification.
:raises: BadSignature if the signature can't be verified.
:return: True | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jws/dsa.py#L55-L85 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.