Skip to content

Improve performance of ring::rand using getrandom() for 257-byte outputs #353

Closed

Description

@briansmith

Currently we use the fact that getrandom() will never return a partial result if the requested output is 256 bytes or less, as specified in the getrandom man page. In particular, if we need more than 256 bytes of output then issue multiple syscalls for (up to) 256 bytes. I wrote that code on the assumption that we'd never need more than 256 bytes of output in a performance-sensitive situation.

However, the new RSA blinding code from #283 often needs 257 bytes of output, so the assumption is now wrong. Therefore, we should change the code to ask for all the random bytes at once in the getrandom syscall, handling the case where the syscall returns only a partial result by looping.

Activity

  1. kimhyunkang commented on Nov 17, 2016

    @kimhyunkang
    Contributor

    I'm trying to start contributing to ring, and I'd like to take this.

  2. briansmith commented on Nov 17, 2016

    @briansmith
    OwnerAuthor

    I'm trying to start contributing to ring, and I'd like to take this.

    Awesome!

  3. briansmith commented on Dec 21, 2016

    @briansmith
    OwnerAuthor

    Done in #355.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions