sdkagent

python-rsa API reference

50 public APIs from python-rsa (sybrenstuvel/python-rsa) — 11 classes, 25 functions, 14 methods. Signatures extracted by static analysis of the actual source.

Repository: sybrenstuvel/python-rsa

KindCount
Classes11
Functions25
Methods14

API list

classrsa.cli.CryptoOperation
CLI callable that operates with input, output, and a key.
methodrsa.cli.CryptoOperation.perform_operation(indata:bytes, key:rsa.key.AbstractKey, cli_args:Indexable) -> typing.Any
Performs the program's operation.
methodrsa.cli.CryptoOperation.read_infile(inname:str) -> bytes
Read the input file
methodrsa.cli.CryptoOperation.read_key(filename:str, keyform:str) -> rsa.key.AbstractKey
Reads a public or private key.
methodrsa.cli.CryptoOperation.write_outfile(outdata:bytes, outname:str) -> None
Write the output file
classrsa.cli.DecryptOperation
Decrypts a file.
methodrsa.cli.DecryptOperation.perform_operation(indata:bytes, priv_key:rsa.key.AbstractKey, cli_args:Indexable=()) -> bytes
Decrypts files.
classrsa.cli.EncryptOperation
Encrypts a file.
methodrsa.cli.EncryptOperation.perform_operation(indata:bytes, pub_key:rsa.key.AbstractKey, cli_args:Indexable=()) -> bytes
Encrypts files.
classrsa.cli.SignOperation
Signs a file.
methodrsa.cli.SignOperation.perform_operation(indata:bytes, priv_key:rsa.key.AbstractKey, cli_args:Indexable) -> bytes
Signs files.
classrsa.cli.VerifyOperation
Verify a signature.
methodrsa.cli.VerifyOperation.perform_operation(indata:bytes, pub_key:rsa.key.AbstractKey, cli_args:Indexable) -> None
Verifies files.
funcrsa.cli.keygen() -> None
Key generator.
funcrsa.common.bit_size(num:int) -> int
Number of bits needed to represent a integer excluding any prefix 0 bits.
funcrsa.common.byte_size(number:int) -> int
Returns the number of bytes required to hold a specific long number.
funcrsa.common.ceil_div(num:int, div:int) -> int
Returns the ceiling function of a division between `num` and `div`.
funcrsa.common.crt(a_values:typing.Iterable[int], modulo_values:typing.Iterable[int]) -> int
Chinese Remainder Theorem.
funcrsa.common.extended_gcd(a:int, b:int) -> typing.Tuple[int, int, int]
Returns a tuple (r, i, j) such that r = gcd(a, b) = ia + jb
funcrsa.core.encrypt_int(message:int, ekey:int, n:int) -> int
Encrypts a message using encryption key 'ekey', working modulo n
classrsa.key.AbstractKey
Abstract superclass for private and public keys.
methodrsa.key.AbstractKey.blind(message:int) -> typing.Tuple[int, int]
Performs blinding on the message.
methodrsa.key.AbstractKey.load_pkcs1(keyfile:bytes, format:str='PEM') -> T
Loads a key in PKCS#1 DER or PEM format.
methodrsa.key.AbstractKey.save_pkcs1(format:str='PEM') -> bytes
Saves the key in PKCS#1 DER or PEM format.
classrsa.key.PrivateKey
Represents a private RSA key.
methodrsa.key.PrivateKey.blinded_decrypt(encrypted:int) -> int
Decrypts the message using blinding to prevent side-channel attacks.
classrsa.key.PublicKey
Represents a public RSA key.
methodrsa.key.PublicKey.load_pkcs1_openssl_der(keyfile:bytes) -> 'PublicKey'
Loads a PKCS#1 DER-encoded public key file from OpenSSL.
methodrsa.key.PublicKey.load_pkcs1_openssl_pem(keyfile:bytes) -> 'PublicKey'
Loads a PKCS#1.5 PEM-encoded public key file from OpenSSL.
funcrsa.key.gen_keys(nbits:int, getprime_func:typing.Callable[[int], int], accurate:bool=True, exponent:int=DEFAULT_EXPONENT, nprimes:int=2) -> typing.Tuple
Generate RSA keys of nbits bits.
funcrsa.parallel.getprime(nbits:int, poolsize:int) -> int
Returns a prime number that can be stored in 'nbits' bits.
funcrsa.pem.load_pem(contents:FlexiText, pem_marker:FlexiText) -> bytes
Loads a PEM file.
funcrsa.pem.save_pem(contents:bytes, pem_marker:FlexiText) -> bytes
Saves a PEM file.
classrsa.pkcs1.CryptoError
Base class for all exceptions in this module.
classrsa.pkcs1.DecryptionError
Raised when decryption fails.
classrsa.pkcs1.VerificationError
Raised when verification fails.
funcrsa.pkcs1.compute_hash(message:typing.Union[bytes, typing.BinaryIO], method_name:str) -> bytes
Returns the message digest.
funcrsa.pkcs1.find_signature_hash(signature:bytes, pub_key:key.PublicKey) -> str
Returns the hash name detected from the signature.
funcrsa.pkcs1.sign(message:bytes, priv_key:key.PrivateKey, hash_method:str) -> bytes
Signs the message with the private key.
funcrsa.pkcs1.sign_hash(hash_value:bytes, priv_key:key.PrivateKey, hash_method:str) -> bytes
Signs a precomputed hash with the private key.
funcrsa.pkcs1.verify(message:bytes, signature:bytes, pub_key:key.PublicKey) -> str
Verifies that the signature matches the message.
funcrsa.pkcs1_v2.mgf1(seed:bytes, length:int, hasher:str='SHA-1') -> bytes
MGF1 is a Mask Generation Function based on a hash function.
funcrsa.prime.are_relatively_prime(a:int, b:int) -> bool
Returns True if a and b are relatively prime, and False if they are not.
funcrsa.prime.gcd(p:int, q:int) -> int
Returns the greatest common divisor of p and q >>> gcd(48, 180) 12
funcrsa.prime.getprime(nbits:int) -> int
Returns a prime number that can be stored in 'nbits' bits.
funcrsa.prime.is_prime(number:int) -> bool
Returns True if the number is prime, and False otherwise.
funcrsa.randnum.read_random_bits(nbits:int) -> bytes
Reads 'nbits' random bits.
funcrsa.randnum.read_random_int(nbits:int) -> int
Reads a random integer of approximately nbits bits.
funcrsa.randnum.read_random_odd_int(nbits:int) -> int
Reads a random odd integer of approximately nbits bits.
funcrsa.transform.bytes2int(raw_bytes:bytes) -> int
Converts a list of bytes or an 8-bit string to an integer.

About this data

These signatures were extracted from the public source of sybrenstuvel/python-rsa using Python's ast module. Argument names, default values, type annotations and return types are taken verbatim from the code. Implementation bodies are never stored. See how it works for details.

Back to all 805 libraries