1
0
mirror of https://github.com/janet-lang/janet synced 2025-12-04 15:48:09 +00:00

Add JANET_HASHSEED environment variable.

This commit is contained in:
Calvin Rose
2020-08-03 20:53:32 -05:00
parent f200bd9594
commit 76cfbde933
6 changed files with 35 additions and 9 deletions

11
jpm
View File

@@ -537,8 +537,15 @@
int main(int argc, const char **argv) {
#if defined(JANET_PRF)
uint8_t hash_key[JANET_HASH_KEY_SIZE];
if (janet_cryptorand(hash_key, JANET_HASH_KEY_SIZE) != 0) {
uint8_t hash_key[JANET_HASH_KEY_SIZE + 1];
#ifdef JANET_REDUCED_OS
char *envvar = NULL;
#else
char *envvar = getenv("JANET_HASHSEED");
#endif
if (NULL != envvar) {
strncpy((char *) hash_key, envvar, sizeof(hash_key) - 1);
} else if (janet_cryptorand(hash_key, JANET_HASH_KEY_SIZE) != 0) {
fputs("unable to initialize janet PRF hash function.\n", stderr);
return 1;
}