Pg/Cipher/ChaCha20Poly1305.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 42 CC 1 SCAR 6.9
CC
1
Cov
0%
cipher_id
2.0
cipher_name
2.0
key_bytes
2.0
CRAP 2.0
1 package Dancer2::Session::Pg::Cipher::ChaCha20Poly1305;
2  
3 use strict;
4 use warnings;
5  
6 use Moo;
7 use Crypt::AuthEnc::ChaCha20Poly1305 ();
8  
9 our $VERSION = '0.002';
10  
11 with 'Dancer2::Session::Pg::Cipher';
12  
13 sub cipher_id { return 4 }
14 sub cipher_name { return 'ChaCha20-Poly1305' }
15 sub key_bytes { return 32 }
16 sub iv_bytes { return 12 }
17 sub tag_bytes { return 16 }
18  
19 sub seal {
20 my ( $self, $key, $iv, $plaintext, $aad ) = @_;
21 return Crypt::AuthEnc::ChaCha20Poly1305::chacha20poly1305_encrypt_authenticate( $key, $iv, $aad, $plaintext );
22 }
23  
24 sub unseal { ## no critic (Subroutines::ProhibitManyArgs) -- six is the AEAD contract in Dancer2::Session::Pg::Cipher
25 my ( $self, $key, $iv, $ciphertext, $tag, $aad ) = @_;
26 return Crypt::AuthEnc::ChaCha20Poly1305::chacha20poly1305_decrypt_verify( $key, $iv, $aad, $ciphertext, $tag );
27 }
28  
29 1;
30  
31 __END__