Crypt-Rijndael-PP

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

t/10-InvMixColumns.t
t/11-decrypt_block.t
t/12-full_cycle_block.t
t/author-critic.t
t/author-eol.t
t/author-no-tabs.t
t/gf_multiplication/01-gf_multiply.t
t/lib/Test/Crypt/Rijndael.pm
t/lib/Test/Crypt/Rijndael/Constant.pm
t/mode/01-ECB-Electronic_Code_Book.t
t/mode/02-CBC-Chaining_Block_Cipher.t
t/mode/03-CTR-Counter.t
t/mode/04-CFB-Cipher_Feedback.t
t/mode/05-OFB-Output_Feedback.t
t/release-cpan-changes.t
t/release-dist-manifest.t
t/release-distmeta.t
t/release-kwalitee.t
t/release-meta-json.t
t/release-minimum-version.t
t/release-mojibake.t
t/release-pod-linkcheck.t
t/release-pod-syntax.t
t/release-portability.t
t/release-synopsis.t
t/release-test-version.t
t/release-unused-vars.t
xt/lib/Test/Crypt/Rijndael/XS.pm
xt/xs/compatability/01-Crypt_CBC.t
xt/xs/mode/01-ECB-Electronic_Code_Book.t
xt/xs/mode/02-CBC-Chaining_Block_Cipher.t
xt/xs/mode/03-CTR-Counter.t
xt/xs/mode/04-CFB-Cipher_Feedback.t
xt/xs/mode/05-OFB-Output_Feedback.t

lib/Crypt/Rijndael/PP.pm  view on Meta::CPAN


    bless $self, $class;

    return $self;
}

sub MODE_ECB {
    return 1;
}

sub MODE_CBC {
    return 2;
}

sub MODE_CTR {
    return 3;
}

sub MODE_CFB {
    return 4;
}

lib/Crypt/Rijndael/PP.pm  view on Meta::CPAN

}

