Crate x690

Source
Expand description

§X.690 Encoding Rules Library

This library provides comprehensive support for X.690 encoding rules, which define how ASN.1 (Abstract Syntax Notation One) data structures are encoded for transmission and storage.

§Overview

X.690 defines several encoding rules:

  • BER (Basic Encoding Rules): The most flexible encoding, supporting both definite and indefinite lengths
  • CER (Canonical Encoding Rules): A restricted form of BER that produces canonical encodings
  • DER (Distinguished Encoding Rules): A restricted form of BER that produces unique encodings

This library focuses on BER encoding and decoding, providing a complete implementation of the X.690 specification.

§Key Features

  • Complete BER encoding and decoding support
  • Support for all ASN.1 universal types
  • Efficient memory management with zero-copy operations where possible
  • Comprehensive error handling with detailed error information
  • Support for both definite and indefinite length encoding
  • Tag and length encoding/decoding utilities

Re-exports§

pub use crate::ber::*;
pub use crate::codec::*;
pub use crate::parsing::*;

Modules§

ber
This module implements the Basic Encoding Rules (BER) for X.690.
codec
X690Codec trait, which is implemented by all X.690 codecs
der
This module implements the Basic Encoding Rules (DER) for X.690.
parsing
Functionality for parsing structured types, such as SEQUENCE and SET

Structs§

DeconstructionIterator
An iterator that iterates over the primitive content octets of the constituent elements of this element, recursively.
X690Element
Represents a complete X.690 encoded element with tag and value

Enums§

X690Length
Represents the length of an X.690 encoded element
X690Value
Represents the value content of an X.690 encoded element

Constants§

X690_REAL_BASE10
Base encoding constant for base-10 REAL values
X690_REAL_BASE_2
Base encoding constant for base-2 REAL values
X690_REAL_BASE_8
Base encoding constant for base-8 REAL values
X690_REAL_BASE_16
Base encoding constant for base-16 REAL values
X690_REAL_BASE_MASK
Bit mask for extracting the base bits from REAL encoding
X690_REAL_BASE_RESERVED
Reserved base encoding constant for REAL values
X690_REAL_BINARY
Base encoding constant for binary REAL values
X690_REAL_BINARY_SCALING_MASK
Bit mask for extracting binary scaling factor from REAL encoding
X690_REAL_EXPONENT_FORMAT_1_OCTET
Exponent format constant for 1-octet exponent
X690_REAL_EXPONENT_FORMAT_2_OCTET
Exponent format constant for 2-octet exponent
X690_REAL_EXPONENT_FORMAT_3_OCTET
Exponent format constant for 3-octet exponent
X690_REAL_EXPONENT_FORMAT_MASK
Bit mask for extracting exponent format from REAL encoding
X690_REAL_EXPONENT_FORMAT_VAR_OCTET
Exponent format constant for variable-length exponent
X690_REAL_NEGATIVE
Sign bit constant for negative REAL values
X690_REAL_NR1
ISO 6093 NR1 format constant for REAL encoding
X690_REAL_NR2
ISO 6093 NR2 format constant for REAL encoding
X690_REAL_NR3
ISO 6093 NR3 format constant for REAL encoding
X690_REAL_POSITIVE
Sign bit constant for positive REAL values
X690_REAL_SIGN_MASK
Bit mask for extracting the sign bit from REAL encoding
X690_REAL_SPECIAL
Flag indicating a special REAL value
X690_SPECIAL_REAL_MINUS_INFINITY
Special REAL value constant for negative infinity
X690_SPECIAL_REAL_MINUS_ZERO
Special REAL value constant for negative zero
X690_SPECIAL_REAL_NOT_A_NUMBER
Special REAL value constant for Not-a-Number (NaN)
X690_SPECIAL_REAL_PLUS_INFINITY
Special REAL value constant for positive infinity
X690_TAG_CLASS_APPLICATION
Tag class bits for APPLICATION tags in X.690 encoding
X690_TAG_CLASS_CONTEXT
Tag class bits for CONTEXT tags in X.690 encoding
X690_TAG_CLASS_PRIVATE
Tag class bits for PRIVATE tags in X.690 encoding
X690_TAG_CLASS_UNIVERSAL
Tag class bits for UNIVERSAL tags in X.690 encoding
_EAL_FOR_EXTERNAL
The Extended Attribute List (EAL) for the X.690-specific encoding of an EXTERNAL value as described in ITU Recommendation X.690, Section 8.18. It is empty, so this is basically just a formality.
_RCTL1_FOR_EXTERNAL
The Root Component Type List (RCTL) #1 for the X.690-specific encoding of an EXTERNAL value as described in ITU Recommendation X.690, Section 8.18.
_RCTL2_FOR_EXTERNAL
The Root Component Type List (RCTL) #2 for the X.690-specific encoding of an EXTERNAL value as described in ITU Recommendation X.690, Section 8.18. It is empty, so this is basically just a formality.

