Skip to content

Commit f676cef

Browse files
committed
crmf: make CertId not profile specific
1 parent e7b25b3 commit f676cef

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

cmpv2/src/oob.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ use der::asn1::BitString;
55

66
use crmf::controls::CertId;
77
use spki::AlgorithmIdentifierOwned;
8+
use x509_cert::certificate::{Profile, Rfc5280};
89

910
#[cfg(feature = "digest")]
1011
use {
1112
der::{Encode, asn1::Null, oid::AssociatedOid},
1213
spki::DigestWriter,
13-
x509_cert::{Certificate, ext::pkix::name::GeneralName},
14+
x509_cert::{certificate::CertificateInner, ext::pkix::name::GeneralName},
1415
};
1516

1617
use crate::header::CmpCertificate;
@@ -38,7 +39,7 @@ pub type OobCert = CmpCertificate;
3839
/// [RFC 4210 Section 5.2.5]: https://www.rfc-editor.org/rfc/rfc4210#section-5.2.5
3940
#[derive(Clone, Debug, Eq, PartialEq, Sequence)]
4041
#[allow(missing_docs)]
41-
pub struct OobCertHash {
42+
pub struct OobCertHash<P: Profile = Rfc5280> {
4243
#[asn1(
4344
context_specific = "0",
4445
tag_mode = "EXPLICIT",
@@ -52,14 +53,17 @@ pub struct OobCertHash {
5253
constructed = "true",
5354
optional = "true"
5455
)]
55-
pub cert_id: Option<CertId>,
56+
pub cert_id: Option<CertId<P>>,
5657
pub hash_val: BitString,
5758
}
5859

5960
#[cfg(feature = "digest")]
60-
impl OobCertHash {
61+
impl<P> OobCertHash<P>
62+
where
63+
P: Profile,
64+
{
6165
/// Create an [`OobCertHash`] from a given certificate
62-
pub fn from_certificate<D>(cert: &Certificate) -> der::Result<Self>
66+
pub fn from_certificate<D>(cert: &CertificateInner<P>) -> der::Result<Self>
6367
where
6468
D: digest::Digest + AssociatedOid,
6569
{

crmf/src/controls.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ use cms::enveloped_data::EnvelopedData;
99
use spki::{AlgorithmIdentifierOwned, SubjectPublicKeyInfoOwned};
1010
use x509_cert::attr::AttributeTypeAndValue;
1111
use x509_cert::ext::pkix::name::GeneralName;
12-
use x509_cert::serial_number::SerialNumber;
12+
use x509_cert::{
13+
certificate::{Profile, Rfc5280},
14+
serial_number::SerialNumber,
15+
};
1316

1417
/// The `Controls` type is defined in [RFC 4211 Section 6].
1518
///
@@ -231,7 +234,7 @@ pub type KeyGenParameters = OctetString;
231234
/// ```
232235
///
233236
/// [RFC 4211 Section 6.5]: https://www.rfc-editor.org/rfc/rfc4211#section-6.5
234-
pub type OldCertId = CertId;
237+
pub type OldCertId<P> = CertId<P>;
235238

236239
/// The `CertId` control is defined in [RFC 4211 Section 6.5].
237240
///
@@ -244,9 +247,9 @@ pub type OldCertId = CertId;
244247
/// [RFC 4211 Section 6.5]: https://www.rfc-editor.org/rfc/rfc4211#section-6.5
245248
#[derive(Clone, Debug, Eq, PartialEq, Sequence)]
246249
#[allow(missing_docs)]
247-
pub struct CertId {
250+
pub struct CertId<P: Profile = Rfc5280> {
248251
pub issuer: GeneralName,
249-
pub serial_number: SerialNumber,
252+
pub serial_number: SerialNumber<P>,
250253
}
251254

252255
/// The `ProtocolEncrKey` control is defined in [RFC 4211 Section 6.6].

0 commit comments

Comments
 (0)