1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! Holding a range to the distinguished rules.
//!
//! Certificates are not the only structure whose schema fixes its encoding
//! regardless of the envelope carrying it. A signed message is BER, and the
//! attributes inside it that a signature covers "MUST be DER encoded, even if
//! the rest of the structure is BER encoded" (RFC 5652 5.3). The walk that
//! decides that question already exists here, so it is exposed rather than
//! written a second time: two answers to what counts as DER is one answer more
//! than a product can defend.
use crate;
use ;
/// Whether a range and everything under it is DER.
///
/// Definite lengths in their shortest form, primitive encodings where the
/// distinguished rules require them, assigned universal types, and the members
/// of a set in ascending order of their encodings (X.690 11.6).
///
/// The reader decides which rules apply to the outermost header, so a caller
/// holding a range to DER inside a BER document reads it again under DER first;
/// [`structured_asn1::Reader::reread`] is what that is for.
///
/// # Errors
///
/// Reports which rule was broken and where.
/// Whether two members of a set are in the order the distinguished rules put
/// them in.
///
/// "The encodings of the component values of a set-of value shall appear in
/// ascending order" (X.690 11.6), comparing octet by octet with the shorter
/// encoding treated as though padded with zeros.
///
/// It is separate from [`conforms`] because a set is not always written under
/// a set's own tag: a signed message writes its attributes under a context tag
/// and signs them under `SET OF`, so the ordering is the schema's to check
/// where the tag no longer says so.
///
/// `parent` supplies the current execution account and original parser-local
/// cumulative ceiling. Before comparison, one work unit per possible octet
/// pair is admitted: the longer length, because X.690 compares the shorter
/// encoding with virtual zero padding. A minimum of one unit covers an empty
/// comparison. This is an upper bound; an unequal pair may stop the walk early.
/// `parent` must belong to the session and source that produced `next`; this
/// is a caller precondition, not a provenance check.
///
/// # Errors
/// Returns a resource refusal at `next`'s original offset before comparing
/// bytes. `Ok(false)` means incorrect order, independently of resource errors.