Crypt-CCM
view release on metacpan or search on metacpan
lib/Crypt/CCM.pm view on Meta::CPAN
=head2 set_aad($associated_data)
=head2 set_tag_length($length)
This allows you to change the MAC length. allow 4,6,8,10,12,14,16 byte string.
=head2 encrypt($plain_text);
my $cipher_text = $cipher->encrypt($plain_text);
=head2 decrypt($cipher_text)
my $plain_text = $cipher->decrypt($cipher_text);
=head1 EXAMPLE
=head2 Encrypt
use Crypt::CCM;
use strict;
my $key = pack 'H*', '00000000000000000000000000000000';
my $nonce = pack 'H*', '0000000000000000';
my $associated_data = 'this is associated data';
my $plain_text = 'Hello World!';
my $c = Crypt::CCM->new(
-key => $key,
-cipher => 'Crypt::Rijndael'
);
$c->set_nonce($nonce);
$c->set_aad($associated_data);
my $cipher_text = $c->encrypt($plain_text);
printf qq{encrypt: %s (hex)\n}, unpack 'H*', $cipher_text;
=head2 Decrypt
use Crypt::CCM;
use strict;
my $key = pack 'H*', '00000000000000000000000000000000';
my $nonce = pack 'H*', '0000000000000000';
my $associated_data = 'this is associated data';
my $cipher_text = pack 'H*', '08da066234def1e5c7481a5a40b6aa4319332731a184426ac77f47de';
my $c = Crypt::CCM->new(
-key => $key,
-cipher => 'Crypt::Rijndael'
);
$c->set_nonce($nonce);
$c->set_aad($associated_data);
my $plain_text = $c->decrypt($cipher_text);
printf qq{decrypt: %s\n}, $plain_text;
=head1 SEE ALSO
NIST Special Publication 800-38C - Recommendation for Block Cipher Modes of Operation: The CCM Mode for Authentication and Confidentiality.
L<http://csrc.nist.gov/CryptoToolkit/modes/800-38_Series_Publications/SP800-38C.pdf>
RFC 3610 - Counter with CBC-MAC (CCM)
L<http://tools.ietf.org/html/rfc3610>
=head1 AUTHOR
Hiroyuki OYAMA, E<lt>oyama@module.jp<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2006 by Hiroyuki OYAMA
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.6 or,
at your option, any later version of Perl 5 you may have available.
=cut
( run in 0.326 second using v1.01-cache-2.11-cpan-e1769b4cff6 )