asn1lib 0.5.2

  • Readme
  • Changelog
  • Installing
  • 74

An ASN.1 Parser for Dart.

Encodes & decodes ASN1 using BER encoding.

There is just enough implementation here to get an LDAP client library working.


 var s = new ASN1Sequence();
s.add( new ASN1Integer(23));
s.add( new ASN1OctetString('This is a test'));
s.add( new ASN1Boolean(true));

// GET the BER Stream
var bytes = s.encodedBytes;

// decode
var p = new ASN1Parser(bytes);
var s2 = p.nextObject();
// s2 is a sequence...

Changes #

Remove obsolete crypto dependency in tests.

Added PrintableString and UTC Time elements

Changes to support RSA Private key : PEM file

Add import "package:bignum/bignum.dart"; in asn1lib.dart

Add ASN1ObjectIdentifier class

Add OBJECT_IDENTIFIER in asn1constants.dart

Modify ASN1Parser._doPrimitive to take OBJECT_IDENTIFIER and NULL_TYPE into account

Modify ASN1Null add contructor ASN1Null.fromBytes

Modify ASN1Integer to support BigInteger

Modify asn1element_test.dart to test BigInteger case, and rsa private key test

Add test/resource folder to store rsa key for testing

Changes to support RSA public key : PEM file

Add ASN1BitString class : not sure how to handle bitstring when unused bits is not zero

Add BIT_STRING_TYPE in asn1constants.dart

Modify ASN1Parser._doPrimitive to take BIT_STRING_TYPE into account

Modify asn1element_test.dart to test rsa public key

Changelog #

0.5.1 #

Add AS1Integer.fromInt factory method

0.5.0 #

  • Convert use of BigInteger to dart SDK BigInt

0.4.3 #

  • Updates for dart 2

0.4.2 #

  • Added contentBytes() getter
  • Removed Int64List dependency and use bignum's BigInteger instead

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  asn1lib: ^0.5.2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:asn1lib/asn1lib.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Nov 24, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:asn1lib/asn1lib.dart.

Health suggestions

Fix lib/asn1parser.dart. (-9.54 points)

Analysis of lib/asn1parser.dart reported 20 hints, including:

line 18 col 3: Prefer using /// for doc comments.

line 33 col 20: Unnecessary new keyword.

line 36 col 16: Don't explicitly initialize variables to null.

line 39 col 7: DO use curly braces for all flow control structures.

line 44 col 9: DO use curly braces for all flow control structures.

Fix lib/asn1object.dart. (-7.24 points)

Analysis of lib/asn1object.dart reported 15 hints, including:

line 4 col 1: Prefer using /// for doc comments.

line 18 col 3: Prefer using /// for doc comments.

line 38 col 7: DO use curly braces for all flow control structures.

line 47 col 22: Use = to separate a named parameter from its default value.

line 49 col 3: Prefer using /// for doc comments.

Fix lib/asn1integer.dart. (-6.78 points)

Analysis of lib/asn1integer.dart reported 14 hints, including:

line 2 col 1: Prefer using /// for doc comments.

line 13 col 35: Use = to separate a named parameter from its default value.

line 37 col 53: Unnecessary new keyword.

line 43 col 24: Unnecessary new keyword.

line 44 col 28: Unnecessary new keyword.

Fix additional 15 files with analysis or formatting issues. (-27.13 points)

Additional issues in the following files:

  • lib/asn1length.dart (10 hints)
  • lib/asn1octetstring.dart (9 hints)
  • lib/asn1set.dart (8 hints)
  • lib/asn1sequence.dart (7 hints)
  • lib/asn1bitstring.dart (4 hints)
  • lib/asn1utctime.dart (4 hints)
  • lib/asn1util.dart (4 hints)
  • lib/asn1boolean.dart (3 hints)
  • lib/asn1enumerated.dart (3 hints)
  • lib/asn1null.dart (1 hint)
  • lib/asn1objectidentifier.dart (1 hint)
  • lib/asn1printablestring.dart (1 hint)
  • lib/asn1constants.dart (Run dartfmt to format lib/asn1constants.dart.)
  • lib/asn1exception.dart (Run dartfmt to format lib/asn1exception.dart.)
  • lib/asn1lib.dart (Run dartfmt to format lib/asn1lib.dart.)

Maintenance suggestions

Package is getting outdated. (-32.33 points)

The package was last published 69 weeks ago.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and asn1lib.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.69.0 <3.0.0
Dev dependencies
convert ^2.0.1
test any