1. 10 9月, 2019 1 次提交
    • D
      drbg: ensure fork-safety without using a pthread_atfork handler · 1b0fe00e
      Dr. Matthias St. Pierre 提交于
      When the new OpenSSL CSPRNG was introduced in version 1.1.1,
      it was announced in the release notes that it would be fork-safe,
      which the old CSPRNG hadn't been.
      
      The fork-safety was implemented using a fork count, which was
      incremented by a pthread_atfork handler. Initially, this handler
      was enabled by default. Unfortunately, the default behaviour
      had to be changed for other reasons in commit b5319bdb, so
      the new OpenSSL CSPRNG failed to keep its promise.
      
      This commit restores the fork-safety using a different approach.
      It replaces the fork count by a fork id, which coincides with
      the process id on UNIX-like operating systems and is zero on other
      operating systems. It is used to detect when an automatic reseed
      after a fork is necessary.
      
      To prevent a future regression, it also adds a test to verify that
      the child reseeds after fork.
      
      CVE-2019-1549
      Reviewed-by: NPaul Dale <paul.dale@oracle.com>
      Reviewed-by: NMatt Caswell <matt@openssl.org>
      (Merged from https://github.com/openssl/openssl/pull/9802)
      1b0fe00e
  2. 01 8月, 2019 1 次提交
  3. 23 7月, 2019 1 次提交
  4. 28 5月, 2019 1 次提交
  5. 22 3月, 2019 1 次提交
  6. 08 11月, 2018 1 次提交
  7. 07 11月, 2018 2 次提交
  8. 06 11月, 2018 4 次提交
  9. 31 10月, 2018 1 次提交
  10. 29 10月, 2018 2 次提交
  11. 27 10月, 2018 3 次提交
    • B
      Fix data race in RAND_DRBG_generate · 1f985276
      Bernd Edlinger 提交于
      Fixes #7394
      Reviewed-by: NPaul Dale <paul.dale@oracle.com>
      (Merged from https://github.com/openssl/openssl/pull/7399)
      
      (cherry picked from commit a83dc59afa2e0207180d7218efed19b20d48de95)
      1f985276
    • D
      RAND_add()/RAND_seed(): fix failure on short input or low entropy · d597a9a8
      Dr. Matthias St. Pierre 提交于
      Commit 5b4cb385c18a (#7382) introduced a bug which had the effect
      that RAND_add()/RAND_seed() failed for buffer sizes less than
      32 bytes. The reason was that now the added random data was used
      exlusively as entropy source for reseeding. When the random input
      was too short or contained not enough entropy, the DRBG failed
      without querying the available entropy sources.
      
      This commit makes drbg_add() act smarter: it checks the entropy
      requirements explicitely. If the random input fails this check,
      it won't be added as entropy input, but only as additional data.
      More precisely, the behaviour depends on whether an os entropy
      source was configured (which is the default on most os):
      
      - If an os entropy source is avaible then we declare the buffer
        content as additional data by setting randomness to zero and
        trigger a regular   reseeding.
      
      - If no os entropy source is available, a reseeding will fail
        inevitably. So drbg_add() uses a trick to mix the buffer contents
        into the DRBG state without forcing a reseeding: it generates a
        dummy random byte, using the buffer content as additional data.
      
      Related-to: #7449
      Reviewed-by: NPaul Dale <paul.dale@oracle.com>
      (Merged from https://github.com/openssl/openssl/pull/7456)
      
      (cherry picked from commit 8817215d5c52a76f2b184b624bde4df8556dee6d)
      d597a9a8
    • D
      Backport some DRBG renamings and typo fixes · 35a34508
      Dr. Matthias St. Pierre 提交于
      In commit 8bf366519661 some renamings andd typo fixes were made
      while adding back the DRBG-HMAC and DRBG-HASH implementation.
      Since the commit could not be backported, a lot of unnecessary
      differences between master and 1.1.1 were introduced.
      
      These differences result in tiresome merge conflicts when
      cherry-picking. To minimize these merge-conflicts, this patch
      ports all 'non-feature' changes of commit 8bf366519661
      (e.g., renamings of private variables, fixes of typographical
      errors, comment changes) manually back to 1.1.1.
      
      The commits a83dc59afa2e (#7399) and 8817215d5c52 (#7456)
      failed to cherry-pick previously to 1.1.1, with this patch
      they both cherry-pick without conflicts.
      Reviewed-by: NRichard Levitte <levitte@openssl.org>
      Reviewed-by: NBernd Edlinger <bernd.edlinger@hotmail.de>
      (Merged from https://github.com/openssl/openssl/pull/7505)
      35a34508
  12. 17 10月, 2018 1 次提交
    • D
      DRBG: fix reseeding via RAND_add()/RAND_seed() with large input · dbf0a496
      Dr. Matthias St. Pierre 提交于
      In pull request #4328 the seeding of the DRBG via RAND_add()/RAND_seed()
      was implemented by buffering the data in a random pool where it is
      picked up later by the rand_drbg_get_entropy() callback. This buffer
      was limited to the size of 4096 bytes.
      
      When a larger input was added via RAND_add() or RAND_seed() to the DRBG,
      the reseeding failed, but the error returned by the DRBG was ignored
      by the two calling functions, which both don't return an error code.
      As a consequence, the data provided by the application was effectively
      ignored.
      
      This commit fixes the problem by a more efficient implementation which
      does not copy the data in memory and by raising the buffer the size limit
      to INT32_MAX (2 gigabytes). This is less than the NIST limit of 2^35 bits
      but it was chosen intentionally to avoid platform dependent problems
      like integer sizes and/or signed/unsigned conversion.
      
      Additionally, the DRBG is now less permissive on errors: In addition to
      pushing a message to the openssl error stack, it enters the error state,
      which forces a reinstantiation on next call.
      
      Thanks go to Dr. Falko Strenzke for reporting this issue to the
      openssl-security mailing list. After internal discussion the issue
      has been categorized as not being security relevant, because the DRBG
      reseeds automatically and is fully functional even without additional
      randomness provided by the application.
      
      Fixes #7381
      Reviewed-by: NPaul Dale <paul.dale@oracle.com>
      (Merged from https://github.com/openssl/openssl/pull/7382)
      
      (cherry picked from commit 3064b55134434a0b2850f07eff57120f35bb269a)
      dbf0a496
  13. 10 10月, 2018 1 次提交
  14. 13 9月, 2018 1 次提交
  15. 11 5月, 2018 1 次提交
  16. 29 4月, 2018 1 次提交
  17. 27 4月, 2018 1 次提交
  18. 17 4月, 2018 1 次提交
  19. 14 4月, 2018 1 次提交
    • D
      DRBG: implement a get_nonce() callback · 5bc6bcf8
      Dr. Matthias St. Pierre 提交于
      Fixes #5849
      
      In pull request #5503 a fallback was added which adds a random nonce of
      security_strength/2 bits if no nonce callback is provided. This change raised
      the entropy requirements form 256 to 384 bit, which can cause problems on some
      platforms (e.g. VMS, see issue #5849).
      
      The requirements for the nonce are given in section 8.6.7 of NIST SP 800-90Ar1:
      
        A nonce may be required in the construction of a seed during instantiation
        in order to provide a security cushion to block certain attacks.
        The nonce shall be either:
      
        a) A value with at least (security_strength/2) bits of entropy, or
      
        b) A value that is expected to repeat no more often than a
           (security_strength/2)-bit random string would be expected to repeat.
      
        Each nonce shall be unique to the cryptographic module in which instantiation
        is performed, but need not be secret. When used, the nonce shall be considered
        to be a critical security parameter.
      
      This commit implements a nonce of type b) in order to lower the entropy
      requirements during instantiation back to 256 bits.
      
      The formulation "shall be unique to the cryptographic module" above implies
      that the nonce needs to be unique among (with high probability) among all
      DRBG instances in "space" and "time". We try to achieve this goal by creating a
      nonce of the following form
      
          nonce = app-specific-data || high-resolution-utc-timestamp || counter
      
      Where || denotes concatenation. The application specific data can be something
      like the process or group id of the application. A utc timestamp is used because
      it increases monotonically, provided the system time is synchronized. This approach
      may not be perfect yet for a FIPS evaluation, but it should be good enough for the
      moment.
      
      This commit also harmonizes the implementation of the get_nonce() and the
      get_additional_data() callbacks and moves the platform specific parts from
      rand_lib.c into rand_unix.c, rand_win.c, and rand_vms.c.
      Reviewed-by: NRichard Levitte <levitte@openssl.org>
      (Merged from https://github.com/openssl/openssl/pull/5920)
      5bc6bcf8
  20. 02 4月, 2018 1 次提交
  21. 30 3月, 2018 1 次提交
  22. 19 3月, 2018 1 次提交
  23. 17 3月, 2018 3 次提交
  24. 16 3月, 2018 1 次提交
  25. 10 3月, 2018 1 次提交
    • D
      RAND_DRBG: add a function for setting the reseeding defaults · 4917e911
      Dr. Matthias St. Pierre 提交于
      The introduction of thread local public and private DRBG instances (#5547)
      makes it very cumbersome to change the reseeding (time) intervals for
      those instances. This commit provides a function to set the default
      values for all subsequently created DRBG instances.
      
       int RAND_DRBG_set_reseed_defaults(
                                         unsigned int master_reseed_interval,
                                         unsigned int slave_reseed_interval,
                                         time_t master_reseed_time_interval,
                                         time_t slave_reseed_time_interval
                                         );
      
      The function is intended only to be used during application initialization,
      before any threads are created and before any random bytes are generated.
      Reviewed-by: NRich Salz <rsalz@openssl.org>
      (Merged from https://github.com/openssl/openssl/pull/5576)
      4917e911
  26. 07 3月, 2018 1 次提交
  27. 15 2月, 2018 1 次提交
    • D
      DRBG: make locking api truly private · 812b1537
      Dr. Matthias St. Pierre 提交于
      In PR #5295 it was decided that the locking api should remain private
      and used only inside libcrypto. However, the locking functions were added
      back to `libcrypto.num` by `mkdef.pl`, because the function prototypes
      were still listed in `internal/rand.h`. (This header contains functions
      which are internal, but shared between libcrypto and libssl.)
      
      This commit moves the prototypes to `rand_lcl.h` and changes the names
      to lowercase, following the convention therein. It also corrects an
      outdated documenting comment.
      Reviewed-by: NRichard Levitte <levitte@openssl.org>
      (Merged from https://github.com/openssl/openssl/pull/5375)
      812b1537
  28. 14 2月, 2018 3 次提交
    • D
      DRBG: make the derivation function the default for ctr_drbg · 8164d91d
      Dr. Matthias St. Pierre 提交于
      The NIST standard presents two alternative ways for seeding the
      CTR DRBG, depending on whether a derivation function is used or not.
      In Section 10.2.1 of NIST SP800-90Ar1 the following is assessed:
      
        The use of the derivation function is optional if either an
        approved RBG or an entropy source provides full entropy output
        when entropy input is requested by the DRBG mechanism.
        Otherwise, the derivation function shall be used.
      
      Since the OpenSSL DRBG supports being reseeded from low entropy random
      sources (using RAND_POOL), the use of a derivation function is mandatory.
      For that reason we change the default and replace the opt-in flag
      RAND_DRBG_FLAG_CTR_USE_DF with an opt-out flag RAND_DRBG_FLAG_CTR_NO_DF.
      This change simplifies the RAND_DRBG_new() calls.
      Reviewed-by: NRich Salz <rsalz@openssl.org>
      (Merged from https://github.com/openssl/openssl/pull/5294)
      8164d91d
    • D
      DRBG: unify initialization and cleanup code · 4f9dabbf
      Dr. Matthias St. Pierre 提交于
      The functions drbg_setup() and drbg_cleanup() used to duplicate a lot of
      code from RAND_DRBG_new() and RAND_DRBG_free(). This duplication has been
      removed, which simplifies drbg_setup() and makes drbg_cleanup() obsolete.
      Reviewed-by: NRich Salz <rsalz@openssl.org>
      (Merged from https://github.com/openssl/openssl/pull/5294)
      4f9dabbf
    • D
      DRBG: add locking api · 3ce1c27b
      Dr. Matthias St. Pierre 提交于
      This commit adds three new accessors to the internal DRBG lock
      
         int RAND_DRBG_lock(RAND_DRBG *drbg)
         int RAND_DRBG_unlock(RAND_DRBG *drbg)
         int RAND_DRBG_enable_locking(RAND_DRBG *drbg)
      
      The three shared DRBGs are intended to be used concurrently, so they
      have locking enabled by default. It is the callers responsibility to
      guard access to the shared DRBGs by calls to RAND_DRBG_lock() and
      RAND_DRBG_unlock().
      
      All other DRBG instances don't have locking enabled by default, because
      they are intendended to be used by a single thread. If it is desired,
      locking can be enabled by using RAND_DRBG_enable_locking().
      Reviewed-by: NRich Salz <rsalz@openssl.org>
      (Merged from https://github.com/openssl/openssl/pull/5294)
      3ce1c27b
  29. 06 2月, 2018 1 次提交