2 * Copyright (C) 2008-2012 Free Software Foundation, Inc.
4 * Author: Nikos Mavrogiannopoulos
6 * This file is part of GnuTLS.
8 * The GnuTLS is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 3 of
11 * the License, or (at your option) any later version.
13 * This library 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 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>
23 /* This file handles all the internal functions that cope with random data.
26 #include <gnutls_int.h>
27 #include <gnutls_errors.h>
33 _gnutls_rnd_init (void)
35 if (_gnutls_rnd_ops
.init
!= NULL
)
37 if (_gnutls_rnd_ops
.init (&gnutls_rnd_ctx
) < 0)
40 return GNUTLS_E_RANDOM_FAILED
;
48 _gnutls_rnd_deinit (void)
50 if (_gnutls_rnd_ops
.deinit
!= NULL
)
52 _gnutls_rnd_ops
.deinit (gnutls_rnd_ctx
);
60 * @level: a security level
61 * @data: place to store random bytes
62 * @len: The requested size
64 * This function will generate random data and store it to output
67 * Returns: Zero or a negative error code on error.
72 gnutls_rnd (gnutls_rnd_level_t level
, void *data
, size_t len
)
74 return _gnutls_rnd(level
, data
, len
);