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
| Kind | Count |
|---|---|
| Classes | 11 |
| Functions | 25 |
| Methods | 14 |
API list
class
rsa.cli.CryptoOperationCLI callable that operates with input, output, and a key.
method
rsa.cli.CryptoOperation.perform_operation(indata:bytes, key:rsa.key.AbstractKey, cli_args:Indexable) -> typing.AnyPerforms the program's operation.
method
rsa.cli.CryptoOperation.read_infile(inname:str) -> bytesRead the input file
method
rsa.cli.CryptoOperation.read_key(filename:str, keyform:str) -> rsa.key.AbstractKeyReads a public or private key.
method
rsa.cli.CryptoOperation.write_outfile(outdata:bytes, outname:str) -> NoneWrite the output file
class
rsa.cli.DecryptOperationDecrypts a file.
method
rsa.cli.DecryptOperation.perform_operation(indata:bytes, priv_key:rsa.key.AbstractKey, cli_args:Indexable=()) -> bytesDecrypts files.
class
rsa.cli.EncryptOperationEncrypts a file.
method
rsa.cli.EncryptOperation.perform_operation(indata:bytes, pub_key:rsa.key.AbstractKey, cli_args:Indexable=()) -> bytesEncrypts files.
class
rsa.cli.SignOperationSigns a file.
method
rsa.cli.SignOperation.perform_operation(indata:bytes, priv_key:rsa.key.AbstractKey, cli_args:Indexable) -> bytesSigns files.
class
rsa.cli.VerifyOperationVerify a signature.
method
rsa.cli.VerifyOperation.perform_operation(indata:bytes, pub_key:rsa.key.AbstractKey, cli_args:Indexable) -> NoneVerifies files.
func
rsa.cli.keygen() -> NoneKey generator.
func
rsa.common.bit_size(num:int) -> intNumber of bits needed to represent a integer excluding any prefix 0 bits.
func
rsa.common.byte_size(number:int) -> intReturns the number of bytes required to hold a specific long number.
func
rsa.common.ceil_div(num:int, div:int) -> intReturns the ceiling function of a division between `num` and `div`.
func
rsa.common.crt(a_values:typing.Iterable[int], modulo_values:typing.Iterable[int]) -> intChinese Remainder Theorem.
func
rsa.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
func
rsa.core.encrypt_int(message:int, ekey:int, n:int) -> intEncrypts a message using encryption key 'ekey', working modulo n
class
rsa.key.AbstractKeyAbstract superclass for private and public keys.
method
rsa.key.AbstractKey.blind(message:int) -> typing.Tuple[int, int]Performs blinding on the message.
method
rsa.key.AbstractKey.load_pkcs1(keyfile:bytes, format:str='PEM') -> TLoads a key in PKCS#1 DER or PEM format.
method
rsa.key.AbstractKey.save_pkcs1(format:str='PEM') -> bytesSaves the key in PKCS#1 DER or PEM format.
class
rsa.key.PrivateKeyRepresents a private RSA key.
method
rsa.key.PrivateKey.blinded_decrypt(encrypted:int) -> intDecrypts the message using blinding to prevent side-channel attacks.
class
rsa.key.PublicKeyRepresents a public RSA key.
method
rsa.key.PublicKey.load_pkcs1_openssl_der(keyfile:bytes) -> 'PublicKey'Loads a PKCS#1 DER-encoded public key file from OpenSSL.
method
rsa.key.PublicKey.load_pkcs1_openssl_pem(keyfile:bytes) -> 'PublicKey'Loads a PKCS#1.5 PEM-encoded public key file from OpenSSL.
func
rsa.key.gen_keys(nbits:int, getprime_func:typing.Callable[[int], int], accurate:bool=True, exponent:int=DEFAULT_EXPONENT, nprimes:int=2) -> typing.TupleGenerate RSA keys of nbits bits.
func
rsa.parallel.getprime(nbits:int, poolsize:int) -> intReturns a prime number that can be stored in 'nbits' bits.
func
rsa.pem.load_pem(contents:FlexiText, pem_marker:FlexiText) -> bytesLoads a PEM file.
func
rsa.pem.save_pem(contents:bytes, pem_marker:FlexiText) -> bytesSaves a PEM file.
class
rsa.pkcs1.CryptoErrorBase class for all exceptions in this module.
class
rsa.pkcs1.DecryptionErrorRaised when decryption fails.
class
rsa.pkcs1.VerificationErrorRaised when verification fails.
func
rsa.pkcs1.compute_hash(message:typing.Union[bytes, typing.BinaryIO], method_name:str) -> bytesReturns the message digest.
func
rsa.pkcs1.find_signature_hash(signature:bytes, pub_key:key.PublicKey) -> strReturns the hash name detected from the signature.
func
rsa.pkcs1.sign(message:bytes, priv_key:key.PrivateKey, hash_method:str) -> bytesSigns the message with the private key.
func
rsa.pkcs1.sign_hash(hash_value:bytes, priv_key:key.PrivateKey, hash_method:str) -> bytesSigns a precomputed hash with the private key.
func
rsa.pkcs1.verify(message:bytes, signature:bytes, pub_key:key.PublicKey) -> strVerifies that the signature matches the message.
func
rsa.pkcs1_v2.mgf1(seed:bytes, length:int, hasher:str='SHA-1') -> bytesMGF1 is a Mask Generation Function based on a hash function.
func
rsa.prime.are_relatively_prime(a:int, b:int) -> boolReturns True if a and b are relatively prime, and False if they are not.
func
rsa.prime.gcd(p:int, q:int) -> intReturns the greatest common divisor of p and q >>> gcd(48, 180) 12
func
rsa.prime.getprime(nbits:int) -> intReturns a prime number that can be stored in 'nbits' bits.
func
rsa.prime.is_prime(number:int) -> boolReturns True if the number is prime, and False otherwise.
func
rsa.randnum.read_random_bits(nbits:int) -> bytesReads 'nbits' random bits.
func
rsa.randnum.read_random_int(nbits:int) -> intReads a random integer of approximately nbits bits.
func
rsa.randnum.read_random_odd_int(nbits:int) -> intReads a random odd integer of approximately nbits bits.
func
rsa.transform.bytes2int(raw_bytes:bytes) -> intConverts 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.