Expand description
§simple-tlv
Implementation of the SIMPLE-TLV serialization format from ISO 7816-4:2005.
§5.2.1 SIMPLE-TLV data objects
Each SIMPLE-TLV data object shall consist of two or three consecutive fields: a mandatory tag field, a mandatory length field and a conditional value field. A record (see 7.3.1) may be a SIMPLE-TLV data object.
- The tag field consists of a single byte encoding a tag number from 1 to 254. The values ‘00’ and ‘FF’ are invalid for tag fields. If a record is a SIMPLE-TLV data object, then the tag may be used as record identifier.
- The length field consists of one or three consecutive bytes.
- If the first byte is not set to ‘FF’, then the length field consists of a single byte encoding a number from zero to 254 and denoted N.
- If the first byte is set to ‘FF’, then the length field continues on the subsequent two bytes with any value encoding a number from zero to 65,535 and denoted N.
- If N is zero, there is no value field, i.e., the data object is empty. Otherwise (N > 0), the value field consists of N consecutive bytes.
§Credits
This library is a remix of RustCrypto/utils/der
, with a view towards:
- not requiring references to ASN.1 (e.g., since SIMPLE-TLV does not have any)
- not requiring allocations or memmoves (like ring, derp, x509:der)
- adding a type layer on top of SIMPLE-TLV’s byte slice values
The core idea taken from der
is to have Encodable
require an encoded_length
method.
By calling this recursively in a first pass, allocations required in other approaches are
avoided.
Structs§
- Decoder
- SIMPLE-TLV decoder.
- Encoder
- SIMPLE-TLV encoder.
- Error
- Error type.
- Length
- SIMPLE-TLV-encoded length.
- Slice
- Slice of at most
Length::max()
bytes. - Tag
- The tag field consists of a single byte encoding a tag number from 1 to 254. The values ‘00’ and ‘FF’ are invalid.
- Tagged
Value - SIMPLE-TLV data object.
Enums§
- Error
Kind - Error type.
Traits§
- Container
- Multiple encodables in a container.
- Decodable
- Decoding trait.
- Encodable
- Encoding trait.
- Tagged
- Types with an associated SIMPLE-TLV
Tag
.
Type Aliases§
- Result
- Result type.
- Tagged
Slice - Raw SIMPLE-TLV data object
TaggedValue<Slice<'_>>
.