| 1 |
package Crypt::SysRandom::XS; |
| 2 |
$Crypt::SysRandom::XS::VERSION = '0.011'; |
| 3 |
use strict; |
| 4 |
use warnings; |
| 5 |
|
| 6 |
use XSLoader; |
| 7 |
|
| 8 |
XSLoader::load(__PACKAGE__, __PACKAGE__->VERSION); |
| 9 |
|
| 10 |
use Exporter 'import'; |
| 11 |
our @EXPORT_OK = 'random_bytes'; |
| 12 |
|
| 13 |
1; |
| 14 |
|
| 15 |
# ABSTRACT: Perl interface to system randomness, XS version |
| 16 |
|
| 17 |
__END__ |
| 18 |
|
| 19 |
=pod |
| 20 |
|
| 21 |
=encoding UTF-8 |
| 22 |
|
| 23 |
=head1 NAME |
| 24 |
|
| 25 |
Crypt::SysRandom::XS - Perl interface to system randomness, XS version |
| 26 |
|
| 27 |
=head1 VERSION |
| 28 |
|
| 29 |
version 0.011 |
| 30 |
|
| 31 |
=head1 SYNOPSIS |
| 32 |
|
| 33 |
use Crypt::SysRandom::XS 'random_bytes'; |
| 34 |
my $random = random_bytes(16); |
| 35 |
|
| 36 |
=head1 DESCRIPTION |
| 37 |
|
| 38 |
This module uses whatever C interface is available to procure cryptographically random data from the system. |
| 39 |
|
| 40 |
=head1 FUNCTIONS |
| 41 |
|
| 42 |
=head2 random_bytes($count) |
| 43 |
|
| 44 |
This will fetch a string of C<$count> random bytes containing cryptographically secure random data. |
| 45 |
|
| 46 |
=head1 BACKENDS |
| 47 |
|
| 48 |
At build-time, it will try the following backends in order: |
| 49 |
|
| 50 |
=over 4 |
| 51 |
|
| 52 |
=item * getrandom |
| 53 |
|
| 54 |
This backend is available on Linux, FreeBSD and Solaris |
| 55 |
|
| 56 |
=item * arc4random |
| 57 |
|
| 58 |
This interface is supported on most BSDs and Mac. |
| 59 |
|
| 60 |
=item * BCryptGenRandom |
| 61 |
|
| 62 |
This backend is available on Windows (Vista and newer) |
| 63 |
|
| 64 |
=item * rdrand64 |
| 65 |
|
| 66 |
This is available on C<x86_64> architectures using most compilers. |
| 67 |
|
| 68 |
=item * rdrand32 |
| 69 |
|
| 70 |
This is available on C<x86_64> and C<x86> architectures using most compilers. |
| 71 |
|
| 72 |
=back |
| 73 |
|
| 74 |
=head1 AUTHOR |
| 75 |
|
| 76 |
Leon Timmermans <[email protected]> |
| 77 |
|
| 78 |
=head1 COPYRIGHT AND LICENSE |
| 79 |
|
| 80 |
This software is copyright (c) 2025 by Leon Timmermans. |
| 81 |
|
| 82 |
This is free software; you can redistribute it and/or modify it under |
| 83 |
the same terms as the Perl 5 programming language system itself. |
| 84 |
|
| 85 |
=cut |