NAME
Crypt::AuthEnc::CCM - Authenticated encryption in CCM mode
SYNOPSIS
my $ae = Crypt::AuthEnc::CCM->new( "AES" , $key , $iv , $adata , $tag_len , $pt_len );
my $ct = $ae ->encrypt_add( 'data1' );
$ct .= $ae ->encrypt_add( 'data2' );
$ct .= $ae ->encrypt_add( 'data3' );
my $tag = $ae ->encrypt_done();
my $ae = Crypt::AuthEnc::CCM->new( "AES" , $key , $iv , $adata , $tag_len , $pt_len );
my $pt = $ae ->decrypt_add( 'ciphertext1' );
$pt .= $ae ->decrypt_add( 'ciphertext2' );
$pt .= $ae ->decrypt_add( 'ciphertext3' );
my $tag = $ae ->decrypt_done();
die "decrypt failed" unless $tag eq $expected_tag ;
my $result = $ae ->decrypt_done( $expected_tag );
( $ciphertext , $tag ) = ccm_encrypt_authenticate( 'AES' , $key , $nonce , $adata , $tag_len , $plaintext );
$plaintext = ccm_decrypt_verify( 'AES' , $key , $nonce , $adata , $ciphertext , $tag );
|
DESCRIPTION
CCM is a encrypt+authenticate mode that is centered around using AES (or any 16-byte cipher) as a primitive. Unlike EAX and OCB mode, it is only meant for packet mode where the length of the input is known in advance.
EXPORT
Nothing is exported by default.
You can export selected functions:
FUNCTIONS
ccm_encrypt_authenticate
my ( $ciphertext , $tag ) = ccm_encrypt_authenticate( $cipher , $key , $nonce , $adata , $tag_len , $plaintext );
|
CCM parameters should follow http://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38c.pdf
ccm_decrypt_verify
my $plaintext = ccm_decrypt_verify( $cipher , $key , $nonce , $adata , $ciphertext , $tag );
|
METHODS
new
my $ae = Crypt::AuthEnc::CCM->new( $cipher , $key , $nonce , $adata , $tag_len , $pt_len );
|
encrypt_add
$ciphertext = $ae ->encrypt_add( $data );
|
encrypt_done
my $tag = $ae ->encrypt_done;
|
decrypt_add
$plaintext = $ae ->decrypt_add( $ciphertext );
|
decrypt_done
my $tag = $ae ->decrypt_done;
my $result = $ae ->decrypt_done( $tag );
|
clone
SEE ALSO