Package-level declarations

Types

Link copied to clipboard

ASN.1 BIT STRING

Link copied to clipboard

ASN1 structure (i.e. containing child nodes) with custom tag

Link copied to clipboard

Interface providing convenience methods to decode from ASN.1. Especially useful when companion objects of classes implementing Asn1Encodable implement it.

Link copied to clipboard
@Serializable(with = Asn1EncodableSerializer::class)
sealed class Asn1Element

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

Link copied to clipboard

ASN.1 OCTET STRING 0x04 (BERTags.OCTET_STRING) containing an Asn1Element

Link copied to clipboard

Interface providing methods to encode to ASN.1

Link copied to clipboard
object Asn1EncodableSerializer : KSerializer<Asn1Element>
Link copied to clipboard
open class Asn1Exception(message: String?, cause: Throwable?) : Throwable
Link copied to clipboard

Explicit ASN.1 Tag. Can contain any number of children

Link copied to clipboard

A very simple implementation of an ASN.1 variable-length integer. It is only good for reading from and writing to ASN.1 structures. It is not a BigInt, nor does it define any operations. It has a sign though, and supports twosComplement representation and converting fromTwosComplement. Hence, it directly interoperates with Kotlin MP BigNum and the JVM BigInteger.

Link copied to clipboard
object Asn1IntegerSerializer : KSerializer<Asn1Integer>
Link copied to clipboard
interface Asn1OctetString

Interface describing an ASN.1 OCTET STRING.

Link copied to clipboard
Link copied to clipboard
open class Asn1Primitive(val tag: Asn1Element.Tag, val content: ByteArray) : Asn1Element

ASN.1 primitive. Holds no children, but content under tag

Link copied to clipboard

ASN.1 OCTET STRING 0x04 (BERTags.OCTET_STRING) containing arbitrary bytes

Link copied to clipboard
Link copied to clipboard
open class Asn1Set : Asn1Structure

ASN.1 SET 0x31 (BERTags.SET OR BERTags.CONSTRUCTED)

Link copied to clipboard

ASN.1 SET OF 0x31 (BERTags.SET OR BERTags.CONSTRUCTED)

Link copied to clipboard
@Serializable
sealed class Asn1String : Asn1Encodable<Asn1Primitive>

ASN.! String class used as wrapper do discriminate between different ASN.1 string types

Link copied to clipboard
class Asn1StructuralException(message: String, cause: Throwable? = null) : Asn1Exception
Link copied to clipboard
sealed class Asn1Structure : Asn1Element

ASN.1 structure. Contains no data itself, but holds zero or more children

Link copied to clipboard
class Asn1TagMismatchException(val expected: Asn1Element.Tag, val actual: Asn1Element.Tag, detailedMessage: String? = null) : Asn1Exception
Link copied to clipboard
@Serializable(with = Asn1TimeSerializer::class)
class Asn1Time(instant: Instant, formatOverride: Asn1Time.Format? = null) : Asn1Encodable<Asn1Primitive>

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

Link copied to clipboard
object Asn1TimeSerializer : KSerializer<Asn1Time>
Link copied to clipboard
object BERTags
Link copied to clipboard
@Serializable(with = BitSetSerializer::class)
class BitSet : Iterable<Boolean>

Pure Kotlin Bit Set created by throwing a bunch of extension functions at a MutableList<Byte>. As a mental model: this BitSet grows from left to right, just like writing a text.

Link copied to clipboard
object BitSetSerializer : KSerializer<BitSet>
Link copied to clipboard
Link copied to clipboard
interface Identifiable

Adds oid to the implementing class

Link copied to clipboard
object KnownOIDs
Link copied to clipboard

ASN.1 OBJECT IDENTIFIER featuring the most cursed encoding of numbers known to man, which probably surfaced due to an ungodly combination of madness, cruelty and a twisted sense of humour. Courtesy of what were most probably tormented souls to begin with.

Link copied to clipboard
object ObjectIdSerializer : KSerializer<ObjectIdentifier>
Link copied to clipboard
Link copied to clipboard
sealed interface TagProperty

Functions

Link copied to clipboard
Link copied to clipboard
inline fun <T : Asn1Element> T.assertTag(tag: Asn1Element.Tag): T

asserts that this element's tag matches tag.

inline fun <T : Asn1Element> T.assertTag(tagNumber: ULong): T

Asserts only the tag number, but neither class, nor CONSTRUCTED bit.

Link copied to clipboard

Returns a binary representation of this byte array's memory layout Bytes are separated by a single space. An empty byte array results in an empty string.

Link copied to clipboard
Link copied to clipboard
inline fun <R> runRethrowing(block: () -> R): R

Runs block inside catching and encapsulates any thrown exception in an Asn1Exception unless it already is one

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Returns all bits as they are accessible by the global bit index (i.e. after wrapping this ByteArray into a BitSet)

Link copied to clipboard
fun Asn1Integer.toJavaBigInteger(): <Error class: unknown class>
Link copied to clipboard

Directly moves the byte array to a buffer without copying. Thus, it keeps bytes managed by a Buffer accessible. The bytes may be overwritten through the Buffer or even recycled to be used by another buffer. Therefore, operating on these bytes after wrapping leads to undefined behaviour.