Asn1Element

Base ASN.1 data class. Can either be a primitive (holding a value), or a structure (holding other ASN.1 elements)

Inheritors

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Properties

Link copied to clipboard

Length (as a plain Int to work with it in code) of the contained data. Guarded: throws Asn1Exception if contentLengthLong exceeds Int.MAX_VALUE (a >2 GiB aggregate) rather than silently overflowing. For such elements use contentLengthLong.

Link copied to clipboard
abstract val contentLengthLong: Long

Length of the contained data as a Long. This is the overflow-safe source of truth; for a primitive it is the size of the held bytes, for a structure the sum of the encoded sizes of all child nodes.

Link copied to clipboard

DER-encoded representation of this ASN.1 element.

Link copied to clipboard
Link copied to clipboard

Total number of bytes required to represent this element when encoding to ASN.1. Guarded: throws Asn1Exception if overallLengthLong exceeds Int.MAX_VALUE. For such elements use overallLengthLong.

Link copied to clipboard

Total number of bytes required to represent this element when encoding to ASN.1, as a Long. Computed arithmetically from the (sentinel-cached) contentLengthLong — no lazy, no materialized length array — so the length post-order (Asn1Structure.contentLengthLong) can sum children without per-node lock/allocation.

Link copied to clipboard

Functions

Link copied to clipboard

Convenience function to cast this element to an Asn1EncapsulatingOctetString

Link copied to clipboard

Convenience function to cast this element to an Asn1ExplicitlyTagged

Link copied to clipboard

Convenience function to cast this element to an Asn1OctetString

Link copied to clipboard

Convenience function to cast this element to an Asn1Primitive

Link copied to clipboard

Convenience function to cast this element to an Asn1Sequence

Link copied to clipboard

Convenience function to cast this element to an Asn1SequenceOf

Link copied to clipboard
fun asSet(): Asn1Set

Convenience function to cast this element to an Asn1Set

Link copied to clipboard

Convenience function to cast this element to an Asn1SetOf

Link copied to clipboard

Convenience function to cast this element to an Asn1Structure

Link copied to clipboard
fun encodeTo(sink: Sink)
Link copied to clipboard
operator override fun equals(other: Any?): Boolean
Link copied to clipboard
override fun hashCode(): Int
Link copied to clipboard
fun prettyPrint(limit: Long = MAX_RENDER_CHARS): String

Verbose, indented human-readable tree, truncated at limit characters with a marker (see renderTo).

Link copied to clipboard
fun renderTo(out: Sink, pretty: Boolean, limit: Long)

Stack-safe renderer that writes this element's compact (pretty = false) or indented (pretty = true) string form as UTF-8 into out, stopping after limit characters (appending a truncation marker). Expressed with DeepRecursiveFunction so deep nesting cannot overflow the call stack; reuses the per-node prettyPrintHeader/prettyPrintTrailer/contentToString so output is unchanged for ordinary elements.

Link copied to clipboard
fun toDerHexString(lineLen: Int? = null): String

Convenience method to directly produce an HEX string of this element's ASN.1 representation

Link copied to clipboard
open override fun toString(): String

fun toString(limit: Long): String

Compact single-line rendering, truncated at limit characters with a marker (see renderTo).

Link copied to clipboard

Creates a new implicitly tagged ASN.1 Element from this ASN.1 Element. NOTE: The TagClass of the provided tag will be used! If you want the result to have TagClass.CONTEXT_SPECIFIC, use element withImplicitTag (tag withClass TagClass.CONTEXT_SPECIFIC)!. If a CONSTRUCTED Tag is applied to an ASN.1 Primitive, the CONSTRUCTED bit is overridden and set to zero.

Creates a new implicitly tagged ASN.1 Element from this ASN.1 Structure. If the provided template's tagClass is not set, the class of the resulting structure defaults to TagClass.CONTEXT_SPECIFIC. If a CONSTRUCTED Tag is applied to an ASN.1 Primitive, the CONSTRUCTED bit is overridden and set to zero.

infix inline fun withImplicitTag(tagValue: ULong): Asn1Element

Creates a new implicitly tagged ASN.1 Element from this ASN.1 Element. Sets the class of the resulting structure to TagClass.CONTEXT_SPECIFIC