summaryrefslogtreecommitdiff
path: root/Doc
diff options
context:
space:
mode:
authorDwayne C. Litzenberger <dlitz@dlitz.net>2010-08-02 16:58:07 -0400
committerDwayne C. Litzenberger <dlitz@dlitz.net>2010-08-02 17:03:29 -0400
commit79f6c64c58cfb8795fa40b6999a89219ac9f102d (patch)
tree7d6b8cb8a98aa81735e6f6e457d38a1ef1047054 /Doc
parent902ea14fc2d3d4a6e01afbef6f45115ab37e7fcd (diff)
downloadpycrypto-79f6c64c58cfb8795fa40b6999a89219ac9f102d.tar.gz
getRandomNumber API compatibility:
Legrandin's getStrongPrime() patch changed the behaviour of Crypto.Util.number.getRandomNumber() to something that is more like what people would expect, but different from what we did before. This change modifies Crypto.Util.number in the following ways: - Rename getRandomNBitNumber -> getRandomNBitInteger and getRandomNumber -> getRandomInteger - Preserve old behaviour by making getRandomNumber work the same as getRandomNBitInteger. - Emit a DeprecationWarning when the old getRandomNumber is used.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/pycrypt.rst27
1 files changed, 26 insertions, 1 deletions
diff --git a/Doc/pycrypt.rst b/Doc/pycrypt.rst
index 2c46d92..4b8114b 100644
--- a/Doc/pycrypt.rst
+++ b/Doc/pycrypt.rst
@@ -852,7 +852,32 @@ corresponding length; the ``get_bytes()`` method of a
``RandomPool`` object will serve the purpose nicely, as will the
``read()`` method of an opened file such as ``/dev/random``.
-**getRandomNumber(N, randfunc)**:
+**getStrongPrime(N, e=0, false_positive_prob=1e-6, randfunc=None)**:
+Return a random strong ``N``-bit prime number.
+In this context p is a strong prime if p-1 and p+1 have at
+least one large prime factor.
+``N`` should be a multiple of 128 and > 512.
+
+If ``e`` is provided the returned prime p-1 will be coprime to ``e``
+and thus suitable for RSA where e is the public exponent.
+
+The optional ``false_positive_prob`` is the statistical probability
+that true is returned even though it is not (pseudo-prime).
+It defaults to 1e-6 (less than 1:1000000).
+Note that the real probability of a false-positive is far less. This is
+just the mathematically provable limit.
+
+``randfunc`` should take a single int parameter and return that
+many random bytes as a string.
+If randfunc is omitted, then ``Random.new().read`` is used.
+
+**getRandomNBitInteger(N, randfunc)**:
+Return an ``N``-bit random number, using random data obtained from the
+function ``randfunc``. As usual, ``randfunc`` must take a single
+integer argument and return a string of random data of the
+corresponding length.
+
+**getRandomNBitInteger(N, randfunc)**:
Return an ``N``-bit random number, using random data obtained from the
function ``randfunc``. As usual, ``randfunc`` must take a single
integer argument and return a string of random data of the