Asn1Primitive

open class Asn1Primitive(tag: UByte, content: ByteArray) : Asn1Element(source)

ASN.1 primitive. Hold o children, but content under tag

Inheritors

Constructors

Link copied to clipboard
constructor(tag: UByte, content: ByteArray)

Properties

Link copied to clipboard
open override val content: ByteArray

Raw data contained in this ASN.1 primitive in its encoded form. Requires decoding to interpret it

Link copied to clipboard
Link copied to clipboard

Length (already properly encoded into a byte array for writing as ASN.1) of the contained data. For a primitive, this is just the size of the held bytes. For a structure, it is the sum of the number of bytes needed to encode all held child nodes.

Link copied to clipboard
val length: Int

Length (as a plain Int to work with it in code) of the contained data. For a primitive, this is just the size of the held bytes. For a structure, it is the sum of the number of bytes needed to encode all held child nodes.

Link copied to clipboard

Total number of bytes required to represent the ths element, when encoding to ASN.1.

Link copied to clipboard
val tag: UByte

Functions

Link copied to clipboard
inline fun <T> Asn1Primitive.decode(tag: UByte, transform: (content: ByteArray) -> T): T

Generic decoding function. Verifies that this Asn1Primitive's tag matches tag and transforms its content as per transform

Link copied to clipboard
inline fun <T> Asn1Primitive.decodeOrNull(tag: UByte, transform: (content: ByteArray) -> T): T?

Exception-free version of decode

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
Link copied to clipboard
fun Asn1Primitive.readBigInteger(): BigInteger

Decode the Asn1Primitive as a BigInteger

Link copied to clipboard
inline fun Asn1Primitive.readBigIntegerOrNull(): BigInteger?

Exception-free version of readBigInteger

Link copied to clipboard

decodes this Asn1Primitive's content into an ByteArray, assuming it was encoded as BIT STRING

Link copied to clipboard
Link copied to clipboard

decodes this Asn1Primitive's content into an Boolean

Link copied to clipboard
fun Asn1Primitive.readInstant(): Instant

decodes this Asn1Primitive's content into an Instant if it is encoded as UTC TIME or GENERALIZED TIME

Link copied to clipboard

Exception-free version of readInstant

Link copied to clipboard

decodes this Asn1Primitive's content into an Int

Link copied to clipboard

Exception-free version of readInt

Link copied to clipboard

decodes this Asn1Primitive's content into a Long

Link copied to clipboard

Exception-free version of readLong

Link copied to clipboard

decodes this Asn1Primitive to null (i.e. verifies the tag to be BERTags.ASN1_NULL and the content to be empty

Link copied to clipboard

Name seems odd, but this is just an exception-free version of readNull

Link copied to clipboard
Link copied to clipboard

decodes this Asn1Primitive's content into an Asn1String

Link copied to clipboard

Exception-free version of readString

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

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

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