detect rng seed strength at runtime based on algorithm not compile time based on platform features
This commit is contained in:
@@ -220,6 +220,7 @@ E NEARDATA boolean mrg_to_wielded;
|
||||
E NEARDATA boolean defer_see_monsters;
|
||||
|
||||
E NEARDATA boolean in_steed_dismounting;
|
||||
E NEARDATA boolean has_strong_rngseed;
|
||||
|
||||
E const int shield_static[];
|
||||
|
||||
|
||||
@@ -120,6 +120,7 @@ NEARDATA boolean mrg_to_wielded = FALSE;
|
||||
/* weapon picked is merged with wielded one */
|
||||
|
||||
NEARDATA boolean in_steed_dismounting = FALSE;
|
||||
NEARDATA boolean has_strong_rngseed = FALSE;
|
||||
|
||||
NEARDATA coord bhitpos = DUMMY;
|
||||
NEARDATA coord doors[DOORMAX] = { DUMMY };
|
||||
|
||||
@@ -899,8 +899,10 @@ init_random()
|
||||
void
|
||||
reseed_random()
|
||||
{
|
||||
/* reseed */
|
||||
init_random();
|
||||
/* only reseed if we are certain that the seed generation is unguessable
|
||||
* by the players. */
|
||||
if (has_strong_rngseed)
|
||||
init_random();
|
||||
}
|
||||
|
||||
time_t
|
||||
|
||||
@@ -776,6 +776,7 @@ sys_random_seed()
|
||||
fptr = fopen(DEV_RANDOM, "r");
|
||||
if (fptr) {
|
||||
fread(&seed, sizeof(long), 1, fptr);
|
||||
has_strong_rngseed = TRUE;
|
||||
}
|
||||
fclose(fptr);
|
||||
#else
|
||||
|
||||
@@ -708,6 +708,7 @@ sys_random_seed(VOID_ARGS)
|
||||
(ULONG) sizeof ourseed, 0);
|
||||
if (status == STATUS_SUCCESS) {
|
||||
BCryptCloseAlgorithmProvider(hRa,0);
|
||||
has_strong_rngseed = TRUE;
|
||||
Plan_B = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user