Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

asn1-tree

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asn1-tree - npm Package Compare versions

Comparing version 0.0.7 to 0.1.0

23

index.js

@@ -9,2 +9,17 @@ const FORM_PRIMITIVE = 0;

const cls = tag >> 6;
const form = tag >> 5 & 1;
let tagCode = tag & 0b11111;
if (tagCode === 0b11111) {
tagCode = 0;
let byte;
do {
byte = buffer.readUInt8(bytesRead);
bytesRead += 1;
tagCode = (tagCode << 8) | (byte & 0x7f);
} while (byte & 0x80);
}
let elementLength = buffer.readUInt8(bytesRead);

@@ -18,10 +33,2 @@ bytesRead += 1;

const cls = tag >> 6;
const form = tag >> 5 & 1;
const tagCode = tag & 0b11111;
if (tagCode === 0b11111) {
throw new Error('Extended tags are not supported');
}
if (elementLength < 128) {

@@ -28,0 +35,0 @@ // Short form length, do nothing

{
"name": "asn1-tree",
"version": "0.0.7",
"version": "0.1.0",
"description": "ASN.1 parser and decoder",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -56,3 +56,3 @@ [![Travis CI](https://img.shields.io/travis/atesgoral/node-asn1-tree.svg)](https://travis-ci.org/atesgoral/node-asn1-tree)

```
const buffer = asn1tree.encode(element);
const buffer = asn1Tree.encode(element);
```

@@ -41,15 +41,18 @@ import test from 'ava';

test('decode: tagCode 0b11111', (t) => {
t.throws(() => {
asn1Tree.decode(b(tag(CLS_UNIVERSAL, FORM_PRIMITIVE, 0b11111), 0));
}, 'Extended tags are not supported');
test('decode: tagCode 50 (extended tag / aka high tag)', (t) => {
t.deepEqual(
asn1Tree.decode(b(tag(CLS_CONTEXT_SPECIFIC, FORM_PRIMITIVE, 31), 50, 3, f(3))),
{
cls: CLS_CONTEXT_SPECIFIC,
form: FORM_PRIMITIVE,
tagCode: 50,
value: f(3)
}
);
});
test('decode: primitive: element with length 0', (t) => {
// @todo offset is out of bounds exception with comparison of empty buffers
// t.deepEqual(
// );
t.is(
JSON.stringify(asn1Tree.decode(b(tag(CLS_UNIVERSAL, FORM_PRIMITIVE, TAG_NULL), 0))),
JSON.stringify({
t.deepEqual(
asn1Tree.decode(b(tag(CLS_UNIVERSAL, FORM_PRIMITIVE, TAG_NULL), 0)),
{
cls: CLS_UNIVERSAL,

@@ -59,3 +62,3 @@ form: FORM_PRIMITIVE,

value: f(0)
})
}
);

@@ -62,0 +65,0 @@ });

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