Asn1BitString

ASN.1 BIT STRING, enforcing strict DER rules:

  1. The number of padding bits must be in range 0..7

  2. The raw bytes must not be empty if padding bits are set

  3. The padding bits must be zero

When serialized to a non-DER format, the following representation is used:"$numPaddingBits:${base64Strict(bitCarryingBytes)}"

val bitSet = BitSet.fromString("001")
val bitString = Asn1BitString(bitSet)

Json.encodeToString(bitString) //produces "5:IA=="

Constructors

Link copied to clipboard
constructor(source: BitSet)

Creates an ASN.1 BIT STRING from the provided bitSet. The transformation to bitCarryingBytes and the calculation of numPaddingBits happens immediately in the constructor. Hence, modifications to the source BitSet have no effect on the resulting Asn1BitString.

constructor(source: ByteArray)

Constructs an ASN.1 BIT STRING with source used for bitCarryingBytes and zero padding bits

Types

Link copied to clipboard

Properties

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

The DER content octets of the bit string, including the padding-bit-count byte.

Link copied to clipboard

The total length of the bit string content octets, including the padding-bit-count byte.

Link copied to clipboard

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

Transforms bitCarryingBytes and wraps into a BitSet. The last numPaddingBits bits are ignored. This is a deep copy and mirrors the bits in every byte to match the native bitset layout where bit and byte indices run in opposite direction. Hence, modifications to the resulting bitset do not affect bitCarryingBytes

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