asn1lib
1.6.8, released 3 weeks ago by an unverified publisher
Encodes and decodes ASN.1 objects using BER byte encoding in Dart.
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.
- csv_plus
Fast, zero-dependency CSV parser, encoder, streamer, and query engine for Dart.
82Compare - standard_message_codec
Binary codec for efficient encoding/decoding of Dart objects without a schema.
80Compare - qs_dart
A query string encoding and decoding library for Dart ported from JavaScript's qs.
77Compare - emvqrcode
Encode and decode EMVCO QR codes in Dart
50Compare
Works with
Packages commonly used together with asn1lib: ones it builds on, ones built on it, and its own family.
- encryptBuilt on asn1libHigh‑level Dart APIs for encryption, decryption, signing and secure random generation.
- livekit_clientBuilt on asn1libFlutter Client SDK for LiveKit to build real-time video, audio, and data features.
- dartssh2Built on asn1libSSH and SFTP client written in pure Dart
- rsa_pkcsBuilt on asn1libPrivacy-Enhanced Mail (PEM) parser for RSA, PKCS#1, PKCS#8, and X.509 formats
- encrypter_plusBuilt on asn1libHigh-level APIs over PointyCastle for two-way cryptography, supporting AES, RSA, Salsa20, and Fernet.
- joseBuilt on asn1libJavascript Object Signing and Encryption library supporting JWE, JWS, JWK and JWT.
- x509Built on asn1libDart library for parsing and working with X.509 certificates.
- cryptonBuilt on asn1libA simple Dart library for asymmetric encryption and digital signatures.