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
标题: expose RAND_bytes() function of OpenSSL
类型: Stage:
Components: Library (Lib) Versions: Python 3.3
process
状态: closed Resolution: fixed
Dependencies: 后续:
分配给: 抄送列表: jcon, pitrou, python-dev, vstinner
优先级: normal 关键字: patch

Created on 2011-05-10 08:10 by vstinner, last changed 2022-04-11 14:57 by admin. This issue is now closed.

文件
文件名 上传时间 Description 编辑
ssl_rand_bytes.patch vstinner, 2011-05-11 20:52 review
Messages (7)
msg135688 - (view) Author: STINNER Victor (vstinner) * (Python committer) 日期: 2011-05-10 08:10
The _ssl module has RAND_add() RAND_status() and RAND_egd() functions, but not RAND_bytes(). I would be nice to be able to generate random bytes using RAND_bytes().

And maybe also RAND_pseudo_bytes()?

I will work on a patch, it's just a reminder.
msg135804 - (view) Author: STINNER Victor (vstinner) * (Python committer) 日期: 2011-05-11 20:52
ssl_rand.patch adds RAND_bytes() and RAND_pseudo_bytes() functions to the ssl module.

I moved /dev/urandom to /dev/urandom.xxx and /dev/random to /dev/random.xxx to test RAND_bytes() error path. In this case, RAND_pseudo_bytes() generates non-cryptographic pseudo-random bytes.

RAND_pseudo_bytes() returns a tuple (bytes, is_cryptographic).

In test_ssl, I used the assertion that RAND_pseudo_bytes() only generates cryptographic numbers if RAND_status() is 1. If the assertion is wrong, the test can be changed to just test the type of is_crytographic.

RAND_bytes() and RAND_pseudo_bytes() raise a SSLError on error using ERR_get_errno() as the error code, whereas other ssl functions uses a value of the py_ssl_error enum. I don't know if it is the good choise.
msg136728 - (view) Author: Roundup Robot (python-dev) (Python triager) 日期: 2011-05-24 10:05
New changeset 5c716437a83a by Victor Stinner in branch 'default':
Issue #12049: Add RAND_bytes() and RAND_pseudo_bytes() functions to the ssl
http://hg.python.org/cpython/rev/5c716437a83a
msg136785 - (view) Author: Roundup Robot (python-dev) (Python triager) 日期: 2011-05-24 19:32
New changeset ca92fa2fe5c9 by Victor Stinner in branch 'default':
Issue #12049: improve RAND_bytes() and RAND_pseudo_bytes() documentation
http://hg.python.org/cpython/rev/ca92fa2fe5c9
msg136832 - (view) Author: Roundup Robot (python-dev) (Python triager) 日期: 2011-05-25 09:15
New changeset 96a82c973224 by Victor Stinner in branch 'default':
Issue #12049: test_ssl now checks also that RAND_bytes() raises an error if
http://hg.python.org/cpython/rev/96a82c973224
msg136833 - (view) Author: Roundup Robot (python-dev) (Python triager) 日期: 2011-05-25 09:27
New changeset 178d367c9733 by Victor Stinner in branch 'default':
Issue #12049: Document errors cases of ssl.RAND_bytes() and
http://hg.python.org/cpython/rev/178d367c9733
msg136838 - (view) Author: Roundup Robot (python-dev) (Python triager) 日期: 2011-05-25 11:14
New changeset 195de3d10879 by Victor Stinner in branch 'default':
Issue #12049: cleanup the warning in the random module doc
http://hg.python.org/cpython/rev/195de3d10879
历史
日期 用户 动作 参数
2022-04-11 14:57:17admin修改github: 56258
2011-05-25 11:14:05python-dev修改消息: + msg136838
2011-05-25 09:27:43python-dev修改消息: + msg136833
2011-05-25 09:15:22python-dev修改消息: + msg136832
2011-05-24 19:32:50python-dev修改消息: + msg136785
2011-05-24 10:05:38vstinner修改状态: open -> closed
resolution: fixed
2011-05-24 10:05:20python-dev修改抄送: + python-dev
消息: + msg136728
2011-05-11 20:52:03vstinner修改文件: + ssl_rand_bytes.patch
keywords: + patch
消息: + msg135804
2011-05-10 19:41:08jcon修改抄送: + jcon
2011-05-10 08:10:02vstinner创建