Package tlslite :: Package utils :: Module cryptomath
[hide private]
[frames] | no frames]

Module cryptomath

source code

cryptomath module

This module has basic math/crypto code.

Functions [hide private]
 
HMAC_MD5(k, b) source code
 
HMAC_SHA1(k, b) source code
 
MD5(b) source code
 
SHA1(b) source code
 
bytesToNumber(b) source code
 
gcd(a, b) source code
 
getRandomBytes(howMany) source code
 
getRandomNumber(low, high) source code
 
getRandomPrime(bits, display=False) source code
 
getRandomSafePrime(bits, display=False) source code
 
invMod(a, b) source code
 
isPrime(n, iterations=5, display=False) source code
 
lcm(a, b) source code
 
makeSieve(n) source code
 
mpiToNumber(mpi) source code
 
numBits(n) source code
 
numBytes(n) source code
 
numberToByteArray(n, howManyBytes=None)
Convert an integer into a bytearray, zero-pad to howManyBytes.
source code
 
numberToMPI(n) source code
 
powMod(base, power, modulus) source code
Variables [hide private]
  __package__ = 'tlslite.utils'
  gmpyLoaded = False
  length = 1011
  m2cryptoLoaded = True
  prngName = 'os.urandom'
  pycryptoLoaded = True
  sieve = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 4...
Function Details [hide private]

numberToByteArray(n, howManyBytes=None)

source code 

Convert an integer into a bytearray, zero-pad to howManyBytes.

The returned bytearray may be smaller than howManyBytes, but will not be larger. The returned bytearray will contain a big-endian encoding of the input integer (n).


Variables Details [hide private]

sieve

Value:
[2,
 3,
 5,
 7,
 11,
 13,
 17,
 19,
...