diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2017-05-31 05:03:27 -0400 |
---|---|---|
committer | Hynek Schlawack <hs@ox.cx> | 2017-05-31 11:03:27 +0200 |
commit | 3ed6273b8f1a64e26ae6e52e21870fe5f1951066 (patch) | |
tree | 47a9172f486ae00f30cc0019385fa0d095e0e868 | |
parent | 0d2aec53b165cd32e66dce647f3642a4eb4bc4bc (diff) | |
download | pyopenssl-3ed6273b8f1a64e26ae6e52e21870fe5f1951066.tar.gz |
Drop the deprecated rand.egd function (#630)
* Drop the deprecated rand.egd function
* Removed egd tests
* Removed egd docs
* Document the removal
* unused imports
* Update CHANGELOG.rst
-rw-r--r-- | CHANGELOG.rst | 4 | ||||
-rw-r--r-- | doc/api/rand.rst | 2 | ||||
-rw-r--r-- | src/OpenSSL/rand.py | 35 | ||||
-rw-r--r-- | tests/test_rand.py | 22 |
4 files changed, 3 insertions, 60 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ae9e359..62335a8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -12,7 +12,9 @@ The third digit is only for regressions. Backward-incompatible changes: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -*none* +- Removed the deprecated ``OpenSSL.rand.egd`` function. + Applications should prefer ``os.urandom()`` for random number generation. + `#630 <https://github.com/pyca/pyopenssl/pull/630>`_ Deprecations: diff --git a/doc/api/rand.rst b/doc/api/rand.rst index 83aec1e..47460a8 100644 --- a/doc/api/rand.rst +++ b/doc/api/rand.rst @@ -20,8 +20,6 @@ This module handles the OpenSSL pseudo random number generator (PRNG) and declar .. autofunction:: cleanup -.. autofunction:: egd(path[, bytes]) - .. autofunction:: load_file(filename[, bytes]) .. autofunction:: seed diff --git a/src/OpenSSL/rand.py b/src/OpenSSL/rand.py index 8f51ad8..09cf988 100644 --- a/src/OpenSSL/rand.py +++ b/src/OpenSSL/rand.py @@ -2,9 +2,6 @@ PRNG management routines, thin wrappers. """ -import os -import warnings - from functools import partial from six import integer_types as _integer_types @@ -113,38 +110,6 @@ def status(): return _lib.RAND_status() -def egd(path, bytes=_unspecified): - """ - Query the system random source and seed the PRNG. - - Does *not* actually query the EGD. - - .. deprecated:: 16.0.0 - EGD was only necessary for some commercial UNIX systems that all - reached their ends of life more than a decade ago. See - `pyca/cryptography#1636 - <https://github.com/pyca/cryptography/pull/1636>`_. - - :param path: Ignored. - :param bytes: (optional) The number of bytes to read, default is 255. - - :returns: ``len(bytes)`` or 255 if not specified. - """ - warnings.warn("OpenSSL.rand.egd() is deprecated as of 16.0.0.", - DeprecationWarning) - - if not isinstance(path, _builtin_bytes): - raise TypeError("path must be a byte string") - - if bytes is _unspecified: - bytes = 255 - elif not isinstance(bytes, int): - raise TypeError("bytes must be an integer") - - seed(os.urandom(bytes)) - return bytes - - def cleanup(): """ Erase the memory used by the PRNG. diff --git a/tests/test_rand.py b/tests/test_rand.py index ac3965b..bdd3af0 100644 --- a/tests/test_rand.py +++ b/tests/test_rand.py @@ -100,28 +100,6 @@ class TestRand(object): # entropy or not. assert rand.status() in (0, 1) - @pytest.mark.parametrize('args', [ - (b"foo", 255), - (b"foo",), - ]) - def test_egd_warning(self, args): - """ - Calling egd raises :exc:`DeprecationWarning`. - """ - pytest.deprecated_call(rand.egd, *args) - - @pytest.mark.parametrize('args', [ - (None, 255), - (b"foo", None), - ]) - def test_egd_wrong_args(self, args): - """ - `OpenSSL.rand.egd` raises `TypeError` if called with a non-`int` - or non-`str` argument. - """ - with pytest.raises(TypeError): - rand.egd(*args) - def test_cleanup(self): """ `OpenSSL.rand.cleanup` releases the memory used by the PRNG and |