summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2016-02-18 19:24:47 +0100
committerWerner Koch <wk@gnupg.org>2016-02-19 14:35:32 +0100
commit7cf3c929331133e4381dbceac53d3addd921c929 (patch)
tree237da9f486a94700da3c9711151ee26b034c1ee4
parente49b3f2c10e012509b5930c0df4d6df378d3b9f4 (diff)
downloadlibgcrypt-7cf3c929331133e4381dbceac53d3addd921c929.tar.gz
random: Use our symbol name pattern also for drbg functions.
* random/random-drbg.c: Rename global functions from _gcry_drbg_* to _gcry_rngdrbg_*. * random/random.c: Adjust for this change. * src/global.c: Ditto. Signed-off-by: Werner Koch <wk@gnupg.org>
-rw-r--r--random/rand-internal.h19
-rw-r--r--random/random-drbg.c46
-rw-r--r--random/random.c20
-rw-r--r--random/random.h13
-rw-r--r--src/global.c6
5 files changed, 53 insertions, 51 deletions
diff --git a/random/rand-internal.h b/random/rand-internal.h
index 62eecdec..dbd23df3 100644
--- a/random/rand-internal.h
+++ b/random/rand-internal.h
@@ -88,15 +88,16 @@ gcry_err_code_t _gcry_rngfips_run_external_test (void *context,
char *buffer, size_t buflen);
void _gcry_rngfips_deinit_external_test (void *context);
-/*-- drbg.c --*/
-void _gcry_drbg_init(int full);
-void _gcry_drbg_close_fds(void);
-void _gcry_drbg_dump_stats(void);
-int _gcry_drbg_is_faked (void);
-gcry_error_t _gcry_drbg_add_bytes (const void *buf, size_t buflen, int quality);
-void _gcry_drbg_randomize (void *buffer, size_t length,
- enum gcry_random_level level);
-gcry_error_t _gcry_drbg_selftest (selftest_report_func_t report);
+/*-- random-drbg.c --*/
+void _gcry_rngdrbg_inititialize (int full);
+void _gcry_rngdrbg_close_fds (void);
+void _gcry_rngdrbg_dump_stats (void);
+int _gcry_rngdrbg_is_faked (void);
+gcry_error_t _gcry_rngdrbg_add_bytes (const void *buf, size_t buflen,
+ int quality);
+void _gcry_rngdrbg_randomize (void *buffer, size_t length,
+ enum gcry_random_level level);
+gcry_error_t _gcry_rngdrbg_selftest (selftest_report_func_t report);
/*-- random-system.c --*/
void _gcry_rngsystem_initialize (int full);
diff --git a/random/random-drbg.c b/random/random-drbg.c
index 8c9a42e7..2f1296b9 100644
--- a/random/random-drbg.c
+++ b/random/random-drbg.c
@@ -1720,8 +1720,8 @@ gcry_drbg_reseed (struct gcry_drbg_state *drbg,
* libgcrypt backend functions to the RNG API code
***************************************************************/
-/* global state variable holding the current instance of the DRBG -- the
- * default DRBG type is defined in _gcry_gcry_drbg_init */
+/* Global state variable holding the current instance of the DRBG -- the
+ * default DRBG type is defined in _gcry_rngdrbg_inititialize. */
static struct gcry_drbg_state *gcry_drbg = NULL;
/* This is the lock we use to serialize access to this RNG. */
@@ -1831,7 +1831,7 @@ _gcry_drbg_init_internal (u32 flags, struct gcry_drbg_string *pers)
* Initialize one DRBG invoked by the libgcrypt API
*/
void
-_gcry_drbg_init (int full)
+_gcry_rngdrbg_inititialize (int full)
{
/* default DRBG */
u32 flags = GCRY_DRBG_NOPR_HMACSHA256;
@@ -1862,7 +1862,7 @@ _gcry_drbg_init (int full)
* bufer is take as personalization string.
*/
gpg_err_code_t
-_gcry_drbg_reinit (const char *flagstr, gcry_buffer_t *pers, int npers)
+_gcry_rngdrbg_reinit (const char *flagstr, gcry_buffer_t *pers, int npers)
{
gpg_err_code_t ret;
unsigned int flags;
@@ -1896,7 +1896,7 @@ _gcry_drbg_reinit (const char *flagstr, gcry_buffer_t *pers, int npers)
/* Try to close the FDs of the random gather module. This is
* currently only implemented for rndlinux. */
void
-_gcry_drbg_close_fds (void)
+_gcry_rngdrbg_close_fds (void)
{
#if USE_RNDLINUX
gcry_drbg_lock ();
@@ -1907,7 +1907,7 @@ _gcry_drbg_close_fds (void)
/* Print some statistics about the RNG. */
void
-_gcry_drbg_dump_stats (void)
+_gcry_rngdrbg_dump_stats (void)
{
/* Not yet implemented. */
/* Maybe dumping of reseed counter? */
@@ -1916,7 +1916,7 @@ _gcry_drbg_dump_stats (void)
/* This function returns true if no real RNG is available or the
* quality of the RNG has been degraded for test purposes. */
int
-_gcry_drbg_is_faked (void)
+_gcry_rngdrbg_is_faked (void)
{
return 0; /* Faked random is not allowed. */
}
@@ -1925,12 +1925,12 @@ _gcry_drbg_is_faked (void)
* should be in the range of 0..100 to indicate the goodness of the
* entropy added, or -1 for goodness not known. */
gcry_error_t
-_gcry_drbg_add_bytes (const void *buf, size_t buflen, int quality)
+_gcry_rngdrbg_add_bytes (const void *buf, size_t buflen, int quality)
{
gpg_err_code_t ret = 0;
struct gcry_drbg_string seed;
(void) quality;
- _gcry_drbg_init(1); /* Auto-initialize if needed */
+ _gcry_rngdrbg_inititialize (1); /* Auto-initialize if needed */
if (NULL == gcry_drbg)
return GPG_ERR_GENERAL;
gcry_drbg_string_fill (&seed, (unsigned char *) buf, buflen);
@@ -1944,11 +1944,11 @@ _gcry_drbg_add_bytes (const void *buf, size_t buflen, int quality)
* nonces
*/
void
-_gcry_drbg_randomize (void *buffer, size_t length,
+_gcry_rngdrbg_randomize (void *buffer, size_t length,
enum gcry_random_level level)
{
(void) level;
- _gcry_drbg_init(1); /* Auto-initialize if needed */
+ _gcry_rngdrbg_inititialize (1); /* Auto-initialize if needed */
gcry_drbg_lock ();
if (NULL == gcry_drbg)
{
@@ -2287,7 +2287,7 @@ struct gcry_drbg_test_vector gcry_drbg_test_nopr[] = {
* call for the CAVS test tool.
*/
gpg_err_code_t
-gcry_drbg_cavs_test (struct gcry_drbg_test_vector *test, unsigned char *buf)
+gcry_rngdrbg_cavs_test (struct gcry_drbg_test_vector *test, unsigned char *buf)
{
gpg_err_code_t ret = 0;
struct gcry_drbg_state *drbg = NULL;
@@ -2358,14 +2358,14 @@ outbuf:
* call for the CAVS test tool.
*/
gpg_err_code_t
-gcry_drbg_healthcheck_one (struct gcry_drbg_test_vector * test)
+gcry_rngdrbg_healthcheck_one (struct gcry_drbg_test_vector * test)
{
gpg_err_code_t ret = GPG_ERR_ENOMEM;
unsigned char *buf = xcalloc_secure (1, test->expectedlen);
if (!buf)
return GPG_ERR_ENOMEM;
- ret = gcry_drbg_cavs_test (test, buf);
+ ret = gcry_rngdrbg_cavs_test (test, buf);
ret = memcmp (test->expected, buf, test->expectedlen);
xfree (buf);
@@ -2463,21 +2463,21 @@ static int
gcry_drbg_healthcheck (void)
{
int ret = 0;
- ret += gcry_drbg_healthcheck_one (&gcry_drbg_test_nopr[0]);
- ret += gcry_drbg_healthcheck_one (&gcry_drbg_test_nopr[1]);
- ret += gcry_drbg_healthcheck_one (&gcry_drbg_test_nopr[2]);
- ret += gcry_drbg_healthcheck_one (&gcry_drbg_test_nopr[3]);
- ret += gcry_drbg_healthcheck_one (&gcry_drbg_test_nopr[4]);
- ret += gcry_drbg_healthcheck_one (&gcry_drbg_test_pr[0]);
- ret += gcry_drbg_healthcheck_one (&gcry_drbg_test_pr[1]);
- ret += gcry_drbg_healthcheck_one (&gcry_drbg_test_pr[2]);
+ ret += gcry_rngdrbg_healthcheck_one (&gcry_drbg_test_nopr[0]);
+ ret += gcry_rngdrbg_healthcheck_one (&gcry_drbg_test_nopr[1]);
+ ret += gcry_rngdrbg_healthcheck_one (&gcry_drbg_test_nopr[2]);
+ ret += gcry_rngdrbg_healthcheck_one (&gcry_drbg_test_nopr[3]);
+ ret += gcry_rngdrbg_healthcheck_one (&gcry_drbg_test_nopr[4]);
+ ret += gcry_rngdrbg_healthcheck_one (&gcry_drbg_test_pr[0]);
+ ret += gcry_rngdrbg_healthcheck_one (&gcry_drbg_test_pr[1]);
+ ret += gcry_rngdrbg_healthcheck_one (&gcry_drbg_test_pr[2]);
ret += gcry_drbg_healthcheck_sanity (&gcry_drbg_test_nopr[0]);
return ret;
}
/* Run the self-tests. */
gcry_error_t
-_gcry_drbg_selftest (selftest_report_func_t report)
+_gcry_rngdrbg_selftest (selftest_report_func_t report)
{
gcry_err_code_t ec;
const char *errtxt = NULL;
diff --git a/random/random.c b/random/random.c
index 4475d3c7..ff9be166 100644
--- a/random/random.c
+++ b/random/random.c
@@ -140,11 +140,11 @@ void
_gcry_random_initialize (int full)
{
if (fips_mode ())
- _gcry_drbg_init(full);
+ _gcry_rngdrbg_inititialize (full);
else if (rng_types.standard)
_gcry_rngcsprng_initialize (full);
else if (rng_types.fips)
- _gcry_drbg_init(full);
+ _gcry_rngdrbg_inititialize (full);
else if (rng_types.system)
_gcry_rngsystem_initialize (full);
else
@@ -161,11 +161,11 @@ _gcry_random_close_fds (void)
the entropy gatherer. */
if (fips_mode ())
- _gcry_drbg_close_fds ();
+ _gcry_rngdrbg_close_fds ();
else if (rng_types.standard)
_gcry_rngcsprng_close_fds ();
else if (rng_types.fips)
- _gcry_drbg_close_fds ();
+ _gcry_rngdrbg_close_fds ();
else if (rng_types.system)
_gcry_rngsystem_close_fds ();
else
@@ -199,7 +199,7 @@ void
_gcry_random_dump_stats (void)
{
if (fips_mode ())
- _gcry_drbg_dump_stats ();
+ _gcry_rngdrbg_dump_stats ();
else
_gcry_rngcsprng_dump_stats ();
}
@@ -258,7 +258,7 @@ int
_gcry_random_is_faked (void)
{
if (fips_mode ())
- return _gcry_drbg_is_faked ();
+ return _gcry_rngdrbg_is_faked ();
else
return _gcry_rngcsprng_is_faked ();
}
@@ -288,11 +288,11 @@ static void
do_randomize (void *buffer, size_t length, enum gcry_random_level level)
{
if (fips_mode ())
- _gcry_drbg_randomize (buffer, length, level);
+ _gcry_rngdrbg_randomize (buffer, length, level);
else if (rng_types.standard)
_gcry_rngcsprng_randomize (buffer, length, level);
else if (rng_types.fips)
- _gcry_drbg_randomize (buffer, length, level);
+ _gcry_rngdrbg_randomize (buffer, length, level);
else if (rng_types.system)
_gcry_rngsystem_randomize (buffer, length, level);
else /* default */
@@ -424,7 +424,7 @@ _gcry_create_nonce (void *buffer, size_t length)
nonce generator which is seeded by the RNG actual in use. */
if (fips_mode ())
{
- _gcry_drbg_randomize (buffer, length, GCRY_WEAK_RANDOM);
+ _gcry_rngdrbg_randomize (buffer, length, GCRY_WEAK_RANDOM);
return;
}
@@ -501,7 +501,7 @@ gpg_error_t
_gcry_random_selftest (selftest_report_func_t report)
{
if (fips_mode ())
- return _gcry_drbg_selftest (report);
+ return _gcry_rngdrbg_selftest (report);
else
return 0; /* No selftests yet. */
}
diff --git a/random/random.h b/random/random.h
index 2c4f1df6..5dbdf953 100644
--- a/random/random.h
+++ b/random/random.h
@@ -54,9 +54,9 @@ gcry_err_code_t _gcry_random_run_external_test (void *context,
char *buffer, size_t buflen);
void _gcry_random_deinit_external_test (void *context);
-/*-- drbg.c --*/
-gpg_err_code_t _gcry_drbg_reinit (const char *flagstr,
- gcry_buffer_t *pers, int npers);
+/*-- random-drbg.c --*/
+gpg_err_code_t _gcry_rngdrbg_reinit (const char *flagstr,
+ gcry_buffer_t *pers, int npers);
/* private interfaces for testing of DRBG */
struct gcry_drbg_test_vector
{
@@ -79,9 +79,10 @@ struct gcry_drbg_test_vector
size_t addtl_reseed_len;
};
-gpg_err_code_t gcry_drbg_cavs_test (struct gcry_drbg_test_vector *test,
- unsigned char *buf);
-gpg_err_code_t gcry_drbg_healthcheck_one (struct gcry_drbg_test_vector *test);
+gpg_err_code_t gcry_rngdrbg_cavs_test (struct gcry_drbg_test_vector *t,
+ unsigned char *buf);
+gpg_err_code_t gcry_rngdrbg_healthcheck_one (struct gcry_drbg_test_vector *t);
+
/*-- rndegd.c --*/
gpg_error_t _gcry_rndegd_set_socket_name (const char *name);
diff --git a/src/global.c b/src/global.c
index ffba3254..b4954bad 100644
--- a/src/global.c
+++ b/src/global.c
@@ -585,9 +585,9 @@ _gcry_vcontrol (enum gcry_ctl_cmds cmd, va_list arg_ptr)
unsigned char *buf = va_arg (arg_ptr, unsigned char *);
if (buf)
- rc = gcry_drbg_cavs_test (test, buf);
+ rc = gcry_rngdrbg_cavs_test (test, buf);
else
- rc = gcry_drbg_healthcheck_one (test);
+ rc = gcry_rngdrbg_healthcheck_one (test);
}
break;
case 60: /* Deinit external random test. */
@@ -663,7 +663,7 @@ _gcry_vcontrol (enum gcry_ctl_cmds cmd, va_list arg_ptr)
if (va_arg (arg_ptr, void *) || npers < 0)
rc = GPG_ERR_INV_ARG;
else
- rc = _gcry_drbg_reinit (flagstr, pers, npers);
+ rc = _gcry_rngdrbg_reinit (flagstr, pers, npers);
}
break;