openssl/crypto/include/internal
Dr. Matthias St. Pierre 5bc6bcf82d DRBG: implement a get_nonce() callback
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: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5920)
2018-04-13 20:49:28 +02:00
..
__DECC_INCLUDE_EPILOGUE.H VMS: Copy DECC inclusion epi- and prologues to internals 2017-04-20 13:10:06 +02:00
__DECC_INCLUDE_PROLOGUE.H VMS: Copy DECC inclusion epi- and prologues to internals 2017-04-20 13:10:06 +02:00
aria.h Many spelling fixes/typo's corrected. 2017-11-11 19:03:10 -05:00
asn1_int.h Update copyright year 2018-03-20 13:08:46 +00:00
async.h Copyright consolidation 03/10 2016-05-17 14:24:17 -04:00
bn_conf.h.in Copyright consolidation: perl files 2016-04-20 09:45:40 -04:00
bn_dh.h DH named parameter support 2017-10-12 02:40:30 +01:00
bn_int.h Remove dead code in bn 2017-02-28 14:46:24 +00:00
bn_srp.h Copyright consolidation 05/10 2016-05-17 15:38:09 -04:00
chacha.h Copyright consolidation 05/10 2016-05-17 15:38:09 -04:00
cryptlib_int.h Update copyright year 2018-03-20 13:08:46 +00:00
ctype.h This has been added to avoid the situation where some host ctype.h functions 2017-08-22 09:45:25 +10:00
dso_conf.h.in Update copyright year 2018-04-03 13:57:12 +01:00
engine.h Add new /dev/crypto engine 2017-06-28 12:54:33 +02:00
err_int.h Check for errors allocating the error strings. 2016-07-20 19:20:53 +02:00
evp_int.h Add support for the SRP base64 alphabet 2018-04-13 09:37:38 +01:00
md32_common.h Remove email addresses from source code. 2017-10-13 10:06:59 -04:00
objects.h Copyright consolidation 05/10 2016-05-17 15:38:09 -04:00
poly1305.h Add support for Poly1305 in EVP_PKEY 2017-01-24 15:40:37 +01:00
rand_int.h DRBG: implement a get_nonce() callback 2018-04-13 20:49:28 +02:00
sha.h SHA512/224 and SHA512/256 2018-01-24 07:09:46 +10:00
siphash.h Add support for parameterized SipHash 2017-02-01 14:14:36 -05:00
sm3.h SM3: restructure to EVP internal and update doc to right location 2017-11-06 07:21:15 +08:00
sm4.h SM4: Add SM4 block cipher to EVP 2017-10-31 15:19:14 +10:00
store.h Add the STORE module 2017-06-29 11:55:31 +02:00
store_int.h Add internal functions to fetch PEM data from an opened BIO 2017-06-29 19:25:39 +02:00
x509_int.h Add support for custom signature parameters 2017-04-25 22:12:34 +01:00