diff options
author | Norbert Preining <norbert@preining.info> | 2020-09-20 03:03:26 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2020-09-20 03:03:26 +0000 |
commit | 1f457376b478257b88d4a857f5ec1b6155442dd7 (patch) | |
tree | 2a06a60551dea362cf8cb0cb0ba66c78608717c4 /support/dktools/dk-rand.ctr | |
parent | ac690ca29ad5bf8a5203a65fd6252f7b564f4727 (diff) |
CTAN sync 202009200303
Diffstat (limited to 'support/dktools/dk-rand.ctr')
-rw-r--r-- | support/dktools/dk-rand.ctr | 81 |
1 files changed, 52 insertions, 29 deletions
diff --git a/support/dktools/dk-rand.ctr b/support/dktools/dk-rand.ctr index b308de5f9c..9a225a93b0 100644 --- a/support/dktools/dk-rand.ctr +++ b/support/dktools/dk-rand.ctr @@ -2,7 +2,7 @@ copyright owner = Dirk Krause copyright year = 2015-xxxx -license = bsd +SPDX-License-Identifier: BSD-3-Clause %% module @@ -88,7 +88,11 @@ license = bsd #include "dk4maasz.h" #include "dk4mpl.h" #include "dk4svbuf.h" +#include "dk4unused.h" +#ifndef DK4WMAIN_H_INCLUDED +#include "dk4wmain.h" +#endif $!trace-include @@ -114,7 +118,9 @@ static char stdout_buffer[BUFSIZ]; /** Buffer to read seed file. */ +#if (!(DK4_ON_WINDOWS)) static char seed_file_buffer[BUFSIZ]; +#endif @@ -133,7 +139,7 @@ dk-rand [-b bytes] --version Show version information. --license Show license information. -http://dktools.sourceforge.net +http://sourceforge.net/p/dktools/wiki/dk-rand/ $!end }; @@ -148,7 +154,8 @@ This software uses code from the following projects, either directly or as a library: dktools Dirk Krause's tools and libraries. - See http://dktools.sourceforge.net/ for more information. + See http://sourceforge.net/p/dktools/wiki/Home/ + for more information. #if DK4_HAVE_OPENSSL_RAND_H OpenSSL Cryptographic toolkit, used to build file checksums here. @@ -176,27 +183,27 @@ All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -* Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -* Neither the name of the Dirk Krause nor the names of contributors may be - used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. - -IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. #if DK4_HAVE_OPENSSL_RAND_H @@ -471,8 +478,9 @@ sig_pass_pointer(DK4_VOLATILE dk4_sig_atomic_t *ptr) */ static void -sig_handler_pipe(int signo) +sig_handler_pipe(int DK4_ARG_UNUSED(signo) ) { + DK4_UNUSED_ARG(signo) *sig_pass_pointer(&sig_had_pipe) = 1; } #endif @@ -483,8 +491,9 @@ sig_handler_pipe(int signo) */ static void -sig_handler_int(int signo) +sig_handler_int(int DK4_ARG_UNUSED(signo) ) { + DK4_UNUSED_ARG(signo) *sig_pass_pointer(&sig_had_int) = 1; } @@ -494,8 +503,9 @@ sig_handler_int(int signo) */ static void -sig_handler_term(int signo) +sig_handler_term(int DK4_ARG_UNUSED(signo) ) { + DK4_UNUSED_ARG(signo) *sig_pass_pointer(&sig_had_term) = 1; } @@ -521,9 +531,18 @@ sig_read_atomic(DK4_VOLATILE dk4_sig_atomic_t *ap) */ static int -can_continue(int dopipe) +can_continue( +#ifdef SIGPIPE +int dopipe +#else +int DK4_ARG_UNUSED(dopipe) +#endif +) { int back = 1; +#ifndef SIGPIPE + DK4_UNUSED_ARG(dopipe) +#endif if (0 != sig_read_atomic(&sig_had_term)) { back = 0; } if (0 != sig_read_atomic(&sig_had_int)) { back = 0; } #ifdef SIGPIPE @@ -558,7 +577,9 @@ int seed_prng(void) { char buffer[64]; +#if DK4_HAVE_RAND_EGD && DK4_HAVE_STRUCT_SOCKADDR_UN char *envptr; +#endif #if DK4_ON_WINDOWS HCRYPTPROV hcp; BOOL res; @@ -569,7 +590,9 @@ seed_prng(void) int cc; int rounds = 0; int back = 0; +#if (!(DK4_ON_WINDOWS)) int svbres = 0; +#endif $? "+ dk_pwgen_seed_prng" /* Let OpenSSL library functions try to initialize. @@ -603,7 +626,7 @@ seed_prng(void) cc = 1; do { if (0 != can_continue(0)) { - res = CryptGenRandom(hcp, (DWORD)sizeof(buffer), buffer); + res = CryptGenRandom(hcp, (DWORD)sizeof(buffer), (BYTE *)buffer); if (res) { RAND_seed(buffer, sizeof(buffer)); if (1 == RAND_status()) { |