Utilities

Internal class delegating to a module, and displaying warnings when attributes related to the deprecated “abstractclassmethod” attributes in the josepy.util module.

class josepy.util.ComparableX509(wrapped: Union[OpenSSL.crypto.X509, OpenSSL.crypto.X509Req])[source]

Bases: object

Wrapper for OpenSSL.crypto.X509** objects that supports __eq__.

Variables:wrapped – Wrapped certificate or certificate request.
_dump(filetype: int = 2) → bytes[source]

Dumps the object into a buffer with the specified encoding.

Parameters:filetype (int) – The desired encoding. Should be one of OpenSSL.crypto.FILETYPE_ASN1, OpenSSL.crypto.FILETYPE_PEM, or OpenSSL.crypto.FILETYPE_TEXT.
Returns:Encoded X509 object.
Return type:bytes
class josepy.util.ComparableKey(wrapped: Union[cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey, cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey, cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey, cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey])[source]

Bases: object

Comparable wrapper for cryptography keys.

See https://github.com/pyca/cryptography/issues/2122.

public_key() → josepy.util.ComparableKey[source]

Get wrapped public key.

class josepy.util.ComparableRSAKey(wrapped: Union[cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey, cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey, cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey, cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey])[source]

Bases: josepy.util.ComparableKey

Wrapper for cryptography RSA keys.

Wraps around:

class josepy.util.ComparableECKey(wrapped: Union[cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey, cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey, cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey, cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey])[source]

Bases: josepy.util.ComparableKey

Wrapper for cryptography RSA keys. Wraps around: - EllipticCurvePrivateKey - EllipticCurvePublicKey

class josepy.util.ImmutableMap(**kwargs)[source]

Bases: collections.abc.Mapping, collections.abc.Hashable

Immutable key to value mapping with attribute access.

update(**kwargs) → josepy.util.ImmutableMap[source]

Return updated map.

class josepy.util.frozendict(*args, **kwargs)[source]

Bases: collections.abc.Mapping, collections.abc.Hashable

Frozen dictionary.

class josepy.util._UtilDeprecationModule(module: module)[source]

Bases: object

Internal class delegating to a module, and displaying warnings when attributes related to the deprecated “abstractclassmethod” attributes in the josepy.util module.