Parse/Template.pm

filter: Statementstmt 100% 6 / 6 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 1 / 1 Podpod 0.0% 0 / 1 totaltotal 87.5% 7 / 8 CC 1 SCAR 0.0
CC
1
Cov
100%
get_template
1.0
CRAP 1.0
« Parse.pm ↑ Summary Parse/KeyBase.pm »
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 2 my $ASN1_TEMPLATE = q<
8  
9 FG_FAUX_INTEGER ::= <WHAT_IS_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 1 ▶sub get_template {
Subroutine get_template: called CC=1 SCAR=0.0
Pod undocumented
64 1 my ($what_is_big_fat_int) = @_;
65  
66 1 my $template = $ASN1_TEMPLATE;
67 1 $template =~ s/<WHAT_IS_FG_FAUX_INTEGER>/$what_is_big_fat_int/;
68  
69 1 return $template;
70 }
71  
72 2 1;
« Parse.pm ↑ Summary Parse/KeyBase.pm »