summaryrefslogtreecommitdiff
path: root/random
AgeCommit message (Collapse)AuthorFilesLines
2016-02-20Fix building random-drbg for Win32/64Jussi Kivilinna1-17/+15
* random/random-drbg.c: Remove include for sys/types.h and asm/types.h. (DRBG_PREDICTION_RESIST, DRBG_CTRAES, DRBG_CTRSERPENT, DRBG_CTRTWOFISH) (DRBG_HASHSHA1, DRBG_HASHSHA224, DRBG_HASHSHA256, DRBG_HASHSHA384) (DRBG_HASHSHA512, DRBG_HMAC, DRBG_SYM128, DRBG_SYM192) (DRBG_SYM256): Change 'u_int32_t' to 'u32'. (drbg_get_entropy) [USE_RNDUNIX, USE_RNDW32]: Fix parameters 'drbg_read_cb' and 'len'. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2016-02-19random: Remove ANSI X9.31 DRNGStephan Mueller2-26/+0
* random-fips.c: Remove. -- The ANSI X9.31 DRNG is removed as it is completely replaced with the SP800-90A DRBG. Signed-off-by: Stephan Mueller <smueller@chronox.de>
2016-02-19random: Allow DRBG_REINIT before initialization.Werner Koch1-8/+13
* random/random-drbg.c (DRBG_DEFAULT_TYPE): New. (_drbg_init_internal): Set the default type if no type has been set before. (_gcry_rngdrbg_inititialize): Pass 0 for flags to use the default. -- Without this change we can't call GCRYCTL_DRBG_REINIT before intialization. Signed-off-by: Werner Koch <wk@gnupg.org>
2016-02-19Add new private header gcrypt-testapi.h.Werner Koch2-36/+16
* src/gcrypt-testapi.h: New. * src/Makefile.am (libgcrypt_la_SOURCES): Add new file. * random/random.h: Include gcrypt-testapi.h. (struct gcry_drbg_test_vector) : Move to gcrypt-testapi.h. * src/global.c: Include gcrypt-testapi.h. (_gcry_vcontrol): Use PRIV_CTL_* constants instead of 58, 59, 60, 61. * cipher/cipher.c: Include gcrypt-testapi.h. (_gcry_cipher_ctl): Use PRIV_CIPHERCTL_ constants instead of 61, 62. * tests/fipsdrv.c: Include gcrypt-testapi.h. Remove definition of PRIV_CTL_ constants and replace their use by the new PRIV_CIPHERCTL_ constants. * tests/t-lock.c: Include gcrypt-testapi.h. Remove PRIV_CTL_EXTERNAL_LOCK_TEST and EXTERNAL_LOCK_TEST_ constants. * random/random-drbg.c (gcry_rngdrbg_cavs_test): Rename to ... (_gcry_rngdrbg_cavs_test): this. (gcry_rngdrbg_healthcheck_one): Rename to ... (_gcry_rngdrbg_healthcheck_one): this. Signed-off-by: Werner Koch <wk@gnupg.org>
2016-02-19random: Make the DRBG C-90 clean and use a flag string.Werner Koch2-261/+311
* random/random.h (struct gcry_drbg_test_vector): Rename "flags" to "flagstr" and turn it into a string. * random/random-drbg.c (drbg_test_pr, drbg_test_nopr): Replace use of designated initializers. Use a string for the flags. (gcry_rngdrbg_cavs_test): Parse the flag string into a flag value. (drbg_healthcheck_sanity): Ditto. -- Libgcrypt needs to be build-able on C-90 only systems and thus we can't use C-99 designated initializers. Because we have removed the flag macros from the API we should not use them in the CAVS test code either. Thus they are replaced by the flag string which also tests the flag string parser. Signed-off-by: Werner Koch <wk@gnupg.org>
2016-02-19random: Symbol name cleanup for random-drbg.c.Werner Koch1-551/+565
* random/random-drbg.c: Rename all static objects and macros from "gcry_drbg" to "drbg". (drbg_string_t): New typedef. (drbg_gen_t): New typedef. (drbg_state_t): New typedef. Replace all "struct drbg_state_s *" by this. (_drbg_init_internal): Replace xcalloc_secure by xtrycalloc_secure so that an error if actually returned. (gcry_rngdrbg_cavs_test): Ditto. (gcry_drbg_healthcheck_sanity): Ditto. Signed-off-by: Werner Koch <wk@gnupg.org>
2016-02-19random: Use our symbol name pattern also for drbg functions.Werner Koch4-48/+50
* 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>
2016-02-19random: Rename drbg.c to random-drbg.c.Werner Koch2-1/+1
* random/drbg.c: Rename to ... * random/random-drbg.c: this. * random/Makefile.am (librandom_la_SOURCES): Adjust accordingly. -- We should stick to our name comventions. Signed-off-by: Werner Koch <wk@gnupg.org>
2016-02-19random: Remove the new API introduced by the new DRBG.Werner Koch2-26/+173
* src/gcrypt.h.in (struct gcry_drbg_gen): Move to random/drbg.c. (struct gcry_drbg_string): Ditto. (gcry_drbg_string_fill): Ditto. (gcry_randomize_drbg): Remove. * random/drbg.c (parse_flag_string): New. (_gcry_drbg_reinit): Change the way the arguments are passed. * src/global.c (_gcry_vcontrol) <GCRYCTL_DRBG_REINIT>: Change calling convention. -- It does not make sense to extend the API for a somewhat questionable feature. For GCRYCTL_DRBG_REINIT we change to use a string with flags and libgcrypt's native buffer data structure. NB: GCRYCTL_DRBG_REINIT has not been tested! Signed-off-by: Werner Koch <wk@gnupg.org>
2016-02-18random: Remove DRBG constants from the public API.Werner Koch1-0/+69
* src/gcrypt.h.in (GCRY_DRBG_): Remove all new flags to ... * random/drbg.c: here. Signed-off-by: Werner Koch <wk@gnupg.org>
2016-02-18random: Add SP800-90A DRBGStephan Mueller5-49/+2386
* random/drbg.c: New. * random/random.c (_gcry_random_initialize): Replace rngfips init by drbg init. (__gcry_random_close_fds): Likewise. (_gcry_random_dump_stats): Likewise. (_gcry_random_is_faked): Likewise. (do_randomize): Likewise. (_gcry_random_selftest): Likewise. (_gcry_create_nonce): Replace rngfips_create_noce by drbg_randomize. (_gcry_random_init_external_test): Remove. (_gcry_random_run_external_test): Remove. (_gcry_random_deinit_external_test): Remove. * random/random.h (struct gcry_drbg_test_vector): New. * src/gcrypt.h.in (struct gcry_drbg_gen): New. (struct gcry_drbg_string): New. (gcry_drbg_string_fill): New. (gcry_randomize_drbg): New. (GCRY_DRBG_): Lots of new macros. * src/global.c (_gcry_vcontrol) <Init external random test>: Turn into a nop. (_gcry_vcontrol) <Deinit external random test>: Ditto. (_gcry_vcontrol) <Run external random test>: Change. (_gcry_vcontrol) <GCRYCTL_DRBG_REINIT>: New. -- This patch set adds the SP800-90A DRBG for AES128, AES192, AES256 with derivation function, SHA-1 through SHA-512 with derivation function, HMAC SHA-1 through HMAC SHA-512. All DRBGs are provided with and without prediction resistance. In addition, all DRBGs allow reseeding by the caller. The default DRBG is HMAC SHA-256 without prediction resistance. The caller may re-initialize the DRBG with the control GCRYCTL_DRBG_REINIT: The patch replaces the invocation of the existing ANSI X9.31 DRNG. This covers the control calls of 58 through 60. Control call 58 and 60 are simply deactivated. Control 59 is replaced with the DRBG CAVS test interface. Signed-off-by: Stephan Mueller <smueller@chronox.de> ChangeLog entries added by -wk
2016-01-15Fix build problem for rndegd.cWerner Koch1-2/+2
* Makefile.am (DISTCHECK_CONFIGURE_FLAGS): Test all RND modules. * random/rndegd.c (_gcry_rndegd_connect_socket) (my_make_filename): Use functions with '_' prefix. Signed-off-by: Werner Koch <wk@gnupg.org>
2016-01-15random: Fix possible AIX problem with sysconf in rndunix.Werner Koch1-3/+12
* random/rndunix.c [HAVE_STDINT_H]: Include stdint.h. (start_gatherer): Detect misbehaving sysconf. -- See GnuPG-bug-id: 1778 for the reason of this patch. There is no concrete bug report but this change should not harm. Signed-off-by: Werner Koch <wk@gnupg.org>
2015-12-27random: Take at max 25% from RDRANDWerner Koch1-3/+11
* random/rndlinux.c (_gcry_rndlinux_gather_random): Change use of RDRAND from 50% to 25%. Signed-off-by: Werner Koch <wk@gnupg.org>
2015-12-02random: Drop fake entropy gathering function.Justus Winter1-53/+3
* random/random-csprng.c (faked_rng): Drop variable. (gather_faked): Drop prototype and function. (initialize): Drop fallback code. (_gcry_rngcsprng_is_faked): Change accordingly. -- The fake entropy gathering function is deemed too dangerous to be used by accident, and is therefore removed. This reverts commit 468a5796ffb1a7776db4004d534376c1b981d740. Signed-off-by: Justus Winter <justus@g10code.com>
2015-12-02random: Fix selection of entropy gathering function.Justus Winter1-2/+2
* random/random-csprng.c (getfnc_gather_random): Do return NULL if no usable entropy gathering function is found. The callsite then installs the fake gather function. Signed-off-by: Justus Winter <justus@g10code.com>
2015-11-17Fix typos found using codespellJustus Winter3-6/+6
* cipher/cipher-ocb.c: Fix typos. * cipher/des.c: Likewise. * cipher/dsa-common.c: Likewise. * cipher/ecc.c: Likewise. * cipher/pubkey.c: Likewise. * cipher/rsa-common.c: Likewise. * cipher/scrypt.c: Likewise. * random/random-csprng.c: Likewise. * random/random-fips.c: Likewise. * random/rndw32.c: Likewise. * src/cipher-proto.h: Likewise. * src/context.c: Likewise. * src/fips.c: Likewise. * src/gcrypt.h.in: Likewise. * src/global.c: Likewise. * src/sexp.c: Likewise. * tests/mpitests.c: Likewise. * tests/t-lock.c: Likewise. Signed-off-by: Justus Winter <justus@g10code.com>
2015-09-04w32: Avoid a few compiler warnings.Werner Koch1-1/+1
* cipher/cipher-selftest.c (_gcry_selftest_helper_cbc) (_gcry_selftest_helper_cfb, _gcry_selftest_helper_ctr): Mark variable as unused. * random/rndw32.c (slow_gatherer): Avoid signed pointer mismatch warning. * src/secmem.c (init_pool): Avoid unused variable warning. * tests/random.c (writen, readn): Include on if needed. Signed-off-by: Werner Koch <wk@gnupg.org>
2015-05-21random: Change initial extra seeding from 2400 bits to 128 bits.Werner Koch1-2/+2
* random/random-csprng.c (read_pool): Reduce initial seeding. -- See discussion starting at https://lists.gnupg.org/pipermail/gnupg-devel/2015-April/029750.html and also in May. Signed-off-by: Werner Koch <wk@gnupg.org>
2015-05-01Fix rndhw for 64-bit Windows buildJussi Kivilinna1-2/+2
* configure.ac: Add sizeof check for 'void *'. * random/rndhw.c (poll_padlock): Check for SIZEOF_VOID_P == 8 instead of defined(__LP64__). (RDRAND_LONG): Check for SIZEOF_UNSIGNED_LONG == 8 instead of defined(__LP64__). -- __LP64__ is not predefined for 64-bit mingw64-gcc, which caused wrong assembly code selections. Do selection based on type sizes instead, to support x86_64, x32 and win64 properly. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-05-01Prepare random/win32.c fast poll for 64-bit WindowsJussi Kivilinna1-31/+52
* random/win32.c (_gcry_rndw32_gather_random_fast) [ADD]: Rename to ADDINT. (_gcry_rndw32_gather_random_fast): Add ADDPTR. (_gcry_rndw32_gather_random_fast): Disable entropy gathering from GetQueueStatus(QS_ALLEVENTS). (_gcry_rndw32_gather_random_fast): Change minimumWorkingSetSize and maximumWorkingSetSize to SIZE_T from DWORD. (_gcry_rndw32_gather_random_fast): Only add lower 32-bits of minimumWorkingSetSize and maximumWorkingSetSize to random poll. (_gcry_rndw32_gather_random_fast) [__WIN64__]: Read TSC directly using intrinsic. -- Introduce entropy gatherer changes related to 64-bit Windows platform as done in cryptlib fast poll: - Change ADD macro to ADDPTR/ADDINT to handle pointer values. ADDPTR discards high 32-bits of 64-bit pointer values. - minimum/maximumWorkingSetSize changed to SIZE_T type to avoid stack corruption on 64-bit; only low 32-bits are used for entropy. - Use __rdtsc() intrinsic on 64-bit (as TSC is always available). Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2015-01-05random: Silent warning under NetBSD using rndunixWerner Koch1-1/+18
* random/rndunix.c (STDERR_FILENO): Define if needed. (start_gatherer): Re-open standard descriptors. Fix an unsigned/signed pointer warning. -- GnuPG-bug-id: 1702
2014-12-25random-csprng: fix compiler warnings on ARMJussi Kivilinna1-2/+2
* random/random-csprng.c (_gcry_rngcsprng_update_seed_file) (read_pool): Cast keypool and rndpool to 'unsigned long *' through 'void *'. -- Patch fixes 'cast increases required alignment' warnings seen on GCC: random-csprng.c: In function '_gcry_rngcsprng_update_seed_file': random-csprng.c:867:15: warning: cast increases required alignment of target type [-Wcast-align] for (i=0,dp=(unsigned long*)keypool, sp=(unsigned long*)rndpool; ^ random-csprng.c:867:43: warning: cast increases required alignment of target type [-Wcast-align] for (i=0,dp=(unsigned long*)keypool, sp=(unsigned long*)rndpool; ^ random-csprng.c: In function 'read_pool': random-csprng.c:1023:14: warning: cast increases required alignment of target type [-Wcast-align] for(i=0,dp=(unsigned long*)keypool, sp=(unsigned long*)rndpool; ^ random-csprng.c:1023:42: warning: cast increases required alignment of target type [-Wcast-align] for(i=0,dp=(unsigned long*)keypool, sp=(unsigned long*)rndpool; ^ Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2014-04-22random: Small patch for consistency and really burn the stack.Werner Koch1-7/+9
* random/rndlinux.c (_gcry_rndlinux_gather_random): s/int/size_t/. (_gcry_rndlinux_gather_random): Replace memset by wipememory. -- size_t was suggested by Marcus Meissner <meissner@suse.de>. While looking at the code I identified the useless (i.e. likely optimized away) memset.
2014-01-16Replace ath based mutexes by gpgrt based locks.Werner Koch5-75/+34
* configure.ac (NEED_GPG_ERROR_VERSION): Require 1.13. (gl_LOCK): Remove. * src/ath.c, src/ath.h: Remove. Remove from all files. Replace all mutexes by gpgrt based statically initialized locks. * src/global.c (global_init): Remove ath_init. (_gcry_vcontrol): Make ath install a dummy function. (print_config): Remove threads info line. * doc/gcrypt.texi: Simplify the multi-thread related documentation. -- The current code does only work on ELF systems with weak symbol support. In particular no locks were used under Windows. With the new gpgrt_lock functions from the soon to be released libgpg-error 1.13 we have a better portable scheme which also allows for static initialized mutexes. Signed-off-by: Werner Koch <wk@gnupg.org>
2013-12-16random: Call random progress handler more often.Werner Koch1-7/+13
* random/rndlinux.c (_gcry_rndlinux_gather_random): Update progress indicator earlier. -- GnuPG-bug-id: 1531 Signed-off-by: Werner Koch <wk@gnupg.org>
2013-12-13Fix W32 buildJussi Kivilinna1-3/+3
* random/rndw32.c (register_poll, slow_gatherer): Change gcry_xmalloc to xmalloc, and gcry_xrealloc to xrealloc. -- Patch fixes following errors: ../random/.libs/librandom.a(rndw32.o): In function `registry_poll': .../libgcrypt/random/rndw32.c:434: undefined reference to `__gcry_USE_THE_UNDERSCORED_FUNCTION' .../libgcrypt/random/rndw32.c:454: undefined reference to `__gcry_USE_THE_UNDERSCORED_FUNCTION' ../random/.libs/librandom.a(rndw32.o): In function `slow_gatherer': .../random/rndw32.c:658: undefined reference to `__gcry_USE_THE_UNDERSCORED_FUNCTION' Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2013-12-12Remove macro hacks for internal vs. external functions. Part 2 and last.Werner Koch5-28/+28
* src/visibility.h: Remove remaining define/undef hacks for symbol visibility. Add macros to detect the use of the public functions. Change all affected functions by replacing them by the x-macros. * src/g10lib.h: Add internal prototypes. (xtrymalloc, xtrycalloc, xtrymalloc_secure, xtrycalloc_secure) (xtryrealloc, xtrystrdup, xmalloc, xcalloc, xmalloc_secure) (xcalloc_secure, xrealloc, xstrdup, xfree): New macros. -- The use of xmalloc/xtrymalloc/xfree is a more common pattern than the gcry_free etc. functions. Those functions behave like those defined by C and thus for better readability we use these macros and not the underscore prefixed functions. Signed-off-by: Werner Koch <wk@gnupg.org>
2013-12-11random: Add a feature to close device file descriptors.Werner Koch7-12/+126
* src/gcrypt.h.in (GCRYCTL_CLOSE_RANDOM_DEVICE): New. * src/global.c (_gcry_vcontrol): Call _gcry_random_close_fds. * random/random.c (_gcry_random_close_fds): New. * random/random-csprng.c (_gcry_rngcsprng_close_fds): New. * random/random-fips.c (_gcry_rngfips_close_fds): New. * random/random-system.c (_gcry_rngsystem_close_fds): New. * random/rndlinux.c (open_device): Add arg retry. (_gcry_rndlinux_gather_random): Add mode to close open fds. * tests/random.c (check_close_random_device): New. (main): Call new test. Signed-off-by: Werner Koch <wk@gnupg.org>
2013-12-05Remove macro hacks for internal vs. external functions. Part 1.Werner Koch3-39/+39
* src/visibility.h: Remove almost all define/undef hacks for symbol visibility. Add macros to detect the use of the public functions. Change all affected functions by prefixing them explicitly with an underscore and change all internal callers to call the underscore prefixed versions. Provide convenience macros from sexp and mpi functions. * src/visibility.c: Change all functions to use only gpg_err_code_t and translate to gpg_error_t only in visibility.c. -- The use of the macro magic made if hard to follow the function calls in the source. It was not easy to see if an internal or external function (as defined by visibility.c) was called. The change is quite large but hopefully makes Libgcrypt easier to maintain. Some function have not yet been fixed; this will be done soon. Because Libgcrypt does no make use of any other libgpg-error using libraries it is useless to always translate between gpg_error_t and gpg_err_code_t (i.e with and w/o error source identifier). This translation has no mostly be moved to the function wrappers in visibility.c. An additional advantage of using gpg_err_code_t is that comparison can be done without using gpg_err_code(). I am sorry for that large patch, but a series of patches would actually be more work to audit. Signed-off-by: Werner Koch <wk@gnupg.org>
2013-09-01Fix building for x32 targetJussi Kivilinna1-2/+2
* mpi/amd64/mpi-asm-defs.h: New file. * random/rndhw.c (poll_padlock) [__x86_64__]: Also check if __LP64__ is defined. [USE_DRNG, __x86_64__]: Also check if __LP64__ is defined. -- In short, x32 is new x86-64 ABI with 32-bit pointers. Adding support is straightforward, small fix for mpi and fixes for random/rndhw.c. AMD64 assembly functions appear to work fine with x32 and 'make check' passes. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2013-07-10Fix 'Please include winsock2.h before windows.h' warnings with mingw32Jussi Kivilinna1-0/+1
* random/rndw32.c: include winsock2.h before windows.h. * src/ath.h [_WIN32]: Ditto. * tests/benchmark.c [_WIN32]: Ditto. -- Patch silences warnings of following type: /usr/lib/gcc/i686-w64-mingw32/4.6/../../../../i686-w64-mingw32/include/winsock2.h:15:2: warning: #warning Please include winsock2.h before windows.h [-Wcpp] Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2013-07-10Fix i386/amd64 inline assembly "cc" clobbersJussi Kivilinna1-1/+2
* cipher/bithelp.h [__GNUC__, __i386__] (rol, ror): add "cc" globber for inline assembly. * cipher/cast5.c [__GNUC__, __i386__] (rol): Ditto. * random/rndhw.c [USE_DRNG] (rdrand_long): Ditto. * src/hmac256.c [__GNUC__, __i386__] (ror): Ditto. * mpi/longlong.c [__i386__] (add_ssaaaa, sub_ddmmss, umul_ppmm) (udiv_qrnnd, count_leading_zeros, count_trailing_zeros): Ditto. -- These assembly snippets modify cflags but do not mark "cc" clobber. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
2012-12-18Add support for using DRNG random number generatorDmitry Kasatkin1-0/+68
* configure.ac: Add option --disable-drng-support. (ENABLE_DRNG_SUPPORT): New. * random/rndhw.c (USE_DRNG): New. (rdrand_long, rdrand_nlong, poll_drng): New. (_gcry_rndhw_poll_fast, _gcry_rndhw_poll_slow): Call poll function. * src/g10lib.h (HWF_INTEL_RDRAND): New. * src/global.c (hwflist): Add "intel-rdrand". * src/hwfeatures.c (detect_x86_64_gnuc) [ENABLE_DRNG_SUPPORT]: Detect RDRAND. (detect_ia32_gnuc) [ENABLE_DRNG_SUPPORT]: Detect RDRAND. -- This patch provides support for using Digital Random Number Generator (DRNG) engine, which is available on the latest Intel's CPUs. DRNG engine is accesible via new the RDRAND instruction. This patch adds the following: - support for disabling using of rdrand instruction - checking for RDRAND instruction support using cpuid - RDRAND usage implementation Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com> ChangeLog and editorial changes by wk.
2012-12-03random: Add a RNG selection interface and system RNG wrapper.Werner Koch5-5/+375
* random/random-system.c: New. * random/Makefile.am (librandom_la_SOURCES): Add new module. * random/random.c (struct rng_types): New. (_gcry_set_preferred_rng_type, _gcry_get_rng_type): New. (_gcry_random_initialize, gcry_random_add_bytes, do_randomize) (_gcry_set_random_seed_file, _gcry_update_random_seed_file) (_gcry_fast_random_poll): Dispatch to the actual RNG. * src/gcrypt.h.in (GCRYCTL_SET_PREFERRED_RNG_TYPE): New. GCRYCTL_GET_CURRENT_RNG_TYPE): New. (gcry_rng_types): New. * src/global.c (print_config): Print the TNG type. (global_init, _gcry_vcontrol): Implement the new control codes. * doc/gcrypt.texi (Controlling the library): Document the new control codes. * tests/benchmark.c (main): Add options to test the RNG types. * tests/random.c (main): Add new options. (print_hex): Print to stderr. (progress_cb, rng_type): New. (check_rng_type_switching, check_early_rng_type_switching): New. (run_all_rng_tests): New. -- The purpose of this change is to allow applications with moderate random requirements to use the system's RNG (e.g. /dev/urandom). The type switching logic makes sure that existing applications won't be affected by this change. A library is in almost all cases not able to degrade the quality of the RNG. The definition of "degrade" comes from our own assertion of the quality/trustworthiness of the RNGs: The most trustworthy RNG is the CSPRNG which dates back to the early GnuPG days. It is quite conservative and often requires more seeding than might be justified. GCRY_RNG_TYPE_STANDARD is the default unless the process is in FIPS mode. The second trustworthy RNG is the FIPS recommended X9.81 AES based implementation. It is seeded by the system's RNG. GCRY_RNG_TYPE_FIPS is the only available RNG if running in FIPS mode. The third trustworthy RNG is a mere wrapper around the system's native RNG. Thus there is no extra step on top of what, for example, /dev/random provides. GCRY_RNG_TYPE_SYSTEM may be used by applications which would use /dev/random or /dev/urandom instead.
2012-12-03Make random-fips.c work multi-threaded.Werner Koch1-1/+1
* random/random-fips.c (basic_initialization): Fix reversed logic. -- The module never initialized the mutex at all. Probably this was never an issue before commit 38fcd59 which removed static lock init.
2012-12-03Move nonce creation from csprng backend to random main module.Werner Koch5-121/+105
* random/random-csprng.c (_gcry_rngcsprng_create_nonce): Remove. (nonce_buffer_lock): Remove. (initialize_basics): Remove init of nonce_buffer_lock. * random/random.c: Add a few header files. (nonce_buffer_lock): New. (_gcry_random_initialize): Init nonce_buffer_lock. (gcry_create_nonce): Add code from _gcry_rngcsprng_create_nonce. * random/random-daemon.c (_gcry_daemon_create_nonce): Remove. -- The nonce generation code is useful for all RNG types and thus it should be in random.c. The only exception is the fips-mode, which requires the use of the fips nonce generator.
2012-11-21Use configure test for aligned attribute.Werner Koch1-1/+1
* configure.ac (HAVE_GCC_ATTRIBUTE_ALIGNED): New test and ac_define. * cipher/cipher-internal.h, cipher/rijndael.c, random/rndhw.c: Use new macro instead of a fixed test for __GNUC__. -- We assume that compilers that grok "__attribute__ ((aligned (16)))" implement that in the same way as gcc does. In case it turns out that this is not the case we will need to do two more things: Detect such different behaviour and come up with a construct to allows the use of that other style of alignment forcing.
2012-06-21Beautify last change.Werner Koch1-2/+5
* cipher/rijndael.c: Replace C99 feature from last patch. Keep cpp lines short. * random/rndhw.c: Keep cpp lines short. * src/hwfeatures.c (_gcry_detect_hw_features): Make cpp def chain better readable.
2012-06-21Enable VIA Padlock on x86_64 platformsRafaël Carré1-1/+12
* cipher/rijndael.c: Duplicate x86 assembly and convert to x86_64. * random/rndhw.c: Likewise. * src/hwfeatures.c: Likewise. -- Changes made to the x86 assembly: - *l -> *q (long -> quad) - e** registers -> r** registers (use widest registers available) - don't mess with ebx GOT register Tested with make check on VIA Nano X2 L4350 Signed-off-by: Rafaël Carré <funman@videolan.org>
2011-12-01Generate the ChangeLog from commit logs.Werner Koch1-0/+11
* scripts/gitlog-to-changelog: New script. Taken from gnulib. * scripts/git-log-fix: New file. * scripts/git-log-footer: New file. * doc/HACKING: Describe the ChangeLog policy * ChangeLog: New file. * Makefile.am (EXTRA_DIST): Add new files. (gen-ChangeLog): New. (dist-hook): Run gen-ChangeLog. Rename all ChangeLog files to ChangeLog-2011.
2011-12-01Completed switch to a simpler thread model.Werner Koch3-3/+4
This is only a first step. We will need to either implement pthread_atfork or - better - make use use POSIX RT semaphores.
2011-09-08Fix a problem with select and high fds.Werner Koch3-21/+37
If on systems where the maximum number of fds may be dynamically configured to a value of FD_MAXSIZE or higher and the RNG is first used after more than FD_SETSIZE-1 descriptors are in use, we disable the progress messages from the RNG. A better solution would be too use poll but that requires more tests. The same problem exists in rndunix.c - however this rng is only used on old Unices and I assume that they don't feature dynamically configured maximum fd sizes.
2011-02-04Nuked almost all trailing whitespace.Werner Koch14-182/+175
Check and install the standard git pre-commit hook.
2010-11-04Doc fixes.Werner Koch1-2/+2
Started some work on dumpsexp.
2010-10-18Look at GNUPG_RNDW32_NOPERFWerner Koch2-31/+49
2010-08-19Fix bug 1263Werner Koch1-0/+2
2010-04-272010-04-27 Marcus Brinkmann <marcus@g10code.de>Marcus Brinkmann2-13/+24
* rndw32ce.c (fillup_buffer): Rewrite without using nested functions, which are broken on arm/cegcc.
2010-04-12Applied spelling fixes and more verbose test diagnositcs by Brad Hards.Werner Koch8-16/+20
2010-03-24Added an entropy gatherer for W32CE.Werner Koch6-30/+226