Skip to content

Commit

Permalink
Add personalization string callback to match description
Browse files Browse the repository at this point in the history
  • Loading branch information
torben-hansen committed Nov 8, 2024
1 parent 547cfcd commit 6575401
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crypto/fipsmodule/rand/entropy/entropy_sources.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ static int entropy_get_prediction_resistance(
return 1;
}

static int entropy_get_personalization_string(
const struct entropy_source_t *entropy_source,
uint8_t personalization_string[CTR_DRBG_ENTROPY_LEN]) {
CRYPTO_sysrand(personalization_string, CTR_DRBG_ENTROPY_LEN);
return 1;
}

// - Tree DRBG with Jitter Entropy as root for seeding.
// - OS as personalization string source.
// - If run-time is on an Intel CPU and it supports rdrand, use it as a source
Expand All @@ -29,7 +36,7 @@ DEFINE_LOCAL_DATA(struct entropy_source_methods, tree_jitter_entropy_source_meth
out->zeroize_thread = tree_jitter_zeroize_thread_drbg;
out->free_thread = tree_jitter_free_thread_drbg;
out->get_seed = tree_jitter_get_seed;
out->get_personalization_string = NULL;
out->get_personalization_string = entropy_get_personalization_string;
if (have_fast_rdrand() == 1) {
out->get_prediction_resistance = entropy_get_prediction_resistance;
} else {
Expand Down

0 comments on commit 6575401

Please sign in to comment.