** libgnutls: Added functions to directly set the DN in a certificate
or request from an RFC4514 string.
-** libgnutls: Optimizations in the nonce level of the random generator.
+** libgnutls: Optimizations in the random generator. The re-seeding of
+it is now explicitly done on every session deinit.
** libgnutls: Simplified the DTLS sliding window implementation.
gnutls_record_send_range: Added
gnutls_record_set_max_empty_records: Added
gnutls_record_can_use_length_hiding: Added
+gnutls_rnd_refresh: Added
GNUTLS_SEC_PARAM_EXPORT: Added
GNUTLS_SEC_PARAM_VERY_WEAK: Added
{
int (*init) (void **ctx);
int (*rnd) (void *ctx, int level, void *data, size_t datasize);
+ void (*rnd_refresh) (void *ctx);
void (*deinit) (void *ctx);
} gnutls_crypto_rnd_st;
/*
- * Copyright (C) 2002-2012 Free Software Foundation, Inc.
+ * Copyright (C) 2002-2013 Free Software Foundation, Inc.
*
* Author: Nikos Mavrogiannopoulos
*
#include <gnutls_rsa_export.h>
#include <gnutls_extensions.h>
#include <system.h>
+#include <random.h>
#include <gnutls/dtls.h>
#include <timespec.h>
if (session == NULL)
return;
+ _gnutls_rnd_refresh();
+
/* remove auth info firstly */
_gnutls_free_auth_info (session);
int gnutls_rnd (gnutls_rnd_level_t level, void *data, size_t len);
+ void gnutls_rnd_refresh (void);
+
#ifdef __cplusplus
}
#endif
int ret;
RND_LOCK;
- gettime(¤t_time);
/* update state only when having a non-nonce or if nonce
* and nsecs%4096 == 0, i.e., one out of 4096 times called .
*
* The reason we do that is to avoid any delays when generating nonces.
*/
- if (level != GNUTLS_RND_NONCE || ((current_time.tv_nsec & 0x0fff) == 0))
+ if (level != GNUTLS_RND_NONCE)
{
+ gettime(¤t_time);
+
ret = do_trivia_source (0);
if (ret < 0)
{
return 0;
}
+static void
+wrap_nettle_rnd_refresh (void *_ctx)
+{
+ RND_LOCK;
+ gettime(¤t_time);
+
+ do_trivia_source (0);
+ do_device_source (0);
+
+ RND_UNLOCK;
+ return;
+}
+
int crypto_rnd_prio = INT_MAX;
gnutls_crypto_rnd_st _gnutls_rnd_ops = {
.init = wrap_nettle_rnd_init,
.deinit = wrap_nettle_rnd_deinit,
.rnd = wrap_nettle_rnd,
+ .rnd_refresh = wrap_nettle_rnd_refresh,
};
{
return _gnutls_rnd(level, data, len);
}
+
+/**
+ * gnutls_rnd_refresh:
+ *
+ * This function refreshes the random generator state.
+ * That is the current precise time, CPU usage, and
+ * other values are input into its state.
+ *
+ * On a slower rate input from /dev/urandom is mixed too.
+ *
+ * Since: 3.1.7
+ **/
+void
+gnutls_rnd_refresh ()
+{
+ _gnutls_rnd_refresh();
+}
return 0;
}
+inline static void
+_gnutls_rnd_refresh (void)
+{
+ _gnutls_rnd_ops.rnd_refresh (gnutls_rnd_ctx);
+}
+
void _gnutls_rnd_deinit (void);
int _gnutls_rnd_init (void);