sub encrypt {
    my $self  = shift;
    my $input = shift;

    ## no critic (ControlStructures::ProhibitCascadingIfElse)
    if( $self->{mode} == MODE_ECB() ) {
        return $self->_encrypt_mode_ecb( $input );
    }
    elsif( $self->{mode} == MODE_CBC() ) {
        return $self->_encrypt_mode_cbc( $input );
    }
    elsif( $self->{mode} == MODE_CTR() ) {
        return $self->_encrypt_mode_ctr( $input );
    }
    elsif( $self->{mode} == MODE_CFB() ) {
        return $self->_encrypt_mode_cfb( $input );
    }
    elsif( $self->{mode} == MODE_OFB() ) {
        return $self->_encrypt_mode_ofb( $input );

lib/Crypt/Rijndael/PP.pm  view on Meta::CPAN

}

sub decrypt {
    my $self  = shift;
    my $input = shift;

    ## no critic (ControlStructures::ProhibitCascadingIfElse)
    if( $self->{mode} == MODE_ECB() ) {
        return $self->_decrypt_mode_ecb( $input );
    }
    elsif( $self->{mode} == MODE_CBC() ) {
        return $self->_decrypt_mode_cbc( $input );
    }
    elsif( $self->{mode} == MODE_CTR() ) {
        return $self->_decrypt_mode_ctr( $input );
    }
    elsif( $self->{mode} == MODE_CFB() ) {
        return $self->_decrypt_mode_cfb( $input );
    }
    elsif( $self->{mode} == MODE_OFB() ) {
        return $self->_decrypt_mode_ofb( $input );

lib/Crypt/Rijndael/PP.pod  view on Meta::CPAN

    use Crypt::Rijndael::PP;

    # Please use securely generated keys and IV's, these are purely examples!!!
    my $key   = 'A' x 32;
    my $input = 'B' x 16;

    # For you hardcore low level 'I want to control everything!' types:
    {
        my $iv = 'A' x 16;

        # If you aren't sure which mode to use, use CBC (Chaining Block Cipher)
        my $cipher = Crypt::Rijndael::PP->new(
            $key, Crypt::Rijndael::PP::MODE_CBC()
        );

        $cipher->set_iv( $iv );

        my $cipher_text = $cipher->encrypt( $input );
        my $plain_text  = $cipher->decrypt( $cipher_text );
    }

    # For you, 'do it for me' types:
    {
        my $cipher = Crypt::CBC->new(
            -key    => $key,
            -cipher => 'Rijndael::PP',
        );

        my $cipher_text = $cipher->encrypt( $input );
        my $plain_text  = $cipher->decrypt( $cipher_text );
    }

=head1 DESCRIPTION

Crypt::Rijndael::PP is a pure perl drop in alternative to Crypt::Rijndael, fully compatiable with L<Crypt::CBC>.  It exposes the exact same functionatly and can be used in place for any use case where you can not use the XS version of the Rijndael mo...

Though named Crypt::Rinjdae::PP, this module implements the Advanced Encryption Standard (AES) and is suitable for all of your strong cryptographic needs.  It will accept either a 128, 192, or 256 bit key and inputs that are multiples of the blocksiz...

=over 4

=item MODE_ECB - Electronic Code Book

The default, but you most likely do not want to use this.  In Electronic Code Book, each block is encrypted as a seperate indepedent block meaning that the same plain text produces the same cipher text.

=item MODE_CBC - Chaining Block Cipher

My personal choice, uses an initialization vector (IV) as a 'salt' of sorts.  Much better then ECB because the same plain text will not produce the same cipher text.

=item MODE_CTR - Counter

Similiar to CBC, but adds a counter to the IV for each succesive block.

=item MODE_CFB - Cipher Feedback

Similiar to CBC, but uses the IV as input to the cipher algorthim then XOR'ing the plain text with the result of the algorthim.

=item MODE_OFB - Output Feedback

Similiar to CFB, but uses the the result of the cipher algorthim before XOR'ing it with the plain text as input to the next block.

=back

=head1 METHODS

=head2 new

lib/Crypt/Rijndael/PP.pod  view on Meta::CPAN

Sets the initialization vector.

=head2 get_iv

    my $iv = $cipher->get_iv();

Gets the current IV.

=head1 COMPATABILITY

Crypt::Rijndael::PP is intended to be fully compatable with Crypt::Rijndael, and is fully compatable with Crypt::CBC when using 256 bit keys.

=head1 REPOSITORY and BUG REPORTING

The repository for this module is publically available on github at L<https://github.com/drzigman/crypt-rijndael-pp> so feel free to go fork yourself!  Please use the github issues tracker for any normal bugs and try to create a failing test case if ...

=head1 EXTERNAL LINKS

=over 4

=item L<My Presentation on the AES Algorthim and How it Works|http://houston.pm.org/talks/2014talks/1410Talk/index.html>

script/test.pl  view on Meta::CPAN

#!/usr/bin/env perl

use strict;
use warnings;

use Crypt::Rijndael::PP;
use Crypt::CBC;

my $key   = 'A' x 32;
my $input = 'B' x 16;

test_cbc();

print "\n";

test_pp();

sub test_cbc {
    my $cipher = Crypt::CBC->new(
        -key    => $key,
        -cipher => 'Rijndael::PP',
    );

    my $cipher_text = $cipher->encrypt( $input );
    my $plain_text  = $cipher->decrypt( $cipher_text );

    print "Input       : " . $input . "\n";
    print "Cipher Text : " . unpack( 'H*', $cipher_text ) . "\n";
    print "Plain Text  : " . $plain_text . "\n";
}

sub test_pp {
    my $cipher = Crypt::Rijndael::PP->new(
        $key, Crypt::Rijndael::PP::MODE_CBC()
    );

    my $cipher_text = $cipher->encrypt( $input );
    my $plain_text  = $cipher->decrypt( $cipher_text );

    print "Input       : " . $input . "\n";
    print "Cipher Text : " . unpack( 'H*', $cipher_text ) . "\n";
    print "Plain Text  : " . $plain_text . "\n";
}

t/author-no-tabs.t  view on Meta::CPAN

    't/10-InvMixColumns.t',
    't/11-decrypt_block.t',
    't/12-full_cycle_block.t',
    't/author-critic.t',
    't/author-eol.t',
    't/author-no-tabs.t',
    't/gf_multiplication/01-gf_multiply.t',
    't/lib/Test/Crypt/Rijndael.pm',
    't/lib/Test/Crypt/Rijndael/Constant.pm',
    't/mode/01-ECB-Electronic_Code_Book.t',
    't/mode/02-CBC-Chaining_Block_Cipher.t',
    't/mode/03-CTR-Counter.t',
    't/mode/04-CFB-Cipher_Feedback.t',
    't/mode/05-OFB-Output_Feedback.t',
    't/release-cpan-changes.t',
    't/release-dist-manifest.t',
    't/release-distmeta.t',
    't/release-kwalitee.t',
    't/release-meta-json.t',
    't/release-minimum-version.t',
    't/release-mojibake.t',

t/lib/Test/Crypt/Rijndael/Constant.pm  view on Meta::CPAN

our @EXPORT_OK = qw(
    $DEFAULT_IV

    $ONE_BLOCK_INPUT $TWO_BLOCK_INPUT $THREE_BLOCK_INPUT
    $INPUT_BLOCKS

    $KEY_128_BIT $KEY_192_BIT $KEY_256_BIT
    $KEYS

    $CIPHER_TEXT
    $CBC_CIPHER_TEXT
);

use Readonly;

Readonly our $DEFAULT_IV => 'a' x 16;

Readonly our $ONE_BLOCK_INPUT =>
    [ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, ];
Readonly our $TWO_BLOCK_INPUT =>
    [ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,

t/lib/Test/Crypt/Rijndael/Constant.pm  view on Meta::CPAN

        192 => $CIPHER_TEXT_TWO_BLOCK_192_BIT_KEY_ECB,
        256 => $CIPHER_TEXT_TWO_BLOCK_256_BIT_KEY_ECB,
    },
    3 => {
        128 => $CIPHER_TEXT_THREE_BLOCK_128_BIT_KEY_ECB,
        192 => $CIPHER_TEXT_THREE_BLOCK_192_BIT_KEY_ECB,
        256 => $CIPHER_TEXT_THREE_BLOCK_256_BIT_KEY_ECB,
    },
};

Readonly our $CIPHER_TEXT_ONE_BLOCK_128_BIT_KEY_CBC =>
    [ 0x41, 0x6b, 0xd0, 0xb3, 0x7b, 0x2e, 0xb6, 0x7b, 0xce, 0x2c, 0xd9, 0x98, 0x89, 0xa7, 0x72, 0xef, ];
Readonly our $CIPHER_TEXT_TWO_BLOCK_128_BIT_KEY_CBC =>
    [ 0x41, 0x6b, 0xd0, 0xb3, 0x7b, 0x2e, 0xb6, 0x7b, 0xce, 0x2c, 0xd9, 0x98, 0x89, 0xa7, 0x72, 0xef,
      0x9b, 0x85, 0x31, 0x41, 0x26, 0x81, 0xd5, 0x72, 0xda, 0x0c, 0xb3, 0xb8, 0x25, 0xdc, 0x35, 0xaf, ];
Readonly our $CIPHER_TEXT_THREE_BLOCK_128_BIT_KEY_CBC =>
    [ 0x41, 0x6b, 0xd0, 0xb3, 0x7b, 0x2e, 0xb6, 0x7b, 0xce, 0x2c, 0xd9, 0x98, 0x89, 0xa7, 0x72, 0xef,
      0x9b, 0x85, 0x31, 0x41, 0x26, 0x81, 0xd5, 0x72, 0xda, 0x0c, 0xb3, 0xb8, 0x25, 0xdc, 0x35, 0xaf,
      0x15, 0xc2, 0x35, 0x51, 0xe7, 0x2d, 0x3f, 0x10, 0xf3, 0x8e, 0x88, 0x65, 0x2b, 0xc5, 0xfe, 0x8e, ];

Readonly our $CIPHER_TEXT_ONE_BLOCK_192_BIT_KEY_CBC =>
    [ 0x36, 0x67, 0xa8, 0xcc, 0x0d, 0x29, 0xfd, 0xae, 0x7f, 0x79, 0x83, 0xcf, 0x87, 0x17, 0xc5, 0xe4, ];
Readonly our $CIPHER_TEXT_TWO_BLOCK_192_BIT_KEY_CBC =>
    [ 0x36, 0x67, 0xa8, 0xcc, 0x0d, 0x29, 0xfd, 0xae, 0x7f, 0x79, 0x83, 0xcf, 0x87, 0x17, 0xc5, 0xe4,
      0x90, 0x1e, 0x97, 0x81, 0x41, 0x79, 0x7c, 0xae, 0x03, 0x6c, 0x9e, 0x2a, 0x69, 0x9c, 0x39, 0x59, ];
Readonly our $CIPHER_TEXT_THREE_BLOCK_192_BIT_KEY_CBC =>
    [ 0x36, 0x67, 0xa8, 0xcc, 0x0d, 0x29, 0xfd, 0xae, 0x7f, 0x79, 0x83, 0xcf, 0x87, 0x17, 0xc5, 0xe4,
      0x90, 0x1e, 0x97, 0x81, 0x41, 0x79, 0x7c, 0xae, 0x03, 0x6c, 0x9e, 0x2a, 0x69, 0x9c, 0x39, 0x59,
      0x89, 0xd7, 0xc5, 0x30, 0x60, 0xe0, 0xaa, 0xcd, 0xce, 0xbd, 0x7e, 0xc8, 0x94, 0x93, 0xca, 0x1d, ];

Readonly our $CIPHER_TEXT_ONE_BLOCK_256_BIT_KEY_CBC =>
    [ 0xc8, 0x30, 0x5a, 0xff, 0xaa, 0xef, 0x80, 0x30, 0x11, 0xe8, 0xab, 0x78, 0xb3, 0x29, 0xa3, 0x8d, ];
Readonly our $CIPHER_TEXT_TWO_BLOCK_256_BIT_KEY_CBC =>
    [ 0xc8, 0x30, 0x5a, 0xff, 0xaa, 0xef, 0x80, 0x30, 0x11, 0xe8, 0xab, 0x78, 0xb3, 0x29, 0xa3, 0x8d,
      0x5d, 0x7c, 0x5b, 0xe0, 0x3c, 0xea, 0x60, 0xc1, 0x42, 0x5c, 0x6d, 0x5c, 0x9c, 0x76, 0x55, 0xec, ];
Readonly our $CIPHER_TEXT_THREE_BLOCK_256_BIT_KEY_CBC =>
    [ 0xc8, 0x30, 0x5a, 0xff, 0xaa, 0xef, 0x80, 0x30, 0x11, 0xe8, 0xab, 0x78, 0xb3, 0x29, 0xa3, 0x8d,
      0x5d, 0x7c, 0x5b, 0xe0, 0x3c, 0xea, 0x60, 0xc1, 0x42, 0x5c, 0x6d, 0x5c, 0x9c, 0x76, 0x55, 0xec,
      0x0d, 0xee, 0xd7, 0x56, 0xd6, 0x36, 0x7b, 0xc8, 0xe2, 0x4c, 0x29, 0xce, 0xd8, 0x84, 0x2d, 0x32, ];

Readonly our $CBC_CIPHER_TEXT => {
    1 => {
        128 => $CIPHER_TEXT_ONE_BLOCK_128_BIT_KEY_CBC,
        192 => $CIPHER_TEXT_ONE_BLOCK_192_BIT_KEY_CBC,
        256 => $CIPHER_TEXT_ONE_BLOCK_256_BIT_KEY_CBC,
    },
    2 => {
        128 => $CIPHER_TEXT_TWO_BLOCK_128_BIT_KEY_CBC,
        192 => $CIPHER_TEXT_TWO_BLOCK_192_BIT_KEY_CBC,
        256 => $CIPHER_TEXT_TWO_BLOCK_256_BIT_KEY_CBC,
    },
    3 => {
        128 => $CIPHER_TEXT_THREE_BLOCK_128_BIT_KEY_CBC,
        192 => $CIPHER_TEXT_THREE_BLOCK_192_BIT_KEY_CBC,
        256 => $CIPHER_TEXT_THREE_BLOCK_256_BIT_KEY_CBC,
    },
};

Readonly our $CIPHER_TEXT_ONE_BLOCK_128_BIT_KEY_CTR =>
    [ 0xb8, 0x51, 0xd9, 0x93, 0x81, 0x06, 0x2d, 0x0b, 0x9b, 0xa2, 0x46, 0x40, 0xd7, 0xba, 0xa3, 0x0c, ];
Readonly our $CIPHER_TEXT_TWO_BLOCK_128_BIT_KEY_CTR =>
    [ 0xb8, 0x51, 0xd9, 0x93, 0x81, 0x06, 0x2d, 0x0b, 0x9b, 0xa2, 0x46, 0x40, 0xd7, 0xba, 0xa3, 0x0c,
      0xb2, 0x3c, 0xa5, 0x32, 0xaf, 0x6a, 0x7c, 0x15, 0x90, 0x3e, 0xb0, 0x0f, 0x7b, 0xe6, 0x51, 0xf3, ];
Readonly our $CIPHER_TEXT_THREE_BLOCK_128_BIT_KEY_CTR =>
    [ 0xb8, 0x51, 0xd9, 0x93, 0x81, 0x06, 0x2d, 0x0b, 0x9b, 0xa2, 0x46, 0x40, 0xd7, 0xba, 0xa3, 0x0c,

t/lib/Test/Crypt/Rijndael/Constant.pm  view on Meta::CPAN

    },
    3 => {
        128 => $CIPHER_TEXT_THREE_BLOCK_128_BIT_KEY_OFB,
        192 => $CIPHER_TEXT_THREE_BLOCK_192_BIT_KEY_OFB,
        256 => $CIPHER_TEXT_THREE_BLOCK_256_BIT_KEY_OFB,
    },
};

Readonly our $CIPHER_TEXT => {
    ECB => $ECB_CIPHER_TEXT,
    CBC => $CBC_CIPHER_TEXT,
    CTR => $CTR_CIPHER_TEXT,
    CFB => $CFB_CIPHER_TEXT,
    OFB => $OFB_CIPHER_TEXT,
};

1;

t/mode/02-CBC-Chaining_Block_Cipher.t  view on Meta::CPAN

    $CIPHER_TEXT
);

