Skip to content
pubscout

asn1lib

1.6.8, released 3 weeks ago by an unverified publisher

Encodes and decodes ASN.1 objects using BER byte encoding in Dart.

WASM-readyRock solid
$ flutter pub add asn1lib
Source repository

What it does

Provides classes to construct, serialize, and parse ASN.1 data structures using Basic Encoding Rules (BER). It supports primitive ASN.1 types like sequences, integers, octet strings, and booleans, with limited handling for context-specific and application tags. It includes security safeguards against common denial-of-service vectors in untrusted input.

AI-written summary of version 1.6.8, based on the package's README and metadata. Report an inaccuracy

Use it when

  • Working with cryptographic structures, certificates, or keys that require BER/DER ASN.1 encoding or decoding
  • Implementing network protocols like LDAP or SNMP that serialize messages with ASN.1 BER

Skip it when

  • Dealing with non-BER formats or complex schema-driven ASN.1 specifications requiring full compiler support
  • Only needing standard data formats like JSON, XML, or YAML

Strengths

  • Zero external dependencies, running on pure Dart across all platforms
  • Recent updates address security issues like CPU exhaustion, stack overflows, and integer overflows on untrusted inputs
  • Provides a relaxed parsing mode for gracefully handling unsupported or nested structures

Weaknesses

  • Minimal support for ASN.1 Application, Context-specific, and Private classes requiring manual casting

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0
import 'package:asn1lib/asn1lib.dart';

void main() {
  var sequence = ASN1Sequence();
  sequence.add(ASN1Integer(42));
  sequence.add(ASN1OctetString('test'));
  var bytes = sequence.encodedBytes;

  var parser = ASN1Parser(bytes);
  var decodedSequence = parser.nextObject() as ASN1Sequence;
}

Alternatives

Packages that do the same job and could replace asn1lib.

Works with

Packages commonly used together with asn1lib: ones it builds on, ones built on it, and its own family.