pike.git/
src/
post_modules/
Nettle/
nettle.cmod
Branch:
Tag:
Non-build tags
All tags
No tags
2017-11-25
2017-11-25 22:43:36 by Martin Nilsson <nilsson@fastmail.com>
c4e773943a14814d484fd643b1b9e984ef2d7ffd (
19
lines) (+
4
/-
15
)
[
Show
|
Annotate
]
Branch:
master
Cleanup.
393:
CVAR struct aes_ctx aes_ctx; CVAR uint8_t *key; CVAR uint8_t *ctr;
-
CVAR uint8_t *temp;
+
CVAR INT64 counter; DECLARE_STORAGE;
426:
aes_set_encrypt_key(&THIS->aes_ctx, AES128_KEY_SIZE, THIS->key); }
-
PIKEFUN string get_key()
-
{
-
RETURN make_shared_binary_string(THIS->key, 16);
-
}
-
-
PIKEFUN string get_ctr()
-
{
-
RETURN make_shared_binary_string(THIS->ctr, 16);
-
}
-
+
/*! @decl void reseed(string(8bit) data) *! Updated the internal key with the provided additional entropy. */
478:
if( len>stored ) {
+
uint8_t buf[16];
INCREMENT(16, THIS->ctr);
-
aes_encrypt(&THIS->aes_ctx, 16,
THIS->temp
, THIS->ctr);
-
memcpy(str,
THIS->temp
, len-stored);
+
aes_encrypt(&THIS->aes_ctx, 16,
buf
, THIS->ctr);
+
memcpy(str,
buf
, len-stored);
} ctr_debug_update(NULL);
491:
INIT {
-
THIS->temp = xcalloc(1,16);
+
THIS->ctr = xcalloc(1,16); THIS->key = xcalloc(1,16); THIS->counter = 1;
503:
{ free(THIS->ctr); free(THIS->key);
-
free(THIS->temp);
+
} }