| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Crypt::Stream::Sosemanuk; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
1256
|
use strict; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
85
|
|
|
4
|
3
|
|
|
3
|
|
11
|
use warnings; |
|
|
3
|
|
|
|
|
2
|
|
|
|
3
|
|
|
|
|
191
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.089'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
15
|
use CryptX; |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
198
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
1403
|
sub CLONE_SKIP { 1 } # prevent cloning |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
1; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=pod |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Crypt::Stream::Sosemanuk - Stream cipher Sosemanuk |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use Crypt::Stream::Sosemanuk; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# encrypt |
|
24
|
|
|
|
|
|
|
my $key = "1234567890123456"; |
|
25
|
|
|
|
|
|
|
my $iv = "123456789012"; |
|
26
|
|
|
|
|
|
|
my $enc_stream = Crypt::Stream::Sosemanuk->new($key, $iv); |
|
27
|
|
|
|
|
|
|
my $ct = $enc_stream->crypt("plain message"); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# decrypt |
|
30
|
|
|
|
|
|
|
my $dec_stream = Crypt::Stream::Sosemanuk->new($key, $iv); |
|
31
|
|
|
|
|
|
|
my $pt = $dec_stream->crypt($ct); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Provides an interface to the Sosemanuk stream cipher. |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 METHODS |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Unless noted otherwise, assume C<$stream> is an existing stream object created |
|
40
|
|
|
|
|
|
|
via C, for example: |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $stream = Crypt::Stream::Sosemanuk->new($key, $iv); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 new |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $stream = Crypt::Stream::Sosemanuk->new($key, $iv); |
|
47
|
|
|
|
|
|
|
# $key .. [binary string] keylen must be multiple of 4 bytes |
|
48
|
|
|
|
|
|
|
# $iv .. [binary string] ivlen must be multiple of 4 bytes (OPTIONAL - simply omit to skip IV setup) |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 crypt |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Encrypts or decrypts data. The output has the same length as the input. |
|
53
|
|
|
|
|
|
|
Returns a binary string (raw bytes). |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
The input is converted using Perl's usual scalar stringification. Passing |
|
56
|
|
|
|
|
|
|
C is treated as an empty string with the usual warning, and numeric |
|
57
|
|
|
|
|
|
|
scalars are stringified before processing. |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my $ciphertext = $stream->crypt($plaintext); |
|
60
|
|
|
|
|
|
|
#or |
|
61
|
|
|
|
|
|
|
my $plaintext = $stream->crypt($ciphertext); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 keystream |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Returns C<$length> bytes of raw keystream as a binary string. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
The length is taken using Perl's usual numeric coercion. Values that coerce to |
|
68
|
|
|
|
|
|
|
an oversized unsigned length are rejected as too large. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $random_key = $stream->keystream($length); |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 clone |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Returns a copy of the stream cipher object in its current state. |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $stream2 = $stream->clone(); |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=over |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item * L, L, L, L |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item * L |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=back |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |