Crypt-Random-Source-0.07000755000765000024 011511027342 16020 5ustar00nothingmuchstaff000000000000README000644000765000024 50511511027342 16740 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07 This archive contains the distribution Crypt-Random-Source, version 0.07: Get weak or strong random data from pluggable sources This software is copyright (c) 2011 by Yuval Kogman. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Changes000644000765000024 76511511027342 17363 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.070.07 - Switch to using Capture::Tiny for Proc.pm, for Windows support. - Prevent a warning from Handle.pm during global destruction. - Make Crypt::Random::Source work properly in taint mode. 0.06 - Use Any::Moose to allow either Moose or Mouse. - Switch to dzil. 0.05 - dep on Moose instead of Mouse 0.04 - zap Squirrel 0.03 - Fucking manifest... we hates it 0.02 - Missing deps 0.01 - Added factory and sugary version 0.01_01 - Preview release, missing functionality LICENSE000644000765000024 4351411511027342 17134 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07This software is copyright (c) 2011 by Yuval Kogman. 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) 2011 by Yuval Kogman. 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. 59 Temple Place, Suite 330, Boston, MA 02111-1307, 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. Copyright (C) 19yy 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, 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. , 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) 2011 by Yuval Kogman. 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 dist.ini000644000765000024 73411511027342 17530 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07name = Crypt-Random-Source version = 0.07 author = Yuval Kogman license = Perl_5 copyright_holder = Yuval Kogman [@Filter] -bundle = @NUFFIN -remove = NoTabsTests -remove = PodCoverageTests dist = Crypt-Random-Source repository_at = github ; @NUFFIN loads AutoPrereqs - this is just for specific version requirements we ; do not want to repeat in all files that need it [Prereqs] Any::Moose = 0.11 namespace::clean = 0.08 Capture::Tiny = 0.08 t000755000765000024 011511027342 16204 5ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07proc.t000644000765000024 56611511027342 17462 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/t#!/usr/bin/perl use strict; use warnings; use Test::More 'no_plan'; use Test::Exception; use ok 'Crypt::Random::Source::Base::Proc'; { my $p = Crypt::Random::Source::Base::Proc->new( command => [qw( echo foo bar )] ); is( $p->get(3), 'foo', "got data" ); throws_ok { $p->get(50) } qr/enough bytes/, "not having enough data is fatal"; } # ex: set sw=4 et: rand.t000644000765000024 104011511027342 17447 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/t#!/usr/bin/perl use strict; use warnings; use Test::More 'no_plan'; use ok 'Crypt::Random::Source::Weak::rand'; { ok( Crypt::Random::Source::Weak::rand->available, "rand is always available" ); my $p = Crypt::Random::Source::Weak::rand->new; isa_ok( $p, "Crypt::Random::Source::Weak::rand" ); isa_ok( $p, "Crypt::Random::Source::Weak" ); my $buf = $p->get(1000); is( length($buf), 1000, "got 1000 bytes" ); cmp_ok( $buf, "ne", $p->get(length($buf)), "not equal to more randomness" ); } # ex: set sw=4 et: META.yml000644000765000024 1035711511027342 17377 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07--- abstract: 'Get weak or strong random data from pluggable sources' author: - 'Yuval Kogman ' build_requires: IO::Select: 0 Test::Exception: 0 Test::More: 0 ok: 0 configure_requires: ExtUtils::MakeMaker: 6.31 dynamic_config: 0 generated_by: 'Dist::Zilla version 4.200000, CPAN::Meta::Converter version 2.101610' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Crypt-Random-Source requires: Any::Moose: 0.11 Capture::Tiny: 0.08 Carp: 0 Errno: 0 File::Spec: 0 IO::File: 0 IO::Handle: 0 Module::Find: 0 Sub::Exporter: 0 bytes: 0 namespace::clean: 0.08 perl: 5.008 resources: bugtracker: http://rt.cpan.org/Public/Dist/Display.html?Name=Crypt-Random-Source homepage: http://search.cpan.org/dist/Crypt-Random-Source repository: git://github.com/nothingmuch/crypt-random-source.git version: 0.07 x_Dist_Zilla: plugins: - class: Dist::Zilla::Plugin::GatherDir name: '@Filter/@Basic/GatherDir' version: 4.200000 - class: Dist::Zilla::Plugin::PruneCruft name: '@Filter/@Basic/PruneCruft' version: 4.200000 - class: Dist::Zilla::Plugin::ManifestSkip name: '@Filter/@Basic/ManifestSkip' version: 4.200000 - class: Dist::Zilla::Plugin::MetaYAML name: '@Filter/@Basic/MetaYAML' version: 4.200000 - class: Dist::Zilla::Plugin::License name: '@Filter/@Basic/License' version: 4.200000 - class: Dist::Zilla::Plugin::Readme name: '@Filter/@Basic/Readme' version: 4.200000 - class: Dist::Zilla::Plugin::ExtraTests name: '@Filter/@Basic/ExtraTests' version: 4.200000 - class: Dist::Zilla::Plugin::ExecDir name: '@Filter/@Basic/ExecDir' version: 4.200000 - class: Dist::Zilla::Plugin::ShareDir name: '@Filter/@Basic/ShareDir' version: 4.200000 - class: Dist::Zilla::Plugin::MakeMaker name: '@Filter/@Basic/MakeMaker' version: 4.200000 - class: Dist::Zilla::Plugin::Manifest name: '@Filter/@Basic/Manifest' version: 4.200000 - class: Dist::Zilla::Plugin::TestRelease name: '@Filter/@Basic/TestRelease' version: 4.200000 - class: Dist::Zilla::Plugin::ConfirmRelease name: '@Filter/@Basic/ConfirmRelease' version: 4.200000 - class: Dist::Zilla::Plugin::UploadToCPAN name: '@Filter/@Basic/UploadToCPAN' version: 4.200000 - class: Dist::Zilla::Plugin::MetaConfig name: '@Filter/MetaConfig' version: 4.200000 - class: Dist::Zilla::Plugin::MetaJSON name: '@Filter/MetaJSON' version: 4.200000 - class: Dist::Zilla::Plugin::PkgVersion name: '@Filter/PkgVersion' version: 4.200000 - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@Filter/PodSyntaxTests' version: 4.200000 - class: Dist::Zilla::Plugin::MetaResources name: '@Filter/MetaResources' version: 4.200000 - class: Dist::Zilla::Plugin::Authority name: '@Filter/Authority' version: 1.000 - class: Dist::Zilla::Plugin::EOLTests name: '@Filter/EOLTests' version: 0.02 - class: Dist::Zilla::Plugin::PodWeaver name: '@Filter/PodWeaver' version: 3.101530 - class: Dist::Zilla::Plugin::AutoPrereq name: '@Filter/AutoPrereq' version: 4.200000 - class: Dist::Zilla::Plugin::Signature name: '@Filter/Signature' version: 1.100930 - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: runtime type: requires name: Prereqs version: 4.200000 - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: 4.200000 - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: 4.200000 - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: 4.200000 - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: 4.200000 zilla: class: Dist::Zilla::Dist::Builder config: is_trial: 0 version: 4.200000 x_authority: cpan:NUFFIN MANIFEST000644000765000024 120211511027342 17224 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07Changes LICENSE MANIFEST META.json META.yml Makefile.PL README SIGNATURE dist.ini lib/Crypt/Random/Source.pm lib/Crypt/Random/Source/Base.pm lib/Crypt/Random/Source/Base/File.pm lib/Crypt/Random/Source/Base/Handle.pm lib/Crypt/Random/Source/Base/Proc.pm lib/Crypt/Random/Source/Base/RandomDevice.pm lib/Crypt/Random/Source/Factory.pm lib/Crypt/Random/Source/Strong.pm lib/Crypt/Random/Source/Strong/devrandom.pm lib/Crypt/Random/Source/Weak.pm lib/Crypt/Random/Source/Weak/devurandom.pm lib/Crypt/Random/Source/Weak/rand.pm t/blocking.t t/dev_random.t t/factory.t t/proc.t t/rand.t t/release-eol.t t/release-pod-syntax.t t/reread.t t/sugar.t sugar.t000644000765000024 61311511027342 17631 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/t#!/usr/bin/perl use strict; use warnings; use Test::More 'no_plan'; use ok 'Crypt::Random::Source'; ok( defined &get_weak, "get_weak" ); ok( defined &get_strong, "get_strong" ); is( length(get_weak(10)), "10", "got 10 weak bytes" ); isa_ok( $Crypt::Random::Source::weak, "Crypt::Random::Source::Weak" ); ok( !$Crypt::Random::Source::strong, "no strong source yet" ); # ex: set sw=4 et: META.json000644000765000024 1516711511027342 17553 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07{ "abstract" : "Get weak or strong random data from pluggable sources", "author" : [ "Yuval Kogman " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 4.200000, CPAN::Meta::Converter version 2.101610", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Crypt-Random-Source", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.31" } }, "runtime" : { "requires" : { "Any::Moose" : "0.11", "Capture::Tiny" : "0.08", "Carp" : 0, "Errno" : 0, "File::Spec" : 0, "IO::File" : 0, "IO::Handle" : 0, "Module::Find" : 0, "Sub::Exporter" : 0, "bytes" : 0, "namespace::clean" : "0.08", "perl" : "5.008" } }, "test" : { "requires" : { "IO::Select" : 0, "Test::Exception" : 0, "Test::More" : 0, "ok" : 0 } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-Crypt-Random-Source@rt.cpan.org", "web" : "http://rt.cpan.org/Public/Dist/Display.html?Name=Crypt-Random-Source" }, "homepage" : "http://search.cpan.org/dist/Crypt-Random-Source", "repository" : { "type" : "git", "url" : "git://github.com/nothingmuch/crypt-random-source.git", "web" : "http://github.com/nothingmuch/crypt-random-source" } }, "version" : "0.07", "x_Dist_Zilla" : { "plugins" : [ { "class" : "Dist::Zilla::Plugin::GatherDir", "name" : "@Filter/@Basic/GatherDir", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "@Filter/@Basic/PruneCruft", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@Filter/@Basic/ManifestSkip", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@Filter/@Basic/MetaYAML", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@Filter/@Basic/License", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::Readme", "name" : "@Filter/@Basic/Readme", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::ExtraTests", "name" : "@Filter/@Basic/ExtraTests", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@Filter/@Basic/ExecDir", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@Filter/@Basic/ShareDir", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::MakeMaker", "name" : "@Filter/@Basic/MakeMaker", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@Filter/@Basic/Manifest", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "@Filter/@Basic/TestRelease", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@Filter/@Basic/ConfirmRelease", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "@Filter/@Basic/UploadToCPAN", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@Filter/MetaConfig", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@Filter/MetaJSON", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::PkgVersion", "name" : "@Filter/PkgVersion", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@Filter/PodSyntaxTests", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::MetaResources", "name" : "@Filter/MetaResources", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::Authority", "name" : "@Filter/Authority", "version" : "1.000" }, { "class" : "Dist::Zilla::Plugin::EOLTests", "name" : "@Filter/EOLTests", "version" : "0.02" }, { "class" : "Dist::Zilla::Plugin::PodWeaver", "name" : "@Filter/PodWeaver", "version" : "3.101530" }, { "class" : "Dist::Zilla::Plugin::AutoPrereq", "name" : "@Filter/AutoPrereq", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::Signature", "name" : "@Filter/Signature", "version" : "1.100930" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "runtime", "type" : "requires" } }, "name" : "Prereqs", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "4.200000" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "4.200000" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : 0 }, "version" : "4.200000" } }, "x_authority" : "cpan:NUFFIN" } SIGNATURE000644000765000024 521711511027342 17371 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07This file contains message digests of all files listed in MANIFEST, signed via the Module::Signature module, version 0.62. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: % cpansign -v It will check each file's integrity, as well as the signature's validity. If "==> Signature verified OK! <==" is not displayed, the distribution may already have been compromised, and you should not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 SHA1 cc09f03f01df5a5ba66b6b8405734f5bdd552a05 Changes SHA1 e4efa15e6ccd24e12d153aa60bfe980a2e6d1343 LICENSE SHA1 a2173600579ba2c4b83274ecd27fbf290831d637 MANIFEST SHA1 1d430badb52fefb8d483665ef8f185669bdc8ebb META.json SHA1 e176715689c4badf8331f8e71426ff7d4f23af4a META.yml SHA1 fca886fca7db6af72fff488e03ba3bb7970924a2 Makefile.PL SHA1 dcd2a63dcd71ea7305fe4be845fbf0a9dc723846 README SHA1 961e78a883cc2623d612940dae13025feb8d6c98 dist.ini SHA1 8056baf341dc8a0fffaa203abeb52f48e847afcd lib/Crypt/Random/Source.pm SHA1 c24087791a2fd33e2a5167a31aebb169ee7f2d59 lib/Crypt/Random/Source/Base.pm SHA1 69956e19822f8732365f1e3fba4054c5e810ff0b lib/Crypt/Random/Source/Base/File.pm SHA1 1d87e7e413c9ec1549a6a12e7f85079935b77a69 lib/Crypt/Random/Source/Base/Handle.pm SHA1 d53919a458f55707d80acc4bfc32fd561bf38e84 lib/Crypt/Random/Source/Base/Proc.pm SHA1 77a0b1e7fd82750a9a5af00959373bde4f636e2c lib/Crypt/Random/Source/Base/RandomDevice.pm SHA1 e91db1d7f9d6aca5070f5b3cb2569e94a276c258 lib/Crypt/Random/Source/Factory.pm SHA1 c1e484298fc47c6e2ef3e2938d36c0b5de0ca9d3 lib/Crypt/Random/Source/Strong.pm SHA1 b75304ed00a111ee98c57a46111fa224b2af56d3 lib/Crypt/Random/Source/Strong/devrandom.pm SHA1 f47356336c449566a61c2fccc1d761520d711d10 lib/Crypt/Random/Source/Weak.pm SHA1 6ece1d694ef5e6f555fe0dfbd4f47cd416891ae2 lib/Crypt/Random/Source/Weak/devurandom.pm SHA1 b70686a7af1ab43b282201b2a7ac33434e05f477 lib/Crypt/Random/Source/Weak/rand.pm SHA1 e7ba6e0bc0d80a09b558e138023943ad6cb243e8 t/blocking.t SHA1 af1612eb5a5080602308288547ccc27eac136d00 t/dev_random.t SHA1 11c91b903e63107041fa8f9c449e6b13e24b4de2 t/factory.t SHA1 3ea210c6125b704b5eda012a5da184f469fa164d t/proc.t SHA1 1106667c380e97424333cff5f01bc157b8448a93 t/rand.t SHA1 a032c41ef6887fab1b900669c2d304fab46680e2 t/release-eol.t SHA1 b30cbdfaf935017c4568c0c91b242438cb87786e t/release-pod-syntax.t SHA1 63388e8c1f78ee730a0a3d9f2df77625bdbd67a1 t/reread.t SHA1 30c9ba85f408b228c647e314f248cf65531cc941 t/sugar.t -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.12 (Darwin) iEYEARECAAYFAk0kLuIACgkQVCwRwOvSdBjQNACcCZ26xeLGzpKSvKsl1d1xax+p 19QAoJxAyCR8VHIXPHGCeYFMob3EGeob =cjKO -----END PGP SIGNATURE----- reread.t000644000765000024 110011511027342 17762 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/t#!/usr/bin/perl # ex: set sw=4 et: use strict; use warnings; use Test::More 'no_plan'; use Test::Exception; use ok 'Crypt::Random::Source::Base::Handle'; { my $p = Crypt::Random::Source::Base::Handle->new( handle => \*DATA ); is( $p->handle, \*DATA, "correct handle set up" ); is( $p->get(4), "foo\n", "read some bytes" ); throws_ok { $p->get(100) } qr/enough bytes/i, "underread"; $p->allow_under_read(1); my $buf; lives_ok { $buf = $p->get(100) } "underread now allowed"; is( $buf, '', "nothing read" ); } __DATA__ foo bar gorch factory.t000644000765000024 137711511027342 20207 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/t#!/usr/bin/perl use strict; use warnings; use Test::More 'no_plan'; use ok 'Crypt::Random::Source::Factory'; { my $f = Crypt::Random::Source::Factory->new; ok( $f->weak_source, "got a weak source" ); ok( !$f->weak_source->is_strong, "weak is weak" ); isa_ok( $f->get_weak, "Crypt::Random::Source::Weak" ); SKIP: { skip "need a strong source", 2 unless eval { require Crypt::Random::Source::Strong::devrandom; Crypt::Random::Source::Strong::devrandom->available; }; ok( $f->strong_source, "got a strong source" ); isa_ok( $f->get_strong, "Crypt::Random::Source::Strong" ); } isa_ok( $f->get, "Crypt::Random::Source::Base" ); } # ex: set sw=4 et: Makefile.PL000644000765000024 260011511027342 20050 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07 use strict; use warnings; BEGIN { require 5.008; } use ExtUtils::MakeMaker 6.31; my %WriteMakefileArgs = ( 'ABSTRACT' => 'Get weak or strong random data from pluggable sources', 'AUTHOR' => 'Yuval Kogman ', 'BUILD_REQUIRES' => { 'IO::Select' => '0', 'Test::Exception' => '0', 'Test::More' => '0', 'ok' => '0' }, 'CONFIGURE_REQUIRES' => { 'ExtUtils::MakeMaker' => '6.31' }, 'DISTNAME' => 'Crypt-Random-Source', 'EXE_FILES' => [], 'LICENSE' => 'perl', 'NAME' => 'Crypt::Random::Source', 'PREREQ_PM' => { 'Any::Moose' => '0.11', 'Capture::Tiny' => '0.08', 'Carp' => '0', 'Errno' => '0', 'File::Spec' => '0', 'IO::File' => '0', 'IO::Handle' => '0', 'Module::Find' => '0', 'Sub::Exporter' => '0', 'bytes' => '0', 'namespace::clean' => '0.08' }, 'VERSION' => '0.07', 'test' => { 'TESTS' => 't/*.t' } ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.56) } ) { my $br = delete $WriteMakefileArgs{BUILD_REQUIRES}; my $pp = $WriteMakefileArgs{PREREQ_PM}; for my $mod ( keys %$br ) { if ( exists $pp->{$mod} ) { $pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod}; } else { $pp->{$mod} = $br->{$mod}; } } } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); blocking.t000644000765000024 144411511027342 20323 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/t#!/usr/bin/perl use strict; use warnings; use Test::More tests => 3; use 5.008; use IO::Handle; use IO::Select; use ok 'Crypt::Random::Source::Base::Handle'; SKIP: { skip "Windows can't open a blocking child pipe", 2 if $^O =~ /Win32/i; defined ( my $child = open my $fh, "-|" ) or die "open: $!"; if ($child) { my $p = Crypt::Random::Source::Base::Handle->new( handle => $fh ); $p->blocking(0); if ( IO::Select->new( $fh )->can_read(1) ) { is( $p->get(5), "foo", "underread due to blocking" ); is( $p->get(5), '', "underread due to blocking" ); } kill TERM => $child; } else { STDOUT->autoflush(1); print "foo"; sleep 10; print "bar"; exit; } } # ex: set sw=4 et: dev_random.t000644000765000024 355211511027342 20653 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/t#!/usr/bin/perl use strict; use warnings; use Test::More; use Errno qw(EWOULDBLOCK); BEGIN { plan skip_all => "no /dev/random and /dev/urandom" unless -e "/dev/random" and -e "/dev/urandom"; plan 'no_plan'; } use ok 'Crypt::Random::Source::Strong::devrandom'; use ok 'Crypt::Random::Source::Weak::devurandom'; { ok( Crypt::Random::Source::Strong::devrandom->available, "/dev/random is available" ); my $p = Crypt::Random::Source::Strong::devrandom->new; isa_ok( $p, "Crypt::Random::Source::Strong" ); isa_ok( $p, "Crypt::Random::Source::Base::RandomDevice" ); isa_ok( $p, "Crypt::Random::Source::Base::Handle" ); isa_ok( $p, "Crypt::Random::Source::Strong::devrandom" ); $p->blocking(0); ok( $p->is_strong, "it's a strong source" ); can_ok( $p, "get" ); if ( length( my $buf = $p->get(100) ) ) { # blocking cmp_ok( length($buf), '<=', 100, "got up to 100 bytes" ); # this test should fail around every few universes or so ;-) cmp_ok( $buf, 'ne', $p->get(length($buf)), "random data differs" ); } else { is( $!, EWOULDBLOCK, "would have blocked" ); } can_ok($p, "seed"); } { ok( Crypt::Random::Source::Weak::devurandom->available, "/dev/random is available" ); my $p = Crypt::Random::Source::Weak::devurandom->new; isa_ok( $p, "Crypt::Random::Source::Weak" ); isa_ok( $p, "Crypt::Random::Source::Base::RandomDevice" ); isa_ok( $p, "Crypt::Random::Source::Base::Handle" ); isa_ok( $p, "Crypt::Random::Source::Weak::devurandom" ); ok( !$p->is_strong, "it's a weak source" ); can_ok( $p, "get" ); my $buf = $p->get(100); is( length($buf), 100, "got 100 bytes" ); # this test should fail around every few universes or so ;-) cmp_ok( $buf, 'ne', $p->get(length($buf)), "random data differs" ); can_ok($p, "seed"); } # ex: set sw=4 et: release-eol.t000644000765000024 47611511027342 20714 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/t BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use strict; use warnings; use Test::More; eval 'use Test::EOL'; plan skip_all => 'Test::EOL required' if $@; all_perl_files_ok({ trailing_whitespace => 1 }); release-pod-syntax.t000644000765000024 45011511027342 22233 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/t#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval "use Test::Pod 1.41"; plan skip_all => "Test::Pod 1.41 required for testing POD" if $@; all_pod_files_ok(); Random000755000765000024 011511027342 21030 5ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/lib/CryptSource.pm000644000765000024 417411511027342 22773 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/lib/Crypt/Randompackage Crypt::Random::Source; BEGIN { $Crypt::Random::Source::AUTHORITY = 'cpan:NUFFIN'; } BEGIN { $Crypt::Random::Source::VERSION = '0.07'; } # ABSTRACT: Get weak or strong random data from pluggable sources use strict; use 5.008; use warnings; use Sub::Exporter -setup => { exports => [qw( get get_weak get_strong factory )], groups => { default => [qw(get get_weak get_strong)] }, }; use Crypt::Random::Source::Factory; our ( $factory, $weak, $strong, $any ); # silence some stupid destructor warnings END { undef $weak; undef $strong; undef $any; undef $factory } sub factory () { $factory ||= Crypt::Random::Source::Factory->new } sub _weak () { $weak ||= factory->get_weak } sub _strong () { $strong ||= factory->get_strong } sub _any () { $any ||= factory->get } sub get ($;@) { _any->get(@_) } sub get_weak ($;@) { _weak->get(@_) } sub get_strong ($;@) { _strong->get(@_) } # silence some stupid destructor warnings END { undef $weak; undef $strong; undef $any; undef $factory } 1; # ex: set sw=4 et: __END__ =pod =encoding utf-8 =head1 NAME Crypt::Random::Source - Get weak or strong random data from pluggable sources =head1 SYNOPSIS use Crypt::Random::Source qw(get_strong); # get 10 cryptographically strong random bytes from an available source my $bytes = get_strong(10); =head1 DESCRIPTION This module provides implementations for a number of byte oriented sources of random data. See L for a more powerful way to locate sources, and the various sources for specific implementations. =head1 EXPORTS =over 4 =item get =item get_weak =item get_strong These functions delegate to a source chosen by an instance of L, calling get =back =head1 SEE ALSO L, L =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Yuval Kogman. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Source000755000765000024 011511027342 22270 5ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/lib/Crypt/RandomBase.pm000644000765000024 473111511027342 23644 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/lib/Crypt/Random/Sourcepackage Crypt::Random::Source::Base; BEGIN { $Crypt::Random::Source::Base::AUTHORITY = 'cpan:NUFFIN'; } BEGIN { $Crypt::Random::Source::Base::VERSION = '0.07'; } # ABSTRACT: Abstract base class for L classes use Any::Moose; sub available { 0 } sub rank { 0 } sub seed { } sub get { die "abstract" } # cannibalized from IO::Scalar sub read { my $self = $_[0]; my $n = $_[2]; my $off = $_[3] || 0; my $read = $self->get($n); $n = length($read); ($off ? substr($_[1], $off) : $_[1]) = $read; return $n; } sub get_data { my ( $self, %params ) = @_; if ( my $n = $params{Length} ) { return $self->get($n); } else { my $size = $params{Size}; if (ref $size && ref $size eq "Math::Pari") { $size = Math::Pari::pari2num($size); } return $self->get( int($size / 8) + 1 ); } } 1; # ex: set sw=4 et: __END__ =pod =encoding utf-8 =head1 NAME Crypt::Random::Source::Base - Abstract base class for L classes =head1 SYNOPSIS use Moose; extends qw(Crypt::Random::Source::Base); =head1 DESCRIPTION This is an abstract base class. In the future it will be a role. =head1 METHODS =head2 get $n, %args Gets C<$n> random bytes and returns them as a string. This method may produce fatal errors if the source was unable to provide enough data. =head2 read $buf, $n, [ $off ] This method is cannibalized from L. It provides an L work-alike. Note that subclasses override this to operate on a real handle directly if available. =head2 seed @stuff On supporting sources this method will add C<@stuff>, whatever it may be, to the random seed. Some sources may not support this, so be careful. =head2 available This is a class method, such that when it returns true calling C without arguments on the class should provide a working source of random data. This is use by L. =head2 rank This is a class method, with some futz value for a ranking, to help known good sources be tried before known bad (slower, less available) sources. =head2 get_data %Params Provided for compatibility with L =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Yuval Kogman. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Weak.pm000644000765000024 161611511027342 23660 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/lib/Crypt/Random/Sourcepackage Crypt::Random::Source::Weak; BEGIN { $Crypt::Random::Source::Weak::AUTHORITY = 'cpan:NUFFIN'; } BEGIN { $Crypt::Random::Source::Weak::VERSION = '0.07'; } # ABSTRACT: Abstract base class for weak random data sources use Any::Moose; sub is_strong { 0 } 1; # ex: set sw=4 et: __END__ =pod =encoding utf-8 =head1 NAME Crypt::Random::Source::Weak - Abstract base class for weak random data sources =head1 SYNOPSIS use Moose; extends qw(Crypt::Random::Source::Weak); =head1 DESCRIPTION This is an abstract base class. There isn't much to describe. =head1 METHODS =head2 is_strong Returns false =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Yuval Kogman. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Strong.pm000644000765000024 163311511027342 24244 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/lib/Crypt/Random/Sourcepackage Crypt::Random::Source::Strong; BEGIN { $Crypt::Random::Source::Strong::AUTHORITY = 'cpan:NUFFIN'; } BEGIN { $Crypt::Random::Source::Strong::VERSION = '0.07'; } # ABSTRACT: Abstract base class for strong random data sources use Any::Moose; sub is_strong { 1 } 1; # ex: set sw=4 et: __END__ =pod =encoding utf-8 =head1 NAME Crypt::Random::Source::Strong - Abstract base class for strong random data sources =head1 SYNOPSIS use Moose; extends qw(Crypt::Random::Source::Strong); =head1 DESCRIPTION This is an abstract base class. There isn't much to describe. =head1 METHODS =head2 is_strong Returns true =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Yuval Kogman. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Factory.pm000644000765000024 1072611511027342 24422 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/lib/Crypt/Random/Sourcepackage Crypt::Random::Source::Factory; BEGIN { $Crypt::Random::Source::Factory::AUTHORITY = 'cpan:NUFFIN'; } BEGIN { $Crypt::Random::Source::Factory::VERSION = '0.07'; } # ABSTRACT: Load and instantiate sources of random data use Any::Moose; use Carp qw(croak); use Module::Find; use namespace::clean -except => [qw(meta)]; sub get { my ( $self, %args ) = @_; my $type = delete $args{type} || "any"; my $method = "new_$type"; $self->can($method) or croak "Don't know how to create a source of type $type"; $self->$method(%args); } sub get_weak { my ( $self, @args ) = @_; $self->get( @args, type => "weak" ); } sub get_strong { my ( $self, @args ) = @_; $self->get( @args, type => "strong" ); } has weak_source => ( isa => "ClassName", is => "rw", lazy_build => 1, clearer => "clear_weak_source", handles => { new_weak => "new" }, ); sub _build_weak_source { my $self = shift; $self->best_available(@{ $self->weak_sources }); } has strong_source => ( isa => "ClassName", is => "rw", lazy_build => 1, clearer => "clear_strong_source", handles => { new_strong => "new" }, ); sub _build_strong_source { my $self = shift; $self->best_available(@{ $self->strong_sources }); } has any_source => ( isa => "ClassName", is => "rw", lazy_build => 1, clearer => "clear_any_source", handles => { new_any => 'new' }, ); sub _build_any_source { my $self = shift; $self->weak_source || $self->strong_source; } has scan_inc => ( is => "ro", isa => "Bool", lazy_build => 1, ); sub _build_scan_inc { my $self = shift; if ( exists $ENV{CRYPT_RANDOM_NOT_PLUGGABLE} ) { return !$ENV{CRYPT_RANDOM_NOT_PLUGGABLE}; } else { return 1; } } has weak_sources => ( isa => "ArrayRef[Str]", is => "rw", lazy_build => 1, ); sub _build_weak_sources { my $self = shift; if ( $self->scan_inc ) { $self->locate_sources("Weak"); } else { return [qw( Crypt::Random::Source::Weak::devurandom Crypt::Random::Source::Weak::openssl Crypt::Random::Source::Weak::rand )]; } } has strong_sources => ( isa => "ArrayRef[Str]", is => "rw", lazy_build => 1, ); sub _build_strong_sources { my $self = shift; if ( $self->scan_inc ) { return $self->locate_sources("Strong"); } else { return [qw( Crypt::Random::Source::Strong::devrandom Crypt::Random::Source::Strong::egd )]; } } sub best_available { my ( $self, @sources ) = @_; my @available = grep { local $@; eval { Any::Moose::load_class($_); $_->available }; } @sources; my @sorted = sort { $b->rank <=> $a->rank } @available; wantarray ? @sorted : $sorted[0]; } sub first_available { my ( $self, @sources ) = @_; foreach my $class ( @sources ) { local $@; return $class if eval { Any::Moose::load_class($class); $class->available }; } } sub locate_sources { my ( $self, $category ) = @_; my @sources = findsubmod "Crypt::Random::Source::$category"; # Untaint class names (which are tainted in taint mode because # they came from the disk). ($_) = $_ =~ /^(.*)$/ foreach @sources; return \@sources; } 1; # ex: set sw=4 et: __END__ =pod =encoding utf-8 =head1 NAME Crypt::Random::Source::Factory - Load and instantiate sources of random data =head1 SYNOPSIS use Crypt::Random::Source::Factory; my $f = Crypt::Random::Source::Factory->new; my $strong = $f->get_strong; my $weak = $f->get_weak; my $any = $f->get; =head1 DESCRIPTION This class implements a loading and instantiation factory for L objects. If C<$ENV{CRYPT_RANDOM_NOT_PLUGGABLE}> is set then only a preset list of sources will be tried. Otherwise L will be used to locate any installed sources, and use the first available one. =head1 METHODS =head2 get %args Instantiate any random source, passing %args to the constructor. The C argument can be C, C or C. =head2 get_weak %args =head2 get_strong %args Instantiate a new weak or strong random source. =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Yuval Kogman. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Base000755000765000024 011511027342 23142 5ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/lib/Crypt/Random/SourceFile.pm000644000765000024 260711511027342 24523 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/lib/Crypt/Random/Source/Basepackage Crypt::Random::Source::Base::File; BEGIN { $Crypt::Random::Source::Base::File::AUTHORITY = 'cpan:NUFFIN'; } BEGIN { $Crypt::Random::Source::Base::File::VERSION = '0.07'; } # ABSTRACT: File (or device) random data sources use Any::Moose; use Carp qw(croak); extends qw(Crypt::Random::Source::Base::Handle); use IO::File; has path => ( is => "rw", required => 1, ); sub open_handle { my ( $self, $mode ) = @_; my $file = $self->path; my $fh = IO::File->new; $fh->open($file, $mode || "r") or croak "open($file): $!"; return $fh; } 1; # ex: set sw=4 et: __END__ =pod =encoding utf-8 =head1 NAME Crypt::Random::Source::Base::File - File (or device) random data sources =head1 SYNOPSIS use Moose; extends qw(Crypt::Random::Source::Base::File); has '+path' => ( default => "/foo/bar", ); =head1 DESCRIPTION This is a base class for file (or file like) random data sources. =head1 ATTRIBUTES =head2 path A required attribute, the path to the file to open. =head1 METHODS =head2 open_handle Uses L to open C for reading. =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Yuval Kogman. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Proc.pm000644000765000024 437011511027342 24546 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/lib/Crypt/Random/Source/Basepackage Crypt::Random::Source::Base::Proc; BEGIN { $Crypt::Random::Source::Base::Proc::AUTHORITY = 'cpan:NUFFIN'; } BEGIN { $Crypt::Random::Source::Base::Proc::VERSION = '0.07'; } # ABSTRACT: Base class for helper processes (e.g. C) use Any::Moose; extends qw(Crypt::Random::Source::Base::Handle); use Capture::Tiny qw(capture); use File::Spec; use IO::File; use 5.008; has command => ( is => "rw", required => 1 ); has search_path => ( is => 'rw', isa => 'Str', lazy_build => 1 ); # This is a scalar so that people can customize it (which they would # particularly need to do on Windows). our $TAINT_PATH = '/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin'; sub _build_search_path { # In taint mode it's not safe to use $ENV{PATH}. if (${^TAINT}) { return $TAINT_PATH; } return $ENV{PATH}; } sub open_handle { my $self = shift; my $cmd = $self->command; my @cmd = ref $cmd ? @$cmd : $cmd; my $retval; local $ENV{PATH} = $self->search_path; my ($stdout, $stderr) = capture { $retval = system(@cmd) }; chomp($stderr); if ($retval) { my $err = join(' ', @cmd) . ": $! ($?)"; if ($stderr) { $err .= "\n$stderr"; } die $err; } warn $stderr if $stderr; my $fh = IO::File->new(\$stdout, '<'); return $fh; } 1; # ex: set sw=4 et: __END__ =pod =encoding utf-8 =head1 NAME Crypt::Random::Source::Base::Proc - Base class for helper processes (e.g. C) =head1 SYNOPSIS use Moose; extends qw(Crypt::Random::Source::Base::Proc); has '+command' => ( default => ... ); =head1 DESCRIPTION This is a base class for using command line utilities which output random data on STDOUT as L objects. =head1 ATTRIBUTES =head2 command An array reference or string that is the command to run. =head1 METHODS =head2 open_handle Opens a pipe for reading using C. =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Yuval Kogman. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Weak000755000765000024 011511027342 23157 5ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/lib/Crypt/Random/Sourcerand.pm000644000765000024 300511511027342 24576 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/lib/Crypt/Random/Source/Weakpackage Crypt::Random::Source::Weak::rand; BEGIN { $Crypt::Random::Source::Weak::rand::AUTHORITY = 'cpan:NUFFIN'; } BEGIN { $Crypt::Random::Source::Weak::rand::VERSION = '0.07'; } # ABSTRACT: Use C to create random bytes use Any::Moose; use bytes; extends qw( Crypt::Random::Source::Weak Crypt::Random::Source::Base ); sub rank { -100 } # slow fallback sub available { 1 } sub seed { my ( $self, @args ) = @_; srand( unpack("%L*", @args) ); } sub get { my ( $self, $n ) = @_; pack "C*", map { int rand 256 } 1 .. $n; } 1; # ex: set sw=4 et: __END__ =pod =encoding utf-8 =head1 NAME Crypt::Random::Source::Weak::rand - Use C to create random bytes =head1 SYNOPSIS use Crypt::Random::Source::Weak::rand; my $p = Crypt::Random::Source::Weak::rand->new; $p->get(1024); =head1 DESCRIPTION This is a weak source of random data, that uses Perl's builtin C function. =head1 METHODS =head2 seed @blah Sets the random seed to a checksum of the stringified values of C<@blah>. There is no need to call this method unless you want the random sequence to be identical to a previously run, in which case you should seed with the same value. =head2 get $n Produces C<$n> random bytes. =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Yuval Kogman. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Handle.pm000644000765000024 1047311511027342 25057 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/lib/Crypt/Random/Source/Basepackage Crypt::Random::Source::Base::Handle; BEGIN { $Crypt::Random::Source::Base::Handle::AUTHORITY = 'cpan:NUFFIN'; } BEGIN { $Crypt::Random::Source::Base::Handle::VERSION = '0.07'; } # ABSTRACT: L based random data sources use Any::Moose; use Errno qw(EWOULDBLOCK); use Carp qw(croak); use IO::Handle; extends qw(Crypt::Random::Source::Base); has allow_under_read => ( isa => "Bool", is => "rw", default => 0, ); has reread_attempts => ( is => "rw", default => 1, ); has handle => ( is => "rw", predicate => "has_handle", clearer => "clear_handle", lazy_build => 1, ); sub blocking { shift->handle->blocking(@_) } sub read { shift->handle->read(@_) } sub opened { shift->handle->opened(@_) } sub DEMOLISH { my $self = shift; $self->close; } sub _build_handle { my ( $self, @args ) = @_; $self->open_handle; } sub open_handle { die "open_handle is an abstract method"; } sub get { my ( $self, $n, @args ) = @_; croak "How many bytes would you like to read?" unless $n; return $self->_read($self->handle, $n, @args); } sub _read { my ( $self, $handle, $n, @args) = @_; my $buf; my $got = $self->read($buf, $n); if ( defined($got) && $got == $n || $! == EWOULDBLOCK ) { return $buf; } else { croak "read error: $!" unless defined $got; return $self->_read_too_short($buf, $got, $n, @args); } } sub _read_too_short { my ( $self, $buf, $got, $req, %args ) = @_; if ( $self->allow_under_read ) { return $buf; } else { if ( ($self->reread_attempts || 0) >= ($args{reread_attempt} || 0) ) { croak "Source failed to read enough bytes (requested $req, got $got)"; } else { return $buf . $self->_read( $req - $got, reread_attempt => 1 + ( $args{reread_attempt} || 0 ) ); } } } sub close { my $self = shift; # During global destruction, $self->handle can be undef already, # so we need to also check if it is defined. if ( $self->has_handle and $self->handle ) { $self->handle->close or die "close: $!"; $self->clear_handle; } } 1; # ex: set sw=4 et: __END__ =pod =encoding utf-8 =head1 NAME Crypt::Random::Source::Base::Handle - L based random data sources =head1 SYNOPSIS use Moose; extends qw(Crypt::Random::Source::Base::Handle); sub open_handle { # invoked as needed } # this class can also be used directly Crypt::Random::Source::Base::Handle->new( handle => $file_handle ); # it supports some standard methods: $p->blocking(0); $p->read( my $buf, $n ); # no error handling here =head1 DESCRIPTION This is a concrete base class for all L based random data sources. It implements error handling =head1 ATTRIBUTES =head2 handle An L or file handle to read from. =head2 blocking This is actually handled by C, and is documented in L. =head2 allow_under_read Whether or not under reading is considered an error. Defaults to false. =head2 reread_attempts The number of attempts to make at rereading if the handle did not provide enough bytes on the first attempt. Defaults to 1. Only used if C is enabled. =head1 METHODS =head2 get See L. When C or C are set to a true value this method may return fewer bytes than requested. =head2 read This delegates directly to C. It B provide the same validation as C would have, so no checking for underreads is done. =head2 close Close the handle and clear it. =head2 _read C<< $self->handle->read >> but with additional error checking and different calling conventions. =head2 _read_too_short Called by C<_read> when not enough data was read from the handle. Normally it will either die with an error or attempt to reread. When C is true it will just return the partial buffer. =head2 open_handle Abstract method, should return an L to use. =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Yuval Kogman. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut devurandom.pm000644000765000024 163211511027342 26022 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/lib/Crypt/Random/Source/Weakpackage Crypt::Random::Source::Weak::devurandom; BEGIN { $Crypt::Random::Source::Weak::devurandom::AUTHORITY = 'cpan:NUFFIN'; } BEGIN { $Crypt::Random::Source::Weak::devurandom::VERSION = '0.07'; } # ABSTRACT: A weak random data source using F use Any::Moose; extends qw( Crypt::Random::Source::Weak Crypt::Random::Source::Base::RandomDevice ); sub default_path { "/dev/urandom" } 1; # ex: set sw=4 et: __END__ =pod =encoding utf-8 =head1 NAME Crypt::Random::Source::Weak::devurandom - A weak random data source using F =head1 SYNOPSIS use Crypt::Random::Source::Weak::devurandom; =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Yuval Kogman. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut Strong000755000765000024 011511027342 23544 5ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/lib/Crypt/Random/Sourcedevrandom.pm000644000765000024 164311511027342 26224 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/lib/Crypt/Random/Source/Strongpackage Crypt::Random::Source::Strong::devrandom; BEGIN { $Crypt::Random::Source::Strong::devrandom::AUTHORITY = 'cpan:NUFFIN'; } BEGIN { $Crypt::Random::Source::Strong::devrandom::VERSION = '0.07'; } # ABSTRACT: A strong random data source using F use Any::Moose; extends qw( Crypt::Random::Source::Strong Crypt::Random::Source::Base::RandomDevice ); sub default_path { "/dev/random" } 1; # ex: set sw=4 et: __END__ =pod =encoding utf-8 =head1 NAME Crypt::Random::Source::Strong::devrandom - A strong random data source using F =head1 SYNOPSIS use Crypt::Random::Source::Strong::devrandom; =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Yuval Kogman. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut RandomDevice.pm000644000765000024 254511511027342 26205 0ustar00nothingmuchstaff000000000000Crypt-Random-Source-0.07/lib/Crypt/Random/Source/Basepackage Crypt::Random::Source::Base::RandomDevice; BEGIN { $Crypt::Random::Source::Base::RandomDevice::AUTHORITY = 'cpan:NUFFIN'; } BEGIN { $Crypt::Random::Source::Base::RandomDevice::VERSION = '0.07'; } # ABSTRACT: Base class for random devices use Any::Moose; extends qw(Crypt::Random::Source::Base::File); sub rank { 100 } # good quality, pretty fast has '+path' => ( builder => "default_path", ); sub available { -r shift->default_path; } sub seed { my ( $self, @args ) = @_; my $fh = $self->open_handle("w+"); print $fh @args; close $fh; } sub default_path { die "abstract"; } 1; # ex: set sw=4 et: __END__ =pod =encoding utf-8 =head1 NAME Crypt::Random::Source::Base::RandomDevice - Base class for random devices =head1 SYNOPSIS use Moose; extends qw(Crypt::Random::Source::Base::RandomDevice); sub default_path { "/dev/myrandom" } =head1 DESCRIPTION This is a base class for random device sources. See L and L for actual implementations. =head1 AUTHOR Yuval Kogman =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2011 by Yuval Kogman. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut