static void wrap_nettle_rnd_deinit(void *ctx) { _rnd_system_entropy_deinit(); gnutls_mutex_deinit(&nonce_ctx.mutex); nonce_ctx.mutex = NULL; gnutls_mutex_deinit(&rnd_ctx.mutex); rnd_ctx.mutex = NULL; }
void _gnutls_rnd_deinit(void) { if (_gnutls_rnd_ops.deinit != NULL) { struct rnd_ctx_list_st *e = head, *next; while(e != NULL) { next = e->next; _gnutls_rnd_ops.deinit(e->ctx); gnutls_free(e); e = next; } head = NULL; } rnd_initialized = 0; _rnd_system_entropy_deinit(); return; }
void doit(void) { char buf[512]; char empty[32]; int ret; struct itimerval ival; struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = sig_handler; sigemptyset (&sa.sa_mask); sigaction(SIGALRM, &sa, NULL); memset(&ival, 0, sizeof(ival)); ival.it_interval.tv_usec = 5000; ival.it_value.tv_usec = 5000; _rnd_system_entropy_init(); ret = setitimer(ITIMER_REAL, &ival, NULL); if (ret < 0) { fail("error in setitimer: %s\n", strerror(errno)); } memset(empty, 0, sizeof(empty)); for (;stop_loop<1024;) { memset(buf, 0, sizeof(buf)); ret = _rnd_get_system_entropy(buf, sizeof(buf)); if (ret < 0) { fail("error obtaining entropy: %s\n", gnutls_strerror(ret)); } if (memcmp(empty, buf+sizeof(buf)-sizeof(empty)-1, sizeof(empty)) == 0) { fail("_rnd_get_system_entropy: did not fill buffer\n"); } } _rnd_system_entropy_deinit(); }