| 1 | ## | ||||||||||||||||||||||||||||
| 2 | ## Copyright (c) 1998-2025, Vipul Ved Prakash. All rights reserved. | ||||||||||||||||||||||||||||
| 3 | ## This code is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 4 | ## it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | package Crypt::Random::Provider::rand; | ||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use Math::Pari qw(pari2num); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Crypt::URandom qw/urandom/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 3 | our $VERSION = '1.57'; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 13 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 13 | my ($class, %params) = @_; | |||||||||||||||||||||||||||
| 17 | 13 | ▶ | my $self = { Source => $params{Source} || sub { Crypt::URandom::urandom($_[0]) } }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.6
Condition33%1/3
$params{'Source'} || sub {
Crypt::URandom::urandom($_[0]);
}
MC/DC0%0/2
$params{'Source'} || sub {
Crypt::URandom::urandom($_[0]);
}
$params{'Source'}
sub {
Crypt::URandom::urandom($_[0]);
}
Truth table33%1/3
A || B
A= $params{'Source'}B= sub {
Crypt::URandom::urandom($_[0]);
}
| |||||||||||||||||||||||||||||
| 18 | 13 | return bless $self, $class; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 13 | ▶ | sub get_data { | ||||||||||||||||||||||||||
|
Subroutine
get_data: called CC=10 SCAR=24.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 13 | my ($self, %params) = @_; | |||||||||||||||||||||||||||
| 25 | 13 | ▶ | $self = {} unless ref $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 13 | my $size = $params{Size}; | |||||||||||||||||||||||||||
| 28 | 13 | ▶ | my $skip = $params{Skip} || $$self{Skip} || ''; | ||||||||||||||||||||||||||
|
Condition80%4/5
$params{'Skip'} || $self->{'Skip'} || ''
$params{"Skip"} or $self->{"Skip"}
MC/DC50%1/2
$params{'Skip'} || $self->{'Skip'} || ''
$params{"Skip"}
$self->{"Skip"}
Truth table66%2/3
A or B
A= $params{"Skip"}B= $self->{"Skip"}
| |||||||||||||||||||||||||||||
| 29 | 13 | my $q_skip = quotemeta($skip); | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 13 | ▶ | if ($size && ref $size eq "Math::Pari") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$size and ref $size eq "Math::Pari"
MC/DC0%0/2
$size and ref $size eq "Math::Pari"
$size
ref $size eq "Math::Pari"
Truth table66%2/3
A and B
A= $sizeB= ref $size eq "Math::Pari"
| |||||||||||||||||||||||||||||
| 32 | 0 | $size = pari2num($size); | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 13 | ▶ | my $bytes = $params{Length} || (int($size / 8) + 1); | ||||||||||||||||||||||||||
|
Condition66%2/3
$params{'Length'} || int($size / 8) + 1
MC/DC0%0/2
$params{'Length'} || int($size / 8) + 1
$params{'Length'}
int($size / 8) + 1
Truth table66%2/3
A || B
A= $params{'Length'}B= int($size / 8) + 1
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | my $source = $$self{Source} || sub { Crypt::URandom::urandom($_[0]) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.0
Condition33%1/3
$self->{'Source'} || sub {
Crypt::URandom::urandom($_[0]);
}
MC/DC0%0/2
$self->{'Source'} || sub {
Crypt::URandom::urandom($_[0]);
}
$self->{'Source'}
sub {
Crypt::URandom::urandom($_[0]);
}
Truth table33%1/3
A || B
A= $self->{'Source'}B= sub {
Crypt::URandom::urandom($_[0]);
}
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 13 | my($r, $read, $rt) = ('', 0); | |||||||||||||||||||||||||||
| 40 | 13 | ▶ | while ($read < $bytes) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 58 | $rt = &$source($bytes - $read); | |||||||||||||||||||||||||||
| 42 | 58 | ▶ | $rt =~ s/[$q_skip]//g if $skip; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 58 | $r .= $rt; | |||||||||||||||||||||||||||
| 44 | 58 | $read = length $r; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 13 | $r; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 5 | ▶ | sub available { | ||||||||||||||||||||||||||
|
Subroutine
available: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 5 | return 1; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 3 | 1; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||