Reputation: 33
I'm attempting to generate a JWE with (5 parts) using Crypt::JWT. It's my first foray into perl.
Following the example from the documentation:
use Crypt::JWT qw(encode_jwt);
my $claims = {
iss => 'some issuer',
cd => 'some cd'
}
my $jws_token = encode_jwt(payload=>$claims, alg=>'HS256', key=>'secret');
my $jwe_token = encode_jwt(payload=>$jws_token, alg=>'dir', enc=>'A256GCM', key=>'secret');
I get the error:
JWE: wrong AES key length 32 vs 3
Other attempt using sha256 on the key first:
use Crypt::JWT qw(encode_jwt);
use Digest::SHA qw(sha256_hex);
my $key = sha256_hex('secret');
my $claims = {
iss => 'some issuer',
cd => 'some cd'
}
my $jws_token = encode_jwt(payload=>$claims, alg=>'HS256', key=>$key);
my $jwe_token = encode_jwt(payload=>$jws_token, alg=>'dir', enc=>'A256GCM', key=>$key);
Which gives a similar error:
JWE: wrong AES key length 32 vs 64
Any pointers would be appreciated?
P.S: I don't have control over the choice of enc and alg as I'm trying to match the output of a different module
Upvotes: 1
Views: 164