This library can be used for ASN.1 (Abstract Syntax Notation One) encoding/decoding
using distinguished encoding rules (DER) according to the ITU-T X.690
For more info, please find the complete X.690-0207.pdf
specification.
Getting Started
ASN1Kit requires Swift 5.1.
Setup for integration
Carthage: Put this in your Cartfile:
github "gematik/ASN1Kit" ~> 1.0
Setup for development
You will need Bundler, XcodeGen
and fastlane to conveniently use the established development environment.
Checkout (and build) dependencies and generate the xcodeproject
$ make setup
Build the project
$ make cibuild
Code Samples
Use ASN1Decoder.decode(asn1:) to decode serialized data
and String(from:) to get a hex representation of it:
Construct an ASN1Object of your choice and serialize it:
let data = Data([0x0, 0x1, 0x2, 0x4]) as ASN1EncodableType
let data2 = Data([0x4, 0x3, 0x2, 0x1]) as ASN1EncodableType
let array = [data, data2]
let expected = Data([0x30, 0xc, 0x4, 0x4, 0x0, 0x1, 0x2, 0x4, 0x4, 0x4, 0x4, 0x3, 0x2, 0x1])
expect(try array.asn1encode().serialize()) == expected
ASN.1-encode Swift primitives and extract the encoded value(s):
ASN1Kit
ASN.1 Decoder for Swift
API Documentation
Generated API docs are available at https://gematik.github.io/ASN1Kit.
License
Licensed under the Apache License, Version 2.0.
Overview
This library can be used for ASN.1 (Abstract Syntax Notation One) encoding/decoding using distinguished encoding rules (DER) according to the ITU-T X.690
For more info, please find the complete X.690-0207.pdf specification.
Getting Started
ASN1Kit requires Swift 5.1.
Setup for integration
Carthage: Put this in your
Cartfile
:Setup for development
You will need Bundler, XcodeGen and fastlane to conveniently use the established development environment.
Checkout (and build) dependencies and generate the xcodeproject
Build the project
Code Samples
Use
ASN1Decoder.decode(asn1:)
to decode serialized data andString(from:)
to get a hex representation of it:Construct an
ASN1Object
of your choice and serialize it:ASN.1-encode Swift primitives and extract the encoded value(s):
Extract the tag of the first element of a constructed
ASN1Object
: