| 1 | 21 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 21 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | package HTML::Tested::Seal; | ||||||||||||||||||||||||||||
| 5 | 21 | ▶ | use base 'Class::Singleton'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 21 | ▶ | use Crypt::CBC; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 21 | ▶ | use Digest::CRC qw(crc8); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 21 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 21 | ▶ | use Digest::MD5 qw(md5); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 21 | ▶ | use bytes; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 7 | ▶ | sub _new_instance { | ||||||||||||||||||||||||||
|
Subroutine
_new_instance: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||
| 13 | 7 | my ($class, $key) = @_; | |||||||||||||||||||||||||||
| 14 | 7 | my $self = bless({}, $class); | |||||||||||||||||||||||||||
| 15 | 7 | ▶ | confess "No key!" unless $key; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | 7 | my $iv = substr(md5($key), 0, 8); | |||||||||||||||||||||||||||
| 17 | 7 | my $c = Crypt::CBC->new(-key => $key, -cipher => 'Blowfish' | |||||||||||||||||||||||||||
| 18 | , -iv => $iv, -header => 'none'); | ||||||||||||||||||||||||||||
| 19 | 7 | ▶ | confess "No cipher!" unless $c; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 7 | $self->{_cipher} = $c; | |||||||||||||||||||||||||||
| 21 | 7 | return $self; | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 178 | ▶ | sub encrypt { | ||||||||||||||||||||||||||
|
Subroutine
encrypt: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 25 | 178 | my ($self, $data) = @_; | |||||||||||||||||||||||||||
| 26 | 178 | ▶ | confess "# No data to encrypt given!" unless defined($data); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 177 | my $c = crc8($data); | |||||||||||||||||||||||||||
| 28 | 177 | return $self->{_cipher}->encrypt_hex(pack("Ca*", $c, $data)); | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 127 | ▶ | sub decrypt { | ||||||||||||||||||||||||||
|
Subroutine
decrypt: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 32 | 127 | my ($self, $data) = @_; | |||||||||||||||||||||||||||
| 33 | 127 | my $d; | |||||||||||||||||||||||||||
| 34 | 127 | eval { $d = $self->{_cipher}->decrypt_hex($data) }; | |||||||||||||||||||||||||||
| 35 | 127 | ▶ | return undef unless defined($d); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 125 | my ($c, $res) = unpack("Ca*", $d); | |||||||||||||||||||||||||||
| 38 | 125 | ▶ | return undef unless (defined($c) && defined($res)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $c and defined $res
MC/DC50%1/2
defined $c and defined $res
defined $c
defined $res
Truth table66%2/3
A and B
A= defined $cB= defined $res
| |||||||||||||||||||||||||||||
| 39 | 32 | my $c1 = crc8($res); | |||||||||||||||||||||||||||
| 40 | 32 | ▶ | return $c1 == $c ? $res : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 21 | 1; | |||||||||||||||||||||||||||