ASN1Object

public protocol ASN1Object

ASN.1 Object implementation according to the X.690-0207 specification

For more information see the X.690-0207.pdf specification.

ASN1Object protocol that represents any ASN.1 Tag or Sequence

  • tag

    Type of the object

    Declaration

    Swift

    var tag: ASN1DecodedTag { get }
  • The raw bytes of the object

    Declaration

    Swift

    var data: ASN1Data { get }
  • The parsed length byte(s)

    Note

    this length should not include its own tag and length bytes needed for encoding

    Declaration

    Swift

    var length: Int { get }
  • Whether the object is a constructed object.

    Declaration

    Swift

    var constructed: Bool { get }
  • tagNo Extension method

    Tag No in case of Context-Specific or Application class

    Declaration

    Swift

    public var tagNo: UInt? { get }
  • wrap(with:constructed:) Extension method

    Wrap an ASN1Object to build a ASN1 tree/document

    Declaration

    Swift

    public func wrap(with tag: ASN1DecodedTag, constructed: Bool = true) -> ASN1Object

    Parameters

    tag

    The ASN1 Tag to wrap around the receiver

    constructed

    Whether the wrapping tag should be constructed or implicit. (default: true)

    Return Value

    The wrapped Tag

  • serialize() Extension method

    DER encode the ASN1Object model to an ASN.1 serialized data blob

    Throws

    ASN1EncodingError

    Declaration

    Swift

    public func serialize() throws -> Data

    Return Value

    the serialized ASN.1 data

  • subscript(_:) Extension method

    Search for tag

    Declaration

    Swift

    public subscript(tag: ASN1DecodedTag) -> ASN1Object? { get }

    Parameters

    tag

    the tag to look for

    Return Value

    first object that matches tag or nil when not found