Asn1Time

ASN.1 TIME (required since GENERALIZED TIME and UTC TIME exist).

The concrete subtype — SecondsCapped vs Fractional — is the single source of truth for whether an encoded fractional second is present:

Do not infer the presence or absence of a fraction from instant (or instant.nanosecondsOfSecond). instant is truncated to nanosecond resolution, so a Fractional carrying a sub-nanosecond or all-zero fraction (e.g. .0000000000001 or .000) can report nanosecondsOfSecond == 0 while still encoding a fraction. Branch on the subtype, never on the instant — using the instant may misclassify cases.

Inheritors

Types

Link copied to clipboard
Link copied to clipboard

Enum of supported Time formats

Link copied to clipboard

A GENERALIZED TIME carrying an exact fractional second. Produced only by decoding or from a sub-second Instant; a whole-second value is always a SecondsCapped instead.

Link copied to clipboard
class SecondsCapped(instant: Instant, formatOverride: Asn1Time.Format? = null) : Asn1Time

An Asn1Time with no encoded fractional second (whole-second) — the canonical DER-minimal form, and the only way to construct a time from Kotlin.

Properties

Link copied to clipboard
abstract val format: Asn1Time.Format

Indicates whether this timestamp uses UTC TIME or GENERALIZED TIME.

Link copied to clipboard
abstract val instant: Instant

The timestamp value only, truncated to Instant's nanosecond resolution. For SecondsCapped this is whole-second; for Fractional it reflects the decoded fraction only up to nanoseconds.

Functions

Link copied to clipboard

Convenience function to directly get the DER-encoded representation of the implementing object

Link copied to clipboard

Exception-free version of encodeToDer

Link copied to clipboard
open override fun encodeToTlv(): Asn1Primitive

Encodes the implementing object into an A

Link copied to clipboard
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

shorthand for Asn1Element.prettyPrint, hence, a call to this function encodes this encodable to an Asn1Element, holds it in memory, pretty prints it, and discards it. This characteristic may be relevant in memory-constrained environments.

Link copied to clipboard

Returns a fresh instance of a SecondsCapped version of this Asn1Time.

Link copied to clipboard
fun Asn1Encodable<*>.toDerHexString(lineLen: Int? = null): String
Link copied to clipboard
open override fun toString(): String
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, also invoke 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

open infix 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