Asn1String

ASN.1 String class used as wrapper do discriminate between different ASN.1 string types By default, the string value is decoded using UTF-8. If a different charset or custom decoding is needed, the rawValue property can be used directly.

To enable parsing of non-compliant strings without exploding, every String is internally represented as raw ByteArray and not validated during decoding from ASN.1. The isValid property indicates whether the bytes contained in an ASN.1 String object type are valid according to the validation rules of that type.

Inheritors

Types

Link copied to clipboard
class BMP : Asn1String

BMP STRING (unchecked). Validation is not implemented. This string format is deprecated for HTTPS certificates and its use in generally discouraged in favor of UTF-8 strings (see Asn1String.UTF8).

Link copied to clipboard
Link copied to clipboard

GENERAL STRING (checked)

Link copied to clipboard

GRAPHIC STRING (checked)

Link copied to clipboard
class IA5 : Asn1String

IA5 STRING (checked)

Link copied to clipboard

NUMERIC STRING (checked)

Link copied to clipboard

PRINTABLE STRING (checked)

Link copied to clipboard

TELETEX STRING (checked). This string format is deprecated for HTTPS certificates and its use in generally discouraged in favor of UTF-8 strings (see Asn1String.UTF8).

Link copied to clipboard

UNIVERSAL STRING (no checks) Validation is not implemented. This string format is deprecated for HTTPS certificates and its use in generally discouraged in favor of UTF-8 strings (see Asn1String.UTF8).

Link copied to clipboard

CHARACTER/UNRESTRICTED STRING (no checks)

Link copied to clipboard

UTF8 STRING (verbatim String)

Link copied to clipboard

VIDEOTEX STRING (no checks) Validation is not implemented. This type is no longer used in practice.

Link copied to clipboard

VISIBLE STRING (checked)

Properties

Link copied to clipboard
abstract val isValid: Boolean?

Returns whether this string is valid:

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract val tag: ULong
Link copied to clipboard

Always the UTF-8 interpretation of rawValue. The decoding is performed via String.decodeFromAsn1ContentBytes, which internally uses the standard library's ByteArray.decodeToString.

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 fun encodeToDerSafe(): KmmResult<ByteArray>

Safe version of encodeToDer, wrapping the result into a KmmResult

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

Encodes the implementing object into an A

Link copied to clipboard

Exception-free version of encodeToTlv

Link copied to clipboard
open fun encodeToTlvSafe(): KmmResult<Asn1Primitive>

Safe version of encodeToTlv, wrapping the result into a KmmResult

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

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