use Crypt::Rijndael::PP;

subtest 'Encryption with 128 Bit Key' => sub {
    for my $num_blocks ( 1, 2, 3 ) {
        subtest "$num_blocks Blocks" => sub {
            test_rijndael_pp_encryption_and_decryption(
                key   => $KEYS->{128},
                mode  => 'MODE_CBC',
                iv    => $DEFAULT_IV,
                plain_text  => $INPUT_BLOCKS->{$num_blocks},
                cipher_text => $CIPHER_TEXT->{CBC}{$num_blocks}{128},
            );
        };
    }
};

subtest 'Encryption with 192 Bit Key' => sub {
    for my $num_blocks ( 1, 2, 3 ) {
        subtest "$num_blocks Blocks" => sub {
            test_rijndael_pp_encryption_and_decryption(
                key   => $KEYS->{192},
                mode  => 'MODE_CBC',
                iv    => $DEFAULT_IV,
                plain_text  => $INPUT_BLOCKS->{$num_blocks},
                cipher_text => $CIPHER_TEXT->{CBC}{$num_blocks}{192},
            );
        };
    }
};

subtest 'Encryption with 256 Bit Key' => sub {
    for my $num_blocks ( 1, 2, 3 ) {
        subtest "$num_blocks Blocks" => sub {
            test_rijndael_pp_encryption_and_decryption(
                key   => $KEYS->{256},
                mode  => 'MODE_CBC',
                iv    => $DEFAULT_IV,
                plain_text  => $INPUT_BLOCKS->{$num_blocks},
                cipher_text => $CIPHER_TEXT->{CBC}{$num_blocks}{256},
            );
        };
    }
};

done_testing;

xt/xs/compatability/01-Crypt_CBC.t  view on Meta::CPAN

use MooseX::Params::Validate;

use FindBin;
use lib "$FindBin::Bin/../../../t/lib/";
use Test::Crypt::Rijndael::Constant qw(
    $INPUT_BLOCKS
    $KEY_256_BIT
);


use Crypt::CBC;
use Crypt::Rijndael;
use Crypt::Rijndael::PP;

use Readonly;

Readonly my $DEFAULT_IV  => 'a' x 16;
Readonly my $CIPHER_TEXT => {
    1 => [ 0xc8, 0x30, 0x5a, 0xff, 0xaa, 0xef, 0x80, 0x30, 0x11, 0xe8, 0xab, 0x78, 0xb3, 0x29, 0xa3, 0x8d,
           0xb8, 0xfd, 0x32, 0xe2, 0x80, 0x34, 0xc6, 0xd7, 0x15, 0xb2, 0x52, 0x42, 0xb5, 0x3a, 0xae, 0x8f ],
    2 => [ 0xc8, 0x30, 0x5a, 0xff, 0xaa, 0xef, 0x80, 0x30, 0x11, 0xe8, 0xab, 0x78, 0xb3, 0x29, 0xa3, 0x8d,

xt/xs/compatability/01-Crypt_CBC.t  view on Meta::CPAN

        key    => { isa => 'ArrayRef' },
        iv     => { isa => 'Str' },
        plain_text  => { isa => 'ArrayRef' },
        cipher_text => { isa => 'ArrayRef' },
    );

    my $packed_key  = pack( "C*", @{ $args{key} } );
    my $packed_plain_text  = pack( "C*", @{ $args{plain_text} } );
    my $packed_cipher_text = pack( "C*", @{ $args{cipher_text} } );

    subtest 'Encrypt with Crypt::CBC - ' . $args{cipher} => sub {
        my $cipher;
        lives_ok {
            $cipher = Crypt::CBC->new(
                -key    => $packed_key,
                -cipher => $args{cipher},
                -iv     => $args{iv},
                -header => 'none',
                -literal_key => 1,
            );

        } "Lives through Crypt::CBC Object Creation";

        my $cipher_text;
        lives_ok {
            $cipher_text = $cipher->encrypt( $packed_plain_text );
        } "Lives through encryption";

        cmp_ok( unpack( "H*", $cipher_text ), 'eq',
            unpack( "H*", $packed_cipher_text ), "Correct Cipher Text" );
    };

xt/xs/compatability/01-Crypt_CBC.t  view on Meta::CPAN

        key    => { isa => 'ArrayRef' },
        iv     => { isa => 'Str' },
        plain_text  => { isa => 'ArrayRef' },
        cipher_text => { isa => 'ArrayRef' },
    );

    my $packed_key  = pack( "C*", @{ $args{key} } );
    my $packed_plain_text  = pack( "C*", @{ $args{plain_text} } );
    my $packed_cipher_text = pack( "C*", @{ $args{cipher_text} } );

    subtest 'Decrypt with Crypt::CBC - ' . $args{cipher} => sub {
        my $cipher;
        lives_ok {
            $cipher = Crypt::CBC->new(
                -key    => $packed_key,
                -cipher => $args{cipher},
                -iv     => $args{iv},
                -header => 'none',
                -literal_key => 1,
            );

        } "Lives through Crypt::CBC Object Creation";

        my $plain_text;
        lives_ok {
            $plain_text = $cipher->decrypt( $packed_cipher_text );
        } "Lives through decryption";

        cmp_ok( unpack( "H*", $plain_text ), 'eq',
            unpack( "H*", $packed_plain_text ), "Correct Plain Text" );
    };

