Skip to content

Commit

Permalink
der: add Any::value accessor (RustCrypto#833)
Browse files Browse the repository at this point in the history
* add value function to Any. change BasicOcspResponse to use AlgorithmIdentifierOwned (the repo needs similar owned treatment as x509-cert but changing this one field is an immediate need).

* address clippy warning
  • Loading branch information
carl-wallace authored Jan 2, 2023
1 parent 4e2266e commit b79a4c1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions der/src/asn1/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ impl Any {
Ok(Self { tag, value })
}

/// Allow access to value
pub fn value(&self) -> &[u8] {
self.value.as_slice()
}

/// Attempt to decode this [`Any`] type into the inner value.
pub fn decode_as<'a, T>(&'a self) -> Result<T>
where
Expand Down
4 changes: 2 additions & 2 deletions x509-ocsp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extern crate alloc;
use der::asn1::{BitStringRef, Ia5StringRef, ObjectIdentifier, OctetStringRef, UintRef};
use der::asn1::{GeneralizedTime, Null};
use der::{AnyRef, Choice, Enumerated, Sequence};
use spki::AlgorithmIdentifierRef;
use spki::{AlgorithmIdentifierOwned, AlgorithmIdentifierRef};
use x509_cert::ext::pkix::name::GeneralName;
use x509_cert::ext::pkix::{AuthorityInfoAccessSyntax, CrlReason};
use x509_cert::ext::Extensions;
Expand Down Expand Up @@ -242,7 +242,7 @@ pub struct ResponseBytes<'a> {
#[allow(missing_docs)]
pub struct BasicOcspResponse<'a> {
pub tbs_response_data: ResponseData<'a>,
pub signature_algorithm: AlgorithmIdentifierRef<'a>,
pub signature_algorithm: AlgorithmIdentifierOwned,
pub signature: BitStringRef<'a>,

#[asn1(context_specific = "0", optional = "true", tag_mode = "EXPLICIT")]
Expand Down

0 comments on commit b79a4c1

Please sign in to comment.