b91ce5d4d5
* bmo#1910071 - Copy original corpus to heap-allocated buffer * bmo#1910079 - Fix min ssl version for DTLS client fuzzer * bmo#1908990 - Remove OS2 support just like we did on NSPR * bmo#1910605 - clang-format NSS improvements * bmo#1902078 - Adding basicutil.h to use HexString2SECItem function * bmo#1908990 - removing dirent.c from build * bmo#1902078 - Allow handing in keymaterial to shlibsign to make the output reproducible * bmo#1908990 - remove nec4.3, sunos4, riscos and SNI references * bmo#1908990 - remove other old OS (BSDI, old HP UX, NCR, openunix, sco, unixware or reliantUnix * bmo#1908990 - remove mentions of WIN95 * bmo#1908990 - remove mentions of WIN16 * bmo#1913750 - More explicit directory naming * bmo#1913755 - Add more options to TLS server fuzz target * bmo#1913675 - Add more options to TLS client fuzz target * bmo#1835240 - Use OSS-Fuzz corpus in NSS CI * bmo#1908012 - set nssckbi version number to 2.70. * bmo#1914499 - Remove Email Trust bit from ACCVRAIZ1 root cert. * bmo#1908009 - Remove Email Trust bit from certSIGN ROOT CA. * bmo#1908006 - Add Cybertrust Japan Roots to NSS. * bmo#1908004 - Add Taiwan CA Roots to NSS. * bmo#1911354 - remove search by decoded serial in nssToken_FindCertificateByIssuerAndSerialNumber * bmo#1913132 - Fix tstclnt CI build failure * bmo#1913047 - vfyserv: ensure peer cert chain is in db for CERT_VerifyCertificateNow * bmo#1912427 - Enable all supported protocol versions for UDP * bmo#1910361 - Actually use random PSK hash type OBS-URL: https://build.opensuse.org/package/show/mozilla:Factory/mozilla-nss?expand=0&rev=457
112 lines
3.1 KiB
Diff
112 lines
3.1 KiB
Diff
Index: nss/coreconf/Linux.mk
|
|
===================================================================
|
|
--- nss.orig/coreconf/Linux.mk
|
|
+++ nss/coreconf/Linux.mk
|
|
@@ -136,7 +136,7 @@ OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLA
|
|
ifeq ($(KERNEL),Linux)
|
|
OS_CFLAGS += -DLINUX -Dlinux
|
|
endif
|
|
-OS_LIBS = $(OS_PTHREAD) -ldl -lc
|
|
+OS_LIBS = $(OS_PTHREAD) -ldl -lc -ljitterentropy
|
|
|
|
ifeq ($(OS_TARGET),Android)
|
|
OS_LIBS += -llog
|
|
Index: nss/lib/freebl/drbg.c
|
|
===================================================================
|
|
--- nss.orig/lib/freebl/drbg.c
|
|
+++ nss/lib/freebl/drbg.c
|
|
@@ -6,6 +6,8 @@
|
|
#include "stubs.h"
|
|
#endif
|
|
|
|
+#include <jitterentropy.h>
|
|
+
|
|
#include <unistd.h>
|
|
|
|
#include "prerror.h"
|
|
@@ -107,6 +109,45 @@ typedef struct RNGContextStr RNGContext;
|
|
static RNGContext *globalrng = NULL;
|
|
static RNGContext theGlobalRng;
|
|
|
|
+/* Jitterentropy */
|
|
+#define JITTER_FLAGS JENT_FORCE_FIPS
|
|
+static struct rand_data *jitter;
|
|
+
|
|
+static ssize_t
|
|
+FIPS_jent_get_entropy (void *dest, ssize_t len)
|
|
+{
|
|
+ int result = -1;
|
|
+
|
|
+ /* Ensure that the jitterentropy generator is initialized */
|
|
+
|
|
+ if (!jitter)
|
|
+ {
|
|
+ if (jent_entropy_init_ex (1, JITTER_FLAGS))
|
|
+ goto out;
|
|
+
|
|
+ jitter = jent_entropy_collector_alloc (1, JITTER_FLAGS);
|
|
+ if (!jitter)
|
|
+ goto out;
|
|
+ }
|
|
+
|
|
+ /* Get some entropy */
|
|
+
|
|
+ result = jent_read_entropy_safe (&jitter, dest, len);
|
|
+
|
|
+out:
|
|
+ return result;
|
|
+}
|
|
+
|
|
+static void
|
|
+FIPS_jent_deinit (void)
|
|
+{
|
|
+ if (jitter)
|
|
+ {
|
|
+ jent_entropy_collector_free (jitter);
|
|
+ jitter = NULL;
|
|
+ }
|
|
+}
|
|
+
|
|
/*
|
|
* The next several functions are derived from the NIST SP 800-90
|
|
* spec. In these functions, an attempt was made to use names consistent
|
|
@@ -180,7 +221,7 @@ static PRCallOnceType coRNGInitEntropy;
|
|
static PRStatus
|
|
prng_initEntropy(void)
|
|
{
|
|
- size_t length;
|
|
+ ssize_t length;
|
|
PRUint8 block[PRNG_ENTROPY_BLOCK_SIZE];
|
|
SHA256Context ctx;
|
|
|
|
@@ -203,8 +244,8 @@ prng_initEntropy(void)
|
|
/* For FIPS 140-2 4.9.2 continuous random number generator test,
|
|
* fetch the initial entropy from the system RNG and keep it for
|
|
* later comparison. */
|
|
- length = RNG_SystemRNG(block, sizeof(block));
|
|
- if (length == 0) {
|
|
+ length = FIPS_jent_get_entropy(block, sizeof(block));
|
|
+ if (length < 1) {
|
|
coRNGInitEntropy.status = PR_FAILURE;
|
|
__sync_synchronize ();
|
|
coRNGInitEntropy.initialized = 1;
|
|
@@ -244,8 +285,8 @@ prng_getEntropy(PRUint8 *buffer, size_t
|
|
* iteratively fetch fixed sized blocks from the system and
|
|
* compare consecutive blocks. */
|
|
while (total < requestLength) {
|
|
- size_t length = RNG_SystemRNG(block, sizeof(block));
|
|
- if (length == 0) {
|
|
+ ssize_t length = FIPS_jent_get_entropy(block, sizeof(block));
|
|
+ if (length < 1) {
|
|
rv = SECFailure; /* error is already set */
|
|
goto out;
|
|
}
|
|
@@ -792,6 +833,7 @@ RNG_RNGShutdown(void)
|
|
/* clear */
|
|
prng_freeRNGContext(globalrng);
|
|
globalrng = NULL;
|
|
+ FIPS_jent_deinit ();
|
|
/* reset the callonce struct to allow a new call to RNG_RNGInit() */
|
|
coRNGInit = pristineCallOnce;
|
|
}
|