JOSE protocol implementation in Python with support for JSON Web Algorithms, Keys, and Signatures
73
Utility module for converting between JOSE-safe encodings and X.509 objects with strict length validation.
dGVzdA (ASCII or bytes input) yields the bytes b"test" and re-encoding returns the same paddingless string. @testZGF0YQ (4-byte content) fails with a size-validation error. @testdeadbeef to bytes returns b"\xde\xad\xbe\xef" and enforcing an exact 4-byte size passes. @test0a0b0c succeeds and leaves the 3-byte result unchanged. @test@generates
from typing import Optional, Union
from cryptography import x509
def to_jose_base64(data: bytes) -> str:
"""Encode binary data to paddingless, URL-safe base64 suitable for JOSE contexts."""
def from_jose_base64(value: Union[str, bytes], expected_size: Optional[int] = None, minimum: bool = False) -> bytes:
"""Decode JOSE-safe base64 input with optional exact or minimum-length enforcement."""
def encode_hex(value: bytes) -> str:
"""Produce a lowercase hexadecimal representation of binary data."""
def decode_hex(value: str, expected_size: Optional[int] = None, minimum: bool = False) -> bytes:
"""Decode hex strings with optional exact or minimum-length enforcement."""
def serialize_certificate(cert: x509.Certificate) -> str:
"""Convert a certificate object to a base64 DER string."""
def parse_certificate(value: str) -> x509.Certificate:
"""Parse a base64 DER certificate string and return a certificate object."""
def serialize_csr(csr: x509.CertificateSigningRequest) -> str:
"""Convert a CSR object to a base64 DER string."""
def parse_csr(value: str) -> x509.CertificateSigningRequest:
"""Parse a base64 DER CSR string and return a CSR object."""Provides JOSE-focused base64, hex, and X.509 DER helpers with length validation.
@satisfied-by
Supplies X.509 certificate and CSR primitives for encoding and decoding.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/pypi-josepyevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10