1
1
//! Trust anchor-related structures as defined in RFC 5914
2
2
3
+ use crate :: certificate:: { CertificateInner , Profile , Rfc5280 , TbsCertificateInner } ;
3
4
use crate :: ext:: pkix:: { certpolicy:: CertificatePolicies , NameConstraints } ;
4
5
use crate :: { ext:: Extensions , name:: Name } ;
5
- use crate :: { Certificate , TbsCertificate } ;
6
6
7
7
use alloc:: string:: String ;
8
8
use der:: asn1:: OctetString ;
@@ -37,7 +37,7 @@ pub enum Version {
37
37
/// ```
38
38
#[ derive( Clone , Debug , PartialEq , Eq , Sequence ) ]
39
39
#[ allow( missing_docs) ]
40
- pub struct TrustAnchorInfo {
40
+ pub struct TrustAnchorInfo < P : Profile + ' static = Rfc5280 > {
41
41
#[ asn1( default = "Default::default" ) ]
42
42
pub version : Version ,
43
43
@@ -49,7 +49,7 @@ pub struct TrustAnchorInfo {
49
49
pub ta_title : Option < String > ,
50
50
51
51
#[ asn1( optional = "true" ) ]
52
- pub cert_path : Option < CertPathControls > ,
52
+ pub cert_path : Option < CertPathControls < P > > ,
53
53
54
54
#[ asn1( context_specific = "1" , tag_mode = "EXPLICIT" , optional = "true" ) ]
55
55
pub extensions : Option < Extensions > ,
@@ -70,11 +70,11 @@ pub struct TrustAnchorInfo {
70
70
/// ```
71
71
#[ derive( Clone , Debug , Eq , PartialEq , Sequence ) ]
72
72
#[ allow( missing_docs) ]
73
- pub struct CertPathControls {
73
+ pub struct CertPathControls < P : Profile + ' static = Rfc5280 > {
74
74
pub ta_name : Name ,
75
75
76
76
#[ asn1( context_specific = "0" , tag_mode = "IMPLICIT" , optional = "true" ) ]
77
- pub certificate : Option < Certificate > ,
77
+ pub certificate : Option < CertificateInner < P > > ,
78
78
79
79
#[ asn1( context_specific = "1" , tag_mode = "IMPLICIT" , optional = "true" ) ]
80
80
pub policy_set : Option < CertificatePolicies > ,
@@ -114,22 +114,27 @@ flags! {
114
114
/// [RFC 5280 Section 4.2.1.13]: https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.13
115
115
pub type CertPolicyFlags = FlagSet < CertPolicies > ;
116
116
117
+ /// TrustAnchorInfo allows for the representation of a single trust anchor.
118
+ /// Defined in [RFC 5914 Section 3].
119
+ ///
117
120
/// ```text
118
121
/// TrustAnchorChoice ::= CHOICE {
119
122
/// certificate Certificate,
120
123
/// tbsCert [1] EXPLICIT TBSCertificate,
121
124
/// taInfo [2] EXPLICIT TrustAnchorInfo
122
125
/// }
123
126
/// ```
127
+ ///
128
+ /// [RFC 5914 Section 3]: https://www.rfc-editor.org/rfc/rfc5914#section-3
124
129
#[ derive( Clone , Debug , PartialEq , Eq , Choice ) ]
125
130
#[ allow( clippy:: large_enum_variant) ]
126
131
#[ allow( missing_docs) ]
127
- pub enum TrustAnchorChoice {
128
- Certificate ( Certificate ) ,
132
+ pub enum TrustAnchorChoice < P : Profile + ' static = Rfc5280 > {
133
+ Certificate ( CertificateInner < P > ) ,
129
134
130
135
#[ asn1( context_specific = "1" , tag_mode = "EXPLICIT" , constructed = "true" ) ]
131
- TbsCertificate ( TbsCertificate ) ,
136
+ TbsCertificate ( TbsCertificateInner < P > ) ,
132
137
133
138
#[ asn1( context_specific = "2" , tag_mode = "EXPLICIT" , constructed = "true" ) ]
134
- TaInfo ( TrustAnchorInfo ) ,
139
+ TaInfo ( TrustAnchorInfo < P > ) ,
135
140
}
0 commit comments