Asn1BitString

constructor(source: BitSet)(source)

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.

BEWARE: a bitset (as BitSet implements it) is, by definition, only as long as the highest bit set! Hence, trailing zeroes are ALWAYS stripped. If you require tailing zeroes, the easiest quick-and-dirty hack to accomplish this in general is as follows:

  • set the last bit you require as tailing zero to one

  • call this constructor

  • flip the previously set bit back (this will be the lowest bit set in last byte of bitCarryingBytes).

Parameters

source

the source BitSet, which is discarded after bitCarryingBytes and numPaddingBits have been calculated

Throws

if source does not fulfill the ASN.1 BIT STRING requirements


constructor(source: ByteArray)(source)

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

Throws

if source does not fulfill the ASN.1 BIT STRING requirements