xt/xs/compatability/01-Crypt_CBC.t  view on Meta::CPAN

sub test_encryption {
    my ( $case ) = pos_validated_list( \@_, { isa => 'HashRef' } );

    my $packed_input       = pack( "C*", @{ $case->{input} } );
    my $packed_cipher_key  = pack( "C*", @{ $case->{key} } );
    my $packed_expected_cipher_text = pack( "C*", @{ $case->{cipher_text} } );

    my $cipher;
    lives_ok {

        $cipher = Crypt::CBC->new(
            -key    => $packed_cipher_key,
            -cipher => 'Rijndael::PP',
            -iv     => $DEFAULT_IV,
            -header => 'none',
        );
    } "Lives through Crypt::CBC Object Creation";

    my $cipher_text;
    lives_ok {
        $cipher_text = $cipher->encrypt( $packed_input );
    } "Lives through encryption";

    cmp_ok( unpack( "H*", $cipher_text ), 'eq',
        unpack( "H*", $packed_expected_cipher_text ), "Correct Cipher Text" );

    return;

xt/xs/mode/02-CBC-Chaining_Block_Cipher.t  view on Meta::CPAN

    $CIPHER_TEXT
);

use Crypt::Rijndael;

subtest 'Encryption with 128 Bit Key' => sub {
    for my $num_blocks ( 1, 2, 3 ) {
        subtest "$num_blocks Blocks" => sub {
            test_rijndael_xs_encryption_and_decryption(
                key   => $KEYS->{128},
                mode  => 'MODE_CBC',
                iv    => $DEFAULT_IV,
                plain_text  => $INPUT_BLOCKS->{$num_blocks},
                cipher_text => $CIPHER_TEXT->{CBC}{$num_blocks}{128},
            );
        };
    }
};

subtest 'Encryption with 192 Bit Key' => sub {
    for my $num_blocks ( 1, 2, 3 ) {
        subtest "$num_blocks Blocks" => sub {
            test_rijndael_xs_encryption_and_decryption(
                key   => $KEYS->{192},
                mode  => 'MODE_CBC',
                iv    => $DEFAULT_IV,
                plain_text  => $INPUT_BLOCKS->{$num_blocks},
                cipher_text => $CIPHER_TEXT->{CBC}{$num_blocks}{192},
            );
        };
    }
};

subtest 'Encryption with 256 Bit Key' => sub {
    for my $num_blocks ( 1, 2, 3 ) {
        subtest "$num_blocks Blocks" => sub {
            test_rijndael_xs_encryption_and_decryption(
                key   => $KEYS->{256},
                mode  => 'MODE_CBC',
                iv    => $DEFAULT_IV,
                plain_text  => $INPUT_BLOCKS->{$num_blocks},
                cipher_text => $CIPHER_TEXT->{CBC}{$num_blocks}{256},
            );
        };
    }
};

done_testing;



( run in 1.012 second using v1.01-cache-2.11-cpan-e1769b4cff6 )