tlslite.utils.pycrypto_rsakey module

PyCrypto RSA implementation.

class tlslite.utils.pycrypto_rsakey.PyCrypto_RSAKey(n=0, e=0, d=0, p=0, q=0, dP=0, dQ=0, qInv=0, key_type='rsa')

Bases: RSAKey

__init__(n=0, e=0, d=0, p=0, q=0, dP=0, dQ=0, qInv=0, key_type='rsa')

Create a new RSA key.

If n and e are passed in, the new key will be initialized.

Parameters:
  • n (int) – RSA modulus.

  • e (int) – RSA public exponent.

  • key_type (str) – type of the RSA key, “rsa” for rsaEncryption (universal, able to perform all operations) or “rsa-pss” for a RSASSA-PSS key (able to perform only RSA-PSS signature verification and creation)

static generate(bits, key_type='rsa')

Generate a new key with the specified bit length.

Return type:

RSAKey

hasPrivateKey()

Return whether or not this key has a private component.

Return type:

bool

tlslite.utils.pycrypto_rsakey.bytes_to_int(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.