Socket
Socket
Sign inDemoInstall

@lapo/asn1js

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lapo/asn1js - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

28

asn1.js
// ASN.1 JavaScript decoder
// Copyright (c) 2008-2018 Lapo Luchini <lapo@lapo.it>
// Copyright (c) 2008-2019 Lapo Luchini <lapo@lapo.it>

@@ -101,11 +101,29 @@ // Permission to use, copy, modify, and/or distribute this software for any

Stream.prototype.parseStringUTF = function (start, end) {
function ex(c) { // must be 10xxxxxx
if ((c < 0x80) || (c >= 0xC0))
throw new Error('Invalid UTF-8 continuation byte: ' + c);
return (c & 0x3F);
}
function surrogate(cp) {
if (cp < 0x10000)
throw new Error('UTF-8 overlong encoding, codepoint encoded in 4 bytes: ' + cp);
// we could use String.fromCodePoint(cp) but let's be nice to older browsers and use surrogate pairs
cp -= 0x10000;
return String.fromCharCode((cp >> 10) + 0xD800, (cp & 0x3FF) + 0xDC00);
}
var s = "";
for (var i = start; i < end; ) {
var c = this.get(i++);
if (c < 128)
if (c < 0x80) // 0xxxxxxx (7 bit)
s += String.fromCharCode(c);
else if ((c > 191) && (c < 224))
s += String.fromCharCode(((c & 0x1F) << 6) | (this.get(i++) & 0x3F));
else if (c < 0xC0)
throw new Error('Invalid UTF-8 starting byte: ' + c);
else if (c < 0xE0) // 110xxxxx 10xxxxxx (11 bit)
s += String.fromCharCode(((c & 0x1F) << 6) | ex(this.get(i++)));
else if (c < 0xF0) // 1110xxxx 10xxxxxx 10xxxxxx (16 bit)
s += String.fromCharCode(((c & 0x0F) << 12) | (ex(this.get(i++)) << 6) | ex(this.get(i++)));
else if (c < 0xF8) // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx (21 bit)
s += surrogate(((c & 0x07) << 18) | (ex(this.get(i++)) << 12) | (ex(this.get(i++)) << 6) | ex(this.get(i++)));
else
s += String.fromCharCode(((c & 0x0F) << 12) | ((this.get(i++) & 0x3F) << 6) | (this.get(i++) & 0x3F));
throw new Error('Invalid UTF-8 starting byte (since 2003 it is restricted to 4 bytes): ' + c);
}

@@ -112,0 +130,0 @@ return s;

23

base64.js
// Base64 JavaScript decoder
// Copyright (c) 2008-2018 Lapo Luchini <lapo@lapo.it>
// Copyright (c) 2008-2019 Lapo Luchini <lapo@lapo.it>

@@ -20,3 +20,4 @@ // Permission to use, copy, modify, and/or distribute this software for any

var Base64 = {},
decoder;
decoder, // populated on first usage
haveU8 = ('Uint8Array' in (typeof window == 'object' ? window : global));

@@ -37,4 +38,4 @@ Base64.decode = function (a) {

}
var out = [];
var bits = 0, char_count = 0;
var out = haveU8 ? new Uint8Array(a.length * 3 >> 2) : [];
var bits = 0, char_count = 0, len = 0;
for (i = 0; i < a.length; ++i) {

@@ -51,5 +52,5 @@ var c = a.charAt(i);

if (++char_count >= 4) {
out[out.length] = (bits >> 16);
out[out.length] = (bits >> 8) & 0xFF;
out[out.length] = bits & 0xFF;
out[len++] = (bits >> 16);
out[len++] = (bits >> 8) & 0xFF;
out[len++] = bits & 0xFF;
bits = 0;

@@ -65,9 +66,11 @@ char_count = 0;

case 2:
out[out.length] = (bits >> 10);
out[len++] = (bits >> 10);
break;
case 3:
out[out.length] = (bits >> 16);
out[out.length] = (bits >> 8) & 0xFF;
out[len++] = (bits >> 16);
out[len++] = (bits >> 8) & 0xFF;
break;
}
if (haveU8 && out.length > len) // in case it was originally longer because of ignored characters
out = out.subarray(0, len);
return out;

@@ -74,0 +77,0 @@ };

// Hex JavaScript decoder
// Copyright (c) 2008-2018 Lapo Luchini <lapo@lapo.it>
// Copyright (c) 2008-2019 Lapo Luchini <lapo@lapo.it>

@@ -20,3 +20,4 @@ // Permission to use, copy, modify, and/or distribute this software for any

var Hex = {},
decoder;
decoder, // populated on first usage
haveU8 = ('Uint8Array' in (typeof window == 'object' ? window : global));

@@ -37,5 +38,6 @@ Hex.decode = function(a) {

}
var out = [],
var out = haveU8 ? new Uint8Array(a.length >> 1) : [],
bits = 0,
char_count = 0;
char_count = 0,
len = 0;
for (i = 0; i < a.length; ++i) {

@@ -52,3 +54,3 @@ var c = a.charAt(i);

if (++char_count >= 2) {
out[out.length] = bits;
out[len++] = bits;
bits = 0;

@@ -62,2 +64,4 @@ char_count = 0;

throw "Hex encoding incomplete: 4 bits missing";
if (haveU8 && out.length > len) // in case it was originally longer because of ignored characters
out = out.subarray(0, len);
return out;

@@ -64,0 +68,0 @@ };

// Big integer base-10 printing library
// Copyright (c) 2014-2018 Lapo Luchini <lapo@lapo.it>
// Copyright (c) 2008-2019 Lapo Luchini <lapo@lapo.it>

@@ -4,0 +4,0 @@ // Permission to use, copy, modify, and/or distribute this software for any

{
"name": "@lapo/asn1js",
"version": "1.0.2",
"version": "1.1.0",
"description": "Generic ASN.1 parser/decoder that can decode any valid ASN.1 DER or BER structures.",

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

@@ -11,3 +11,3 @@ asn1js

ASN.1 JavaScript decoder Copyright (c) 2008-2018 Lapo Luchini <lapo@lapo.it>
ASN.1 JavaScript decoder Copyright (c) 2008-2019 Lapo Luchini <lapo@lapo.it>

@@ -14,0 +14,0 @@ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

Sorry, the diff of this file is not supported yet

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