Socket
Socket
Sign inDemoInstall

asn1-tree

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asn1-tree

ASN.1 parser and decoder


Version published
Maintainers
2
Created
Source

Travis CI Coverage Status NPM Package

asn1-tree

Yet another ASN.1 encoder/decoder in JavaScript. Parses a binary ASN.1 buffer into a JavaScript object that describes the ASN.1 structure. Nested elements form a tree, and hence the name "asn1-tree", and a primitive value would just result in an object.

This is just an encoder/decoder. The interpretation of the structure (i.e. matching against a schema) is beyond the scope of this library. See asn1-mapper, an ASN.1 schema mapper, for that purpose.

Installation

npm install --save asn1-tree

Usage

const asn1Tree = require('asn1-tree');

const buffer = Buffer.from('3080800803221200644241f40201028301010000', 'hex');

const element = asn1Tree.decode(buffer);

The value of element will be:

{
  cls: 0,
  form: 1,
  tagCode: 16,
  elements: [{
    cls: 2,
    form: 0,
    tagCode: 0,
    value: Buffer.from([ 3, 34, 18, 0, 100, 66, 65, 244 ])
  }, {
    cls: 0,
    form: 0,
    tagCode: 2,
    value: Buffer.from([ 2 ])
  }, {
    cls: 2,
    form: 0,
    tagCode: 3,
    value: Buffer.from([ 1 ])
  }]
}

Going back:

const buffer = asn1Tree.encode(element);

Keywords

FAQs

Package last updated on 16 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc