Advanced Encryption Standard - Block Cipher
Cipher Block Chaining Mode of Operation
Diffie-Hellman Key Exchange
Time OTP implementation for 2-factor authentication
Various mathematical function used in public key cryptography
Test whether n is prime using the probabilistic Miller-Rabin primality test. If n is composite, then this test will declare it to be probably prime with a probability of at most 4**-k.
To be on the safe side, a value of k=64 for integers up to 3072 bits is recommended (error probability = 2**-128). If the function is used for RSA or DSA, NIST recommends some values in FIPS PUB 186-3:
<http://csrc.nist.gov/publications/fips/fips186-3/fips_186-3.pdf>
Do not use this function for small numbers.
Return a random prime up to a certain length
This function uses random.SystemRandom.
Euler’s totient function for n which can be written as pq
This is the number of k in the range 0 <= k <= n where gcd(n, k) is = 1 or, in other words, the number of integers k <= n that are relatively prime to n.
Password based key-derivation function - PBKDF2
The arguments for this function are:
- digestmod
- a crypographic hash constructor, such as hashlib.sha256 which will be used as an argument to the hmac function. Note that the performance difference between sha1 and sha256 is not very big. New applications should choose sha256 or better.
- password
- The arbitrary-length password (passphrase) (bytes)
- salt
- A bunch of random bytes, generated using a cryptographically strong random number generator (such as os.urandom()). NIST recommend the salt be _at least_ 128bits (16 bytes) long.
- count
- The iteration count. Set this value as large as you can tolerate. NIST recommend that the absolute minimum value be 1000. However, it should generally be in the range of tens of thousands, or however many cause about a half-second delay to the user.
- dk_length
- The lenght of the desired key in bytes. This doesn’t need to be the same size as the hash functions digest size, but it makes sense to use a larger digest hash function if your key size is large.
PKCS7 Padding for Block Cipher Modes
Groups for Diffie-Hellman as defined by RFC 3526
To get access to the 2048 bit group, for example, type:
>>> prime, generator = rfc3526.groups[2048]
See http://tools.ietf.org/html/rfc3526 for notes on usage.
XTEA block cipher (32 rounds)