Skip to content
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

ssl.RAND_add() should only accept bytes (not str) #52983

Closed
vstinner opened this issue May 16, 2010 · 4 comments
Closed

ssl.RAND_add() should only accept bytes (not str) #52983

vstinner opened this issue May 16, 2010 · 4 comments
Labels
stdlib Python modules in the Lib dir

Comments

@vstinner
Copy link
Member

BPO 8737
Nosy @amauryfa, @pitrou, @vstinner
Files
  • ssl_rand_add_bytes.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2010-05-16.22:38:29.273>
    created_at = <Date 2010-05-16.21:31:23.544>
    labels = ['invalid', 'library']
    title = 'ssl.RAND_add() should only accept bytes (not str)'
    updated_at = <Date 2010-05-16.22:38:29.271>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2010-05-16.22:38:29.271>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-05-16.22:38:29.273>
    closer = 'vstinner'
    components = ['Library (Lib)']
    creation = <Date 2010-05-16.21:31:23.544>
    creator = 'vstinner'
    dependencies = []
    files = ['17371']
    hgrepos = []
    issue_num = 8737
    keywords = ['patch']
    message_count = 4.0
    messages = ['105879', '105881', '105883', '105886']
    nosy_count = 3.0
    nosy_names = ['amaury.forgeotdarc', 'pitrou', 'vstinner']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue8737'
    versions = ['Python 3.2']

    @vstinner
    Copy link
    Member Author

    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.

    @vstinner vstinner added the stdlib Python modules in the Lib dir label May 16, 2010
    @amauryfa
    Copy link
    Member

    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.

    @pitrou
    Copy link
    Member

    pitrou commented May 16, 2010

    I think Amaury is right. You could add a test that bytes are also accepted, though.

    @vstinner
    Copy link
    Member Author

    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 :-)

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants