| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Net::SSH::Perl::Cipher::AES_CTR; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 30 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 40 |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 1 |  |  | 1 |  | 7 | use Net::SSH::Perl::Cipher; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 33 |  | 
| 6 | 1 |  |  | 1 |  | 5 | use base qw( Net::SSH::Perl::Cipher ); | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 152 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 1 |  |  | 1 |  | 475 | use Net::SSH::Perl::Cipher::CTR; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 30 |  | 
| 9 | 1 |  |  | 1 |  | 5 | use Crypt::Cipher::AES; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 255 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | sub new { | 
| 12 | 6 |  |  | 6 | 1 | 34 | my $class = shift; | 
| 13 | 6 |  |  |  |  | 17 | my $ciph = bless { }, $class; | 
| 14 | 6 | 50 |  |  |  | 52 | $ciph->init(@_) if @_; | 
| 15 | 6 |  |  |  |  | 19 | $ciph; | 
| 16 |  |  |  |  |  |  | } | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  | 0 | 0 |  | sub keysize { } # stub | 
| 19 | 0 |  |  | 0 | 0 | 0 | sub blocksize { 16 } # 128 bits as required by AES | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | sub init { | 
| 22 | 6 |  |  | 6 | 0 | 13 | my $ciph = shift; | 
| 23 | 6 |  |  |  |  | 18 | my($key, $iv) = @_; | 
| 24 |  |  |  |  |  |  |  | 
| 25 | 6 |  |  |  |  | 62 | $key = substr($key,0,$ciph->keysize); | 
| 26 | 6 |  |  |  |  | 139 | my $aes = Crypt::Cipher::AES->new($key); | 
| 27 | 6 |  |  |  |  | 33 | $ciph->{ctr} = Net::SSH::Perl::Cipher::CTR->new($aes, $iv); | 
| 28 |  |  |  |  |  |  | } | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | sub encrypt { | 
| 31 | 3 |  |  | 3 | 1 | 2745 | my($ciph, $text) = @_; | 
| 32 | 3 |  |  |  |  | 21 | return $ciph->{ctr}->encrypt($text); | 
| 33 |  |  |  |  |  |  | } | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | sub decrypt { | 
| 36 | 3 |  |  | 3 | 1 | 20 | my($ciph, $text) = @_; | 
| 37 | 3 |  |  |  |  | 12 | return $ciph->{ctr}->decrypt($text); | 
| 38 |  |  |  |  |  |  | } | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | 1; | 
| 41 |  |  |  |  |  |  | __END__ |