Package Exports
- asn1-ts
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (asn1-ts) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ASN.1 TypeScript Library
- Author: Jonathan M. Wilbur <jonathan@wilbur.space>
- Copyright Year: 2018
- License: MIT License
- Version: See
versionfile or git tags.
This library was based off of my D ASN.1 Library.
What is ASN.1?
ASN.1 stands for Abstract Syntax Notation. ASN.1 was first specified in X.680 - Abstract Syntax Notation One (ASN.1), by the International Telecommunications Union. ASN.1 messages can be encoded in one of several encoding/decoding standards. It provides a system of types that are extensible, and can presumably describe every protocol. You can think of it as a protocol for describing other protocols as well as a family of standards for encoding and decoding said protocols. It is similar to Google's Protocol Buffers, or Sun Microsystems' External Data Representation (XDR).
For more information on what ASN.1 is, see documentation/asn1.md.
Why ASN.1?
ASN.1 is used in, or required by, multiple technologies, including:
- X.509 Certificates, used in SSL/TLS
- Lightweight Directory Access Protocol (LDAP)
- X.400, the messaging system used by the U.S. Military
- X.500
- The magnetic stripes on credit cards and debit cards
- Microsoft's Remote Desktop Protocol (RDP)
- Simple Network Management Protocol (SNMP)
- Common Management Information Protocol (CMIP)
- Signalling System Number 7 (SS7), used to make most phone calls on the Public Switched Telephone Network (PSTN).
- Kerberos 5
- H.323 Video conferencing
- Biometrics Protocols:
- Computer Supported Telecommunications Applications (CSTA)
- Dedicated Short Range Communications (SAE J2735)
- Cellular telephony:
If you look in the
asn1 directory of WireShark's source code,
you'll see all of the protocols that use ASN.1.
This list can also be found in documentation/asn1.d.
Building
This library requires NodeJS v10.3.0 or higher, mostly to support Regular Expression Named Capture Groups. See this page for NodeJS ES2018 support.
You can build this library by running:
npm run-script buildmake -f build/Makefile
The outputs will all be in dist.
dist/web/asn1.jsis the entire ASN.1 library for the web browser, which is not minified.dist/webcontains other smaller libraries that only contain specific codecs, and which are minified.dist/node/asn1.jsis the entire NodeJS library.dist/typescontains all of the type declarations.
Library Usage
For each codec in the library, usage entails instantiating the class,
then using that class' properties to get and set the encoded value.
For all classes, the empty constructor creates an END OF CONTENT
element. The remaining constructors will be codec-specific.
Here is a TypeScript example of encoding with Basic Encoding Rules, using the
BERElement class.
let el : BERElement = new BERElement();
el.typeTag = ASN1UniversalType.integer;
el.integer = 1433; // Now the data is encoded.
console.log(el.integer); // Logs '1433'... and here is how you would decode that same element:
let encodedData : Uint8Array = el.toBytes();
let el2 : BERElement = new BERElement();
el2.fromBytes(encodedData);
console.log(el2.integer); // Logs '1433'See Also
- X.680 - Abstract Syntax Notation One (ASN.1), published by the International Telecommunications Union.
- X.690 - ASN.1 encoding rules, published by the International Telecommunications Union.
- ASN.1: Communication Between Heterogeneous Systems by Olivier Dubuisson
Contact Me
If you would like to suggest fixes or improvements on this library, please just leave an issue on this GitHub page. If you would like to contact me for other reasons, please email me at jonathan@wilbur.space (My GPG Key) (My TLS Certificate). 🐗