Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:huakim:matrix
perl-Crypt-Random-Seed
_service:obs_scm:Crypt-Random-Seed.obscpio
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:Crypt-Random-Seed.obscpio of Package perl-Crypt-Random-Seed
07070100000000000081A4000000000000000000000001634AFEFF0000012F000000000000000000000000000000000000001E00000000Crypt-Random-Seed/.travis.ymllanguage: "perl" perl: - "5.16" - "5.14" - "5.12" - "5.10" install: - cpanm -v --installdeps --notest --mirror http://cpan.mirrors.travis-ci.org . script: "perl Makefile.PL; make test" notifications: recipients: - dana@acm.org email: on_success: change on_failure: always 07070100000001000081A4000000000000000000000001634AFEFF000002DD000000000000000000000000000000000000001A00000000Crypt-Random-Seed/ChangesRevision history for Perl extension Crypt::Random::Seed 0.03 16 Feb 2013 - Allow tests to run even if TESHA2 isn't installed. Thanks to Salvatore Bonaccorso for suggestion. - Use binmode on file reads. Thanks for David Dick for idea. - Minor documentation updates. 0.02 29 Jan 2013 - Add EGD/PRNGD source. - More documentation. - More strict with perlcritic (used Bytes::Random::Secure for some reference) - Remove 'Weak' constructor option. There was too little logic behind what got called strong or weak. The is_strong() call remains, so the calle can use it possibly in conjunction with the name() value to make a more informed decision. 0.01 12 Jan 2013 - Initial development 07070100000002000081A4000000000000000000000001634AFEFF000047BD000000000000000000000000000000000000001A00000000Crypt-Random-Seed/LICENSEThis software is Copyright (c) 2012-2013 by Dana Jacobsen. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2012-2013 by Dana Jacobsen. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Suite 500, Boston, MA 02110-1335 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) 19yy <name of author> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. <signature of Ty Coon>, 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2012-2013 by Dana Jacobsen. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End 07070100000003000081A4000000000000000000000001634AFEFF00000214000000000000000000000000000000000000001B00000000Crypt-Random-Seed/MANIFESTChanges Makefile.PL LICENSE MANIFEST README TODO lib/Crypt/Random/Seed.pm t/01-load.t t/02-new.t t/03-can.t t/04-win32.t t/10-name.t t/11-random_bytes.t t/12-random_values.t t/13-whitelist.t t/14-blacklist.t t/90-release-perlcritic.t t/91-release-pod-syntax.t t/92-release-pod-coverage.t t/93-release-kwalitee.t t/94-release-manifest.t examples/brs.pl .travis.yml META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) 07070100000004000081A4000000000000000000000001634AFEFF000004E4000000000000000000000000000000000000001C00000000Crypt-Random-Seed/META.json{ "abstract" : "Provide strong randomness for seeding", "author" : [ "Dana A Jacobsen <dana@acm.org>" ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 6.64, CPAN::Meta::Converter version 2.120921", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Crypt-Random-Seed", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "Test::More" : "0.45" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Carp" : "0", "Crypt::Random::TESHA2" : "0", "Exporter" : "5.562", "Fcntl" : "0", "base" : "0", "constant" : "0", "perl" : "5.006002" } } }, "release_status" : "stable", "resources" : { "homepage" : "https://github.com/danaj/Crypt-Random-Seed", "repository" : { "url" : "https://github.com/danaj/Crypt-Random-Seed" } }, "version" : "0.03" } 07070100000005000081A4000000000000000000000001634AFEFF000002C4000000000000000000000000000000000000001B00000000Crypt-Random-Seed/META.yml--- abstract: 'Provide strong randomness for seeding' author: - 'Dana A Jacobsen <dana@acm.org>' build_requires: Test::More: 0.45 configure_requires: ExtUtils::MakeMaker: 0 dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 6.64, CPAN::Meta::Converter version 2.120921' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Crypt-Random-Seed no_index: directory: - t - inc requires: Carp: 0 Crypt::Random::TESHA2: 0 Exporter: 5.562 Fcntl: 0 base: 0 constant: 0 perl: 5.006002 resources: homepage: https://github.com/danaj/Crypt-Random-Seed repository: https://github.com/danaj/Crypt-Random-Seed version: 0.03 07070100000006000081A4000000000000000000000001634AFEFF00000942000000000000000000000000000000000000001E00000000Crypt-Random-Seed/Makefile.PLuse 5.006000; use strict; use warnings; use ExtUtils::MakeMaker; my %os_prereq; if ($^O eq 'MSWin32') { # Make sure we use a newish version of Win32::API for 64-bit my $api_version = (~0 > 281474976710656) ? 0.62 : 0; %os_prereq = ( 'Win32' => 0, 'Win32::API' => $api_version, #'Win32::API::Type' => 0, # a submodule of Win32::API ); } WriteMakefile1( NAME => 'Crypt::Random::Seed', ABSTRACT => "Provide strong randomness for seeding", VERSION_FROM => 'lib/Crypt/Random/Seed.pm', # finds $VERSION LICENSE => 'perl', AUTHOR => 'Dana A Jacobsen <dana@acm.org>', BUILD_REQUIRES=>{ 'Test::More' => '0.45', }, PREREQ_PM => { 'Exporter' => '5.562', 'base' => 0, 'constant' => 0, 'Carp' => 0, 'Fcntl' => 0, %os_prereq, 'Crypt::Random::TESHA2' => 0, }, META_MERGE => { resources => { homepage => 'https://github.com/danaj/Crypt-Random-Seed', repository => 'https://github.com/danaj/Crypt-Random-Seed', }, }, MIN_PERL_VERSION => 5.006002, ); sub WriteMakefile1 { # Cribbed from eumm-upgrade by Alexandr Ciornii my %params = @_; my $eumm_version = $ExtUtils::MakeMaker::VERSION; $eumm_version = eval $eumm_version; if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) { #EUMM 6.5502 has problems with BUILD_REQUIRES $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} }; delete $params{BUILD_REQUIRES}; } delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52; delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48; delete $params{META_MERGE} if $eumm_version < 6.46; delete $params{META_ADD} if $eumm_version < 6.46; delete $params{LICENSE} if $eumm_version < 6.31; delete $params{AUTHOR} if $] < 5.005; delete $params{ABSTRACT_FROM} if $] < 5.005; delete $params{BINARY_LOCATION} if $] < 5.005; WriteMakefile(%params); } 07070100000007000081A4000000000000000000000001634AFEFF00000456000000000000000000000000000000000000001900000000Crypt-Random-Seed/READMECrypt::Random::Seed version 0.03 ======================== Crypt::Random::Seed provides a simple interface to get the strongest source of randomness on the current platform, typically for use in seeding a CSPRNG such as Math::Random::ISAAC. It can also be restricted to non-blocking sources, and has a very simple plug-in method. The following sources are tried, in order: Win32 Crypto API EGD /dev/random Crypt::Random::TESHA2 INSTALLATION To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES Win32::API on Windows. Crypt::Random::TESHA2, only used if /dev/random or Win32 API doesn't work. SEE ALSO Crypt::URandom provides similar functionality for non-blocking sources. For more complex setups, Crypt::Random::Source has multiple plugins. COPYRIGHT AND LICENCE Copyright (C) 2013 by Dana Jacobsen <dana@acm.org> This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.16.2 or, at your option, any later version of Perl 5 you may have available. 07070100000008000081A4000000000000000000000001634AFEFF0000000A000000000000000000000000000000000000001700000000Crypt-Random-Seed/TODO- Add EGD 07070100000009000041ED000000000000000000000004634AFEFF00000000000000000000000000000000000000000000001900000000Crypt-Random-Seed/debian0707010000000A000081A4000000000000000000000001634AFEFF00000533000000000000000000000000000000000000002300000000Crypt-Random-Seed/debian/changeloglibcrypt-random-seed-perl (0.03-3) unstable; urgency=medium [ Debian Janitor ] * Apply multi-arch hints. + libcrypt-random-seed-perl: Add Multi-Arch: foreign. -- Jelmer Vernooij <jelmer@debian.org> Sat, 15 Oct 2022 19:42:07 +0100 libcrypt-random-seed-perl (0.03-2) unstable; urgency=medium [ Laurent Baillet ] * fix lintian wrong-path-for-interpreter error [ gregor herrmann ] * Strip trailing slash from metacpan URLs. [ Salvatore Bonaccorso ] * Update Vcs-Browser URL to cgit web frontend * debian/control: Use HTTPS transport protocol for Vcs-Git URI [ gregor herrmann ] * debian/copyright: change Copyright-Format 1.0 URL to HTTPS. [ Salvatore Bonaccorso ] * Update Vcs-* headers for switch to salsa.debian.org [ gregor herrmann ] * debian/watch: use uscan version 4. -- Jelmer Vernooij <jelmer@debian.org> Sun, 12 Jun 2022 22:29:43 +0100 libcrypt-random-seed-perl (0.03-1.1) unstable; urgency=medium * Non maintainer upload by the Reproducible Builds team. * No source change upload to rebuild on buildd with .buildinfo files. -- Holger Levsen <holger@debian.org> Fri, 25 Dec 2020 18:09:11 +0100 libcrypt-random-seed-perl (0.03-1) unstable; urgency=low * Initial Release (Closes: #700692). -- Salvatore Bonaccorso <carnil@debian.org> Sat, 16 Feb 2013 22:55:17 +0100 0707010000000B000081A4000000000000000000000001634AFEFF00000488000000000000000000000000000000000000002100000000Crypt-Random-Seed/debian/controlSource: libcrypt-random-seed-perl Section: perl Priority: optional Maintainer: Debian Perl Group <pkg-perl-maintainers@lists.alioth.debian.org> Uploaders: Salvatore Bonaccorso <carnil@debian.org> Build-Depends: debhelper-compat (= 13) Build-Depends-Indep: perl Standards-Version: 3.9.4 Vcs-Browser: https://salsa.debian.org/perl-team/modules/packages/libcrypt-random-seed-perl Vcs-Git: https://salsa.debian.org/perl-team/modules/packages/libcrypt-random-seed-perl.git Homepage: https://metacpan.org/release/Crypt-Random-Seed Testsuite: autopkgtest-pkg-perl Package: libcrypt-random-seed-perl Architecture: all Depends: ${misc:Depends}, ${perl:Depends} Multi-Arch: foreign Description: Perl module providing strong randomness for seeding Crypt::Random::Seed implements a simple mechanism to get strong randomness. The main purpose of this module is to provide a simple way to generate a seed for a PRNG such as Math::Random::ISAAC, for use in cryptographic key generation, or as the seed for an upstream module such as Bytes::Random::Secure. Flags for requiring non-blocking sources are allowed, as well as a very simple method for plugging in a source. 0707010000000C000081A4000000000000000000000001634AFEFF0000042A000000000000000000000000000000000000002300000000Crypt-Random-Seed/debian/copyrightFormat: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: Crypt-Random-Seed Source: https://metacpan.org/release/Crypt-Random-Seed Upstream-Contact: Dana A Jacobsen <dana@acm.org> Files: * Copyright: 2013, Dana A Jacobsen <dana@acm.org> License: Artistic or GPL-1+ Files: debian/* Copyright: 2013, Salvatore Bonaccorso <carnil@debian.org> License: Artistic or GPL-1+ License: Artistic This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License, which comes with Perl. . On Debian systems, the complete text of the Artistic License can be found in `/usr/share/common-licenses/Artistic'. License: GPL-1+ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. . On Debian systems, the complete text of version 1 of the GNU General Public License can be found in `/usr/share/common-licenses/GPL-1'. 0707010000000D000081A4000000000000000000000001634AFEFF00000005000000000000000000000000000000000000003800000000Crypt-Random-Seed/debian/libcrypt-random-seed-perl.docsTODO 0707010000000E000081A4000000000000000000000001634AFEFF0000000B000000000000000000000000000000000000003C00000000Crypt-Random-Seed/debian/libcrypt-random-seed-perl.examplesexamples/* 0707010000000F000081ED000000000000000000000001634AFEFF000000FD000000000000000000000000000000000000001F00000000Crypt-Random-Seed/debian/rules#!/usr/bin/make -f PACKAGE = $(shell dh_listpackages) TMP = $(CURDIR)/debian/$(PACKAGE) %: dh $@ override_dh_installexamples: dh_installexamples sed -i '1s|^#!/usr/bin/env perl|#!/usr/bin/perl|' $(TMP)/usr/share/doc/$(PACKAGE)/examples/brs.pl 07070100000010000041ED000000000000000000000002634AFEFF00000000000000000000000000000000000000000000002000000000Crypt-Random-Seed/debian/source07070100000011000081A4000000000000000000000001634AFEFF0000000C000000000000000000000000000000000000002700000000Crypt-Random-Seed/debian/source/format3.0 (quilt) 07070100000012000041ED000000000000000000000002634AFEFF00000000000000000000000000000000000000000000002200000000Crypt-Random-Seed/debian/upstream07070100000013000081A4000000000000000000000001634AFEFF000000FF000000000000000000000000000000000000002B00000000Crypt-Random-Seed/debian/upstream/metadata--- Bug-Database: https://github.com/danaj/Crypt-Random-Seed/issues Bug-Submit: https://github.com/danaj/Crypt-Random-Seed/issues/new Repository: https://github.com/danaj/Crypt-Random-Seed.git Repository-Browse: https://github.com/danaj/Crypt-Random-Seed 07070100000014000081A4000000000000000000000001634AFEFF0000006E000000000000000000000000000000000000001F00000000Crypt-Random-Seed/debian/watchversion=4 https://metacpan.org/release/Crypt-Random-Seed .*/Crypt-Random-Seed-v?@ANY_VERSION@@ARCHIVE_EXT@$ 07070100000015000041ED000000000000000000000002634AFEFF00000000000000000000000000000000000000000000001B00000000Crypt-Random-Seed/examples07070100000016000081A4000000000000000000000001634AFEFF00000607000000000000000000000000000000000000002200000000Crypt-Random-Seed/examples/brs.pl#!/usr/bin/env perl use strict; use warnings; use Crypt::Random::Seed; use Math::Random::ISAAC; # Get a strong random source. my $source = Crypt::Random::Seed->new(); die "Cannot find a source" unless defined $source; { # Win32 uses FIPS 186-2 with SHA1, so has a 160-bit internal state, meaning # they start with 5 32-bit values worth of entropy. # ISAAC uses 256 32-bit values for state, and zero-pads everything not # supplied. Using 8 values (256 bits) for seeding should be more than enough. my $RNG = Math::Random::ISAAC->new( $source->random_values(8) ); sub random_bytes { my $bytes = shift; $bytes = defined $bytes ? int($bytes) : 0; my $str = ''; while ($bytes >= 4) { $str .= pack("L", $RNG->irand); $bytes -= 4; } if ($bytes > 0) { my $rval = $RNG->irand; $str .= pack("S", ($rval >> 8) & 0xFFFF) if $bytes >= 2; $str .= pack("C", $rval & 0xFF) if $bytes % 2; } return $str; } } # Create a big stream of output for testing. Takes about 2 seconds. print random_bytes(8192) for 1..1024; __END__ ./entest -vf brs.out Test Results Sample: 8388608 bytes Entropy: 7.999976 bits Chi-Square: 282.623535(11.296928%) Mean: 127.488821 PI: 3.139942(-0.052543%) Correlation: 0.000195 Sample looks good! ./a.out ========= Summary results of Rabbit ========= Version: TestU01 1.2.3 File: brs.out Number of bits: 67108864 Number of statistics: 40 Total CPU time: 00:00:31.53 All tests were passed 07070100000017000041ED000000000000000000000003634AFEFF00000000000000000000000000000000000000000000001600000000Crypt-Random-Seed/lib07070100000018000041ED000000000000000000000003634AFEFF00000000000000000000000000000000000000000000001C00000000Crypt-Random-Seed/lib/Crypt07070100000019000041ED000000000000000000000002634AFEFF00000000000000000000000000000000000000000000002300000000Crypt-Random-Seed/lib/Crypt/Random0707010000001A000081A4000000000000000000000001634AFEFF000068A3000000000000000000000000000000000000002B00000000Crypt-Random-Seed/lib/Crypt/Random/Seed.pmpackage Crypt::Random::Seed; use strict; use warnings; use Fcntl; use Carp qw/carp croak/; # cert insists on using constant, but regular critic doesn't like it. ## no critic (constant) BEGIN { $Crypt::Random::Seed::AUTHORITY = 'cpan:DANAJ'; $Crypt::Random::Seed::VERSION = '0.03'; } use base qw( Exporter ); our @EXPORT_OK = qw( ); our %EXPORT_TAGS = (all => [ @EXPORT_OK ]); # Export nothing by default use constant UINT32_SIZE => 4; # These are the pre-defined names. We don't let user methods use these. my %defined_methods = map { $_ => 1 } (qw(CryptGenRandom RtlGenRand EGD /dev/random /dev/urandom TESHA2-strong TESHA2-weak)); # If given one of these names as whitelist/blacklist, we add these also. my %name_aliases = ( 'Win32' => [qw(RtlGenRand CryptGenRandom)], 'TESHA2' => [qw(TESHA2-strong TESHA2-weak)], ); sub new { my ($class, %params) = @_; my $self = {}; # Trying to handle strong vs. weak is fraught with complication, so just # remove the idea entirely. if (defined $params{Weak}) { # In this release, just silently don't use it. delete $params{Weak}; } if (defined $params{Source}) { if (ref($params{Source}) eq 'CODE') { $self->{Name} = 'User'; $self->{SourceSub} = $params{Source}; # We don't know if it is blocking or strong, assume neither $self->{Blocking} = 0; $self->{Strong} = 0; } elsif (ref($params{Source}) eq 'ARRAY') { ($self->{Name}, $self->{SourceSub}, $self->{Blocking}, $self->{Strong}) = @{$params{Source}}; # For sanity, don't let them redefine the standard names. croak "Invalid name: $self->{Name}. Name reserved." if defined $defined_methods{$self->{Name}}; } else { croak "Invalid 'Source'. Should be code or array reference."; } } else { # This is a sorted list -- the first one that returns true gets used. my @methodlist = ( \&_try_win32, \&_try_egd, \&_try_dev_random, \&_try_dev_urandom, \&_try_tesha2, ); my %whitelist; my $have_whitelist = 0; if (defined $params{Only}) { croak "Parameter 'Only' must be an array ref" unless ref($params{Only}) eq 'ARRAY'; $have_whitelist = 1; $whitelist{$_} = 1 for @{$params{Only}}; while ( my($name, $list) = each %name_aliases) { @whitelist{@$list} = (1) x scalar @$list if $whitelist{$name}; } } my %blacklist; if (defined $params{Never}) { croak "Parameter 'Never' must be an array ref" unless ref($params{Never}) eq 'ARRAY'; $blacklist{$_} = 1 for @{$params{Never}}; while ( my($name, $list) = each %name_aliases) { @blacklist{@$list} = (1) x scalar @$list if $blacklist{$name}; } } foreach my $m (@methodlist) { my ($name, $rsub, $isblocking, $isstrong) = $m->(); next unless defined $name; next if $isblocking && ($params{NonBlocking} || $params{Nonblocking} || $params{nonblocking}); #next if !$isstrong && !$params{Weak}; next if $blacklist{$name}; next if $have_whitelist && !$whitelist{$name}; $self->{Name} = $name; $self->{SourceSub} = $rsub; $self->{Blocking} = $isblocking; $self->{Strong} = $isstrong; last; } } # Couldn't find anything appropriate return unless defined $self->{SourceSub}; bless $self, $class; return $self; } # Nothing special to do on destroy #sub DESTROY { # my $self = shift; # delete $self->{$_} for keys $self; # return; #} sub name { my $self = shift; return $self->{Name}; } sub is_blocking { my $self = shift; return $self->{Blocking}; } sub is_strong { my $self = shift; return $self->{Strong}; } sub random_bytes { my ($self, $nbytes) = @_; return '' unless defined $nbytes && int($nbytes) > 0; my $rsub = $self->{SourceSub}; return unless defined $rsub; return $rsub->(int($nbytes)); } sub random_values { my ($self, $nvalues) = @_; return unless defined $nvalues && int($nvalues) > 0; my $rsub = $self->{SourceSub}; return unless defined $rsub; return unpack( 'L*', $rsub->(UINT32_SIZE * int($nvalues)) ); } sub _try_tesha2 { eval { require Crypt::Random::TESHA2; Crypt::Random::TESHA2->import(); 1; } or return; my $isstrong = Crypt::Random::TESHA2::is_strong(); my $name = join('-', 'TESHA2', ($isstrong) ? 'strong' : 'weak'); return ($name, \&Crypt::Random::TESHA2::random_bytes, 0, 1); } sub _try_dev_urandom { return unless -r "/dev/urandom"; return ('/dev/urandom', sub { __read_file('/dev/urandom', @_); }, 0, 0); } sub _try_dev_random { return unless -r "/dev/random"; # FreeBSD's /dev/random is 256-bit Yarrow non-blocking. # Is it 'strong'? Debatable -- we'll say it is. my $blocking = ($^O eq 'freebsd') ? 0 : 1; return ('/dev/random', sub { __read_file('/dev/random', @_); }, $blocking, 1); } sub __read_file { my ($file, $nbytes) = @_; return unless defined $nbytes && $nbytes > 0; sysopen(my $fh, $file, O_RDONLY); binmode $fh; my($s, $buffer, $nread) = ('', '', 0); while ($nread < $nbytes) { my $thisread = sysread $fh, $buffer, $nbytes-$nread; # Count EOF as an error. croak "Error reading $file: $!\n" unless defined $thisread && $thisread > 0; $s .= $buffer; $nread += length($buffer); #die unless $nread == length($s); # assert } croak "Internal file read error: wanted $nbytes, read $nread" unless $nbytes == length($s); # assert return $s; } # Most of this is taken without notice from Crypt::URandom 0.28 and # Crypt::Random::Source::Strong::Win32 0.07. # Kudos to David Dick and Max Kanat-Alexander for doing all the work. # # See some documentation here: # http://msdn.microsoft.com/en-us/library/aa379942.aspx # where they note that the output of these is really a well seeded CSPRNG: # either FIPS 186-2 (older) or AES-CTR (Vista SP1 and newer). sub _try_win32 { return unless $^O eq 'MSWin32'; # Cygwin has /dev/random at least as far back as 2000. eval { require Win32; require Win32::API; require Win32::API::Type; 1; } or return; use constant CRYPT_SILENT => 0x40; # Never display a UI. use constant PROV_RSA_FULL => 1; # Which service provider. use constant VERIFY_CONTEXT => 0xF0000000; # Don't need existing keypairs. use constant W2K_MAJOR_VERSION => 5; # Windows 2000 use constant W2K_MINOR_VERSION => 0; my ($major, $minor) = (Win32::GetOSVersion())[1, 2]; return if $major < W2K_MAJOR_VERSION; if ($major == W2K_MAJOR_VERSION && $minor == W2K_MINOR_VERSION) { # We are Windows 2000. Use the older CryptGenRandom interface. my $crypt_acquire_context_a = Win32::API->new( 'advapi32', 'CryptAcquireContextA', 'PPPNN', 'I' ); return unless defined $crypt_acquire_context_a; my $context = chr(0) x Win32::API::Type->sizeof('PULONG'); my $result = $crypt_acquire_context_a->Call( $context, 0, 0, PROV_RSA_FULL, CRYPT_SILENT | VERIFY_CONTEXT ); return unless $result; my $pack_type = Win32::API::Type::packing('PULONG'); $context = unpack $pack_type, $context; my $crypt_gen_random = Win32::API->new( 'advapi32', 'CryptGenRandom', 'NNP', 'I' ); return unless defined $crypt_gen_random; return ('CryptGenRandom', sub { my $nbytes = shift; my $buffer = chr(0) x $nbytes; my $result = $crypt_gen_random->Call($context, $nbytes, $buffer); croak "CryptGenRandom failed: $^E" unless $result; return $buffer; }, 0, 1); # Assume non-blocking and strong } else { my $rtlgenrand = Win32::API->new( 'advapi32', <<'_RTLGENRANDOM_PROTO_'); INT SystemFunction036( PVOID RandomBuffer, ULONG RandomBufferLength ) _RTLGENRANDOM_PROTO_ return unless defined $rtlgenrand; return ('RtlGenRand', sub { my $nbytes = shift; my $buffer = chr(0) x $nbytes; my $result = $rtlgenrand->Call($buffer, $nbytes); croak "RtlGenRand failed: $^E" unless $result; return $buffer; }, 0, 1); # Assume non-blocking and strong } return; } sub _try_egd { # For locations, we'll look in the files OpenSSL's RAND_egd looks, as well # as /etc/entropy which egd 0.9 recommends. This also works with PRNGD. # PRNGD uses a seed+CSPRNG so is non-blocking, but we can't tell them apart. foreach my $device (qw( /var/run/egd-pool /dev/egd-pool /etc/egd-pool /etc/entropy )) { next unless -r $device && -S $device; eval { require IO::Socket; 1; } or return; # We're looking for a socket that returns the entropy available when given # that command. Set timeout to 1 to prevent hanging -- if it is a socket # but won't return the available entropy in under a second, move on. my $socket = IO::Socket::UNIX->new(Peer => $device, Timeout => 1); next unless $socket; $socket->syswrite( pack("C", 0x00), 1) or next; die if $socket->error; my($entropy_string, $nread); # Sadly this doesn't honor the timeout. We'll have to do an eval / alarm. # We only timeout here if this is a live socket to a sleeping process. eval { local $SIG{ALRM} = sub { die "alarm\n" }; alarm 1; $nread = $socket->sysread($entropy_string, 4); alarm 0; }; if ($@) { die unless $@ eq "alarm\n"; next; } next unless defined $nread && $nread == 4; my $entropy_avail = unpack("N", $entropy_string); return ('EGD', sub { __read_egd($device, @_); }, 1, 1); } return; } sub __read_egd { my ($device, $nbytes) = @_; return unless defined $device; return unless defined $nbytes && int($nbytes) > 0; croak "$device doesn't exist!" unless -r $device && -S $device; my $socket = IO::Socket::UNIX->new(Peer => $device); croak "Can't talk to EGD on $device. $!" unless $socket; my($s, $buffer, $toread) = ('', '', $nbytes); while ($toread > 0) { my $this_request = ($toread > 255) ? 255 : $toread; # Use the blocking interface. $socket->syswrite( pack("CC", 0x02, $this_request), 2); my $this_grant = $socket->sysread($buffer, $this_request); croak "Error reading EDG data from $device: $!\n" unless defined $this_grant && $this_grant == $this_request; $s .= $buffer; $toread -= length($buffer); } croak "Internal EGD read error: wanted $nbytes, read ", length($s), "" unless $nbytes == length($s); # assert return $s; } 1; __END__ # ABSTRACT: Simple method to get strong randomness =pod =head1 NAME Crypt::Random::Seed - Simple method to get strong randomness =head1 VERSION Version 0.03 =head1 SYNOPSIS use Crypt::Random::Seed; my $source = new Crypt::Random::Seed; die "No strong sources exist" unless defined $source; my $seed_string = $source->random_bytes(4); my @seed_values = $source->random_values(4); # Only non-blocking sources my $nonblocking_source = Crypt::Random::Seed->new( NonBlocking=>1 ); # Blacklist sources (never choose the listed sources) my $nowin32_source = Crypt::Random::Seed->new( Never=>['Win32'] ); # Whitelist sources (only choose from these sources) my $devr_source = Crypt::Random::Seed->new( Only=>['TESHA2'] ); # Supply a custom source. my $user_src = Crypt::Random::Seed->new( Source=>sub { myfunc(shift) } ); # Or supply a list of [name, sub, is_blocking, is_strong] $user_src = Crypt::Random::Seed->new( Source=>['MyRandomFunction',sub {myfunc(shift)},0,1] ); # Given a source there are a few things we can do: say "My randomness source is ", $source->name(); say "I am a blocking source" if $source->is_blocking(); say "I am a strong randomness source" if $source->is_strong() say "Four 8-bit numbers:", join(",", map { ord $source->random_bytes(1) } 1..4);' say "Four 32-bit numbers:", join(",", $source->random_values(4)); =head1 DESCRIPTION A simple mechanism to get strong randomness. The main purpose of this module is to provide a simple way to generate a seed for a PRNG such as L<Math::Random::ISAAC>, for use in cryptographic key generation, or as the seed for an upstream module such as L<Bytes::Random::Secure>. Flags for requiring non-blocking sources are allowed, as well as a very simple method for plugging in a source. The randomness sources used are, in order: =over 4 =item User supplied. If the constructor is called with a Source defined, then it is used. It is not checked vs. other flags (NonBlocking, Never, Only). =item Win32 Crypto API. This will use C<CryptGenRandom> on Windows 2000 and C<RtlGenRand> on Windows XP and newer. According to MSDN, these are well-seeded CSPRNGs (FIPS 186-2 or AES-CTR), so will be non-blocking. =item EGD / PRNGD. This looks for sockets that speak the L<EGD|http://egd.sourceforge.net/> protocol, including L<PRNGD|http://prngd.sourceforge.net/>. These are userspace entropy daemons that are commonly used by OpenSSL, OpenSSH, and GnuGP. The locations searched are C</var/run/egd-pool>, C</dev/egd-pool>, C</etc/egd-pool>, and C</etc/entropy>. EGD is blocking, while PRNGD is non-blocking (like the Win32 API, it is really a seeded CSPRNG). However there is no way to tell them apart, so we treat it as blocking. If your O/S supports /dev/random, consider L<HAVEGED|http://www.issihosts.com/haveged/> as an alternative (a system daemon that refills /dev/random as needed). =item /dev/random. The strong source of randomness on most UNIX-like systems. Cygwin uses this, though it maps to the Win32 API. On almost all systems this is a blocking source of randomness -- if it runs out of estimated entropy, it will hang until more has come into the system. If this is an issue, which it often is on embedded devices, running a tool such as L<HAVEGED|http://www.issihosts.com/haveged/> will help immensely. =item /dev/urandom. A nonblocking source of randomness that we label as weak, since it will continue providing output even if the actual entropy has been exhausted. =item TESHA2. L<Crypt::Random::TESHA2> is a Perl module that generates random bytes from an entropy pool fed with timer/scheduler variations. Measurements and tests are performed on installation to determine whether the source is considered strong or weak. This is entirely in portable userspace, which is good for ease of use, but really requires user verification that it is working as expected if we expect it to be strong. The concept is similar to L<Math::TrulyRandom> though updated to something closer to what TrueRand 2.1 does vs. the obsolete version 1 that L<Math::TrulyRandom> implements. It is very slow and has wide speed variability across platforms : I've seen numbers ranging from 40 to 150,000 bits per second. =back A source can also be supplied in the constructor. Each of these sources will have its debatable points about perceived strength. E.g. Why is /dev/urandom considered weak while Win32 is strong? Can any userspace method such as TrueRand or TESHA2 be considered strong? =head2 SOURCE TABLE This table summarizes the default sources: +------------------+-------------+------------+--------------------+ | SOURCE | STRENGTH | BLOCKING | NOTE | |------------------+-------------+------------+--------------------| | RtlGenRandom | Strong(1) | No | Default WinXP+ | |------------------+-------------+------------+--------------------| | CryptGenRandom | Strong(1) | No | Default Win2000 | |------------------+-------------+------------+--------------------| | EGD | Strong | Yes(2) | also PRNGD, etc. | |------------------+-------------+------------+--------------------| | /dev/random | Strong | Yes | Typical UNIX | |------------------+-------------+------------+--------------------| | /dev/urandom | Weak | No | Typical UNIX NB | |------------------+-------------+------------+--------------------| | TESHA2-strong | Strong | No | | |------------------+-------------+------------+--------------------| | TESHA2-weak | Weak | No | | +------------------+-------------+------------+--------------------+ The alias 'Win32' can be used in whitelist and blacklist and will match both the Win32 sources C<RtlGenRandom> and C<CryptGenRandom>. The alias 'TESHA2' may be similarly used and matches both the weak and strong sources. 1) Both CryptGenRandom and RtlGenRandom are considered strong by this package, even though both are seeded CSPRNGs so should be the equal of /dev/urandom in this respect. The CryptGenRandom function used in Windows 2000 has some known issues so should be considered weaker. 2) EGD is blocking, PRNGD is not. We cannot tell the two apart. There are other software products that use the same protocol, and each will act differently. E.g. EGD mixes in system entropy on every request, while PRNGD mixes on a time schedule. =head2 STRENGTH In theory, a strong generator will provide true entropy. Even if a third party knew a previous result and the entire state of the generator at any time up to when their value was returned, they could still not effectively predict the result of the next returned value. This implies the generator must either be blocking to wait for entropy (e.g. /dev/random) or go through some possibly time-consuming process to gather it (TESHA2, EGD, the HAVEGE daemon refilling /dev/random). Note: strong in this context means practically strong, as most computers don't have a true hardware entropy generator. The goal is to make all the attackers ill-gotten knowledge give them no better solution than if they did not have the information. Creating a satisfactory strength measurement is problematic. The Win32 Crypto API is considered "strong" by most customers and every other Perl module, however it is a well seeded CSPRNG according to the MSDN docs, so is not a strong source based on the definition in the previous paragraph. Similarly, almost all sources consider /dev/urandom to be weak, as once it runs out of entropy it returns a deterministic function based on its state (albeit one that cannot be run either direction from a returned result if the internal state is not known). Because of this confusion, I have removed the C<Weak> configuration option that was present in version 0.01. It will now be ignored. You should be able to use a combination of whitelist, blacklist, and the source's C<is_strong> return value to decide if this meets your needs. On Win32, you really only have a choice of Win32 and TESHA2. The former is going to be what most people want, and can be chosen even with non-blocking set. On most UNIX systems, C</dev/random> will be chosen for blocking and C</dev/urandom> for non-blocking, which is what should be done in most cases. =head2 BLOCKING EGD and /dev/random are blocking sources. This means that if they run out of estimated entropy, they will pause until they've collected more. This means your program also pauses. On typical workstations this may be a few seconds or even minutes. On an isolated network server this may cause a delay of hours or days. EGD is proactive about gathering more entropy as fast as it can. Running a tool such as the HAVEGE daemon or timer_entropyd can make /dev/random act like a non-blocking source, as the entropy daemon will wake up and refill the pool almost instantly. Win32, PRNGD, and /dev/urandom are fast nonblocking sources. When they run out of entropy, they use a CSPRNG to keep supplying data at high speed. However this means that there is no additional entropy being supplied. TESHA2 is nonblocking, but can be very slow. /dev/random can be faster if run on a machine with lots of activity. On an isolated server, TESHA2 may be much faster. Also note that the blocking sources such as EGD and /dev/random both try to maintain reasonably large entropy pools, so small requests can be supplied without blocking. =head2 IN PRACTICE Use the default to get the best source known. If you know more about the sources available, you can use a whitelist, blacklist, or a custom source. In general, to get the best source (typically Win32 or /dev/random): my $source = Crypt::Random::Seed->new(); To get a good non-blocking source (Win32 or /dev/urandom): my $source = Crypt::Random::Seed->new(NonBlocking => 1); =head1 METHODS =head2 new The constructor with no arguments will find the first available source in its fixed list and return an object that performs the defined methods. If no sources could be found (quite unusual) then the returned value will be undef. Optional parameters are passed in as a hash and may be mixed. =head3 NonBlocking => I<boolean> Only non-blocking sources will be allowed. In practice this means EGD and /dev/random will not be chosen (except on FreeBSD where it is non-blocking). =head3 Only => [I<list of strings>] Takes an array reference containing one or more string source names. No source whose name does not match one of these strings will be chosen. The string 'Win32' will match either of the Win32 sources, and 'TESHA2' will match both the strong and weak versions. =head3 Never => [I<list of strings>] Takes an array reference containing one or more string source names. No source whose name matches one of these strings will be chosen. The string 'Win32' will match either of the Win32 sources, and 'TESHA2' will match both the strong and weak versions. =head3 Source => sub { I<...> } Uses the given anonymous subroutine as the generator. The subroutine will be given an integer (the argument to C<random_bytes>) and should return random data in a string of the given length. For the purposes of the other object methods, the returned object will have the name 'User', and be considered non-blocking and non-strong. =head3 Source => ['I<name>', sub { I<...> }, I<is_blocking>, I<is_strong>] Similar to the simpler source routine, but also allows the other source parameters to be defined. The name may not be one of the standard names listed in the L</"name"> section. =head2 random_bytes($n) Takes an integer and returns a string of that size filled with random data. Returns an empty string if the argument is not defined or is not more than zero. =head2 random_values($n) Takes an integer and returns an array of that many random 32-bit values. Returns an empty array if the argument is not defined or is not more than zero. =head2 name Returns the text name of the random source. This will be one of: C<User> for user defined, C<CryptGenRandom> for Windows 2000 Crypto API, C<RtlGenRand> for Windows XP and newer Crypto API, C<EGD> for a known socket speaking the EGD protocol, C</dev/random> for the UNIX-like strong randomness source, C</dev/urandom> for the UNIX-like non-blocking randomness source, C<TESHA2-strong> for the userspace entropy method when considered strong, C<TESHA2-weak> for the userspace entropy method when considered weak. Other methods may be supported in the future. User supplied sources may be named anything other than one of the defined names. =head2 is_strong Returns 1 or 0 indicating whether the source is considered a strong source of randomness. See the L</"STRENGTH"> section for more discussion of what this means, and the L<source table|/"SOURCE TABLE"> for what we think of each source. =head2 is_blocking Returns 1 or 0 indicating whether the source can block on read. Be aware that even if a source doesn't block, it may be extremely slow. =head1 AUTHORS Dana Jacobsen E<lt>dana@acm.orgE<gt> =head1 ACKNOWLEDGEMENTS To the best of my knowledge, Max Kanat-Alexander was the original author of the Perl code that uses the Win32 API. I used his code as a reference. David Oswald gave me a lot of help with API discussions and code reviews. =head1 SEE ALSO The first question one may ask is "Why yet another module of this type?" None of the modules on CPAN quite fit my needs, hence this. Some alternatives: =head2 L<Crypt::Random::Source> A comprehensive system using multiple plugins. It has a nice API, but uses L<Any::Moose> which means you're loading up Moose or Mouse just to read a few bytes from /dev/random. It also has a very long dependency chain, with on the order of 40 modules being installed as prerequisites (depending of course on whether you use any of them on other projects). Lastly, it requires at least Perl 5.8, which may or may not matter to you. But it matters to some other module builders who end up with the restriction in their modules. =head2 L<Crypt::URandom> A great little module that is almost what I was looking for. L<Crypt::Random::Seed> will act the same if given the constructor: my $source = Crypt::Random::Seed->new( NonBlocking => 1, Only => [qw(/dev/random /dev/urandom Win32)] ); croak "No randomness source available" unless defined $source; Or you can leave out the C<Only> and have TESHA2 as a backup. =head2 L<Crypt::Random> Requires L<Math::Pari> which makes it unacceptable in some environments. Has more features (numbers in arbitrary bigint intervals or bit sizes). L<Crypt::Random::Seed> is taking a simpler approach, just handling returning octets and letting upstream modules handle the rest. =head2 L<Data::Entropy> An interesting module that contains a source encapsulation (defaults to system rand, but has many plugins), a good CSPRNG (AES in counter mode), and the L<Data::Entropy::Algorithms> module with many ways to get bits, ints, bigints, floats, bigfloats, shuffles, and so forth. From my perspective, the algorithms module is the highlight, with a lot of interesting code. =head2 Upstream modules Some modules that could use this module to help them: L<Bytes::Random::Secure>, L<Math::Random::ISAAC>, L<Math::Random::Secure>, and L<Math::Random::MT> to name a few. =head1 COPYRIGHT Copyright 2013 by Dana Jacobsen E<lt>dana@acm.orgE<gt> This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The software is provided "AS IS", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software. =cut 0707010000001B000041ED000000000000000000000002634AFEFF00000000000000000000000000000000000000000000001400000000Crypt-Random-Seed/t0707010000001C000081A4000000000000000000000001634AFEFF0000006E000000000000000000000000000000000000001E00000000Crypt-Random-Seed/t/01-load.t#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 1; require_ok 'Crypt::Random::Seed'; 0707010000001D000081A4000000000000000000000001634AFEFF0000012B000000000000000000000000000000000000001D00000000Crypt-Random-Seed/t/02-new.t#!/usr/bin/env perl use strict; use warnings; use Crypt::Random::Seed; use Test::More tests => 2; my $source = Crypt::Random::Seed->new(); isa_ok $source, 'Crypt::Random::Seed'; my $source2 = new Crypt::Random::Seed; ## no critic (ProhibitIndirectSyntax) isa_ok $source, 'Crypt::Random::Seed'; 0707010000001E000081A4000000000000000000000001634AFEFF000000F4000000000000000000000000000000000000001D00000000Crypt-Random-Seed/t/03-can.t#!/usr/bin/env perl use strict; use warnings; use Crypt::Random::Seed; my @methods = (qw/name is_blocking is_strong random_bytes random_values/); use Test::More tests => 1; my $source = Crypt::Random::Seed->new; can_ok($source, @methods); 0707010000001F000081A4000000000000000000000001634AFEFF00000219000000000000000000000000000000000000001F00000000Crypt-Random-Seed/t/04-win32.t#!/usr/bin/env perl use strict; use warnings; BEGIN { if ($^O ne 'MSWin32') { print "1..0 # Skip This testing is for Win32\n"; exit(0); } } use Test::More tests => 3; require_ok("Win32"); require_ok("Win32::API"); require_ok("Win32::API::Type"); # Spit out a big diagnostic if we failed. eval { require Win32; require Win32::API; require Win32::API::Type; 1; } or diag "\n\n\nYou need to install the Win32 and Win32::API modules.\n\nThese should be included by default in most modern Win32 Perl distributions.\n\n\n"; 07070100000020000081A4000000000000000000000001634AFEFF000001AC000000000000000000000000000000000000001E00000000Crypt-Random-Seed/t/10-name.t#!/usr/bin/env perl use strict; use warnings; use Crypt::Random::Seed; use Test::More tests => 4; my $bsource = Crypt::Random::Seed->new(); my $bname = $bsource->name(); ok(defined($bname)); ok($bname ne ''); my $nbsource = Crypt::Random::Seed->new(NonBlocking=>1); my $nbname = $nbsource->name(); ok(defined($nbname)); ok($nbname ne ''); diag "\nDefault blocking method: $bname\nDefault non-blocking method: $nbname"; 07070100000021000081A4000000000000000000000001634AFEFF00000296000000000000000000000000000000000000002600000000Crypt-Random-Seed/t/11-random_bytes.t#!/usr/bin/env perl use strict; use warnings; use Crypt::Random::Seed; # NOTE: We need to read as few bytes as possible -- just as many as we really # need to test the functionality. Every byte we read may steal O/S entropy, # and may mean we block testing for a long time. # We could check is_blocking if we thought we needed more tests. use Test::More tests => 2; my $source = Crypt::Random::Seed->new(NonBlocking=>1); my $byte = $source->random_bytes(4); is( length($byte), 4, "random_bytes(4) returned 4 bytes" ); # All in one. my $seed = Crypt::Random::Seed->new->random_bytes(1); is( length($seed), 1, "CRS->new->random_bytes(1) returned 1 byte" ); 07070100000022000081A4000000000000000000000001634AFEFF0000048E000000000000000000000000000000000000002700000000Crypt-Random-Seed/t/12-random_values.t#!/usr/bin/env perl use strict; use warnings; use Crypt::Random::Seed; # NOTE: Just like random_bytes, try to read as little as possible. use Test::More tests => 9; my $source = Crypt::Random::Seed->new(NonBlocking=>1); { my @vals = $source->random_values(); is( scalar @vals, 0, "random_values() returns empty array"); } { my @vals = $source->random_values(undef); is( scalar @vals, 0, "random_values(undef) returns empty array"); } { my @vals = $source->random_values(-1); is( scalar @vals, 0, "random_values(-1) returns empty array"); } { my @vals = $source->random_values(0); is( scalar @vals, 0, "random_values(0) returns empty array"); } { my @vals = $source->random_values(0.8); is( scalar @vals, 0, "random_values(0.8) returns empty array"); } { my @vals = $source->random_values(2); is( scalar @vals, 2, "random_values(2) returns two values"); ok( $vals[0] >= 0 && $vals[0] <= 4294967295, " first value in range"); ok( $vals[1] >= 0 && $vals[1] <= 4294967295, " second value in range"); } # All in one. my @seeds = Crypt::Random::Seed->new->random_values(2); is( scalar @seeds, 2, "random_values(2) returns two values"); 07070100000023000081A4000000000000000000000001634AFEFF000003BE000000000000000000000000000000000000002300000000Crypt-Random-Seed/t/13-whitelist.t#!/usr/bin/env perl use strict; use warnings; use Crypt::Random::Seed; use Test::More tests => 4; # Expect croak if Only isn't an array reference ok(!eval {Crypt::Random::Seed->new(Only=>0);}, "Only with non-array reference croaks"); SKIP: { my $source = Crypt::Random::Seed->new(Only=>['TESHA2']); if (!defined $source) { # Perhaps TESHA2 isn't installed. # That's a mis-configuration, but let's allow it. if (!eval { require Crypt::Random::TESHA2; 1; }) { diag "You don't have TESHA2 installed."; diag "This looks like a configuration issue."; diag "Proceeding since we know from earlier tests you have a source."; skip "Missing TESHA2", 2; } } ok(defined $source, "Only=>[TESHA2] returned something"); like($source->name(), qr/^TESHA2/, "Only=>[TESHA2] returned TESHA2"); } { my $source = Crypt::Random::Seed->new(Only=>[]); ok(!defined $source, "An empty whitelist means no object returned"); } 07070100000024000081A4000000000000000000000001634AFEFF0000026F000000000000000000000000000000000000002300000000Crypt-Random-Seed/t/14-blacklist.t#!/usr/bin/env perl use strict; use warnings; use Crypt::Random::Seed; use Test::More tests => 3; # Expect croak if Only isn't an array reference ok(!eval {Crypt::Random::Seed->new(Never=>0);}, "Only with non-array reference croaks"); # Find out what source it normally returns my $source = Crypt::Random::Seed->new(); ok(defined $source, "Source found"); my $method = $source->name(); # Now blacklist that source my $source2 = Crypt::Random::Seed->new(Never=>[$method]); my $newmethod = (defined $source2) ? $source2->name() : ""; isnt($newmethod, $method, "Old method $method was blacklisted. Chose '$newmethod'"); 07070100000025000081A4000000000000000000000001634AFEFF000001EE000000000000000000000000000000000000002C00000000Crypt-Random-Seed/t/90-release-perlcritic.t#!/usr/bin/perl use strict; use warnings; use Test::More; unless ($ENV{RELEASE_TESTING}) { plan( skip_all => 'these tests are for release candidate testing' ); } #--------------------------------------------------------------------- eval { require Test::Perl::Critic; 1; }; plan skip_all => "Test::Perl::Critic required for testing PBP compliance" if $@; Test::Perl::Critic->import( -severity => 4 ); my @directories = qw{ blib/ t/ }; Test::Perl::Critic::all_critic_ok(@directories); 07070100000026000081A4000000000000000000000001634AFEFF00000189000000000000000000000000000000000000002C00000000Crypt-Random-Seed/t/91-release-pod-syntax.t#!/usr/bin/perl use strict; use warnings; use Test::More; unless ($ENV{RELEASE_TESTING}) { require Test::More; plan(skip_all => 'these tests are for release candidate testing'); } #--------------------------------------------------------------------- eval 'use Test::Pod 1.41'; ## no critic (eval) plan skip_all => "Test::Pod 1.41 required for testing POD" if $@; all_pod_files_ok(); 07070100000027000081A4000000000000000000000001634AFEFF00000288000000000000000000000000000000000000002E00000000Crypt-Random-Seed/t/92-release-pod-coverage.t#!/usr/bin/perl use strict; use warnings; use Test::More; unless ($ENV{RELEASE_TESTING}) { plan(skip_all => 'these tests are for release candidate testing'); } #--------------------------------------------------------------------- eval 'use Test::Pod::Coverage 1.08'; ## no critic (eval) plan skip_all => "Test::Pod::Coverage 1.08 required for testing POD coverage" if $@; my @modules = Test::Pod::Coverage::all_modules(); plan tests => scalar @modules; foreach my $m (@modules) { if ($m eq 'Data::BitStream::Base') { pod_coverage_ok( $m, { also_private => [ qr/^(BUILD|DEMOLISH)$/ ] } ); } else { pod_coverage_ok( $m); } } 07070100000028000081A4000000000000000000000001634AFEFF00000157000000000000000000000000000000000000002A00000000Crypt-Random-Seed/t/93-release-kwalitee.t#!/usr/bin/perl use strict; use warnings; use Test::More; unless ($ENV{RELEASE_TESTING}) { plan( skip_all => 'these tests are for release candidate testing' ); } eval 'use Test::Kwalitee'; ## no critic (eval) plan( skip_all => 'Test::Kwalitee required for testing kwalitee' ) if $@; unlink 'Debian_CPANTS.txt' if -e 'Debian_CPANTS.txt'; 07070100000029000081A4000000000000000000000001634AFEFF0000018C000000000000000000000000000000000000002A00000000Crypt-Random-Seed/t/94-release-manifest.t#!/usr/bin/perl use strict; use warnings; use Test::More; unless ($ENV{RELEASE_TESTING}) { plan( skip_all => 'these tests are for release candidate testing' ); } eval "use Test::CheckManifest 0.9"; ## no critic (eval) plan skip_all => "Test::CheckManifest 0.9 required" if $@; ok_manifest( { exclude => [qw(/.git /.gitignore /Makefile.old)], filter => [qr/\.swp$/, qr/.tar.gz$/], } ); 07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!140 blocks
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor