2 * Copyright (C) 2008, 2010 Free Software Foundation, Inc.
4 * Author: Nikos Mavrogiannopoulos
6 * This file is part of GnuTLS.
8 * GnuTLS is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
13 * GnuTLS is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with GnuTLS. If not, see <http://www.gnu.org/licenses/>.
31 #include <gnutls/gnutls.h>
32 #include <gnutls/crypto.h>
33 #include "../lib/random.h"
42 rng_rnd (void *ctx, int level, void *data, size_t datasize)
44 memset (data, 1, datasize);
49 rng_deinit (void *ctx)
60 gnutls_crypto_rnd_st rng = { rng_init, rng_rnd, rng_deinit };
63 rc = gnutls_crypto_rnd_register (0, &rng);
65 gnutls_global_init ();
67 memset (buf2, 1, sizeof (buf2));
69 _gnutls_rnd (GNUTLS_RND_RANDOM, buf1, sizeof (buf1));
71 if (memcmp (buf1, buf2, sizeof (buf1)) != 0)
74 gnutls_global_deinit ();
78 success ("rng registered ok\n");
82 fail ("rng register test failed: %d\n", rc);