1 from abc import ABCMeta, abstractmethod
3 from cryptography.hazmat.backends.interfaces import RSABackend
4 from cryptography.hazmat.primitives.asymmetric import AsymmetricVerificationContext
5 from cryptography.hazmat.primitives.asymmetric.padding import AsymmetricPadding
6 from cryptography.hazmat.primitives.asymmetric.utils import Prehashed
7 from cryptography.hazmat.primitives.hashes import HashAlgorithm
8 from cryptography.hazmat.primitives.serialization import Encoding, KeySerializationEncryption, PrivateFormat, PublicFormat
10 class RSAPrivateKey(metaclass=ABCMeta):
13 def key_size(self) -> int: ...
15 def decrypt(self, ciphertext: bytes, padding: AsymmetricPadding) -> bytes: ...
17 def public_key(self) -> RSAPublicKey: ...
19 def sign(self, data: bytes, padding: AsymmetricPadding, algorithm: HashAlgorithm | Prehashed) -> bytes: ...
21 class RSAPrivateKeyWithSerialization(RSAPrivateKey):
24 self, encoding: Encoding, format: PrivateFormat, encryption_algorithm: KeySerializationEncryption
27 def private_numbers(self) -> RSAPrivateNumbers: ...
29 class RSAPublicKey(metaclass=ABCMeta):
32 def key_size(self) -> int: ...
34 def encrypt(self, plaintext: bytes, padding: AsymmetricPadding) -> bytes: ...
36 def public_bytes(self, encoding: Encoding, format: PublicFormat) -> bytes: ...
38 def public_numbers(self) -> RSAPublicNumbers: ...
41 self, signature: bytes, padding: AsymmetricPadding, algorithm: HashAlgorithm | Prehashed
42 ) -> AsymmetricVerificationContext: ...
44 def verify(self, signature: bytes, data: bytes, padding: AsymmetricPadding, algorithm: HashAlgorithm | Prehashed) -> None: ...
46 RSAPublicKeyWithSerialization = RSAPublicKey
48 def generate_private_key(
49 public_exponent: int, key_size: int, backend: RSABackend | None = ...
50 ) -> RSAPrivateKeyWithSerialization: ...
51 def rsa_crt_iqmp(p: int, q: int) -> int: ...
52 def rsa_crt_dmp1(private_exponent: int, p: int) -> int: ...
53 def rsa_crt_dmq1(private_exponent: int, q: int) -> int: ...
54 def rsa_recover_prime_factors(n: int, e: int, d: int) -> tuple[int, int]: ...
56 class RSAPrivateNumbers(object):
57 def __init__(self, p: int, q: int, d: int, dmp1: int, dmq1: int, iqmp: int, public_numbers: RSAPublicNumbers) -> None: ...
59 def p(self) -> int: ...
61 def q(self) -> int: ...
63 def d(self) -> int: ...
65 def dmp1(self) -> int: ...
67 def dmq1(self) -> int: ...
69 def iqmp(self) -> int: ...
71 def public_numbers(self) -> RSAPublicNumbers: ...
72 def private_key(self, backend: RSABackend | None = ...) -> RSAPrivateKey: ...
74 class RSAPublicNumbers(object):
75 def __init__(self, e: int, n: int) -> None: ...
77 def e(self) -> int: ...
79 def n(self) -> int: ...
80 def public_key(self, backend: RSABackend | None = ...) -> RSAPublicKey: ...