line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Perl::RSA::PublicKey; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf-8 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Crypt::Perl::RSA::PublicKey - object representation of an RSA public key |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
#You’ll probably instantiate this class using Parser.pm |
12
|
|
|
|
|
|
|
#or PrivateKey’s get_public_key() method. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#cf. JSON Web Algorithms (RFC 7518, page 5) |
15
|
|
|
|
|
|
|
#These return 1 or 0 to indicate verification or non-verification. |
16
|
|
|
|
|
|
|
$pbkey->verify_RS256($message, $sig); |
17
|
|
|
|
|
|
|
$pbkey->verify_RS384($message, $sig); |
18
|
|
|
|
|
|
|
$pbkey->verify_RS512($message, $sig); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $enc = $pbkey->encrypt_raw($payload); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $der = $pbkey->to_der(); |
27
|
|
|
|
|
|
|
my $pem = $pbkey->to_pem(); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
#For use in creating PKCS #10 CSRs and X.509 certificates |
30
|
|
|
|
|
|
|
my $pub_der = $pbkey->to_subject_der(); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$pbkey->size(); #modulus length, in bits |
35
|
|
|
|
|
|
|
$pbkey->modulus_byte_length(); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
38
|
|
|
|
|
|
|
# The following all return instances of Crypt::Perl::BigInt, |
39
|
|
|
|
|
|
|
# a subclass of Math::BigInt. |
40
|
|
|
|
|
|
|
# The pairs (e.g., modulus() and N()) are aliases. |
41
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$pbkey->modulus(); |
44
|
|
|
|
|
|
|
$pbkey->N(); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$pbkey->publicExponent(); |
47
|
|
|
|
|
|
|
$pbkey->E(); |
48
|
|
|
|
|
|
|
$pbkey->exponent(); #another alias of publicExponent() |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
5
|
|
|
5
|
|
548
|
use strict; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
174
|
|
53
|
5
|
|
|
5
|
|
32
|
use warnings; |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
178
|
|
54
|
|
|
|
|
|
|
|
55
|
5
|
|
|
|
|
106
|
use parent qw( |
56
|
|
|
|
|
|
|
Crypt::Perl::RSA::KeyBase |
57
|
5
|
|
|
5
|
|
29
|
); |
|
5
|
|
|
|
|
17
|
|
58
|
|
|
|
|
|
|
|
59
|
5
|
|
|
5
|
|
337
|
use constant _PEM_HEADER => 'RSA PUBLIC KEY'; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
295
|
|
60
|
5
|
|
|
5
|
|
29
|
use constant _ASN1_MACRO => 'RSAPublicKey'; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
451
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
BEGIN { |
63
|
5
|
|
|
5
|
|
132
|
*exponent = __PACKAGE__->can('publicExponent'); |
64
|
5
|
|
|
|
|
136
|
*to_subject_der = __PACKAGE__->can('_to_subject_public_der'); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |