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

Don't get a lock when querying the parent reseed_count (alternative version) #20970

Closed
wants to merge 3 commits into from

Commits on May 15, 2023

  1. Refactor the DRBG implementations to manage locking themselves

    Previously the EVP layer would call lock and unlock functions on the
    underlying DRBG implementation to say when a lock should be acquired and
    released. This gives the DRBG implementation no say as to what kind of
    lock should obtained (e.g. read/write) or even whether a lock is actually
    needed or not.
    
    In reality we know whether a DRBG is supposed to be in locking mode or
    not because the "enable_locking()" function will have been called if
    locks should be used. Therefore we re-interpret the lock and unlock
    functions as "hints" from the EVP layer which we ignore. Instead we
    acquire locks only when we need them. By knowing the context we can obtain
    either a read or a write lock as appropriate.
    
    This may mean that in some rare cases we acquire the locks more than once
    for a single EVP call, if the EVP call makes several calls to the underlying
    DRBG. But in practice almost all EVP calls only make one such call.
    EVP_RAND_generate() is an example of a call where multiple DRBG calls may
    be made. One of these gets the "max_request" parameter (which is constant
    for all of our own DRBGs) and it may make several calls to the DRBG generate
    call - but only if the requested size is very large which will rarely be
    the case.
    
    Partially fixes openssl#20286
    mattcaswell committed May 15, 2023
    Configuration menu
    Copy the full SHA
    7265395 View commit details
    Browse the repository at this point in the history
  2. Enable obtaining certain DRBG params without a lock

    Even if a DRBG has locking enabled on it, there are certain parameters
    which are still safe to obtain even without a lock. The max_request
    value is constant for all our DRBGs. The reseed_counter does not matter
    if we get it wrong - so it is safe to avoid the lock. So if all we are
    reading are those parameters then we take no lock at all.
    
    Partially fixes openssl#20286
    mattcaswell committed May 15, 2023
    Configuration menu
    Copy the full SHA
    e7c716e View commit details
    Browse the repository at this point in the history

Commits on May 31, 2023

  1. Configuration menu
    Copy the full SHA
    cf1211d View commit details
    Browse the repository at this point in the history