diff --git a/src/cert.rs b/src/cert.rs index cf93e5c8..3450c894 100644 --- a/src/cert.rs +++ b/src/cert.rs @@ -116,7 +116,7 @@ impl<'a> Cert<'a> { der::Tag::Sequence, Error::BadDer, |extension| { - remember_cert_extension(&mut cert, &Extension::parse(extension)?) + remember_cert_extension(&mut cert, &Extension::from_der(extension)?) }, ) }, diff --git a/src/crl.rs b/src/crl.rs index 9616a414..1d4c2948 100644 --- a/src/crl.rs +++ b/src/crl.rs @@ -351,7 +351,7 @@ impl<'a> FromDer<'a> for BorrowedCertRevocationList<'a> { // that the application cannot process, then the application MUST NOT // use that CRL to determine the status of certificates. However, // applications may ignore unrecognized non-critical extensions. - crl.remember_extension(&Extension::parse(extension)?) + crl.remember_extension(&Extension::from_der(extension)?) }, ) }, @@ -537,7 +537,7 @@ impl<'a> FromDer<'a> for BorrowedRevokedCert<'a> { // process, then the application MUST NOT use that CRL to determine the // status of any certificates. However, applications may ignore // unrecognized non-critical CRL entry extensions. - revoked_cert.remember_extension(&Extension::parse(ext_der)?) + revoked_cert.remember_extension(&Extension::from_der(ext_der)?) })?; if reader.at_end() { break; diff --git a/src/x509.rs b/src/x509.rs index 853d2056..7944dce9 100644 --- a/src/x509.rs +++ b/src/x509.rs @@ -23,17 +23,6 @@ pub(crate) struct Extension<'a> { } impl<'a> Extension<'a> { - pub(crate) fn parse(der: &mut untrusted::Reader<'a>) -> Result, Error> { - let id = der::expect_tag_and_get_value(der, der::Tag::OID)?; - let critical = bool::from_der(der)?; - let value = der::expect_tag_and_get_value(der, der::Tag::OctetString)?; - Ok(Extension { - id, - critical, - value, - }) - } - pub(crate) fn unsupported(&self) -> Result<(), Error> { match self.critical { true => Err(Error::UnsupportedCriticalExtension), @@ -42,6 +31,19 @@ impl<'a> Extension<'a> { } } +impl<'a> FromDer<'a> for Extension<'a> { + fn from_der(reader: &mut untrusted::Reader<'a>) -> Result { + let id = der::expect_tag_and_get_value(reader, der::Tag::OID)?; + let critical = bool::from_der(reader)?; + let value = der::expect_tag_and_get_value(reader, der::Tag::OctetString)?; + Ok(Extension { + id, + critical, + value, + }) + } +} + pub(crate) fn set_extension_once( destination: &mut Option, parser: impl Fn() -> Result,