Skip to content

Commit b731988

Browse files
committed
crmf: make CertId not profile specific
1 parent d9afb47 commit b731988

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

cmpv2/src/oob.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ 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::{DigestWriter, Encode, asn1::Null, oid::AssociatedOid},
12-
x509_cert::{Certificate, ext::pkix::name::GeneralName},
13+
x509_cert::{certificate::CertificateInner, ext::pkix::name::GeneralName},
1314
};
1415

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

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

crmf/src/controls.rs

Lines changed: 7 additions & 4 deletions
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)