Skip to content

Commit e223da4

Browse files
authored
Merge pull request #8922 from JacobBarthelmeh/rng
altering macro guards and test case for RNG test on alternate builds
2 parents 5c9ad35 + 6cf3b51 commit e223da4

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

src/ssl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25515,7 +25515,7 @@ static int wolfSSL_RAND_InitMutex(void)
2551525515
#ifdef OPENSSL_EXTRA
2551625516

2551725517
#if defined(HAVE_GETPID) && !defined(WOLFSSL_NO_GETPID) && \
25518-
((defined(HAVE_FIPS) && FIPS_VERSION3_LT(6,0,0)) || defined(HAVE_SELFTEST))
25518+
((defined(HAVE_FIPS) && FIPS_VERSION3_LE(6,0,0)) || defined(HAVE_SELFTEST))
2551925519
/* In older FIPS bundles add check for reseed here since it does not exist in
2552025520
* the older random.c certified files. */
2552125521
static pid_t currentRandPid = 0;
@@ -25534,7 +25534,7 @@ int wolfSSL_RAND_Init(void)
2553425534
ret = wc_InitRng(&globalRNG);
2553525535
if (ret == 0) {
2553625536
#if defined(HAVE_GETPID) && !defined(WOLFSSL_NO_GETPID) && \
25537-
((defined(HAVE_FIPS) && FIPS_VERSION3_LT(6,0,0)) || \
25537+
((defined(HAVE_FIPS) && FIPS_VERSION3_LE(6,0,0)) || \
2553825538
defined(HAVE_SELFTEST))
2553925539

2554025540
currentRandPid = getpid();
@@ -26017,7 +26017,7 @@ int wolfSSL_RAND_bytes(unsigned char* buf, int num)
2601726017
*/
2601826018
if (initGlobalRNG) {
2601926019
#if defined(HAVE_GETPID) && !defined(WOLFSSL_NO_GETPID) && \
26020-
((defined(HAVE_FIPS) && FIPS_VERSION3_LT(6,0,0)) || \
26020+
((defined(HAVE_FIPS) && FIPS_VERSION3_LE(6,0,0)) || \
2602126021
defined(HAVE_SELFTEST))
2602226022
pid_t p;
2602326023

tests/api.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33199,7 +33199,8 @@ static int test_wolfSSL_RAND_bytes(void)
3319933199
const int size4 = RNG_MAX_BLOCK_LEN * 4; /* in bytes */
3320033200
int max_bufsize;
3320133201
byte *my_buf = NULL;
33202-
#if defined(HAVE_GETPID)
33202+
#if defined(OPENSSL_EXTRA) && defined(HAVE_GETPID) && !defined(__MINGW64__) && \
33203+
!defined(__MINGW32__)
3320333204
byte seed[16] = {0};
3320433205
byte randbuf[8] = {0};
3320533206
int pipefds[2] = {0};
@@ -33225,7 +33226,8 @@ static int test_wolfSSL_RAND_bytes(void)
3322533226
ExpectIntEQ(RAND_bytes(my_buf, size4), 1);
3322633227
XFREE(my_buf, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);
3322733228

33228-
#if defined(OPENSSL_EXTRA) && defined(HAVE_GETPID)
33229+
#if defined(OPENSSL_EXTRA) && defined(HAVE_GETPID) && !defined(__MINGW64__) && \
33230+
!defined(__MINGW32__)
3322933231
XMEMSET(seed, 0, sizeof(seed));
3323033232
RAND_cleanup();
3323133233

@@ -33247,17 +33249,17 @@ static int test_wolfSSL_RAND_bytes(void)
3324733249
}
3324833250
else {
3324933251
/* Parent process. */
33250-
word64 childrand64 = 0;
33252+
byte childrand[8] = {0};
3325133253
int waitstatus = 0;
3325233254

3325333255
close(pipefds[1]);
3325433256
ExpectIntEQ(RAND_bytes(randbuf, sizeof(randbuf)), 1);
33255-
ExpectIntEQ(read(pipefds[0], &childrand64, sizeof(childrand64)),
33256-
sizeof(childrand64));
33257+
ExpectIntEQ(read(pipefds[0], childrand, sizeof(childrand)),
33258+
sizeof(childrand));
3325733259
#ifdef WOLFSSL_NO_GETPID
33258-
ExpectBufEQ(randbuf, &childrand64, sizeof(randbuf));
33260+
ExpectBufEQ(randbuf, childrand, sizeof(randbuf));
3325933261
#else
33260-
ExpectBufNE(randbuf, &childrand64, sizeof(randbuf));
33262+
ExpectBufNE(randbuf, childrand, sizeof(randbuf));
3326133263
#endif
3326233264
close(pipefds[0]);
3326333265
waitpid(pid, &waitstatus, 0);

0 commit comments

Comments
 (0)