1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-25 17:57:17 +00:00

Merge pull request #259 from andrewchambers/futureproofhash

Make hash api more future proof.
This commit is contained in:
Calvin Rose 2020-01-18 09:45:47 -06:00 committed by GitHub
commit bbd7355313
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -200,9 +200,9 @@ static uint32_t halfsiphash(const uint8_t *in, const size_t inlen, const uint8_t
} }
/* end of siphash */ /* end of siphash */
static uint8_t hash_key[16] = {0}; static uint8_t hash_key[JANET_HASH_KEY_SIZE] = {0};
void janet_init_hash_key(uint8_t new_key[16]) { void janet_init_hash_key(uint8_t new_key[JANET_HASH_KEY_SIZE]) {
memcpy(hash_key, new_key, sizeof(hash_key)); memcpy(hash_key, new_key, sizeof(hash_key));
} }

View File

@ -1303,7 +1303,8 @@ JANET_API JanetBuffer *janet_pretty(JanetBuffer *buffer, int depth, int flags, J
/* Misc */ /* Misc */
#ifndef JANET_NO_PRF #ifndef JANET_NO_PRF
JANET_API void janet_init_hash_key(uint8_t key[16]); #define JANET_HASH_KEY_SIZE 16
JANET_API void janet_init_hash_key(uint8_t key[JANET_HASH_KEY_SIZE]);
#endif #endif
JANET_API int janet_equals(Janet x, Janet y); JANET_API int janet_equals(Janet x, Janet y);
JANET_API int32_t janet_hash(Janet x); JANET_API int32_t janet_hash(Janet x);