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>
impl<'a> HashIndex<'a>
Sourcepub fn of_token(token: &Token<'a>, parent: &Reader<'a>) -> Result<Self>
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>
impl<'a> HashIndex<'a>
Sourcepub fn read(parent: &Reader<'a>, value: &Element<'a>) -> Result<Self>
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.
Sourcepub fn algorithm(&self) -> &AlgorithmIdentifier<'a>
pub fn algorithm(&self) -> &AlgorithmIdentifier<'a>
The algorithm every index entry and the message imprint are hashed with.
Sourcepub fn certificates(&self) -> &[&'a [u8]]
pub fn certificates(&self) -> &[&'a [u8]]
certificatesHashIndex entries, in their written order.
Sourcepub fn revocations(&self) -> &[&'a [u8]]
pub fn revocations(&self) -> &[&'a [u8]]
crlsHashIndex entries, in their written order.
Sourcepub fn attribute_values(&self) -> &[&'a [u8]]
pub fn attribute_values(&self) -> &[&'a [u8]]
unsignedAttrValuesHashIndex entries, in their written order.