diff --git a/stubs/jwcrypto/@tests/stubtest_allowlist.txt b/stubs/jwcrypto/@tests/stubtest_allowlist.txt index b81e7c4baa58..253d414f8eab 100644 --- a/stubs/jwcrypto/@tests/stubtest_allowlist.txt +++ b/stubs/jwcrypto/@tests/stubtest_allowlist.txt @@ -1,6 +1,7 @@ # test code does not need type hints jwcrypto.tests jwcrypto.tests-cookbook +jwcrypto.tests_mldsa # even if the deprecated decorator is applied, the attribute is not present jwcrypto.jwt.JWTMissingKeyID.__deprecated__ diff --git a/stubs/jwcrypto/METADATA.toml b/stubs/jwcrypto/METADATA.toml index 746c8c0fb382..a80bbcc56e98 100644 --- a/stubs/jwcrypto/METADATA.toml +++ b/stubs/jwcrypto/METADATA.toml @@ -1,3 +1,3 @@ -version = "1.5.8" +version = "1.5.9" upstream-repository = "https://github.com/latchset/jwcrypto" dependencies = ["cryptography"] diff --git a/stubs/jwcrypto/jwcrypto/common.pyi b/stubs/jwcrypto/jwcrypto/common.pyi index b1361916a804..1deafd70a886 100644 --- a/stubs/jwcrypto/jwcrypto/common.pyi +++ b/stubs/jwcrypto/jwcrypto/common.pyi @@ -19,6 +19,9 @@ class InvalidJWAAlgorithm(JWException): class InvalidCEKeyLength(JWException): def __init__(self, expected: int, obtained: int) -> None: ... +class InvalidJWEData(JWException): + def __init__(self, message: str | None = None, exception: BaseException | None = None) -> None: ... + class InvalidJWEOperation(JWException): def __init__(self, message: str | None = None, exception: BaseException | None = None) -> None: ... diff --git a/stubs/jwcrypto/jwcrypto/jwa.pyi b/stubs/jwcrypto/jwcrypto/jwa.pyi index e2932812cdcc..50fdc6d1158d 100644 --- a/stubs/jwcrypto/jwcrypto/jwa.pyi +++ b/stubs/jwcrypto/jwcrypto/jwa.pyi @@ -1,8 +1,9 @@ from abc import ABCMeta, abstractmethod from collections.abc import Mapping -from typing import ClassVar +from typing import ClassVar, Literal default_max_pbkdf2_iterations: int +default_warn_deprecated_algorithms: bool default_enforce_hmac_key_length: bool class JWAAlgorithm(metaclass=ABCMeta): @@ -21,6 +22,8 @@ class JWAAlgorithm(metaclass=ABCMeta): @property @abstractmethod def algorithm_use(self) -> str: ... + status: Literal["active", "deprecated", "prohibited"] + deprecated_by: str | None @property def input_keysize(self) -> int: ... diff --git a/stubs/jwcrypto/jwcrypto/jwe.pyi b/stubs/jwcrypto/jwcrypto/jwe.pyi index 6c22794cd5e3..6c8ba45c94e6 100644 --- a/stubs/jwcrypto/jwcrypto/jwe.pyi +++ b/stubs/jwcrypto/jwcrypto/jwe.pyi @@ -4,7 +4,7 @@ from typing import Any from typing_extensions import LiteralString, Self from jwcrypto import common -from jwcrypto.common import JWException, JWSEHeaderParameter, JWSEHeaderRegistry +from jwcrypto.common import JWSEHeaderParameter, JWSEHeaderRegistry from jwcrypto.jwk import JWK, JWKSet default_max_compressed_size: int @@ -14,10 +14,8 @@ JWEHeaderRegistry: dict[LiteralString, JWSEHeaderParameter] default_allowed_algs: list[LiteralString] -class InvalidJWEData(JWException): - def __init__(self, message: str | None = None, exception: BaseException | None = None) -> None: ... - InvalidCEKeyLength = common.InvalidCEKeyLength +InvalidJWEData = common.InvalidJWEData InvalidJWEKeyLength = common.InvalidJWEKeyLength InvalidJWEKeyType = common.InvalidJWEKeyType InvalidJWEOperation = common.InvalidJWEOperation diff --git a/stubs/jwcrypto/jwcrypto/jwk.pyi b/stubs/jwcrypto/jwcrypto/jwk.pyi index 5cdd0bcc45ba..3db8d2739baf 100644 --- a/stubs/jwcrypto/jwcrypto/jwk.pyi +++ b/stubs/jwcrypto/jwcrypto/jwk.pyi @@ -11,6 +11,14 @@ from cryptography.hazmat.primitives.asymmetric.ed25519 import ( Ed25519PrivateKey as Ed25519PrivateKey, Ed25519PublicKey as Ed25519PublicKey, ) +from cryptography.hazmat.primitives.asymmetric.mldsa import ( + MLDSA44PrivateKey as MLDSA44PrivateKey, + MLDSA44PublicKey as MLDSA44PublicKey, + MLDSA65PrivateKey as MLDSA65PrivateKey, + MLDSA65PublicKey as MLDSA65PublicKey, + MLDSA87PrivateKey as MLDSA87PrivateKey, + MLDSA87PublicKey as MLDSA87PublicKey, +) from cryptography.hazmat.primitives.asymmetric.x448 import X448PrivateKey as X448PrivateKey, X448PublicKey as X448PublicKey from cryptography.hazmat.primitives.asymmetric.x25519 import ( X25519PrivateKey as X25519PrivateKey, @@ -22,11 +30,11 @@ _T = TypeVar("_T") class UnimplementedOKPCurveKey: @classmethod - def generate(cls) -> None: ... + def generate(cls): ... @classmethod - def from_public_bytes(cls, *args) -> None: ... + def from_public_bytes(cls, *args): ... @classmethod - def from_private_bytes(cls, *args) -> None: ... + def from_private_bytes(cls, *args): ... ImplementedOkpCurves: Sequence[str] priv_bytes: Callable[[bytes], X25519PrivateKey] | None @@ -47,6 +55,20 @@ class _X448_CURVE(NamedTuple): pubkey: UnimplementedOKPCurveKey privkey: UnimplementedOKPCurveKey +class UnimplementedAKPAlgorithm: + @classmethod + def generate(cls): ... + @classmethod + def from_public_bytes(cls, *args): ... + @classmethod + def from_seed_bytes(cls, *args): ... + +ImplementedAKPAlgorithms: Sequence[str] + +class _AKPAlg(NamedTuple): + pubkey: UnimplementedAKPAlgorithm + privkey: UnimplementedAKPAlgorithm + _JWKKeyTypeSupported: TypeAlias = Literal["oct", "RSA", "EC", "OKP"] JWKTypesRegistry: dict[_JWKKeyTypeSupported, str]