Interface ASN1Encoder

All Superinterfaces:
Flushable
All Known Implementing Classes:
DEREncoder

public interface ASN1Encoder extends Flushable
An interface for encoding ASN.1 values.
Author:
Farah Juma
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    encodeBitString(byte[] str)
    Encode an ASN.1 bit string value.
    void
    encodeBitString(byte[] str, int numUnusedBits)
    Encode an ASN.1 bit string value.
    void
    Encode an ASN.1 bit string value.
    void
    Encode an ASN.1 bit string where the value represents the binary form of the given integer.
    void
    Encode an ASN.1 bit string value.
    void
    Encode an enum set as an ASN.1 bit string, with each ordinal value of the set representing a single bit.
    void
    Encode an ASN.1 BMPString string value.
    void
    encodeBoolean(boolean value)
    Encode an ASN.1 boolean value.
    void
    Encode an ASN.1 GeneralizedTime type.
    void
    encodeIA5String(byte[] str)
    Encode an ASN.1 IA5 string value.
    void
    Encode an ASN.1 IA5 string value.
    void
    encodeImplicit(int number)
    Indicate that the next encode operation should encode an ASN.1 value using the given implicit, context-specific tag.
    void
    encodeImplicit(int clazz, int number)
    Indicate that the next encode operation should encode an ASN.1 value using the given implicit tag.
    default void
    encodeInteger(int integer)
    Encode an ASN.1 integer value.
    void
    Encode an ASN.1 integer value.
    void
    Encode an ASN.1 null value.
    void
    encodeObjectIdentifier(String objectIdentifier)
    Encode an ASN.1 object identifier value.
    void
    encodeOctetString(byte[] str)
    Encode an ASN.1 octet string value.
    void
    Encode an ASN.1 octet string value.
    void
    Encode an ASN.1 printable string value.
    void
    Encode an ASN.1 printable string value.
    void
    Encode an ASN.1 UniversalString string value.
    void
    Encode an ASN.1 UTF8String string value.
    void
    Finish encoding an ASN.1 explicitly tagged element.
    void
    Finish encoding an ASN.1 sequence.
    void
    Finish encoding an ASN.1 set.
    void
    Finish encoding an ASN.1 "set of" element.
    void
    Flush the encoder, writing any saved ASN.1 encoded values to the target destination.
    byte[]
    Get the ASN.1 encoded bytes.
    void
    startExplicit(int number)
    Start encoding an ASN.1 explicitly tagged element.
    void
    startExplicit(int clazz, int number)
    Start encoding an ASN.1 explicitly tagged element.
    void
    Start encoding an ASN.1 sequence.
    void
    Start encoding an ASN.1 set.
    void
    Start encoding an ASN.1 "set of" element.
    void
    writeEncoded(byte[] encoded)
    Write an already encoded ASN.1 value to the target destination.
  • Method Details

    • startSequence

      void startSequence()
      Start encoding an ASN.1 sequence. All subsequent encode operations will be part of this sequence until endSequence() is called.
    • endSequence

      void endSequence() throws IllegalStateException
      Finish encoding an ASN.1 sequence.
      Throws:
      IllegalStateException - if there is no sequence to end
    • startSet

      void startSet()
      Start encoding an ASN.1 set. All subsequent encode operations will be part of this set until endSet() is called.
    • endSet

      void endSet() throws IllegalStateException
      Finish encoding an ASN.1 set.
      Throws:
      IllegalStateException - if there is no set to end
    • startSetOf

      void startSetOf()
      Start encoding an ASN.1 "set of" element. All subsequent encode operations will be part of this set until endSetOf() is called.
    • endSetOf

      void endSetOf() throws IllegalStateException
      Finish encoding an ASN.1 "set of" element.
      Throws:
      IllegalStateException - if there is no set to end
    • startExplicit

      void startExplicit(int number)
      Start encoding an ASN.1 explicitly tagged element. All subsequent encode operations will be part of this explicitly tagged element until endExplicit() is called.
      Parameters:
      number - the tag number for the explicit, context-specific tag
    • startExplicit

      void startExplicit(int clazz, int number)
      Start encoding an ASN.1 explicitly tagged element. All subsequent encode operations will be part of this explicitly tagged element until endExplicit() is called.
      Parameters:
      clazz - the class for the explicit tag
      number - the tag number for the explicit tag
    • endExplicit

      void endExplicit() throws IllegalStateException
      Finish encoding an ASN.1 explicitly tagged element.
      Throws:
      IllegalStateException - if there is no explicitly tagged element to end
    • encodeOctetString

      void encodeOctetString(String str)
      Encode an ASN.1 octet string value.
      Parameters:
      str - the octet string to encode
    • encodeOctetString

      void encodeOctetString(byte[] str)
      Encode an ASN.1 octet string value.
      Parameters:
      str - the byte array containing the octet string to encode
    • encodeIA5String

      void encodeIA5String(String str)
      Encode an ASN.1 IA5 string value.
      Parameters:
      str - the IA5 string to encode
    • encodeIA5String

      void encodeIA5String(byte[] str)
      Encode an ASN.1 IA5 string value.
      Parameters:
      str - the byte array containing IA5 string to encode
    • encodePrintableString

      void encodePrintableString(byte[] str)
      Encode an ASN.1 printable string value.
      Parameters:
      str - the byte array containing the printable string to encode
    • encodePrintableString

      void encodePrintableString(String str)
      Encode an ASN.1 printable string value.
      Parameters:
      str - the printable string to encode
    • encodeUTF8String

      void encodeUTF8String(String str)
      Encode an ASN.1 UTF8String string value.
      Parameters:
      str - the string to encode
    • encodeBMPString

      void encodeBMPString(String str)
      Encode an ASN.1 BMPString string value.
      Parameters:
      str - the string to encode
    • encodeUniversalString

      void encodeUniversalString(String str)
      Encode an ASN.1 UniversalString string value.
      Parameters:
      str - the string to encode
    • encodeBitString

      void encodeBitString(byte[] str)
      Encode an ASN.1 bit string value.
      Parameters:
      str - the byte array containing the bit string to encode (all bits in the bit string will be used)
    • encodeBitString

      void encodeBitString(byte[] str, int numUnusedBits)
      Encode an ASN.1 bit string value.
      Parameters:
      str - the byte array containing the bit string to encode
      numUnusedBits - the number of unused bits in the byte array
    • encodeBitString

      void encodeBitString(EnumSet<?> enumSet)
      Encode an enum set as an ASN.1 bit string, with each ordinal value of the set representing a single bit.
      Parameters:
      enumSet - the enum set (must not be null)
    • encodeBitString

      void encodeBitString(BitSet bitSet)
      Encode an ASN.1 bit string value.
      Parameters:
      bitSet - the bit set (must not be null)
    • encodeBitString

      void encodeBitString(String binaryStr)
      Encode an ASN.1 bit string value.
      Parameters:
      binaryStr - the bit string to encode, as a binary string
    • encodeBitString

      void encodeBitString(BigInteger integer)
      Encode an ASN.1 bit string where the value represents the binary form of the given integer.
      Parameters:
      integer - the integer to encode as a binary string
    • encodeGeneralizedTime

      void encodeGeneralizedTime(ZonedDateTime time)
      Encode an ASN.1 GeneralizedTime type.
      Parameters:
      time - the time to encode (must not be null)
    • encodeObjectIdentifier

      void encodeObjectIdentifier(String objectIdentifier) throws ASN1Exception
      Encode an ASN.1 object identifier value.
      Parameters:
      objectIdentifier - the object identifier to encode
      Throws:
      ASN1Exception - if the given object identifier is invalid
    • encodeNull

      void encodeNull()
      Encode an ASN.1 null value.
    • encodeImplicit

      void encodeImplicit(int number)
      Indicate that the next encode operation should encode an ASN.1 value using the given implicit, context-specific tag.
      Parameters:
      number - the tag number for the implicit, context-specific tag
    • encodeImplicit

      void encodeImplicit(int clazz, int number)
      Indicate that the next encode operation should encode an ASN.1 value using the given implicit tag.
      Parameters:
      clazz - the class for the implicit tag
      number - the tag number for the implicit tag
    • encodeBoolean

      void encodeBoolean(boolean value)
      Encode an ASN.1 boolean value.
      Parameters:
      value - the boolean to encode
    • encodeInteger

      default void encodeInteger(int integer)
      Encode an ASN.1 integer value.
      Parameters:
      integer - the integer to encode
    • encodeInteger

      void encodeInteger(BigInteger integer)
      Encode an ASN.1 integer value.
      Parameters:
      integer - the integer to encode
    • writeEncoded

      void writeEncoded(byte[] encoded)
      Write an already encoded ASN.1 value to the target destination.
      Parameters:
      encoded - the encoded ASN.1 value to write
    • flush

      void flush()
      Flush the encoder, writing any saved ASN.1 encoded values to the target destination. Any unfinished sequences or sets will be ended.
      Specified by:
      flush in interface Flushable
    • getEncoded

      byte[] getEncoded()
      Get the ASN.1 encoded bytes.
      Returns:
      the ASN.1 encoded bytes