summaryrefslogtreecommitdiffstats
path: root/fips/rand/fips_drbg_selftest.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2011-03-31 17:15:54 +0000
committerDr. Stephen Henson <steve@openssl.org>2011-03-31 17:15:54 +0000
commit52b6ee8245c06042fd4f1bfea32f652ebe1774f3 (patch)
tree2a41aa8eec04b0830d969a6778cdc41579abe706 /fips/rand/fips_drbg_selftest.c
parentbb61a6c80d533c00a2d9d75b3a82aa4346899dc4 (diff)
Reorganise DRBG API so the entropy and nonce callbacks can return a
pointer to a buffer instead of copying to a fixed length buffer. This removes the entropy and nonce length restrictions.
Diffstat (limited to 'fips/rand/fips_drbg_selftest.c')
-rw-r--r--fips/rand/fips_drbg_selftest.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/fips/rand/fips_drbg_selftest.c b/fips/rand/fips_drbg_selftest.c
index 31b7a0be58..a3732c1a4a 100644
--- a/fips/rand/fips_drbg_selftest.c
+++ b/fips/rand/fips_drbg_selftest.c
@@ -732,20 +732,20 @@ typedef struct
int noncecnt;
} TEST_ENT;
-static size_t test_entropy(DRBG_CTX *dctx, unsigned char *out,
+static size_t test_entropy(DRBG_CTX *dctx, unsigned char **pout,
int entropy, size_t min_len, size_t max_len)
{
TEST_ENT *t = FIPS_drbg_get_app_data(dctx);
- memcpy(out, t->ent, t->entlen);
+ *pout = (unsigned char *)t->ent;
t->entcnt++;
return t->entlen;
}
-static size_t test_nonce(DRBG_CTX *dctx, unsigned char *out,
+static size_t test_nonce(DRBG_CTX *dctx, unsigned char **pout,
int entropy, size_t min_len, size_t max_len)
{
TEST_ENT *t = FIPS_drbg_get_app_data(dctx);
- memcpy(out, t->nonce, t->noncelen);
+ *pout = (unsigned char *)t->nonce;
t->noncecnt++;
return t->noncelen;
}
@@ -762,7 +762,7 @@ static int fips_drbg_single_kat(DRBG_CTX *dctx, DRBG_SELFTEST_DATA *td)
unsigned char randout[1024];
if (!FIPS_drbg_init(dctx, td->nid, td->flags))
return 0;
- if (!FIPS_drbg_set_callbacks(dctx, test_entropy, test_nonce))
+ if (!FIPS_drbg_set_callbacks(dctx, test_entropy, 0, test_nonce, 0))
return 0;
FIPS_drbg_set_app_data(dctx, &t);
@@ -818,7 +818,7 @@ static int fips_drbg_health_check(DRBG_CTX *dctx, DRBG_SELFTEST_DATA *td)
if (!FIPS_drbg_init(dctx, td->nid, td->flags))
goto err;
- if (!FIPS_drbg_set_callbacks(dctx, test_entropy, test_nonce))
+ if (!FIPS_drbg_set_callbacks(dctx, test_entropy, 0, test_nonce, 0))
goto err;
FIPS_drbg_set_app_data(dctx, &t);
@@ -860,7 +860,7 @@ static int fips_drbg_health_check(DRBG_CTX *dctx, DRBG_SELFTEST_DATA *td)
/* Instantiate with valid data. NB: errors now reported again */
if (!FIPS_drbg_init(dctx, td->nid, td->flags))
goto err;
- if (!FIPS_drbg_set_callbacks(dctx, test_entropy, test_nonce))
+ if (!FIPS_drbg_set_callbacks(dctx, test_entropy, 0, test_nonce, 0))
goto err;
FIPS_drbg_set_app_data(dctx, &t);
@@ -914,7 +914,7 @@ static int fips_drbg_health_check(DRBG_CTX *dctx, DRBG_SELFTEST_DATA *td)
if (!FIPS_drbg_init(dctx, td->nid, td->flags))
goto err;
- if (!FIPS_drbg_set_callbacks(dctx, test_entropy, test_nonce))
+ if (!FIPS_drbg_set_callbacks(dctx, test_entropy, 0, test_nonce, 0))
goto err;
FIPS_drbg_set_app_data(dctx, &t);