Traits§

RelateTLV
A trait for relating an X.690-encoded element to something

Functions§

deconstruct
Deconstruct an X.690-encoded element that could be primitively-constructed
get_written_x690_length_length
Calculates the number of bytes needed to encode a length value
get_written_x690_tag_length
Calculates the number of bytes needed to encode a tag number
get_x690_tag_and_length_length
Calculates the total length of tag and length bytes in an X.690 encoding
primitive
Get the primitive content octets of an X.690 element, or an error
x690_decode_tag
Decodes an X.690 tag from a byte slice
x690_encode_character_string_components
Encode the components of a CharacterString value as X.690-encoded elements
x690_encode_context_switching_identification
Encode the identification field of a context-switching type
x690_encode_embedded_pdv_components
Encode the components of an EMBEDDED PDV value as X.690-encoded elements
x690_encode_external_components
Encode the components of an EXTERNAL value as X.690-encoded elements
x690_read_boolean_value
Read a BOOLEAN value from an X.690-encoded element’s content octets
x690_read_date_time_value
Read a DATE-TIME value from an X.690-encoded element’s content octets
x690_read_date_value
Read a DATE value from an X.690-encoded element’s content octets
x690_read_duration_value
Read a DURATION value from an X.690-encoded element’s content octets
x690_read_enum_value
Read an ENUMERATED value from an X.690-encoded element’s content octets
x690_read_i64_value
Read an i64 value from an X.690-encoded element’s content octets
x690_read_integer_value
Read an INTEGER value from an X.690-encoded element’s content octets
x690_read_object_identifier_value
Read an OBJECT IDENTIFIER value from an X.690-encoded element’s content octets
x690_read_relative_oid_value
Read a RELATIVE-OID value from an X.690-encoded element’s content octets
x690_read_time_of_day_value
Read a TIME-OF-DAY value from an X.690-encoded element’s content octets
x690_write_bit_string_value
Writes a BIT STRING value in X.690 format
x690_write_bmp_string_value
Write a BMPString value as an X.690-encoded element, returning the number of bytes written
x690_write_boolean_value
Writes a BOOLEAN value in X.690 format
x690_write_character_string_value
Write a CharacterString value as an X.690-encoded element, returning the number of bytes written
x690_write_date_time_value
Write a DATE-TIME value as an X.690-encoded element, returning the number of bytes written
x690_write_date_value
Write a DATE value as an X.690-encoded element, returning the number of bytes written
x690_write_duration_value
Write a DURATION value as an X.690-encoded element, returning the number of bytes written
x690_write_embedded_pdv_value
Write an EMBEDDED PDV value as an X.690-encoded element
x690_write_enum_value
Writes an ENUMERATED value in X.690 format
x690_write_external_value
Write an EXTERNAL value as an X.690-encoded element
x690_write_generalized_time_value
Write a GeneralizedTime value as an X.690-encoded element, returning the number of bytes written
x690_write_i64_value
Writes an i64 value in X.690 INTEGER format
x690_write_integer_value
Writes an INTEGER value in X.690 format
x690_write_length
Writes an X.690 length to a writer
x690_write_object_descriptor_value
Writes an ObjectDescriptor value in X.690 format
x690_write_object_identifier_value
Writes an OBJECT IDENTIFIER value in X.690 format
x690_write_octet_string_value
Writes an OCTET STRING value in X.690 format
x690_write_real_value
Write a REAL value as an X.690-encoded element
x690_write_relative_oid_value
Write a RELATIVE-OID value as an X.690-encoded element, returning the number of bytes written
x690_write_string_value
Write a string value as an X.690-encoded element, returning the number of bytes written
x690_write_tag
Writes an X.690 tag to a writer
x690_write_time_of_day_value
Write a TIME-OF-DAY value as an X.690-encoded element, returning the number of bytes written
x690_write_time_value
Write a TIME value as an X.690-encoded element, returning the number of bytes written
x690_write_tlv
Write an X.690-encoded element to a writable stream, returning the number of bytes written
x690_write_universal_string_value
Write a UniversalString value as an X.690-encoded element, returning the number of bytes written
x690_write_utc_time_value
Write a UTCTime value as an X.690-encoded element, returning the number of bytes written
x690_write_utf8_string_value
Write a UTF8String value as an X.690-encoded element, returning the number of bytes written