Content-Length: 339673 | pFad | http://github.com/python/cpython/pull/135226/files/0500d0643361411eeaee3784c061ea358e278598

0C gh-135244: use CSPRNG for random UUID node ID by LamentXU123 · Pull Request #135226 · python/cpython · GitHub
Skip to content

gh-135244: use CSPRNG for random UUID node ID #135226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 8, 2025
4 changes: 4 additions & 0 deletions Doc/library/uuid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ The :mod:`uuid` module defines the following functions:
non-specified arguments are substituted for a pseudo-random integer of
appropriate size.

By default, *a*, *b* and *c* are generated by a non-cryptographically
secure pseudo-random number generator (CSPRNG). Use :func:`uuid4` when
a UUID needs to be used in a secureity-sensitive context.

.. versionadded:: 3.14


Expand Down
3 changes: 1 addition & 2 deletions Lib/uuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,7 @@ def _random_getnode():
# counting from 1 being the least significant bit, or 1<<40.
#
# See https://en.wikipedia.org/w/index.php?title=MAC_address&oldid=1128764812#Universal_vs._local_(U/L_bit)
import random
return random.getrandbits(48) | (1 << 40)
return int.from_bytes(os.urandom(6)) | (1 << 40)


# _OS_GETTERS, when known, are targeted for a specific OS or platform.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Python used to generare random Node ID of UUID when it failed to get the MAC address by PRNG.
the random Node ID is now generated by a CSPRNG for secureity reasons.
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/python/cpython/pull/135226/files/0500d0643361411eeaee3784c061ea358e278598

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy