From 825779e880cae2d43679b38ba67b135d4bac994b Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sat, 27 Jul 2024 09:32:58 -0400 Subject: [PATCH] Deprecate the rand module refs #1321 --- CHANGELOG.rst | 15 +++++++++++++++ src/OpenSSL/rand.py | 8 ++++++++ 2 files changed, 23 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8a25388cd..61420ee0e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,21 @@ Changelog Versions are year-based with a strict backward-compatibility policy. The third digit is only for regressions. +24.3.0 (UNRELEASED) +------------------- + +Backward-incompatible changes: +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Deprecations: +^^^^^^^^^^^^^ + +- Deprecated ``OpenSSL.rand`` - callers should use ``os.urandom()`` instead. + +Changes: +^^^^^^^^ + + 24.2.1 (2024-07-20) ------------------- diff --git a/src/OpenSSL/rand.py b/src/OpenSSL/rand.py index a4aa7210d..0a9fac6f9 100644 --- a/src/OpenSSL/rand.py +++ b/src/OpenSSL/rand.py @@ -2,8 +2,16 @@ PRNG management routines, thin wrappers. """ +import warnings + from OpenSSL._util import lib as _lib +warnings.warn( + "OpenSSL.rand is deprecated - you should use os.urandom instead", + DeprecationWarning, + stacklevel=3, +) + def add(buffer: bytes, entropy: int) -> None: """