summaryrefslogtreecommitdiff
path: root/lib/random.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@crystal.(none)>2008-06-28 01:25:02 +0300
committerNikos Mavrogiannopoulos <nmav@crystal.(none)>2008-06-28 01:25:02 +0300
commit95c55c0eb57484533f4dd72c10481c66a66a53f2 (patch)
tree3bc580f54abd1775b28415ae8e20aab4fe2baade /lib/random.c
parent0def0a1d7c28de6fd49995755de7b915cf701225 (diff)
downloadgnutls-95c55c0eb57484533f4dd72c10481c66a66a53f2.tar.gz
Initial merge attempt with gnutls_with_ext_mpi
Diffstat (limited to 'lib/random.c')
-rw-r--r--lib/random.c37
1 files changed, 7 insertions, 30 deletions
diff --git a/lib/random.c b/lib/random.c
index 82340c60b7..40b959b0bd 100644
--- a/lib/random.c
+++ b/lib/random.c
@@ -29,26 +29,15 @@
#include <gnutls_errors.h>
#include <random.h>
-static gnutls_crypto_rnd_st * cc = NULL;
static void * rnd_ctx;
-int
-_gnutls_rnd_init ()
+int _gnutls_rnd_init ()
{
- int result;
-
- /* check if a digest has been registered
- */
- cc = _gnutls_get_crypto_rnd();
-
- if (cc != NULL) {
- if (cc->init(& rnd_ctx) < 0) {
+ if (_gnutls_rnd_ops.init != NULL) {
+ if (_gnutls_rnd_ops.init(& rnd_ctx) < 0) {
gnutls_assert();
return GNUTLS_E_RANDOM_FAILED;
}
- } else {
- char c;
- gc_pseudo_random (&c, 1);
}
return 0;
@@ -57,8 +46,8 @@ _gnutls_rnd_init ()
void
_gnutls_rnd_deinit ()
{
- if (cc != NULL) {
- cc->deinit( rnd_ctx);
+ if (_gnutls_rnd_ops.deinit != NULL) {
+ _gnutls_rnd_ops.deinit( rnd_ctx);
}
return;
@@ -67,21 +56,9 @@ _gnutls_rnd_deinit ()
int
_gnutls_rnd (int level, void *data, int len)
{
-int ret = GC_OK;
-
if (len > 0) {
-
- if (cc != NULL) {
- return cc->rnd( rnd_ctx, level, data, len);
- }
-
- if (level == RND_NONCE)
- ret = gc_nonce (data, len);
- else
- ret = gc_pseudo_random( data, len);
+ return _gnutls_rnd_ops.rnd( rnd_ctx, level, data, len);
}
-
- if (ret == GC_OK) return 0;
- else return GNUTLS_E_RANDOM_FAILED;
+ return 0;
}