80
|
83 |
226 |
0 |
$self->{'stream'} //= do {
my $s = eval {
do {
my $pkg = "Crypt::Stream::" . $self->algorithm;
my $counter = $self->counter;
my $pos = 0;
if (defined(my $offset = $self->offset)) {
$counter = int $offset / 64;
$pos = $offset % 64;
};
&load($pkg);
my $s = $pkg->new($self->key, $self->iv, $counter);
$s->keystream($pos) if $pos;
$s
}
};
if (my $err = $@) {
throw("Failed to initialize stream cipher library", "error", $err, "algorithm", $self->{'algorithm'}, "key_length", length $self->key, "iv_length", length $self->iv, "iv", unpack("H*", $self->iv), "key", unpack("H*", $self->key));
};
$s
} |