fication
=item * Encryption & decryption
=item * Import (L<Crypt::Perl::PK>) from & export to L<JSON Web Key|https://tools.ietf.org/html/rfc7517> format
=item * L<JWK thumbprints|https://tools.ietf
attrs ], $class;
}
sub get {
my ( $self, $attr ) = @_;
#Do we need to clone this? Could JSON suffice, or do we need Clone?
return $self->[1]{$attr};
}
sub to_string {
my ($self) = @
parameters ANY DEFINED BY algorithm OPTIONAL
}
>;
use constant _JWK_THUMBPRINT_JSON_ORDER => qw( crv kty x );
sub to_der {
my ($self) = @_;
require Crypt::Perl::ASN1;
y $pbkey = Crypt::Perl::Ed25519::Parse::public($buffer);
# This accepts a structure, not raw JSON.
my $key = Crypt::Perl::Ed25519::Parse::jwk($jwk_hr);
=head1 DESCRIPTION
See L<Crypt::Perl:
s an object
my $pub_obj = $key->get_public_key();
# These return a hash reference, NOT a JSON string.
my $priv_hr = $key->get_struct_for_private_jwk();
my $pub_hr = $key->get_struct_
a hash (e.g., SHA-256) of your original message.
my $sig = $prkey->sign($payload);
#For JSON Web Algorithms (JWT et al.), cf. RFC 7518 page 8
#This will also apply the appropriate SHA al
verify($msg_hash, $sig);
die 'Wut' if !$private->verify($msg_hash, $sig);
# Signature in JSON Web Algorithm format (deterministic):
my $jwa_sig = $private->sign_jwa($msg);
# You can
s an object
my $pub_obj = $key->get_public_key();
# This returns a hash reference, NOT a JSON string.
my $pub_hr = $key->get_struct_for_public_jwk();
=head1 DESCRIPTION
This class imple
OBJECT IDENTIFIER,
ecParameters ECParameters
}
>;
use constant _JWK_THUMBPRINT_JSON_ORDER => qw( crv kty x y );
use constant JWA_DIGEST_prime256v1 => 'sha256';
use constant JWA_DIG
instantiate this class using Parser.pm
#or PrivateKey’s get_public_key() method.
#cf. JSON Web Algorithms (RFC 7518, page 5)
#These return 1 or 0 to indicate verification or non-verifi
publicExponent');
*N = \&modulus;
*E = \&publicExponent;
}
use constant _JWK_THUMBPRINT_JSON_ORDER => qw( e kty n );
sub new {
my ($class, @args) = @_;
my $self = $class->SUPER::ne
ey = Crypt::Perl::RSA::Parse::public($buffer);
# Note that this accepts a structure, not raw JSON.
my $key = Crypt::Perl::RSA::Parse::jwk($jwk_hr);
=head1 DISCUSSION
See L<Crypt::Perl::RSA:
SIS
#You’ll probably instantiate this class using Parser.pm
#or Generate.pm.
#cf. JSON Web Algorithms (RFC 7518, page 5)
#These return an octet string.
$sig = $prkey->sign_RS25
load too long!";
}
$pbkey->verify($payload, $sig) or die "Invalid signature!";
#For JSON Web Algorithms (JWT et al.), cf. RFC 7518 page 8
#This verifies against the appropriate SHA d
r_public_jwk();
my $json = sprintf(
'{' . join(',', map { qq{"$_":"%s"} } $self->_JWK_THUMBPRINT_JSON_ORDER()) . '}',
@{$jwk}{ $self->_JWK_THUMBPRINT_JSON_ORDER() },
);
r
equire MIME::Base64;
return MIME::Base64::encode_base64url( $hash_cr->($json) );
}
1;