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]
 
HKDF_expand(PRK, info, L, algorithm) source code
 
HMAC_MD5(k, b) source code
 
HMAC_SHA1(k, b) source code
 
HMAC_SHA256(k, b) source code
 
HMAC_SHA384(k, b) source code
 
MD5(b)
Return a MD5 digest of data
source code
 
SHA1(b)
Return a SHA1 digest of data
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, sieve=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 5...) source code
 
lcm(a, b) source code
 
makeSieve(n) source code
 
mpiToNumber(mpi) source code
 
numBits(n)
Return number of bits necessary to represent the integer in binary
source code
 
numBytes(n)
Return number of bytes necessary to represent the integer in bytes
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
 
secureHMAC(k, b, algorithm)
Return a HMAC using `b` and `k` using `algorithm`
source code
 
secureHash(data, algorithm)
Return a digest of `data` using `algorithm`
source code
Variables [hide private]
  __package__ = 'tlslite.utils'
  fipsFile = <closed file '/proc/sys/crypto/fips_enabled', mode ...
  gmpyLoaded = False
  m2cryptoLoaded = True
  prngName = 'os.urandom'
  pycryptoLoaded = True
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]

fipsFile

Value:
<closed file '/proc/sys/crypto/fips_enabled', mode 'r' at 0x7fe0510dac\
90>