summaryrefslogtreecommitdiff
path: root/random
Commit message (Collapse)AuthorAgeFilesLines
* Replace ath based mutexes by gpgrt based locks.Werner Koch2014-01-165-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>
* random: Call random progress handler more often.Werner Koch2013-12-161-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>
* Fix W32 buildJussi Kivilinna2013-12-131-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>
* Remove macro hacks for internal vs. external functions. Part 2 and last.Werner Koch2013-12-125-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>
* random: Add a feature to close device file descriptors.Werner Koch2013-12-117-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>
* Remove macro hacks for internal vs. external functions. Part 1.Werner Koch2013-12-053-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>
* Fix building for x32 targetJussi Kivilinna2013-09-011-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>
* Fix 'Please include winsock2.h before windows.h' warnings with mingw32Jussi Kivilinna2013-07-101-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>
* Fix i386/amd64 inline assembly "cc" clobbersJussi Kivilinna2013-07-101-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>
* Add support for using DRNG random number generatorDmitry Kasatkin2012-12-181-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.
* random: Add a RNG selection interface and system RNG wrapper.Werner Koch2012-12-035-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.
* Make random-fips.c work multi-threaded.Werner Koch2012-12-031-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.
* Move nonce creation from csprng backend to random main module.Werner Koch2012-12-035-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.
* Use configure test for aligned attribute.Werner Koch2012-11-211-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.
* Beautify last change.Werner Koch2012-06-211-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.
* Enable VIA Padlock on x86_64 platformsRafaël Carré2012-06-211-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>
* Generate the ChangeLog from commit logs.Werner Koch2011-12-011-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.
* Completed switch to a simpler thread model.Werner Koch2011-12-013-3/+4
| | | | | This is only a first step. We will need to either implement pthread_atfork or - better - make use use POSIX RT semaphores.
* Fix a problem with select and high fds.Werner Koch2011-09-083-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.
* Nuked almost all trailing whitespace.post-nuke-of-trailing-wsWerner Koch2011-02-0414-182/+175
| | | | Check and install the standard git pre-commit hook.
* Doc fixes.Werner Koch2010-11-041-2/+2
| | | | | Started some work on dumpsexp.
* Look at GNUPG_RNDW32_NOPERFWerner Koch2010-10-182-31/+49
|
* Fix bug 1263Werner Koch2010-08-191-0/+2
|
* 2010-04-27 Marcus Brinkmann <marcus@g10code.de>Marcus Brinkmann2010-04-272-13/+24
| | | | | | * rndw32ce.c (fillup_buffer): Rewrite without using nested functions, which are broken on arm/cegcc.
* Applied spelling fixes and more verbose test diagnositcs by Brad Hards.Werner Koch2010-04-128-16/+20
|
* Added an entropy gatherer for W32CE.Werner Koch2010-03-246-30/+226
|
* Support WindowsCE.Werner Koch2010-01-213-8/+41
|
* Cleaned up the cipher encrypy/decrypt constraints checks.Werner Koch2009-12-102-0/+16
|
* [random/ChangeLog]Werner Koch2009-07-093-39/+90
| | | | | | | | | | | | | | * rndlinux.c (_gcry_rndlinux_gather_random): Print real values for the progess function and call it before blocking. Suggested by Christian Grothoff. * rndunix.c (slow_poll): Add similar, but not yet functional, code. SCALAR(0x81980e8) Copyright 2008, 2009 Free Software Foundation, Inc. [tests/ChangeLog] * benchmark.c (progress_cb): New. (main): Add option --progress.
* Get more in sync to the Fedora version.Werner Koch2009-07-022-6/+9
|
* Preparinglibgcrypt-1.4.4Werner Koch2009-01-222-1/+6
|
* Fixed error cases in mpicoder.Werner Koch2008-12-051-4/+10
| | | | | Documentation cleanups.
* Another tweak for the RNG test code.Werner Koch2008-09-164-18/+42
|
* Make fipsrngdriv more pretty.Werner Koch2008-09-162-4/+5
| | | | | | Fix a problem in the RNG test code. Minor doc update.
* Finish FIPS random test driver.Werner Koch2008-09-162-2/+7
| | | | | Disable re-seeding if in test mode.
* Use syslog to log important messages.Werner Koch2008-09-155-8/+189
| | | | | Add an external RNG test hook.
* Let the test suite run the selftests even in non-fips mode.Werner Koch2008-09-053-1/+9
|
* Prepare a release candidatelibgcrypt-1.4.2rc2Werner Koch2008-09-012-15/+36
|
* Changed the way the FIPS RNG is seeded.Werner Koch2008-08-296-84/+188
| | | | | | FIPS cleanups. Documentation upodates.
* Implement a KAT for the fips random module.Werner Koch2008-08-252-22/+210
|
* Completed the RNG implementaion switching.Werner Koch2008-08-225-27/+82
| | | | | | | | | | | | | | | | | | | | | | | | | Added framework for running RNG tests. Added an experimental option --enable-hmac-binary-check to configure. --This line, and those below, will be ignored-- M src/fips.c M src/cipher-proto.h M src/global.c M src/hmac256.c M src/ChangeLog M src/hmac256.h M src/Makefile.am M tests/Makefile.am M configure.ac M doc/gcrypt.texi M random/random-fips.c M random/random.c M random/rand-internal.h M random/random.h M random/ChangeLog M ChangeLog M README
* Finished the X9.31 RNG implementations.Werner Koch2008-08-213-9/+604
|
* Replace assert calls by a new gcry_assert at most places.Werner Koch2008-08-204-15/+11
|
* A whole bunch of changes to eventually support Werner Koch2008-08-197-1269/+1657
| | | | | | | FIPS restricted mode. Also some documentation improvements and other minor enhancements. See the ChangeLogs. Stay tuned.
* Clarify license entry.Werner Koch2008-08-041-2/+2
| | | | | Small indentation change.
* Moved random stuff into its own directory.Werner Koch2008-07-0511-0/+4457