This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ssl.RAND_add() should only accept bytes (not str)
Type: Stage:
Components: Library (Lib) Versions: Python 3.2
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, pitrou, vstinner
Priority: normal Keywords: patch

Created on 2010-05-16 21:31 by vstinner, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ssl_rand_add_bytes.patch vstinner, 2010-05-16 21:31
Messages (4)
msg105879 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-05-16 21:31
PySSL_RAND_add() uses PyArg_ParseTuple(args, "s#d:RAND_add", ...) and so converts implicitly str to bytes using UTF-8. I would prefer that this function only accepts bytes: the user will have to encode str to bytes *explicitly*.

Attached patch replace s# format by y# format.
msg105881 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-05-16 21:39
This function is here to add entropy to the random numbers generator.
the kind of data is not important, and no matter which encoding is used, this will not change the quality of the entropy.
msg105883 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-05-16 22:05
I think Amaury is right. You could add a test that bytes are also accepted, though.
msg105886 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-05-16 22:38
> the kind of data is not important, and no matter which encoding 
> is used, this will not change the quality of the entropy.

Ok, you are right :-)
History
Date User Action Args
2022-04-11 14:57:01adminsetgithub: 52983
2010-05-16 22:38:29vstinnersetstatus: open -> closed
resolution: not a bug
messages: + msg105886
2010-05-16 22:05:41pitrousetmessages: + msg105883
2010-05-16 21:40:19vstinnersetnosy: + pitrou
2010-05-16 21:39:41amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg105881
2010-05-16 21:31:23vstinnercreate