11import ctypes
22from types import TracebackType
3- from typing import Final , TypeVar
3+ from typing import Final , TypeVar , final , TypedDict
44
55_TKeyEncapsulation = TypeVar ("_TKeyEncapsulation" , bound = "KeyEncapsulation" )
66_TSignature = TypeVar ("_TSignature" , bound = "Signature" )
@@ -22,6 +22,17 @@ class MechanismNotEnabledError(MechanismNotSupportedError):
2222 # alg_name and message are inherited from MechanismNotSupportedError
2323 def __init__ (self , alg_name : str ) -> None : ...
2424
25+ class KeyEncapsulationDetails (TypedDict ):
26+ name : str
27+ version : str
28+ claimed_nist_level : int
29+ is_ind_cca : bool
30+ length_public_key : int
31+ length_secret_key : int
32+ length_ciphertext : int
33+ length_shared_secret : int
34+
35+ @final
2536class KeyEncapsulation :
2637 # Attributes from the underlying ctypes.Structure, exposed with Python types
2738 method_name : bytes
@@ -35,7 +46,7 @@ class KeyEncapsulation:
3546
3647 # Custom attributes set during initialization
3748 alg_name : str
38- details : dict [ str , str | int | bool ]
49+ details : KeyEncapsulationDetails
3950
4051 def __init__ (self , alg_name : str , secret_key : int | bytes | None = None ) -> None : ...
4152 def __enter__ (self : _TKeyEncapsulation ) -> _TKeyEncapsulation : ...
@@ -52,6 +63,17 @@ class KeyEncapsulation:
5263 def free (self ) -> None : ...
5364 def __repr__ (self ) -> str : ...
5465
66+ class SignatureDetails (TypedDict ):
67+ name : str
68+ version : str
69+ claimed_nist_level : int
70+ is_euf_cma : bool
71+ sig_with_ctx_support : bool
72+ length_public_key : int
73+ length_secret_key : int
74+ length_signature : int
75+
76+ @final
5577class Signature :
5678 # Attributes from the underlying ctypes.Structure, exposed with Python types
5779 method_name : bytes
@@ -65,7 +87,7 @@ class Signature:
6587
6688 # Custom attributes set during initialization
6789 alg_name : str
68- details : dict [ str , str | int | bool ]
90+ details : SignatureDetails
6991
7092 def __init__ (self , alg_name : str , secret_key : int | bytes | None = None ) -> None : ...
7193 def __enter__ (self : _TSignature ) -> _TSignature : ...
@@ -91,4 +113,4 @@ def get_enabled_kem_mechanisms() -> tuple[str, ...]: ...
91113def get_supported_kem_mechanisms () -> tuple [str , ...]: ...
92114def is_sig_enabled (alg_name : str ) -> bool : ...
93115def get_enabled_sig_mechanisms () -> tuple [str , ...]: ...
94- def get_supported_sig_mechanisms () -> tuple [str , ...]: ...
116+ def get_supported_sig_mechanisms () -> tuple [str , ...]: ...
0 commit comments