Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Core
Tor
Commits
acbde10f
Commit
acbde10f
authored
6 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Patches
Plain Diff
Add a test-rng program so we can pipe to dieharder.
parent
490e1870
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+2
-0
2 additions, 0 deletions
.gitignore
src/test/include.am
+9
-2
9 additions, 2 deletions
src/test/include.am
src/test/test_rng.c
+59
-0
59 additions, 0 deletions
src/test/test_rng.c
with
70 additions
and
2 deletions
.gitignore
+
2
−
0
View file @
acbde10f
...
...
@@ -248,6 +248,7 @@ uptime-*.json
/src/test/test-memwipe
/src/test/test-ntor-cl
/src/test/test-hs-ntor-cl
/src/test/test-rng
/src/test/test-switch-id
/src/test/test-timers
/src/test/test_workqueue
...
...
@@ -258,6 +259,7 @@ uptime-*.json
/src/test/test-ntor-cl.exe
/src/test/test-hs-ntor-cl.exe
/src/test/test-memwipe.exe
/src/test/test-rng.exe
/src/test/test-switch-id.exe
/src/test/test-timers.exe
/src/test/test_workqueue.exe
...
...
This diff is collapsed.
Click to expand it.
src/test/include.am
+
9
−
2
View file @
acbde10f
...
...
@@ -68,7 +68,8 @@ noinst_PROGRAMS+= \
src/test/test-process \
src/test/test_workqueue \
src/test/test-switch-id \
src/test/test-timers
src/test/test-timers \
src/test/test-rng
endif
src_test_AM_CPPFLAGS = -DSHARE_DATADIR="\"$(datadir)\"" \
...
...
@@ -258,7 +259,13 @@ src_test_test_LDADD = \
src_test_test_slow_CPPFLAGS = $(src_test_test_CPPFLAGS)
src_test_test_slow_CFLAGS = $(src_test_test_CFLAGS)
src_test_test_slow_LDADD = $(src_test_test_LDADD)
src_test_test_slow_LDFLAGS = $(src_test_test_LDFLAGS)
src_test_test_slow_LDFLAGS =@TOR_LDFLAGS_openssl@
src_test_test_rng_CPPFLAGS = $(src_test_test_CPPFLAGS)
src_test_test_rng_CFLAGS = $(src_test_test_CFLAGS)
src_test_test_rng_SOURCES = src/test/test_rng.c
src_test_test_rng_LDFLAGS = $(src_test_test_LDFLAGS)
src_test_test_rng_LDADD = $(src_test_test_LDADD)
src_test_test_memwipe_CPPFLAGS = $(src_test_test_CPPFLAGS)
# Don't use bugtrap cflags here: memwipe tests require memory violations.
...
...
This diff is collapsed.
Click to expand it.
src/test/test_rng.c
0 → 100644
+
59
−
0
View file @
acbde10f
/* Copyright (c) 2016-2019, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/*
* Example usage:
*
* ./src/test/test-rng --emit | dieharder -g 200 -a
*
* Remember, dieharder can tell you that your RNG is completely broken, but if
* your RNG is not _completely_ broken, dieharder cannot tell you whether your
* RNG is actually secure.
*/
#include
"orconfig.h"
#ifdef HAVE_UNISTD_H
#include
<unistd.h>
#endif
#include
<stdio.h>
#include
<string.h>
#include
<errno.h>
#include
"lib/crypt_ops/crypto_rand.h"
int
main
(
int
argc
,
char
**
argv
)
{
uint8_t
buf
[
0x123
];
if
(
argc
!=
2
||
strcmp
(
argv
[
1
],
"--emit"
))
{
fprintf
(
stderr
,
"If you want me to fill stdout with a bunch of random "
"bytes, you need to say --emit.
\n
"
);
return
1
;
}
if
(
crypto_seed_rng
()
<
0
)
{
fprintf
(
stderr
,
"Can't seed RNG.
\n
"
);
return
1
;
}
#if 0
while (1) {
crypto_rand(buf, sizeof(buf));
if (write(1 /*stdout*/, buf, sizeof(buf)) != sizeof(buf)) {
fprintf(stderr, "write() failed: %s\n", strerror(errno));
return 1;
}
}
#endif
crypto_fast_rng_t
*
rng
=
crypto_fast_rng_new
();
while
(
1
)
{
crypto_fast_rng_getbytes
(
rng
,
buf
,
sizeof
(
buf
));
if
(
write
(
1
/*stdout*/
,
buf
,
sizeof
(
buf
))
!=
sizeof
(
buf
))
{
fprintf
(
stderr
,
"write() failed: %s
\n
"
,
strerror
(
errno
));
return
1
;
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment