add missing stubs in cryptography rsa/serialization (#2376)

This commit is contained in:
Brandon Lin
2018-08-15 20:50:56 -07:00
committed by Jelle Zijlstra
parent f25c9548ed
commit 700efc43dd
2 changed files with 69 additions and 11 deletions

View File

@@ -1,4 +1,57 @@
# Minimal stub expressing only the classes required by OpenSSL.crypto.
from cryptography.hazmat.primitives.serialization import Encoding, KeySerializationEncryption, PrivateFormat, PublicFormat
from typing import Tuple
class RSAPrivateKey: ...
class RSAPublicKey: ...
class RSAPrivateKey:
def signer(self, padding, algorithm): ...
def decrypt(self, ciphertext: bytes, padding) -> bytes: ...
def public_key(self) -> RSAPublicKey: ...
@property
def key_size(self) -> int: ...
def sign(self, data: bytes, padding, algorithm) -> bytes: ...
class RSAPrivateKeyWithSerialization(RSAPrivateKey):
def private_numbers(self) -> RSAPrivateNumbers: ...
def private_bytes(self, encoding: Encoding, format: PrivateFormat, encryption_algorithm: KeySerializationEncryption) -> bytes: ...
class RSAPublicKey:
def verifier(self, signature: bytes, padding, algorithm): ...
def encrypt(self, plaintext: bytes, padding) -> bytes: ...
@property
def key_size(self) -> int: ...
def public_numbers(self) -> RSAPublicNumbers: ...
def public_bytes(self, encoding: Encoding, format: PublicFormat) -> bytes: ...
def verify(self, signature: bytes, data: bytes, padding, algorithm) -> None: ...
RSAPublicKeyWithSerialization = RSAPublicKey
def generate_private_key(public_exponent: int, key_size: int, backend) -> RSAPrivateKey: ...
def rsa_crt_iqmp(p: int, q: int) -> int: ...
def rsa_crt_dmp1(private_exponent: int, p: int) -> int: ...
def rsa_crt_dmq1(private_exponent: int, q: int) -> int: ...
def rsa_recover_prime_factors(n: int, e: int, d: int) -> Tuple[int, int]: ...
class RSAPrivateNumbers:
def __init__(self, p: int, q: int, d: int, dmp1: int, dmq1: int, iqmp: int, public_numbers: RSAPublicNumbers) -> None: ...
@property
def p(self) -> int: ...
@property
def q(self) -> int: ...
@property
def d(self) -> int: ...
@property
def dmp1(self) -> int: ...
@property
def dmq1(self) -> int: ...
@property
def iqmp(self) -> int: ...
@property
def public_numbers(self) -> RSAPublicNumbers: ...
def private_key(self, backend) -> RSAPrivateKey: ...
class RSAPublicNumbers:
def __init__(self, e: int, n: int) -> None: ...
@property
def p(self) -> int: ...
@property
def q(self) -> int: ...
def public_key(self, backend) -> RSAPublicKey: ...

View File

@@ -1,15 +1,16 @@
from typing import Any
from typing import Any, Optional
from enum import Enum
def load_pem_private_key(data, password, backend): ...
def load_pem_public_key(data, backend): ...
def load_der_private_key(data, password, backend): ...
def load_der_public_key(data, backend): ...
def load_ssh_public_key(data, backend): ...
def load_pem_private_key(data: bytes, password: Optional[bytes], backend): ...
def load_pem_public_key(data: bytes, backend): ...
def load_der_private_key(data: bytes, password: Optional[bytes], backend): ...
def load_der_public_key(data: bytes, backend): ...
def load_ssh_public_key(data: bytes, backend): ...
class Encoding(Enum):
PEM = ... # type: str
DER = ... # type: str
OpenSSH = ... # type: str
class PrivateFormat(Enum):
PKCS8 = ... # type: str
@@ -18,11 +19,15 @@ class PrivateFormat(Enum):
class PublicFormat(Enum):
SubjectPublicKeyInfo = ... # type: str
PKCS1 = ... # type: str
OpenSSH = ... # type: str
class ParameterFormat(Enum):
PKCS3 = ... # type: str
class KeySerializationEncryption: ...
class BestAvailableEncryption:
class BestAvailableEncryption(KeySerializationEncryption):
password = ... # type: Any
def __init__(self, password) -> None: ...
class NoEncryption: ...
class NoEncryption(KeySerializationEncryption): ...