| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Crypt::Perl::RSA::Template; |
|
2
|
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
40
|
use strict; |
|
|
6
|
|
|
|
|
14
|
|
|
|
6
|
|
|
|
|
164
|
|
|
4
|
6
|
|
|
6
|
|
33
|
use warnings; |
|
|
6
|
|
|
|
|
11
|
|
|
|
6
|
|
|
|
|
759
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#cf. RFC 3447 appendix A.1.1 |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
#replacing INTEGER with FG_FAUX_INTEGER to facilitate “lite” mode |
|
9
|
|
|
|
|
|
|
#which doesn’t bring in Math::BigInt. |
|
10
|
|
|
|
|
|
|
my $ASN1_TEMPLATE = q< |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
FG_FAUX_INTEGER ::= |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
RSAPublicKey ::= SEQUENCE { |
|
15
|
|
|
|
|
|
|
modulus FG_FAUX_INTEGER, -- n |
|
16
|
|
|
|
|
|
|
publicExponent FG_FAUX_INTEGER -- e |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
-- FG: simplified from RFC for Convert::ASN1 |
|
20
|
|
|
|
|
|
|
Version ::= INTEGER |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
OtherPrimeInfo ::= SEQUENCE { |
|
23
|
|
|
|
|
|
|
prime FG_FAUX_INTEGER, -- ri |
|
24
|
|
|
|
|
|
|
exponent FG_FAUX_INTEGER, -- di |
|
25
|
|
|
|
|
|
|
coefficient FG_FAUX_INTEGER -- ti |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
-- FG: simplified from RFC for Convert::ASN1 |
|
29
|
|
|
|
|
|
|
OtherPrimeInfos ::= SEQUENCE OF OtherPrimeInfo |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
RSAPrivateKey ::= SEQUENCE { |
|
32
|
|
|
|
|
|
|
version Version, |
|
33
|
|
|
|
|
|
|
modulus FG_FAUX_INTEGER, -- n |
|
34
|
|
|
|
|
|
|
publicExponent INTEGER, -- e |
|
35
|
|
|
|
|
|
|
privateExponent FG_FAUX_INTEGER, -- d |
|
36
|
|
|
|
|
|
|
prime1 FG_FAUX_INTEGER, -- p |
|
37
|
|
|
|
|
|
|
prime2 FG_FAUX_INTEGER, -- q |
|
38
|
|
|
|
|
|
|
exponent1 FG_FAUX_INTEGER, -- d mod (p-1) |
|
39
|
|
|
|
|
|
|
exponent2 FG_FAUX_INTEGER, -- d mod (q-1) |
|
40
|
|
|
|
|
|
|
coefficient FG_FAUX_INTEGER, -- (inverse of q) mod p |
|
41
|
|
|
|
|
|
|
otherPrimeInfos OtherPrimeInfos OPTIONAL |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
-- cf. RFC 3280 4.1.1.2 |
|
45
|
|
|
|
|
|
|
AlgorithmIdentifier ::= SEQUENCE { |
|
46
|
|
|
|
|
|
|
algorithm OBJECT IDENTIFIER, |
|
47
|
|
|
|
|
|
|
parameters ANY DEFINED BY algorithm OPTIONAL |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
-- cf. RFC 5208 appendix A |
|
51
|
|
|
|
|
|
|
PrivateKeyInfo ::= SEQUENCE { |
|
52
|
|
|
|
|
|
|
version Version, |
|
53
|
|
|
|
|
|
|
privateKeyAlgorithm AlgorithmIdentifier, |
|
54
|
|
|
|
|
|
|
privateKey PrivateKey |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
PrivateKey ::= OCTET STRING |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
-- cf. RFC 3280 4.1 |
|
60
|
|
|
|
|
|
|
SubjectPublicKeyInfo ::= SEQUENCE { |
|
61
|
|
|
|
|
|
|
algorithm AlgorithmIdentifier, |
|
62
|
|
|
|
|
|
|
subjectPublicKey BIT STRING |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
>; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub get_template { |
|
67
|
339
|
|
|
339
|
0
|
19568
|
my ($what_is_big_fat_int) = @_; |
|
68
|
|
|
|
|
|
|
|
|
69
|
339
|
|
|
|
|
851
|
my $template = $ASN1_TEMPLATE; |
|
70
|
339
|
|
|
|
|
2831
|
$template =~ s//$what_is_big_fat_int/; |
|
71
|
|
|
|
|
|
|
|
|
72
|
339
|
|
|
|
|
1778
|
return $template; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |