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