You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
230 lines
8.6 KiB
230 lines
8.6 KiB
11 years ago
|
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
||
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
||
|
#
|
||
11 years ago
|
# Filename: package/.../csprng/0001-configure-add-option-to-disable-http-rng.patch
|
||
11 years ago
|
# Copyright (C) 2013 The OpenSDE Project
|
||
|
#
|
||
|
# More information can be found in the files COPYING and README.
|
||
|
#
|
||
|
# This patch file is dual-licensed. It is available under the license the
|
||
|
# patched project is licensed under, as long as it is an OpenSource license
|
||
|
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
|
||
|
# of the GNU General Public License as published by the Free Software
|
||
|
# Foundation; either version 2 of the License, or (at your option) any later
|
||
|
# version.
|
||
|
# --- SDE-COPYRIGHT-NOTE-END ---
|
||
|
|
||
11 years ago
|
From 5f069c7847bc02a738594fc21d437ecae04e2db9 Mon Sep 17 00:00:00 2001
|
||
|
From: Christian Wiese <chris@opensde.org>
|
||
|
Date: Wed, 4 Sep 2013 22:39:09 +0200
|
||
|
Subject: [PATCH] configure: add option to disable http rng
|
||
11 years ago
|
|
||
11 years ago
|
---
|
||
|
configure.ac | 17 +++++++++++++++++
|
||
|
src/Makefile.am | 15 ++++++++++-----
|
||
|
src/csprng.c | 12 ++++++++++++
|
||
|
test/Makefile.am | 5 ++++-
|
||
|
utils/csprng-generate.c | 6 ++++++
|
||
|
5 files changed, 49 insertions(+), 6 deletions(-)
|
||
|
|
||
|
diff --git a/configure.ac b/configure.ac
|
||
|
index 40dfaa4..12fd277 100755
|
||
|
--- a/configure.ac
|
||
|
+++ b/configure.ac
|
||
|
@@ -55,6 +55,23 @@ AC_FUNC_SELECT_ARGTYPES
|
||
11 years ago
|
AC_TYPE_SIGNAL
|
||
|
AC_CHECK_FUNCS([floor gettimeofday memset pow select sqrt clock_gettime])
|
||
|
|
||
|
+#### disable http rng feature (default: enabled)
|
||
|
+AC_ARG_ENABLE([http-rng],
|
||
|
+ AS_HELP_STRING([--disable-http-rng], [Disable feature to fetch random data via http from random.irb.hr]))
|
||
|
+
|
||
|
+AS_IF([test "x$enable_http_rng" != "xno"], [
|
||
|
+ dnl Do the stuff needed for enabling the feature
|
||
|
+ DISABLE_HTTP_RNG="yes"
|
||
|
+])
|
||
|
+
|
||
|
+AM_CONDITIONAL([ENABLE_HTTP_RNG], [test "x$DISABLE_HTTP_RNG" = "xyes"])
|
||
|
+
|
||
|
+# Define HTTP_RNG in config.h if we're going to compile against it
|
||
|
+if test "x$DISABLE_HTTP_RNG" = "xyes"; then
|
||
|
+ AC_DEFINE([ENABLE_HTTP_RNG], 1, ["Define to 1 if you want to enable http rng feature."])
|
||
|
+ AC_MSG_NOTICE([disable http rng])
|
||
|
+fi
|
||
|
+
|
||
|
#### Find OpenSSL
|
||
|
AC_MSG_CHECKING([for --with-openssl])
|
||
|
AC_ARG_WITH(
|
||
11 years ago
|
diff --git a/src/Makefile.am b/src/Makefile.am
|
||
|
index 8e1a2bb..302a87b 100644
|
||
|
--- a/src/Makefile.am
|
||
|
+++ b/src/Makefile.am
|
||
|
@@ -16,6 +16,14 @@ libcsprng_la_LIBADD =
|
||
11 years ago
|
libcsprng_la_CPPFLAGS = -I$(top_srcdir)/include
|
||
|
libcsprng_la_LDFLAGS = -version-number @CSPRNG_LT_VERSION@
|
||
|
|
||
|
+if ENABLE_HTTP_RNG
|
||
|
+ HTTP_RNG_SOURCES= \
|
||
|
+ QRBG.h \
|
||
|
+ QRBG.cpp \
|
||
|
+ qrbg-c.cpp \
|
||
|
+ http_rng.c
|
||
|
+endif
|
||
|
+
|
||
|
# Sources
|
||
|
# The shell script is the easy way to do this, by far. But it may not
|
||
|
# be sufficiently portable.
|
||
11 years ago
|
@@ -29,11 +37,8 @@ libcsprng_la_SOURCES = \
|
||
11 years ago
|
csprng.c \
|
||
|
memt19937ar-JH.c \
|
||
|
sha1_rng.c \
|
||
|
- fips.c \
|
||
|
- QRBG.h \
|
||
|
- QRBG.cpp \
|
||
|
- qrbg-c.cpp \
|
||
|
- http_rng.c
|
||
|
+ $(HTTP_RNG_SOURCES) \
|
||
|
+ fips.c
|
||
|
|
||
|
MAINTAINERCLEANFILES = Makefile.in
|
||
|
|
||
11 years ago
|
diff --git a/src/csprng.c b/src/csprng.c
|
||
|
index 76823e2..89dedad 100644
|
||
|
--- a/src/csprng.c
|
||
|
+++ b/src/csprng.c
|
||
|
@@ -38,7 +38,9 @@ along with CSRNG. If not, see <http://www.gnu.org/licenses/>.
|
||
11 years ago
|
#include <csprng/nist_ctr_drbg.h>
|
||
|
#include <csprng/memt19937ar-JH.h>
|
||
|
#include <csprng/sha1_rng.h>
|
||
|
+#if defined(ENABLE_HTTP_RNG)
|
||
|
#include <csprng/http_rng.h>
|
||
|
+#endif
|
||
|
#include <csprng/csprng.h>
|
||
|
#include <csprng/fips.h>
|
||
|
|
||
11 years ago
|
@@ -282,6 +284,7 @@ static void fill_buffer_using_SHA ( rng_buf_type* data )
|
||
11 years ago
|
}
|
||
|
//}}}
|
||
|
|
||
|
+#if defined(ENABLE_HTTP_RNG)
|
||
|
//{{{ static void fill_buffer_using_HTTP ( rng_buf_type* data )
|
||
|
static void fill_buffer_using_HTTP ( rng_buf_type* data )
|
||
|
{
|
||
11 years ago
|
@@ -332,6 +335,7 @@ static void fill_buffer_using_HTTP ( rng_buf_type* data )
|
||
11 years ago
|
return;
|
||
|
}
|
||
|
//}}}
|
||
|
+#endif
|
||
|
|
||
|
//{{{ static void fill_buffer_using_MT_RNG ( rng_buf_type* data )
|
||
|
static void fill_buffer_using_MT_RNG ( rng_buf_type* data )
|
||
11 years ago
|
@@ -380,9 +384,11 @@ static const unsigned char* get_data_from_RNG_buffer ( rng_buf_type* data, unsig
|
||
11 years ago
|
case SHA1_RNG:
|
||
|
fill_buffer_using_SHA (data);
|
||
|
break;
|
||
|
+#if defined(ENABLE_HTTP_RNG)
|
||
|
case HTTP_RNG:
|
||
|
fill_buffer_using_HTTP (data);
|
||
|
break;
|
||
|
+#endif
|
||
|
case MT_RNG:
|
||
|
fill_buffer_using_MT_RNG (data);
|
||
|
break;
|
||
11 years ago
|
@@ -906,9 +912,11 @@ csprng_state_type* csprng_initialize( const mode_of_operation_type* mode_of_oper
|
||
11 years ago
|
unsigned int allocated_size; //Number of bytes allocated for seed.
|
||
|
rng_state_type rng_state;
|
||
|
csprng_state_type* csprng_state;
|
||
|
+#if defined(ENABLE_HTTP_RNG)
|
||
|
char* QRBG_RNG_login_name; //User name for random.irb.hr
|
||
|
char* QRBG_RNG_passwd; //Password for random.irb.hr
|
||
|
char HTTP_source_bitmask; //source bitmask for http_random_init
|
||
|
+#endif
|
||
|
|
||
|
//{{{ Init csprng_state, do sanity checks
|
||
|
assert ( mode_of_operation->entropy_source < SOURCES_COUNT );
|
||
11 years ago
|
@@ -1072,6 +1080,7 @@ csprng_state_type* csprng_initialize( const mode_of_operation_type* mode_of_oper
|
||
11 years ago
|
}
|
||
|
//}}}
|
||
|
|
||
|
+#if defined(ENABLE_HTTP_RNG)
|
||
|
//{{{ Check if need HTTP_RNG and init it
|
||
|
if ( csprng_state->mode.entropy_source == HTTP_RNG || csprng_state->mode.add_input_source == HTTP_RNG ) {
|
||
|
QRBG_RNG_login_name = getenv("QRBG_USER");
|
||
11 years ago
|
@@ -1097,6 +1106,7 @@ csprng_state_type* csprng_initialize( const mode_of_operation_type* mode_of_oper
|
||
11 years ago
|
if ( unsetenv("QRBG_PASSWD") ) fprintf(stderr, "WARNING: unsetenv(\"QRBG_PASSWD\") failed with %s.\n", strerror(errno));
|
||
|
}
|
||
|
//}}}
|
||
|
+#endif
|
||
|
|
||
|
//{{{ Check if need HAVEGE and init it
|
||
|
if ( csprng_state->mode.entropy_source == HAVEGE || csprng_state->mode.add_input_source == HAVEGE ) {
|
||
11 years ago
|
@@ -1485,9 +1495,11 @@ csprng_destroy ( csprng_state_type* csprng_state )
|
||
11 years ago
|
destroy_buffer( csprng_state->entropy_buf );
|
||
|
}
|
||
|
|
||
|
+#if defined(ENABLE_HTTP_RNG)
|
||
|
if ( csprng_state->http != NULL ) {
|
||
|
http_random_destroy( csprng_state->http );
|
||
|
}
|
||
|
+#endif
|
||
|
|
||
|
if ( csprng_state->sha != NULL ) {
|
||
|
destroy_SHA1( csprng_state->sha );
|
||
11 years ago
|
diff --git a/test/Makefile.am b/test/Makefile.am
|
||
|
index d3e045e..023ded7 100644
|
||
|
--- a/test/Makefile.am
|
||
|
+++ b/test/Makefile.am
|
||
|
@@ -4,7 +4,10 @@ include $(top_srcdir)/common.mk
|
||
11 years ago
|
#bin_PROGRAMS = openssl-rand sha1_main memt qrbg_main http_main ctr_drbg_test
|
||
|
#TODO - link static does not work for qrbg_main.c => move it to C++ ??
|
||
|
|
||
|
-bin_PROGRAMS = openssl-rand_main sha1_main memt_main qrbg_main http_main ctr_drbg_test havege_main
|
||
|
+bin_PROGRAMS = openssl-rand_main sha1_main memt_main ctr_drbg_test havege_main
|
||
|
+if ENABLE_HTTP_RNG
|
||
|
+ bin_PROGRAMS += qrbg_main http_main
|
||
|
+endif
|
||
|
if HAVE_LIBTESTU01
|
||
|
bin_PROGRAMS += TestU01_raw_stdin_input_with_log
|
||
|
endif
|
||
11 years ago
|
diff --git a/utils/csprng-generate.c b/utils/csprng-generate.c
|
||
|
index f9207fb..7a1928a 100644
|
||
|
--- a/utils/csprng-generate.c
|
||
|
+++ b/utils/csprng-generate.c
|
||
|
@@ -832,7 +832,9 @@ int main(int argc, char **argv) {
|
||
11 years ago
|
mode_of_operation.file_read_size = 16384;
|
||
|
mode_of_operation.max_number_of_csprng_blocks = arguments.max_num_of_blocks;
|
||
|
mode_of_operation.random_length_of_csprng_generated_bytes = arguments.randomize_num_of_blocks;
|
||
|
+#if defined(ENABLE_HTTP_RNG)
|
||
|
mode_of_operation.http_random_verbosity = arguments.verbose;
|
||
|
+#endif
|
||
|
|
||
|
fips_state = fips_approved_csprng_initialize(arguments.fips_test, 0, &mode_of_operation);
|
||
|
|
||
11 years ago
|
@@ -942,9 +944,11 @@ int main(int argc, char **argv) {
|
||
11 years ago
|
current_time = time(NULL);
|
||
|
strftime(current_time_string, sizeof(current_time_string) , "%a %b %H:%M:%S %Y", localtime(¤t_time));
|
||
|
fprintf ( stderr, "\n========================= %s ==========================\n", current_time_string );
|
||
|
+#if defined(ENABLE_HTTP_RNG)
|
||
|
if ( arguments.entropy_source == HTTP_RNG || arguments.add_input_source == HTTP_RNG ) {
|
||
|
http_random_status( fips_state->csprng_state->http, 1);
|
||
|
}
|
||
|
+#endif
|
||
|
print_statistics(total_bytes_written, arguments.unlimited, remaining_bytes, arguments.size, stderr, &start_time);
|
||
|
fprintf(stderr, "\n");
|
||
|
if ( arguments.fips_test) fprintf ( stderr, "%s", dump_fips_statistics ( &fips_state->fips_ctx.fips_statistics ) );
|
||
11 years ago
|
@@ -968,9 +972,11 @@ int main(int argc, char **argv) {
|
||
11 years ago
|
current_time = time(NULL);
|
||
|
strftime(current_time_string, sizeof(current_time_string) , "%a %b %H:%M:%S %Y", localtime(¤t_time));
|
||
|
fprintf ( stderr, "\n======FINAL REPORT======= %s ==========================\n", current_time_string );
|
||
|
+#if defined(ENABLE_HTTP_RNG)
|
||
|
if ( arguments.entropy_source == HTTP_RNG || arguments.add_input_source == HTTP_RNG ) {
|
||
|
http_random_status( fips_state->csprng_state->http, 1);
|
||
|
}
|
||
|
+#endif
|
||
|
print_statistics(total_bytes_written, arguments.unlimited, remaining_bytes, arguments.size, stderr, &start_time);
|
||
|
fprintf(stderr, "\n");
|
||
|
if ( arguments.fips_test) fprintf ( stderr, "%s", dump_fips_statistics ( &fips_state->fips_ctx.fips_statistics ) );
|
||
11 years ago
|
--
|
||
|
1.7.2.3
|
||
|
|