diff --git a/lib/Crypto/IO/PKCS8.pyi b/lib/Crypto/IO/PKCS8.pyi index 2fed1b74..cf6aa8ae 100644 --- a/lib/Crypto/IO/PKCS8.pyi +++ b/lib/Crypto/IO/PKCS8.pyi @@ -1,14 +1,17 @@ -from typing import Dict, Tuple, Optional, Union, Callable +from typing import Tuple, Optional, Union, Callable +from typing_extensions import NotRequired from Crypto.Util.asn1 import DerObject +from Crypto.IO._PBES import ProtParams + def wrap(private_key: bytes, key_oid: str, - passphrase: Union[bytes, str] = ..., - protection: str = ..., - prot_params: Dict = ..., - key_params: Optional[DerObject] = ..., - randfunc: Optional[Callable[[int],str]] = ...) -> bytes: ... + passphrase: Union[bytes, str] = ..., + protection: str = ..., + prot_params: Optional[ProtParams] = ..., + key_params: Optional[DerObject] = ..., + randfunc: Optional[Callable[[int], str]] = ...) -> bytes: ... def unwrap(p8_private_key: bytes, passphrase: Optional[Union[bytes, str]] = ...) -> Tuple[str, bytes, Optional[bytes]]: ... diff --git a/lib/Crypto/IO/_PBES.pyi b/lib/Crypto/IO/_PBES.pyi index a8a34ced..06733640 100644 --- a/lib/Crypto/IO/_PBES.pyi +++ b/lib/Crypto/IO/_PBES.pyi @@ -1,4 +1,5 @@ -from typing import Dict, Optional, Callable +from typing import Optional, Callable, TypedDict +from typing_extensions import NotRequired class PbesError(ValueError): ... @@ -7,13 +8,19 @@ class PBES1(object): @staticmethod def decrypt(data: bytes, passphrase: bytes) -> bytes: ... +class ProtParams(TypedDict): + iteration_count: NotRequired[int] + salt_size: NotRequired[int] + block_size: NotRequired[int] + parallelization: NotRequired[int] + class PBES2(object): @staticmethod def encrypt(data: bytes, passphrase: bytes, - protection: str, - prot_params: Optional[Dict] = ..., - randfunc: Optional[Callable[[int],bytes]] = ...) -> bytes: ... + protection: str, + prot_params: Optional[ProtParams] = ..., + randfunc: Optional[Callable[[int],bytes]] = ...) -> bytes: ... @staticmethod def decrypt(data:bytes, passphrase: bytes) -> bytes: ...