{"id":13871903,"url":"https://github.com/DominikHorn/ASN1Parser","last_synced_at":"2025-07-16T01:32:05.948Z","repository":{"id":63908415,"uuid":"426685734","full_name":"DominikHorn/ASN1Parser","owner":"DominikHorn","description":"Minimalistic Swift parser for ASN.1 data. Currently supports DER and therefore also BER binary format","archived":false,"fork":false,"pushed_at":"2023-10-04T12:46:27.000Z","size":362,"stargazers_count":8,"open_issues_count":4,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-17T17:37:28.220Z","etag":null,"topics":["asn-1","asn1","asn1-decoder","asn1-der","ssh-key","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DominikHorn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-10T15:58:47.000Z","updated_at":"2023-08-05T21:26:14.000Z","dependencies_parsed_at":"2022-11-28T20:16:16.337Z","dependency_job_id":null,"html_url":"https://github.com/DominikHorn/ASN1Parser","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DominikHorn%2FASN1Parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DominikHorn%2FASN1Parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DominikHorn%2FASN1Parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DominikHorn%2FASN1Parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DominikHorn","download_url":"https://codeload.github.com/DominikHorn/ASN1Parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226089997,"owners_count":17572112,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asn-1","asn1","asn1-decoder","asn1-der","ssh-key","swift"],"created_at":"2024-08-05T23:00:29.943Z","updated_at":"2024-11-23T19:31:23.365Z","avatar_url":"https://github.com/DominikHorn.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# ASN1Parser\n![tests](https://github.com/DominikHorn/ASN1Parser/actions/workflows/test.yml/badge.svg)\n![coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/DominikHorn/abb8b96dc5a9b8354fb3d70216aedc7d/raw/coverage-badge.json)\n\nSafety first ASN.1 parsing in Swift.\n\n## Documentation\nYou may import `ASN1Parser.docc` into Xcode, open the prebuilt static site found in \n`docs/documentation/asn1parser/index.html`, preview locally using `preview-doc.sh` \nor build the static website on your own using `gen-doc.sh`. \n\nNote that the static site is sadly not hostable via github pages due to its case insensitive\nlinks which github pages routes as 404.\n\n### Quick Start\nGiven the a DER encoded ASN.1 representation of a public key, for example as found in `.pem` files:\n\n```swift\n// Public key data blob from pem file\nlet pemBlob = \"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEQPtmXeh4gkzq30Zq3LXdgcl39fgCOBRZExhNWgZTSv5NTvbRoZNx28Ln/+Wtkfc42nWdunurluAeMPr0BrnLtA==\"\nguard let derData = Data(base64Encoded: pemBlob) else { return }\n\n// Parse DER into ASN.1 value, which is a tree like structure\nlet tree = try DERParser.parse(derData)\n\n// Access values within the tree\nlet q = try tree.asSequence[1].asBitString\n```\n\n### Feature Overview\n- **runtime safe** ASN.1 parsing - error handling enforced by the swift compiler\n- **minimalistic** - only contains the features you need\n- **quick and easy** to use - immediately start parsing DER or BER encoded ASN.1 without any boilerplate\n- **implicit ASN.1 format specification** - no need worry about explicitely specifying the expected data format.\n  Simply access values in the ASN.1 tree and dynamically receive errors if they are not available.\n\nPlease note that the choice of implicit format specification is a deliberate\none. I believe ASN.1 is not particularily suited to be 1:1 mapped to swift\ntypes. Therefore you will most likely have to introduce an abstraction layer,\ni.e., an explicit ASN.1 format specification in addition to the swift type\ndefintion you'd ideally want to use throughout your remaining code. This\nabstraction layer is however unnecessary IMHO, as it only consists of\nboilerplate definitions and code for converting between the ASN.1 format and\nyour swift type. In addition to the often wasteful and messy nature of\nboilerplate code, having two different abstractions for the same underlying\nconcept can introduce inconsistencies and thus bugs.\n\nWith implicit ASN.1 format specification, you can access ASN.1 data safely and\nquicker while not having having to worry about introducing any accidental\ninconsistencies in your codebase, because an additional abstraction layer won't\nexist. Simply define your desired type in swift and dynamically load its\nvalues from the decoded ASN.1 representation.\n\n## Contributing\nPull requests are of course are highly appreciated :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDominikHorn%2FASN1Parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDominikHorn%2FASN1Parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDominikHorn%2FASN1Parser/lists"}