Closed lixmal closed 7 years ago
It is a bug.
The following code:
use Crypt::AuthEnc::GCM;
use Crypt::PRNG 'random_bytes';
my $gcm = Crypt::AuthEnc::GCM->new("AES", "1234567890123456");
$gcm->iv_add("1234567890123456");
$gcm->adata_add('test');
my $ct = $gcm->encrypt_add('');
my $tag = $gcm->encrypt_done;
print "CT='", unpack("H*", $ct), "'\n";
print "TAG='", unpack("H*", $tag), "'\n";
should IMO print:
CT=''
TAG='222798d502b90b2a283d80acd40eed5b'
which means: 1/ empty cipher text + 2/ non-empty tag
Slightly off topic advise: if you are already using CryptX distribution you can use https://metacpan.org/pod/Crypt::PRNG#random_bytes to get random bytes
Try CryptX-0.048_001
Works as intended now, thanks for the info and the quick reply!
Hi,
it seems encryption of the empty string is not supported in GCM mode:
leads to
FATAL: gcm_done failed: Invalid argument provided.
Is that expected behaviour or some restriction of the GCM mode? Crypt::Mode::CBC and CTR work fine on the empty string. Although CTR produces empty ciphertext, I'd like to know if somebody tampered with it, at least.
Using CryptX version 0.048.