Skip to main content

HashIndex

Struct HashIndex 

Source
pub struct HashIndex<'a> { /* private fields */ }
Expand description

One ATSHashIndexV3 value (EN 319 122-1 §5.5.2), in its original DER.

Implementations§

Source§

impl<'a> HashIndex<'a>

Source

pub fn of_token(token: &Token<'a>, parent: &Reader<'a>) -> Result<Self>

Reads the single ats-hash-index-v3 of an archive time-stamp token.

EN 319 122-1 §5.5.3 requires exactly one such attribute in the token’s unsigned attributes, and §5.5.2 exactly one value, with the whole attribute DER encoded.

§Errors

A missing or repeated attribute, a value count other than one, an attribute that is not DER, a value that is not an ATSHashIndexV3, a foreign reader, or a spent work ceiling.

Source§

impl<'a> HashIndex<'a>

Source

pub fn read(parent: &Reader<'a>, value: &Element<'a>) -> Result<Self>

Reads one ATSHashIndexV3 value, rereading it under DER (§5.5.2).

§Examples
use std::sync::Arc;
use structured_asn1::Parser;
use structured_asn1::memory::{Memory, MemoryAccount};
use structured_cms::archive::HashIndex;

// SHA-256, one certificate hash, no revocation or attribute hashes.
let mut index = vec![0x30, 53, 0x30, 11, 6, 9, 0x60, 0x86, 0x48, 1, 0x65, 3, 4, 2, 1];
index.extend([0x30, 34, 4, 32]);
index.extend([7; 32]);
index.extend([0x30, 0, 0x30, 0]);
let parser = Parser::ber(Memory::new(Arc::new(MemoryAccount::new(4096, 4096))));
let mut reader = parser.read(&index, 0).unwrap();
let value = reader.next_element().unwrap().unwrap();
let read = HashIndex::read(&reader, &value).unwrap();
assert_eq!(read.certificates(), &[&[7; 32][..]]);
assert!(read.revocations().is_empty() && read.attribute_values().is_empty());
assert_eq!(read.as_bytes(), index.as_slice());
§Errors

A value that is not DER, not the four-field sequence, or whose index entries are not OCTET STRINGs; a spent work ceiling.

Source

pub fn algorithm(&self) -> &AlgorithmIdentifier<'a>

The algorithm every index entry and the message imprint are hashed with.

Source

pub fn certificates(&self) -> &[&'a [u8]]

certificatesHashIndex entries, in their written order.

Source

pub fn revocations(&self) -> &[&'a [u8]]

crlsHashIndex entries, in their written order.

Source

pub fn attribute_values(&self) -> &[&'a [u8]]

unsignedAttrValuesHashIndex entries, in their written order.

Source

pub fn as_bytes(&self) -> &'a [u8] ⓘ

The original ATSHashIndexV3 encoding, the last part of the imprint input.

Source

pub fn span(&self) -> Span

The original range of the index value.

Trait Implementations§

Source§

impl<'a> Debug for HashIndex<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for HashIndex<'a>

§

impl<'a> !RefUnwindSafe for HashIndex<'a>

§

impl<'a> !Send for HashIndex<'a>

§

impl<'a> !Sync for HashIndex<'a>

§

impl<'a> !UnwindSafe for HashIndex<'a>

§

impl<'a> Unpin for HashIndex<'a>

§

impl<'a> UnsafeUnpin for HashIndex<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.