pike.git
/
src
/
post_modules
/
Nettle
/
nettle.cmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/post_modules/Nettle/nettle.cmod:279:
static void fortuna_rekey(void) { fortuna_generate(); memcpy(THIS->key, THIS->data, 16); fortuna_generate(); memcpy(THIS->key+16, THIS->data, 16); aes_set_encrypt_key(&THIS->aes_ctx, AES256_KEY_SIZE, THIS->key); } /*! @decl void reseed(string(8bit) data)
-
*!
Generates
new
a
new
key
based
on
the provided additional
-
*!
entropy.
+
*!
Updated
the
internal
key
with
the provided additional entropy.
*/ PIKEFUN void reseed(string(8bit) data) { sha256_update(&THIS->sha_ctx, 32, THIS->key); sha256_update(&THIS->sha_ctx, data->len, (const uint8_t *)data->str); sha256_digest(&THIS->sha_ctx, 32, THIS->key); aes_set_encrypt_key(&THIS->aes_ctx, AES256_KEY_SIZE, THIS->key); INCREMENT(16, THIS->ctr); }
pike.git/src/post_modules/Nettle/nettle.cmod:304:
*! the Fortuna PseudoRandomData function, which only allows 2^20 *! bytes of random data per call, the necessary rekey operations *! are here performed internally, so no such restrictions apply. */ PIKEFUN string(8bit) random_string(int len) { int stored = 0; struct string_builder s; if(len<0) Pike_error("Length has to be positive.\n");
-
init_string_builder_alloc(&s,
len+16
, 0);
+
init_string_builder_alloc(&s,
len
, 0);
while( stored < len ) { fortuna_generate(); string_builder_binary_strcat(&s, (const char *)THIS->data, MINIMUM(16, (len-stored))); /* This should really be MINIMUM(16, (len-stored)) instead of 16, but it is only less than 16 in the last round, so it doesn't matter if we rekey here or not. */