Comparing version 0.0.1 to 0.1.0
@@ -6,2 +6,5 @@ 'use strict'; | ||
function u8_to_hex(u8, sep) { | ||
if (undefined === u8.buffer) { | ||
u8 = new Uint8Array(u8);} | ||
return Array | ||
@@ -51,3 +54,3 @@ .from(u8, v => v.toString(16).padStart(2, '0')) | ||
node.hex = u8_to_hex(content, ' '); | ||
//node.hex = u8_to_hex @ content, ' ' | ||
@@ -64,4 +67,15 @@ yield node;} } | ||
, parse_parts() { | ||
return 0x20 & this.id | ||
, hex() {return u8_to_hex(this.content)} | ||
, dbg() {return `id: ${this.id} len: ${this.byteLength} hex: ${this.hex()}`} | ||
, [Symbol.iterator]() {return this.iter_parts()} | ||
, iter_parts(override) { | ||
if (0x20 & this.id || override) { | ||
return asn1_u8_decode_many(this.content)} | ||
else throw new Error('Not a contructed ASN1 node') } | ||
, first_part(override) { | ||
return asn1_u8_decode(this.content)} | ||
, parse_parts(override) { | ||
return 0x20 & this.id || override | ||
? Array.from(asn1_u8_decode_many(this.content)) | ||
@@ -77,2 +91,5 @@ : null} | ||
, *iter_walk(visitor) { | ||
if (true === visitor) { | ||
console.log(this.dbg()); } | ||
let parts = null; | ||
@@ -84,3 +101,3 @@ if (0x20 & this.id) { | ||
if (visitor) { | ||
if ('function' === typeof visitor) { | ||
return visitor(this, parts) } | ||
@@ -111,2 +128,2 @@ else { | ||
exports.with_asn1_identifiers = with_asn1_identifiers; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXNuMV9kZWNvZGUuanMiLCJzb3VyY2VzIjpbIi4uL2NvZGUvdThfdXRpbHMuanN5IiwiLi4vY29kZS9hc24xX2RlY29kZS5qc3kiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGZ1bmN0aW9uIGhleF90b191OChoZXgpIDo6XG4gIGhleCA9IGhleC5yZXBsYWNlKC9bXjAtOWEtZkEtRl0vZywgJycpXG4gIGNvbnN0IHU4ID0gbmV3IFVpbnQ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8,2 +8,4 @@ 'use strict'; | ||
for (const b of parts) { | ||
if (! b.byteLength) { | ||
console.log("WA?", b, parts); } | ||
len += b.byteLength;} | ||
@@ -21,4 +23,2 @@ | ||
function asn1_u8_encode(content_tree) { | ||
const is_lst = Array.isArray(content_tree); | ||
const all_parts = []; | ||
@@ -29,2 +29,7 @@ encode_next(content_tree); | ||
function encode_next(content_tree) { | ||
if (content_tree.byteLength) { | ||
all_parts.push(content_tree); | ||
return content_tree.byteLength} | ||
const is_lst = Array.isArray(content_tree); | ||
const ident = is_lst ? content_tree[0] : content_tree.id; | ||
@@ -38,2 +43,3 @@ const id = ident | 0; | ||
if (! Number.isInteger(ident) || 0 > ident || ident > 255) { | ||
console.log({ident, content_tree}); | ||
throw new Error('Invalid ASN1 identifier') } | ||
@@ -64,6 +70,6 @@ | ||
else { | ||
let octects = 0; | ||
while (0 !== byteLength) { | ||
hdr.push(byteLength & 0xff); | ||
byteLength >>>= 8; | ||
let octects = 0, oct_len = byteLength; | ||
while (0 !== oct_len) { | ||
hdr.push(oct_len & 0xff); | ||
oct_len >>>= 8; | ||
octects ++;} | ||
@@ -76,29 +82,4 @@ hdr[1] = 0x80 | octects;} | ||
const u8_zero = new Uint8Array([0]); | ||
function asn1_der_positive_int(v) { | ||
if (0x80 & v[0]) { | ||
return u8_concat([u8_zero, v]) } | ||
if (0 !== v[0]) {return v} | ||
for (let i=1; i < v.byteLength; i++) { | ||
const b = v[i]; | ||
if (0 !== b) { | ||
if (0x80 & b) {i--;} | ||
return v.subarray(i)} } } | ||
function compact_positive_int(v, len) { | ||
if (v.byteLength <= len) { | ||
return v} | ||
if (0 === v[0] && 0x80 & v[1]) { | ||
return v.subarray(1)} | ||
throw new Error('Unexpected integer construction') } | ||
exports.default = asn1_u8_encode; | ||
exports.asn1_u8_encode = asn1_u8_encode; | ||
exports.asn1_der_positive_int = asn1_der_positive_int; | ||
exports.compact_positive_int = compact_positive_int; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,e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GdCQUFpQjs7O0lBR3JCLElBQUU7TUFDQTs7TUFFQTtNQUNBLE9BQUs7UUFDSCxTQUFVO1FBQ1Y7UUFDQTtNQUNGOztJQUVGO0lBQ0E7SUFDQTs7Ozs7In0= |
@@ -6,2 +6,5 @@ 'use strict'; | ||
function u8_to_hex(u8, sep) { | ||
if (undefined === u8.buffer) { | ||
u8 = new Uint8Array(u8);} | ||
return Array | ||
@@ -14,2 +17,4 @@ .from(u8, v => v.toString(16).padStart(2, '0')) | ||
for (const b of parts) { | ||
if (! b.byteLength) { | ||
console.log("WA?", b, parts); } | ||
len += b.byteLength;} | ||
@@ -66,3 +71,3 @@ | ||
node.hex = u8_to_hex(content, ' '); | ||
//node.hex = u8_to_hex @ content, ' ' | ||
@@ -79,4 +84,15 @@ yield node;} } | ||
, parse_parts() { | ||
return 0x20 & this.id | ||
, hex() {return u8_to_hex(this.content)} | ||
, dbg() {return `id: ${this.id} len: ${this.byteLength} hex: ${this.hex()}`} | ||
, [Symbol.iterator]() {return this.iter_parts()} | ||
, iter_parts(override) { | ||
if (0x20 & this.id || override) { | ||
return asn1_u8_decode_many(this.content)} | ||
else throw new Error('Not a contructed ASN1 node') } | ||
, first_part(override) { | ||
return asn1_u8_decode(this.content)} | ||
, parse_parts(override) { | ||
return 0x20 & this.id || override | ||
? Array.from(asn1_u8_decode_many(this.content)) | ||
@@ -92,2 +108,5 @@ : null} | ||
, *iter_walk(visitor) { | ||
if (true === visitor) { | ||
console.log(this.dbg()); } | ||
let parts = null; | ||
@@ -99,3 +118,3 @@ if (0x20 & this.id) { | ||
if (visitor) { | ||
if ('function' === typeof visitor) { | ||
return visitor(this, parts) } | ||
@@ -106,4 +125,2 @@ else { | ||
function asn1_u8_encode(content_tree) { | ||
const is_lst = Array.isArray(content_tree); | ||
const all_parts = []; | ||
@@ -114,2 +131,7 @@ encode_next(content_tree); | ||
function encode_next(content_tree) { | ||
if (content_tree.byteLength) { | ||
all_parts.push(content_tree); | ||
return content_tree.byteLength} | ||
const is_lst = Array.isArray(content_tree); | ||
const ident = is_lst ? content_tree[0] : content_tree.id; | ||
@@ -123,2 +145,3 @@ const id = ident | 0; | ||
if (! Number.isInteger(ident) || 0 > ident || ident > 255) { | ||
console.log({ident, content_tree}); | ||
throw new Error('Invalid ASN1 identifier') } | ||
@@ -149,6 +172,6 @@ | ||
else { | ||
let octects = 0; | ||
while (0 !== byteLength) { | ||
hdr.push(byteLength & 0xff); | ||
byteLength >>>= 8; | ||
let octects = 0, oct_len = byteLength; | ||
while (0 !== oct_len) { | ||
hdr.push(oct_len & 0xff); | ||
oct_len >>>= 8; | ||
octects ++;} | ||
@@ -161,7 +184,5 @@ hdr[1] = 0x80 | octects;} | ||
const u8_zero = new Uint8Array([0]); | ||
function asn1_der_positive_int(v) { | ||
if (0x80 & v[0]) { | ||
return u8_concat([u8_zero, v]) } | ||
return u8_concat([new Uint8Array([0]), v]) } | ||
@@ -185,3 +206,3 @@ if (0 !== v[0]) {return v} | ||
function pack_ecdsa_asn1({r, s}) { | ||
function encode_ecdsa_asn1({r, s}) { | ||
return asn1_u8_encode([ | ||
@@ -192,3 +213,3 @@ 0x30, // sequence | ||
function unpack_ecdsa_asn1(ecdsa_asn1) { | ||
function decode_ecdsa_asn1(ecdsa_asn1) { | ||
const node = asn1_u8_decode(ecdsa_asn1); | ||
@@ -210,3 +231,3 @@ const [r_node, s_node] = node.parse_parts(); | ||
function pack_ecdsa_raw({r, s}) { | ||
function encode_ecdsa_raw({r, s}) { | ||
const len_part = ecdsa_raw_len[r.byteLength]; | ||
@@ -224,3 +245,3 @@ if (! len_part) { | ||
function unpack_ecdsa_raw(ecdsa_raw) { | ||
function decode_ecdsa_raw(ecdsa_raw) { | ||
const u8 = new Uint8Array(ecdsa_raw.buffer || ecdsa_raw); | ||
@@ -232,6 +253,6 @@ const n = u8.byteLength >>> 1; | ||
exports.pack_ecdsa_asn1 = pack_ecdsa_asn1; | ||
exports.unpack_ecdsa_asn1 = unpack_ecdsa_asn1; | ||
exports.pack_ecdsa_raw = pack_ecdsa_raw; | ||
exports.unpack_ecdsa_raw = unpack_ecdsa_raw; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZWNkc2EuanMiLCJzb3VyY2VzIjpbIi4uL2NvZGUvdThfdXRpbHMuanN5IiwiLi4vY29kZS9hc24xX2RlY29kZS5qc3kiLCIuLi9jb2RlL2FzbjFfZW5jb2RlLmpzeSIsIi4uL2NvZGUvZWNkc2EuanN5Il0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBmdW5jdGlvbiBoZXhfdG9fdTgoaGV4KSA6OlxuICBoZXggPSBoZXgucmVwbGFjZSgvW14wLTlhLWZBLUZdL2csICcnKVxuICBjb25zdCB1OCA9IG5ldyBVaW50OEFycmF5KGhleC5sZW5ndGggPj4gMSlcbiAgZm9yIGxldCBpPTAsIGkyPTA7IGk8dTgubGVuZ3RoOyBpKyssIGkyKz0yIDo6XG4gICAgdThbaV0gPSBwYXJzZUludCBAIGhleC5zbGljZShpMiwgaTIrMiksIDE2XG4gIHJldHVybiB1OFxuXG5leHBvcnQgZnVuY3Rpb24gdThfdG9faGV4KHU4LCBzZXApIDo6XG4gIHJldHVybiBBcnJheVxuICAgIC5mcm9tIEAgdTgsIHYgPT4gdi50b1N0cmluZygxNikucGFkU3RhcnQoMiwgJzAnKVxuICAgIC5qb2luIEAgbnVsbCAhPSBzZXAgPyBzZXAgOiAnJ1xuXG5leHBvcnQgZnVuY3Rpb24gdThfY29uY2F0KHBhcnRzKSA6OlxuICBsZXQgaT0wLCBsZW49MFxuICBmb3IgY29uc3QgYiBvZiBwYXJ0cyA6OlxuICAgIGxlbiArPSBiLmJ5dGVMZW5ndGhcblxuICBjb25zdCB1OCA9IG5ldyBVaW50OEFycmF5KGxlbilcbiAgZm9yIGNvbnN0IHU4X3BhcnQgb2YgcGFydHMgOjpcbiAgICBpZiAhICh1OF9wYXJ0LmJ1ZmZlciB8fCB1O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FBbUI7O0VBRXJCLElBQUUsYUFBYzs7RUFFaEIsS0FBRztJQUNEO0lBQ0EsSUFBRTtNQUNBLElBQUUsV0FBWTtNQUNkOztBQUVOO0VBQ0UsSUFBRTtJQUNBOztFQUVGLElBQUU7SUFDQTs7RUFFRixnQkFBaUI7OztFQ3hFakI7SUFDRTtLQUNHO0tBQ0E7O0FBRVA7RUFDRSw0QkFBNkI7RUFDN0I7RUFDQSxRQUFVOztBQUVaO0dBQ0s7R0FDQTtHQUNBOzs7RUFHSDtJQUNFLEtBQUc7TUFDRDtJQUNGO0VBQ0Y7O0FBRUY7RUFDRTtFQUNBLEtBQUc7SUFDRCxnQkFBaUI7O0VBRW5CO0VBQ0E7O0VBRUE7RUFDQSxPQUFRO0VBQ1IsT0FBUTtFQUNSOztBQUVGO0VBQ0U7RUFDQTtFQUNBO0VBQ0E7RUFDQTs7Ozs7OzsifQ== | ||
exports.encode_ecdsa_asn1 = encode_ecdsa_asn1; | ||
exports.decode_ecdsa_asn1 = decode_ecdsa_asn1; | ||
exports.encode_ecdsa_raw = encode_ecdsa_raw; | ||
exports.decode_ecdsa_raw = decode_ecdsa_raw; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZWNkc2EuanMiLCJzb3VyY2VzIjpbIi4uL2NvZGUvdThfdXRpbHMuanN5IiwiLi4vY29kZS9hc24xX2RlY29kZS5qc3kiLCIuLi9jb2RlL2FzbjFfZW5jb2RlLmpzeSIsIi4uL2NvZGUvYXNuMV9wb3NpdGl2ZV9pbnQuanN5IiwiLi4vY29kZS9lY2RzYS5qc3kiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGZ1bmN0aW9uIGhleF90b191OChoZXgpIDo6XG4gIGhleCA9IGhleC5yZXBsYWNlKC9bXjAtOWEtZkEtRl0vZywgJycpXG4gIGNvbnN0IHU4ID0gbmV3IFVpbnQ4QXJyYXkoaGV4Lmxlbmd0aCA+PiAxKVx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O0VBRUYsZ0JBQWlCOzs7RUNoQmpCO0lBQ0U7S0FDRztLQUNBOztBQUVQO0VBQ0UsNEJBQTZCO0VBQzdCO0VBQ0EsUUFBVTs7QUFFWjtHQUNLO0dBQ0E7R0FDQTs7O0VBR0g7SUFDRSxLQUFHO01BQ0Q7SUFDRjtFQUNGOztBQUVGO0VBQ0U7RUFDQSxLQUFHO0lBQ0QsZ0JBQWlCOztFQUVuQjtFQUNBOztFQUVBO0VBQ0EsT0FBUTtFQUNSLE9BQVE7RUFDUjs7QUFFRjtFQUNFO0VBQ0E7RUFDQTtFQUNBO0VBQ0E7Ozs7Ozs7In0= |
@@ -13,2 +13,5 @@ 'use strict'; | ||
function u8_to_hex(u8, sep) { | ||
if (undefined === u8.buffer) { | ||
u8 = new Uint8Array(u8);} | ||
return Array | ||
@@ -21,2 +24,4 @@ .from(u8, v => v.toString(16).padStart(2, '0')) | ||
for (const b of parts) { | ||
if (! b.byteLength) { | ||
console.log("WA?", b, parts); } | ||
len += b.byteLength;} | ||
@@ -73,3 +78,3 @@ | ||
node.hex = u8_to_hex(content, ' '); | ||
//node.hex = u8_to_hex @ content, ' ' | ||
@@ -86,4 +91,15 @@ yield node;} } | ||
, parse_parts() { | ||
return 0x20 & this.id | ||
, hex() {return u8_to_hex(this.content)} | ||
, dbg() {return `id: ${this.id} len: ${this.byteLength} hex: ${this.hex()}`} | ||
, [Symbol.iterator]() {return this.iter_parts()} | ||
, iter_parts(override) { | ||
if (0x20 & this.id || override) { | ||
return asn1_u8_decode_many(this.content)} | ||
else throw new Error('Not a contructed ASN1 node') } | ||
, first_part(override) { | ||
return asn1_u8_decode(this.content)} | ||
, parse_parts(override) { | ||
return 0x20 & this.id || override | ||
? Array.from(asn1_u8_decode_many(this.content)) | ||
@@ -99,2 +115,5 @@ : null} | ||
, *iter_walk(visitor) { | ||
if (true === visitor) { | ||
console.log(this.dbg()); } | ||
let parts = null; | ||
@@ -106,3 +125,3 @@ if (0x20 & this.id) { | ||
if (visitor) { | ||
if ('function' === typeof visitor) { | ||
return visitor(this, parts) } | ||
@@ -128,4 +147,2 @@ else { | ||
function asn1_u8_encode(content_tree) { | ||
const is_lst = Array.isArray(content_tree); | ||
const all_parts = []; | ||
@@ -136,2 +153,7 @@ encode_next(content_tree); | ||
function encode_next(content_tree) { | ||
if (content_tree.byteLength) { | ||
all_parts.push(content_tree); | ||
return content_tree.byteLength} | ||
const is_lst = Array.isArray(content_tree); | ||
const ident = is_lst ? content_tree[0] : content_tree.id; | ||
@@ -145,2 +167,3 @@ const id = ident | 0; | ||
if (! Number.isInteger(ident) || 0 > ident || ident > 255) { | ||
console.log({ident, content_tree}); | ||
throw new Error('Invalid ASN1 identifier') } | ||
@@ -171,6 +194,6 @@ | ||
else { | ||
let octects = 0; | ||
while (0 !== byteLength) { | ||
hdr.push(byteLength & 0xff); | ||
byteLength >>>= 8; | ||
let octects = 0, oct_len = byteLength; | ||
while (0 !== oct_len) { | ||
hdr.push(oct_len & 0xff); | ||
oct_len >>>= 8; | ||
octects ++;} | ||
@@ -183,25 +206,2 @@ hdr[1] = 0x80 | octects;} | ||
const u8_zero = new Uint8Array([0]); | ||
function asn1_der_positive_int(v) { | ||
if (0x80 & v[0]) { | ||
return u8_concat([u8_zero, v]) } | ||
if (0 !== v[0]) {return v} | ||
for (let i=1; i < v.byteLength; i++) { | ||
const b = v[i]; | ||
if (0 !== b) { | ||
if (0x80 & b) {i--;} | ||
return v.subarray(i)} } } | ||
function compact_positive_int(v, len) { | ||
if (v.byteLength <= len) { | ||
return v} | ||
if (0 === v[0] && 0x80 & v[1]) { | ||
return v.subarray(1)} | ||
throw new Error('Unexpected integer construction') } | ||
function utf8_to_u8(utf8) { | ||
@@ -216,2 +216,6 @@ return Uint8Array.from(Buffer.from(utf8, 'utf-8')) } | ||
function u8_to_base64url(u8) { | ||
return u8_to_base64(u8) | ||
.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '')} | ||
function base64_to_u8(str_b64) { | ||
@@ -226,7 +230,6 @@ return Uint8Array.from(Buffer.from(str_b64, 'base64')) } | ||
exports.asn1_u8_encode = asn1_u8_encode; | ||
exports.asn1_der_positive_int = asn1_der_positive_int; | ||
exports.compact_positive_int = compact_positive_int; | ||
exports.utf8_to_u8 = utf8_to_u8; | ||
exports.u8_to_utf8 = u8_to_utf8; | ||
exports.u8_to_base64 = u8_to_base64; | ||
exports.u8_to_base64url = u8_to_base64url; | ||
exports.base64_to_u8 = base64_to_u8; | ||
@@ -236,2 +239,2 @@ exports.hex_to_u8 = hex_to_u8; | ||
exports.u8_concat = u8_concat; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VzIjpbIi4uL2NvZGUvdThfdXRpbHMuanN5IiwiLi4vY29kZS9hc24xX2RlY29kZS5qc3kiLCIuLi9jb2RlL2FzbjFfZW5jb2RlLmpzeSIsIi4uL2NvZGUvbm9kZWpzL3U4X3V0aWxzLmpzeSJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZnVuY3Rpb24gaGV4X3RvX3U4KGhleCkgOjpcbiAgaGV4ID0gaGV4LnJlcGxhY2UoL1teMC05YS1mQS1GXS9nLCAnJylcbiAgY29uc3QgdTggPSBuZXcgVWludDhBcnJheShoZXgubGVuZ3RoID4+IDEpXG4gIGZvciBsZXQgaT0wLCBpMj0wOyBpPHU4Lmxlbmd0aDsgaSsrLCBpMis9MiA6OlxuICAgIHU4W2ldID0gcGFyc2VJbnQgQCBoZXguc2xpY2UoaTIsIGkyKzIpLCAxNlxuICByZXR1cm4gdThcblxuZXhwb3J0IGZ1bmN0aW9uIHU4X3RvX2hleCh1OCwgc2VwKSA6OlxuICByZXR1cm4gQXJyYXlcbiAgICAuZnJvbSBAIHU4LCB2ID0+IHYudG9TdHJpbmcoMTYpLnBhZFN0YXJ0KDIsICcwJylcbiAgICAuam9pbiBAIG51bGwgIT0gc2VwID8gc2VwIDogJydcblx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Q0UsZ0NBQWdDLFFBQVE7O0FBRTFDO0VBQ0U7YUFDVyxLQUFLLEVBQUUsR0FBRyxVQUFVLEtBQUssRUFBRSxHQUFHLFVBQVUsSUFBSSxFQUFFLEVBQUU7O0FBRTdEO0VBQ0UsdUJBQXdCLHFCQUFzQixRQUFROzs7Ozs7Ozs7Ozs7Ozs7OzsifQ== |
@@ -13,2 +13,5 @@ 'use strict'; | ||
function u8_to_hex(u8, sep) { | ||
if (undefined === u8.buffer) { | ||
u8 = new Uint8Array(u8);} | ||
return Array | ||
@@ -21,2 +24,4 @@ .from(u8, v => v.toString(16).padStart(2, '0')) | ||
for (const b of parts) { | ||
if (! b.byteLength) { | ||
console.log("WA?", b, parts); } | ||
len += b.byteLength;} | ||
@@ -42,2 +47,6 @@ | ||
function u8_to_base64url(u8) { | ||
return u8_to_base64(u8) | ||
.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '')} | ||
function base64_to_u8(str_b64) { | ||
@@ -49,2 +58,3 @@ return Uint8Array.from(Buffer.from(str_b64, 'base64')) } | ||
exports.u8_to_base64 = u8_to_base64; | ||
exports.u8_to_base64url = u8_to_base64url; | ||
exports.base64_to_u8 = base64_to_u8; | ||
@@ -54,2 +64,2 @@ exports.hex_to_u8 = hex_to_u8; | ||
exports.u8_concat = u8_concat; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidThfdXRpbHMuanMiLCJzb3VyY2VzIjpbIi4uLy4uL2NvZGUvdThfdXRpbHMuanN5IiwiLi4vLi4vY29kZS9ub2RlanMvdThfdXRpbHMuanN5Il0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBmdW5jdGlvbiBoZXhfdG9fdTgoaGV4KSA6OlxuICBoZXggPSBoZXgucmVwbGFjZSgvW14wLTlhLWZBLUZdL2csICcnKVxuICBjb25zdCB1OCA9IG5ldyBVaW50OEFycmF5KGhleC5sZW5ndGggPj4gMSlcbiAgZm9yIGxld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FnQyxRQUFROztBQUUxQztFQUNFO2FBQ1csS0FBSyxFQUFFLEdBQUcsVUFBVSxLQUFLLEVBQUUsR0FBRyxVQUFVLElBQUksRUFBRSxFQUFFOztBQUU3RDtFQUNFLHVCQUF3QixxQkFBc0IsUUFBUTs7Ozs7Ozs7Ozs7In0= |
@@ -13,2 +13,5 @@ 'use strict'; | ||
function u8_to_hex(u8, sep) { | ||
if (undefined === u8.buffer) { | ||
u8 = new Uint8Array(u8);} | ||
return Array | ||
@@ -21,2 +24,4 @@ .from(u8, v => v.toString(16).padStart(2, '0')) | ||
for (const b of parts) { | ||
if (! b.byteLength) { | ||
console.log("WA?", b, parts); } | ||
len += b.byteLength;} | ||
@@ -36,2 +41,2 @@ | ||
exports.u8_concat = u8_concat; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidThfdXRpbHMuanMiLCJzb3VyY2VzIjpbIi4uL2NvZGUvdThfdXRpbHMuanN5Il0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBmdW5jdGlvbiBoZXhfdG9fdTgoaGV4KSA6OlxuICBoZXggPSBoZXgucmVwbGFjZSgvW14wLTlhLWZBLUZdL2csICcnKVxuICBjb25zdCB1OCA9IG5ldyBVaW50OEFycmF5KGhleC5sZW5ndGggPj4gMSlcbiAgZm9yIGxldCBpPTAsIGkyPTA7IGk8dTgubGVuZ3RoOyBpKyssIGkyKz0yIDo6XG4gICAgdThbaV0gPSBwYXJzZUludCBAIGhleC5zbGljZShpMiwgaTIrMiksIDE2XG4gIHJldHVybiB1OFxuXG5leHBvcnQgZnVuY3Rpb24gdThfdG9faGV4KHU4LCBzZXApIDo6XG4gIHJldHVybiBBcnJheVxuICAgIC5mcm9tIEAgdTgsIHYgPT4gdi50b1N0cmluZygxNikucGFkU3RhcnQoMiwgJzAnKVxuICAgIC5qb2luIEAgbnVsbCAhPSBzZXAgPyBzZXAgOiAnJ1xuXG5leHBvcnQgZnVuY3R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FLEVBQUU7RUFDckM7RUFDQSxLQUFHO0lBQ0QsaUJBQWtCO0VBQ3BCOztBQUVGO0VBQ0UsSUFBRTtJQUNBOztFQUVGO1VBQ1Msb0NBQXFDLEdBQUc7VUFDeEMsb0JBQXFCOztBQUVoQztFQUNFO0VBQ0EsS0FBRztJQUNELEtBQUc7TUFDRCxZQUFhLEtBQU07SUFDckI7O0VBRUY7RUFDQSxLQUFHO0lBQ0QsS0FBRztNQUNELGdCQUFpQjs7SUFFbkIsT0FBUTtJQUNSO0VBQ0Y7Ozs7OzsifQ== |
@@ -9,2 +9,5 @@ function hex_to_u8(hex) { | ||
function u8_to_hex(u8, sep) { | ||
if (undefined === u8.buffer) { | ||
u8 = new Uint8Array(u8);} | ||
return Array | ||
@@ -17,2 +20,4 @@ .from(u8, v => v.toString(16).padStart(2, '0')) | ||
for (const b of parts) { | ||
if (! b.byteLength) { | ||
console.log("WA?", b, parts); } | ||
len += b.byteLength;} | ||
@@ -69,3 +74,3 @@ | ||
node.hex = u8_to_hex(content, ' '); | ||
//node.hex = u8_to_hex @ content, ' ' | ||
@@ -82,4 +87,15 @@ yield node;} } | ||
, parse_parts() { | ||
return 0x20 & this.id | ||
, hex() {return u8_to_hex(this.content)} | ||
, dbg() {return `id: ${this.id} len: ${this.byteLength} hex: ${this.hex()}`} | ||
, [Symbol.iterator]() {return this.iter_parts()} | ||
, iter_parts(override) { | ||
if (0x20 & this.id || override) { | ||
return asn1_u8_decode_many(this.content)} | ||
else throw new Error('Not a contructed ASN1 node') } | ||
, first_part(override) { | ||
return asn1_u8_decode(this.content)} | ||
, parse_parts(override) { | ||
return 0x20 & this.id || override | ||
? Array.from(asn1_u8_decode_many(this.content)) | ||
@@ -95,2 +111,5 @@ : null} | ||
, *iter_walk(visitor) { | ||
if (true === visitor) { | ||
console.log(this.dbg()); } | ||
let parts = null; | ||
@@ -102,3 +121,3 @@ if (0x20 & this.id) { | ||
if (visitor) { | ||
if ('function' === typeof visitor) { | ||
return visitor(this, parts) } | ||
@@ -124,4 +143,2 @@ else { | ||
function asn1_u8_encode(content_tree) { | ||
const is_lst = Array.isArray(content_tree); | ||
const all_parts = []; | ||
@@ -132,2 +149,7 @@ encode_next(content_tree); | ||
function encode_next(content_tree) { | ||
if (content_tree.byteLength) { | ||
all_parts.push(content_tree); | ||
return content_tree.byteLength} | ||
const is_lst = Array.isArray(content_tree); | ||
const ident = is_lst ? content_tree[0] : content_tree.id; | ||
@@ -141,2 +163,3 @@ const id = ident | 0; | ||
if (! Number.isInteger(ident) || 0 > ident || ident > 255) { | ||
console.log({ident, content_tree}); | ||
throw new Error('Invalid ASN1 identifier') } | ||
@@ -167,6 +190,6 @@ | ||
else { | ||
let octects = 0; | ||
while (0 !== byteLength) { | ||
hdr.push(byteLength & 0xff); | ||
byteLength >>>= 8; | ||
let octects = 0, oct_len = byteLength; | ||
while (0 !== oct_len) { | ||
hdr.push(oct_len & 0xff); | ||
oct_len >>>= 8; | ||
octects ++;} | ||
@@ -179,25 +202,2 @@ hdr[1] = 0x80 | octects;} | ||
const u8_zero = new Uint8Array([0]); | ||
function asn1_der_positive_int(v) { | ||
if (0x80 & v[0]) { | ||
return u8_concat([u8_zero, v]) } | ||
if (0 !== v[0]) {return v} | ||
for (let i=1; i < v.byteLength; i++) { | ||
const b = v[i]; | ||
if (0 !== b) { | ||
if (0x80 & b) {i--;} | ||
return v.subarray(i)} } } | ||
function compact_positive_int(v, len) { | ||
if (v.byteLength <= len) { | ||
return v} | ||
if (0 === v[0] && 0x80 & v[1]) { | ||
return v.subarray(1)} | ||
throw new Error('Unexpected integer construction') } | ||
function utf8_to_u8(utf8) { | ||
@@ -220,2 +220,6 @@ return new TextEncoder('utf-8').encode(utf8.normalize('NFKC')) } | ||
function u8_to_base64url(u8) { | ||
return u8_to_base64(u8) | ||
.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '')} | ||
const _charCodeAt = ''.charCodeAt; | ||
@@ -230,3 +234,3 @@ function base64_to_u8(str_b64) { | ||
export { asn1_u8_decode, asn1_u8_decode_many, asn1_node, asn1_identifiers_byTag, with_asn1_identifiers, asn1_u8_encode, asn1_der_positive_int, compact_positive_int, utf8_to_u8, u8_to_utf8, u8_to_base64, base64_to_u8, hex_to_u8, u8_to_hex, u8_concat }; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXNuMV9jb2RlYy5qcyIsInNvdXJjZXMiOlsiLi4vY29kZS91OF91dGlscy5qc3kiLCIuLi9jb2RlL2FzbjFfZGVjb2RlLmpzeSIsIi4uL2NvZGUvYXNuMV9lbmNvZGUuanN5IiwiLi4vY29kZS93ZWIvdThfdXRpbHMuanN5Il0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBmdW5jdGlvbiBoZXhfdG9fdTgoaGV4KSA6OlxuICBoZXggPSBoZXgucmVwbGFjZSgvW14wLTlhLWZBLUZdL2csICcnKVxuICBjb25zdCB1OCA9IG5ldyBVaW50OEFycmF5KGhleC5sZW5ndGggPj4gMSlcbiAgZm9yIGxldCBpPTAsIGkyPTA7IGk8dTgubGVuZ3RoOyBpKyssIGkyKz0yIDo6XG4gICAgdThbaV0gPSBwYXJzZUludCBAIGhleC5zbGljZShpMiwgaTIrMiksIDE2XG4gIHJldHVybiB1OFxuXG5leHBvcnQgZnVuY3Rpb24gdThfdG9faGV4KHU4LCBzZXApIDo6XG4gIHJldHVybiBBcnJheVxuICAgIC5mcm9tIEAgdTgsIHYgPT4gdi50b1N0cmluZygxNikucGFkU3RhcnQoMiwgJzAnKVxuICAgIC5qb2luIEAgbnVsbCAhPSBzZXAgPyBzZXAgOiAnJ1xuXG5leHBvcnQgZnVuY3Rpb24gdThfY29uY2F0KHBhcnRzKSA6OlxuICBsZXQgaT0wLCBsZW49MFxuICBmb3IgY29uc3QgYiBvZiBwYXJ0cyA6OlxuICAgIGxlbiArPSBiLmJ5dGVMZW5ndGhcblxuICBjb25zdCB1OCA9IG5ldyBVaW50OEF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FDZDs7QUFFTjtFQUNFLElBQUU7SUFDQTs7RUFFRixJQUFFO0lBQ0E7O0VBRUYsZ0JBQWlCOzs7RUN6RWpCLHVCQUF1QixPQUFPLFNBQVUsZUFBZ0IsTUFBTTs7QUFFaEU7RUFDRSx1QkFBdUIsT0FBTyxTQUFVOztBQUUxQztBQUNBO0VBQ0UsSUFBRTtJQUNBOztFQUVGLFFBQVE7RUFDUjtFQUNBLEtBQUc7SUFDRDtFQUNGOztBQUVGLG9CQUFvQixFQUFFO0FBQ3RCO0VBQ0UsZ0JBQWlCLGdCQUFpQixJQUFJLEVBQUUsR0FBRyxVQUFVLElBQUksRUFBRSxHQUFHO0VBQzlEO0VBQ0E7RUFDQSxLQUFHO0lBQ0Q7RUFDRjs7OzsifQ== | ||
export { asn1_u8_decode, asn1_u8_decode_many, asn1_node, asn1_identifiers_byTag, with_asn1_identifiers, asn1_u8_encode, utf8_to_u8, u8_to_utf8, u8_to_base64, u8_to_base64url, base64_to_u8, hex_to_u8, u8_to_hex, u8_concat }; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXNuMV9jb2RlYy5qcyIsInNvdXJjZXMiOlsiLi4vY29kZS91OF91dGlscy5qc3kiLCIuLi9jb2RlL2FzbjFfZGVjb2RlLmpzeSIsIi4uL2NvZGUvYXNuMV9lbmNvZGUuanN5IiwiLi4vY29kZS93ZWIvdThfdXRpbHMuanN5Il0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBmdW5jdGlvbiBoZXhfdG9fdTgoaGV4KSA6OlxuICBoZXggPSBoZXgucmVwbGFjZSgvW14wLTlhLWZBLUZdL2csICcnKVxuICBjb25zdCB1OCA9IG5ldyBVaW50OEFycmF5KGhleC5sZW5ndGggPj4gMSlcbiAgZm9yIGxldCBpPTAsIGkyPTA7IGk8dTgubGVuZ3RoOyBpKyssIGkyKz0yIDo6XG4gICAgdThbaV0gPSBwYXJzZUludCBAIGhleC5zb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FDQTtNQUNGOztJQUVGO0lBQ0E7SUFDQTs7O0VDdERGLHVCQUF1QixPQUFPLFNBQVUsZUFBZ0IsTUFBTTs7QUFFaEU7RUFDRSx1QkFBdUIsT0FBTyxTQUFVOztBQUUxQztBQUNBO0VBQ0UsSUFBRTtJQUNBOztFQUVGLFFBQVE7RUFDUjtFQUNBLEtBQUc7SUFDRDtFQUNGOztBQUVGO0VBQ0U7YUFDVyxLQUFLLEVBQUUsR0FBRyxVQUFVLEtBQUssRUFBRSxHQUFHLFVBQVUsSUFBSSxFQUFFLEVBQUU7O0FBRTdELG9CQUFvQixFQUFFO0FBQ3RCO0VBQ0UsZ0JBQWlCLGdCQUFpQixJQUFJLEVBQUUsR0FBRyxVQUFVLElBQUksRUFBRSxHQUFHO0VBQzlEO0VBQ0E7RUFDQSxLQUFHO0lBQ0Q7RUFDRjs7OzsifQ== |
function u8_to_hex(u8, sep) { | ||
if (undefined === u8.buffer) { | ||
u8 = new Uint8Array(u8);} | ||
return Array | ||
@@ -46,3 +49,3 @@ .from(u8, v => v.toString(16).padStart(2, '0')) | ||
node.hex = u8_to_hex(content, ' '); | ||
//node.hex = u8_to_hex @ content, ' ' | ||
@@ -59,4 +62,15 @@ yield node;} } | ||
, parse_parts() { | ||
return 0x20 & this.id | ||
, hex() {return u8_to_hex(this.content)} | ||
, dbg() {return `id: ${this.id} len: ${this.byteLength} hex: ${this.hex()}`} | ||
, [Symbol.iterator]() {return this.iter_parts()} | ||
, iter_parts(override) { | ||
if (0x20 & this.id || override) { | ||
return asn1_u8_decode_many(this.content)} | ||
else throw new Error('Not a contructed ASN1 node') } | ||
, first_part(override) { | ||
return asn1_u8_decode(this.content)} | ||
, parse_parts(override) { | ||
return 0x20 & this.id || override | ||
? Array.from(asn1_u8_decode_many(this.content)) | ||
@@ -72,2 +86,5 @@ : null} | ||
, *iter_walk(visitor) { | ||
if (true === visitor) { | ||
console.log(this.dbg()); } | ||
let parts = null; | ||
@@ -79,3 +96,3 @@ if (0x20 & this.id) { | ||
if (visitor) { | ||
if ('function' === typeof visitor) { | ||
return visitor(this, parts) } | ||
@@ -102,2 +119,2 @@ else { | ||
export { asn1_u8_decode, asn1_u8_decode_many, asn1_node, asn1_identifiers_byTag, with_asn1_identifiers }; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXNuMV9kZWNvZGUuanMiLCJzb3VyY2VzIjpbIi4uL2NvZGUvdThfdXRpbHMuanN5IiwiLi4vY29kZS9hc24xX2RlY29kZS5qc3kiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGZ1bmN0aW9uIGhleF90b191OChoZXgpIDo6XG4gIGhleCA9IGhleC5yZXBsYWNlKC9bXjAtOWEtZkEtRl0vZywgJycpXG4gIGNvbnN0IHU4ID0gbmV3IFVpbnQ4QXJyYXkoaGV4Lmxlbmd0aCA+PiAxKVxuICBmb3IgbGV0IGk9MCwgaTI9MDsgaTx1OC5sZW5ndGg7IGkrKywgaTIrPTIgOjpcbiAgICB1OFtpXSA9IHBhcnNlSW50IEAgaGV4LnNsaWNlKGkyLCBpMisyKSwgMTZcbiAgcmV0dXJuIHU4XG5cbmV4cG9ydCBmdW5jdGlvbiB1OF90b19oZXgodTgsIHNlcCkgOjpcbiAgcmV0dXJuIEFycmF5XG4gICAgLmZyb20gQCB1OCwgdiA9PiB2LnRvU3RyaW5nKDE2KS5wYWRTdGFydCgyLCAnMCcpXG4gICAgLmpvaW4gQCBudWxsICE9IHNlcCA/IHNlcCA6ICcnXG5cbmV4cG9ydCBmdW5jdGlvbiB1OF9jb25jYXQocGFydHMpIDo6XG4gIGxldCBpPTAsIGxlbj0wXG4gIGZvciBjb25zdCBiIG9mIHBhcnRzIDo6XG4gICAgbGVuICs9IGIuYnl0ZUxlbmd0aFxuXG4gIGNvbnN0IHU4ID0gbmV3IFVpbnQ4QXJyYXkobGVuKVxuICBmb3IgY29uc3QgdThfcGFydCBvZiBwYXJ0cyA6Olx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tQkFBbUIsRUFBRSxtQkFBbUI7RUFDaEUsVUFBVSxFQUFFLE1BQU0sRUFBRSxZQUFZLEVBQUUsY0FBYztFQUNoRCxZQUFZLEVBQUUsY0FBYyxFQUFFLFVBQVUsRUFBRSxVQUFVO0VBQ3BELFVBQVUsRUFBRSxLQUFLLEVBQUUsZUFBZSxFQUFFLGlCQUFpQjtFQUNyRCxXQUFXLEVBQUUsZ0JBQWdCLEVBQUUsV0FBVyxFQUFFLFNBQVM7RUFDckQsaUJBQWlCLEVBQUUsZUFBZSxFQUFFLGVBQWUsRUFBRSxlQUFlO0VBQ3BFLGlCQUFpQixFQUFFLGtCQUFrQixFQUFFLFdBQVc7O0FBRXBEO0VBQ0UsaUJBQWtCO0lBQ2hCOzs7OzsifQ== |
function u8_concat(parts) { | ||
let i=0, len=0; | ||
for (const b of parts) { | ||
if (! b.byteLength) { | ||
console.log("WA?", b, parts); } | ||
len += b.byteLength;} | ||
@@ -16,4 +18,2 @@ | ||
function asn1_u8_encode(content_tree) { | ||
const is_lst = Array.isArray(content_tree); | ||
const all_parts = []; | ||
@@ -24,2 +24,7 @@ encode_next(content_tree); | ||
function encode_next(content_tree) { | ||
if (content_tree.byteLength) { | ||
all_parts.push(content_tree); | ||
return content_tree.byteLength} | ||
const is_lst = Array.isArray(content_tree); | ||
const ident = is_lst ? content_tree[0] : content_tree.id; | ||
@@ -33,2 +38,3 @@ const id = ident | 0; | ||
if (! Number.isInteger(ident) || 0 > ident || ident > 255) { | ||
console.log({ident, content_tree}); | ||
throw new Error('Invalid ASN1 identifier') } | ||
@@ -59,6 +65,6 @@ | ||
else { | ||
let octects = 0; | ||
while (0 !== byteLength) { | ||
hdr.push(byteLength & 0xff); | ||
byteLength >>>= 8; | ||
let octects = 0, oct_len = byteLength; | ||
while (0 !== oct_len) { | ||
hdr.push(oct_len & 0xff); | ||
oct_len >>>= 8; | ||
octects ++;} | ||
@@ -71,27 +77,4 @@ hdr[1] = 0x80 | octects;} | ||
const u8_zero = new Uint8Array([0]); | ||
function asn1_der_positive_int(v) { | ||
if (0x80 & v[0]) { | ||
return u8_concat([u8_zero, v]) } | ||
if (0 !== v[0]) {return v} | ||
for (let i=1; i < v.byteLength; i++) { | ||
const b = v[i]; | ||
if (0 !== b) { | ||
if (0x80 & b) {i--;} | ||
return v.subarray(i)} } } | ||
function compact_positive_int(v, len) { | ||
if (v.byteLength <= len) { | ||
return v} | ||
if (0 === v[0] && 0x80 & v[1]) { | ||
return v.subarray(1)} | ||
throw new Error('Unexpected integer construction') } | ||
export default asn1_u8_encode; | ||
export { asn1_u8_encode, asn1_der_positive_int, compact_positive_int }; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXNuMV9lbmNvZGUuanMiLCJzb3VyY2VzIjpbIi4uL2NvZGUvdThfdXRpbHMuanN5IiwiLi4vY29kZS9hc24xX2VuY29kZS5qc3kiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGZ1bmN0aW9uIGhleF90b191OChoZXgpIDo6XG4gIGhleCA9IGhleC5yZXBsYWNlKC9bXjAtOWEtZkEtRl0vZywgJycpXG4gIGNvbnN0IHU4ID0gbmV3IFVpbnQ4QXJyYXkoaGV4Lmxlbmd0aCA+PiAxKVxuICBmb3IgbGV0IGk9MCwgaTI9MDsgaTx1OC5sZW5ndGg7IGkrKywgaTIrPTIgOjpcbiAgICB1OFtpXSA9IHBhcnNlSW50IEAgaGV4LnNsaWNlKGkyLCBpMisyKSwgMTZcbiAgcmV0dXJuIHU4XG5cbmV4cG9ydCBmdW5jdGlvbiB1OF90b19oZXgodTgsIHNlcCkgOjpcbiAgcmV0dXJuIEFycmF5XG4gICAgLmZyb20gQCB1OCwgdiA9PiB2LnRvU3RyaW5nKDE2KS5wYWRTdGFydCgyLCAnMCcpXG4gICAgLmpvaW4gQCBudWxsICE9IHNlcCA/IHNlcCA6ICcnXG5cbmV4cG9ydCBmdW5jdGlvbiB1OF9jb25jYX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UY7RUFDQSxLQUFHO0lBQ0QsS0FBRztNQUNELGdCQUFpQjs7SUFFbkIsT0FBUTtJQUNSO0VBQ0Y7OztFQ3pCQTtFQUNBO0VBQ0EsaUJBQWtCOztFQUVsQjtJQUNFLElBQUU7TUFDQTtNQUNBOztJQUVGO0lBQ0E7SUFDQTtJQUNBOztJQUVBO0lBQ0E7O0lBRUEsS0FBRztNQUNELGFBQWM7TUFDZCxnQkFBaUI7O0lBRW5CLElBQUU7TUFDQTs7OztNQUlBLElBQUU7UUFDQSxnQkFBaUI7O01BRW5CLEtBQUc7UUFDRDs7O01BR0Y7TUFDQSxlQUFnQjtNQUNoQjs7TUFFQSxJQUFFO1FBQ0EsZ0JBQWlCOzs7SUFHckIsSUFBRTtNQUNBOztNQUVBO01BQ0EsT0FBSztRQUNILFNBQVU7UUFDVjtRQUNBO01BQ0Y7O0lBRUY7SUFDQTtJQUNBOzs7OzsifQ== |
function u8_to_hex(u8, sep) { | ||
if (undefined === u8.buffer) { | ||
u8 = new Uint8Array(u8);} | ||
return Array | ||
@@ -9,2 +12,4 @@ .from(u8, v => v.toString(16).padStart(2, '0')) | ||
for (const b of parts) { | ||
if (! b.byteLength) { | ||
console.log("WA?", b, parts); } | ||
len += b.byteLength;} | ||
@@ -61,3 +66,3 @@ | ||
node.hex = u8_to_hex(content, ' '); | ||
//node.hex = u8_to_hex @ content, ' ' | ||
@@ -74,4 +79,15 @@ yield node;} } | ||
, parse_parts() { | ||
return 0x20 & this.id | ||
, hex() {return u8_to_hex(this.content)} | ||
, dbg() {return `id: ${this.id} len: ${this.byteLength} hex: ${this.hex()}`} | ||
, [Symbol.iterator]() {return this.iter_parts()} | ||
, iter_parts(override) { | ||
if (0x20 & this.id || override) { | ||
return asn1_u8_decode_many(this.content)} | ||
else throw new Error('Not a contructed ASN1 node') } | ||
, first_part(override) { | ||
return asn1_u8_decode(this.content)} | ||
, parse_parts(override) { | ||
return 0x20 & this.id || override | ||
? Array.from(asn1_u8_decode_many(this.content)) | ||
@@ -87,2 +103,5 @@ : null} | ||
, *iter_walk(visitor) { | ||
if (true === visitor) { | ||
console.log(this.dbg()); } | ||
let parts = null; | ||
@@ -94,3 +113,3 @@ if (0x20 & this.id) { | ||
if (visitor) { | ||
if ('function' === typeof visitor) { | ||
return visitor(this, parts) } | ||
@@ -101,4 +120,2 @@ else { | ||
function asn1_u8_encode(content_tree) { | ||
const is_lst = Array.isArray(content_tree); | ||
const all_parts = []; | ||
@@ -109,2 +126,7 @@ encode_next(content_tree); | ||
function encode_next(content_tree) { | ||
if (content_tree.byteLength) { | ||
all_parts.push(content_tree); | ||
return content_tree.byteLength} | ||
const is_lst = Array.isArray(content_tree); | ||
const ident = is_lst ? content_tree[0] : content_tree.id; | ||
@@ -118,2 +140,3 @@ const id = ident | 0; | ||
if (! Number.isInteger(ident) || 0 > ident || ident > 255) { | ||
console.log({ident, content_tree}); | ||
throw new Error('Invalid ASN1 identifier') } | ||
@@ -144,6 +167,6 @@ | ||
else { | ||
let octects = 0; | ||
while (0 !== byteLength) { | ||
hdr.push(byteLength & 0xff); | ||
byteLength >>>= 8; | ||
let octects = 0, oct_len = byteLength; | ||
while (0 !== oct_len) { | ||
hdr.push(oct_len & 0xff); | ||
oct_len >>>= 8; | ||
octects ++;} | ||
@@ -156,7 +179,5 @@ hdr[1] = 0x80 | octects;} | ||
const u8_zero = new Uint8Array([0]); | ||
function asn1_der_positive_int(v) { | ||
if (0x80 & v[0]) { | ||
return u8_concat([u8_zero, v]) } | ||
return u8_concat([new Uint8Array([0]), v]) } | ||
@@ -180,3 +201,3 @@ if (0 !== v[0]) {return v} | ||
function pack_ecdsa_asn1({r, s}) { | ||
function encode_ecdsa_asn1({r, s}) { | ||
return asn1_u8_encode([ | ||
@@ -187,3 +208,3 @@ 0x30, // sequence | ||
function unpack_ecdsa_asn1(ecdsa_asn1) { | ||
function decode_ecdsa_asn1(ecdsa_asn1) { | ||
const node = asn1_u8_decode(ecdsa_asn1); | ||
@@ -205,3 +226,3 @@ const [r_node, s_node] = node.parse_parts(); | ||
function pack_ecdsa_raw({r, s}) { | ||
function encode_ecdsa_raw({r, s}) { | ||
const len_part = ecdsa_raw_len[r.byteLength]; | ||
@@ -219,3 +240,3 @@ if (! len_part) { | ||
function unpack_ecdsa_raw(ecdsa_raw) { | ||
function decode_ecdsa_raw(ecdsa_raw) { | ||
const u8 = new Uint8Array(ecdsa_raw.buffer || ecdsa_raw); | ||
@@ -227,3 +248,3 @@ const n = u8.byteLength >>> 1; | ||
export { pack_ecdsa_asn1, unpack_ecdsa_asn1, pack_ecdsa_raw, unpack_ecdsa_raw }; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZWNkc2EuanMiLCJzb3VyY2VzIjpbIi4uL2NvZGUvdThfdXRpbHMuanN5IiwiLi4vY29kZS9hc24xX2RlY29kZS5qc3kiLCIuLi9jb2RlL2FzbjFfZW5jb2RlLmpzeSIsIi4uL2NvZGUvZWNkc2EuanN5Il0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBmdW5jdGlvbiBoZXhfdG9fdTgoaGV4KSA6OlxuICBoZXggPSBoZXgucmVwbGFjZSgvW14wLTlhLWZBLUZdL2csICcnKVxuICBjb25zdCB1OCA9IG5ldyBVaW50OEFycmF5KGhleC5sZW5ndGggPj4gMSlcbiAgZm9yIGxldCBpPTAsIGkyPTA7IGk8dTgubGVuZ3RoOyBpKyssIGkyKz0yIDo6XG4gICAgdThbaV0gPSBwYXJzZUludCBAIGhleC5zbGljZShpMiwgaTIrMiksIDE2XG4gIHJldHVybiB1OFxuXG5leHBvcnQgZnVuY3Rpb24gdThfdG9faGV4KHU4LCBzZXApIDo6XG4gIHJldHVybiBBcnJheVxuICAgIC5mcm9tIEAgdTgsIHYgPT4gdi50b1N0cmluZygxNikucGFkU3RhcnQoMiwgJzAnKVxuICAgIC5qb2luIEAgbnVsbCAhPSBzZXAgPyBzZXAgOiAnJ1xuXG5leHBvcnQ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0VDdERGLElBQUU7SUFDQSxrQkFBbUI7O0VBRXJCLElBQUUsYUFBYzs7RUFFaEIsS0FBRztJQUNEO0lBQ0EsSUFBRTtNQUNBLElBQUUsV0FBWTtNQUNkOztBQUVOO0VBQ0UsSUFBRTtJQUNBOztFQUVGLElBQUU7SUFDQTs7RUFFRixnQkFBaUI7OztFQ2hCakI7SUFDRTtLQUNHO0tBQ0E7O0FBRVA7RUFDRSw0QkFBNkI7RUFDN0I7RUFDQSxRQUFVOztBQUVaO0dBQ0s7R0FDQTtHQUNBOzs7RUFHSDtJQUNFLEtBQUc7TUFDRDtJQUNGO0VBQ0Y7O0FBRUY7RUFDRTtFQUNBLEtBQUc7SUFDRCxnQkFBaUI7O0VBRW5CO0VBQ0E7O0VBRUE7RUFDQSxPQUFRO0VBQ1IsT0FBUTtFQUNSOztBQUVGO0VBQ0U7RUFDQTtFQUNBO0VBQ0E7RUFDQTs7OzsifQ== |
@@ -9,2 +9,5 @@ function hex_to_u8(hex) { | ||
function u8_to_hex(u8, sep) { | ||
if (undefined === u8.buffer) { | ||
u8 = new Uint8Array(u8);} | ||
return Array | ||
@@ -17,2 +20,4 @@ .from(u8, v => v.toString(16).padStart(2, '0')) | ||
for (const b of parts) { | ||
if (! b.byteLength) { | ||
console.log("WA?", b, parts); } | ||
len += b.byteLength;} | ||
@@ -69,3 +74,3 @@ | ||
node.hex = u8_to_hex(content, ' '); | ||
//node.hex = u8_to_hex @ content, ' ' | ||
@@ -82,4 +87,15 @@ yield node;} } | ||
, parse_parts() { | ||
return 0x20 & this.id | ||
, hex() {return u8_to_hex(this.content)} | ||
, dbg() {return `id: ${this.id} len: ${this.byteLength} hex: ${this.hex()}`} | ||
, [Symbol.iterator]() {return this.iter_parts()} | ||
, iter_parts(override) { | ||
if (0x20 & this.id || override) { | ||
return asn1_u8_decode_many(this.content)} | ||
else throw new Error('Not a contructed ASN1 node') } | ||
, first_part(override) { | ||
return asn1_u8_decode(this.content)} | ||
, parse_parts(override) { | ||
return 0x20 & this.id || override | ||
? Array.from(asn1_u8_decode_many(this.content)) | ||
@@ -95,2 +111,5 @@ : null} | ||
, *iter_walk(visitor) { | ||
if (true === visitor) { | ||
console.log(this.dbg()); } | ||
let parts = null; | ||
@@ -102,3 +121,3 @@ if (0x20 & this.id) { | ||
if (visitor) { | ||
if ('function' === typeof visitor) { | ||
return visitor(this, parts) } | ||
@@ -124,4 +143,2 @@ else { | ||
function asn1_u8_encode(content_tree) { | ||
const is_lst = Array.isArray(content_tree); | ||
const all_parts = []; | ||
@@ -132,2 +149,7 @@ encode_next(content_tree); | ||
function encode_next(content_tree) { | ||
if (content_tree.byteLength) { | ||
all_parts.push(content_tree); | ||
return content_tree.byteLength} | ||
const is_lst = Array.isArray(content_tree); | ||
const ident = is_lst ? content_tree[0] : content_tree.id; | ||
@@ -141,2 +163,3 @@ const id = ident | 0; | ||
if (! Number.isInteger(ident) || 0 > ident || ident > 255) { | ||
console.log({ident, content_tree}); | ||
throw new Error('Invalid ASN1 identifier') } | ||
@@ -167,6 +190,6 @@ | ||
else { | ||
let octects = 0; | ||
while (0 !== byteLength) { | ||
hdr.push(byteLength & 0xff); | ||
byteLength >>>= 8; | ||
let octects = 0, oct_len = byteLength; | ||
while (0 !== oct_len) { | ||
hdr.push(oct_len & 0xff); | ||
oct_len >>>= 8; | ||
octects ++;} | ||
@@ -179,7 +202,5 @@ hdr[1] = 0x80 | octects;} | ||
const u8_zero = new Uint8Array([0]); | ||
function asn1_der_positive_int(v) { | ||
if (0x80 & v[0]) { | ||
return u8_concat([u8_zero, v]) } | ||
return u8_concat([new Uint8Array([0]), v]) } | ||
@@ -203,3 +224,3 @@ if (0 !== v[0]) {return v} | ||
function pack_ecdsa_asn1({r, s}) { | ||
function encode_ecdsa_asn1({r, s}) { | ||
return asn1_u8_encode([ | ||
@@ -210,3 +231,3 @@ 0x30, // sequence | ||
function unpack_ecdsa_asn1(ecdsa_asn1) { | ||
function decode_ecdsa_asn1(ecdsa_asn1) { | ||
const node = asn1_u8_decode(ecdsa_asn1); | ||
@@ -228,3 +249,3 @@ const [r_node, s_node] = node.parse_parts(); | ||
function pack_ecdsa_raw({r, s}) { | ||
function encode_ecdsa_raw({r, s}) { | ||
const len_part = ecdsa_raw_len[r.byteLength]; | ||
@@ -242,3 +263,3 @@ if (! len_part) { | ||
function unpack_ecdsa_raw(ecdsa_raw) { | ||
function decode_ecdsa_raw(ecdsa_raw) { | ||
const u8 = new Uint8Array(ecdsa_raw.buffer || ecdsa_raw); | ||
@@ -250,3 +271,3 @@ const n = u8.byteLength >>> 1; | ||
export { asn1_u8_decode, asn1_u8_decode_many, asn1_node, asn1_identifiers_byTag, with_asn1_identifiers, asn1_u8_encode, asn1_der_positive_int, compact_positive_int, hex_to_u8, u8_to_hex, u8_concat, pack_ecdsa_asn1, unpack_ecdsa_asn1, pack_ecdsa_raw, unpack_ecdsa_raw }; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguYWxsLmpzIiwic291cmNlcyI6WyIuLi9jb2RlL3U4X3V0aWxzLmpzeSIsIi4uL2NvZGUvYXNuMV9kZWNvZGUuanN5IiwiLi4vY29kZS9hc24xX2VuY29kZS5qc3kiLCIuLi9jb2RlL2VjZHNhLmpzeSJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZnVuY3Rpb24gaGV4X3RvX3U4KGhleCkgOjpcbiAgaGV4ID0gaGV4LnJlcGxhY2UoL1teMC05YS1mQS1GXS9nLCAnJylcbiAgY29uc3QgdTggPSBuZXcgVWludDhBcnJheShoZXgubGVuZ3RoID4+IDEpXG4gIGZvciBsZXQgaT0wLCBpMj0wOyBpPHU4Lmxlbmd0aDsgaSsrLCBpMis9MiA6OlxuICAgIHU4W2ldID0gcGFyc2VJbnQgQCBoZXguc2xpY2UoaTIsIGkyKzIpLCAxNlxuICByZXR1cm4gdThcblxuZXhwb3J0IGZ1bmN0aW9uIHU4X3RvX2hleCh1OC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LGFBQWM7O0VBRWhCLEtBQUc7SUFDRDtJQUNBLElBQUU7TUFDQSxJQUFFLFdBQVk7TUFDZDs7QUFFTjtFQUNFLElBQUU7SUFDQTs7RUFFRixJQUFFO0lBQ0E7O0VBRUYsZ0JBQWlCOzs7RUN4RWpCO0lBQ0U7S0FDRztLQUNBOztBQUVQO0VBQ0UsNEJBQTZCO0VBQzdCO0VBQ0EsUUFBVTs7QUFFWjtHQUNLO0dBQ0E7R0FDQTs7O0VBR0g7SUFDRSxLQUFHO01BQ0Q7SUFDRjtFQUNGOztBQUVGO0VBQ0U7RUFDQSxLQUFHO0lBQ0QsZ0JBQWlCOztFQUVuQjtFQUNBOztFQUVBO0VBQ0EsT0FBUTtFQUNSLE9BQVE7RUFDUjs7QUFFRjtFQUNFO0VBQ0E7RUFDQTtFQUNBO0VBQ0E7Ozs7In0= | ||
export { asn1_u8_decode, asn1_u8_decode_many, asn1_node, asn1_identifiers_byTag, with_asn1_identifiers, asn1_u8_encode, hex_to_u8, u8_to_hex, u8_concat, encode_ecdsa_asn1, decode_ecdsa_asn1, encode_ecdsa_raw, decode_ecdsa_raw }; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguYWxsLmpzIiwic291cmNlcyI6WyIuLi9jb2RlL3U4X3V0aWxzLmpzeSIsIi4uL2NvZGUvYXNuMV9kZWNvZGUuanN5IiwiLi4vY29kZS9hc24xX2VuY29kZS5qc3kiLCIuLi9jb2RlL2FzbjFfcG9zaXRpdmVfaW50LmpzeSIsIi4uL2NvZGUvZWNkc2EuanN5Il0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBmdW5jdGlvbiBoZXhfdG9fdTgoaGV4KSA6OlxuICBoZXggPSBoZXgucmVwbGFjZSgvW14wLTlhLWZBLUZdL2csICcnKVxuICBjb25zdCB1OCA9IG5ldyBVaW50OEFycmF5KGhleC5sZW5ndGggPj4gMSlcbiAgZm9yIGxldCBp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return Array | ||
@@ -17,2 +20,4 @@ .from(u8, v => v.toString(16).padStart(2, '0')) | ||
for (const b of parts) { | ||
if (! b.byteLength) { | ||
console.log("WA?", b, parts); } | ||
len += b.byteLength;} | ||
@@ -69,3 +74,3 @@ | ||
node.hex = u8_to_hex(content, ' '); | ||
//node.hex = u8_to_hex @ content, ' ' | ||
@@ -82,4 +87,15 @@ yield node;} } | ||
, parse_parts() { | ||
return 0x20 & this.id | ||
, hex() {return u8_to_hex(this.content)} | ||
, dbg() {return `id: ${this.id} len: ${this.byteLength} hex: ${this.hex()}`} | ||
, [Symbol.iterator]() {return this.iter_parts()} | ||
, iter_parts(override) { | ||
if (0x20 & this.id || override) { | ||
return asn1_u8_decode_many(this.content)} | ||
else throw new Error('Not a contructed ASN1 node') } | ||
, first_part(override) { | ||
return asn1_u8_decode(this.content)} | ||
, parse_parts(override) { | ||
return 0x20 & this.id || override | ||
? Array.from(asn1_u8_decode_many(this.content)) | ||
@@ -95,2 +111,5 @@ : null} | ||
, *iter_walk(visitor) { | ||
if (true === visitor) { | ||
console.log(this.dbg()); } | ||
let parts = null; | ||
@@ -102,3 +121,3 @@ if (0x20 & this.id) { | ||
if (visitor) { | ||
if ('function' === typeof visitor) { | ||
return visitor(this, parts) } | ||
@@ -124,4 +143,2 @@ else { | ||
function asn1_u8_encode(content_tree) { | ||
const is_lst = Array.isArray(content_tree); | ||
const all_parts = []; | ||
@@ -132,2 +149,7 @@ encode_next(content_tree); | ||
function encode_next(content_tree) { | ||
if (content_tree.byteLength) { | ||
all_parts.push(content_tree); | ||
return content_tree.byteLength} | ||
const is_lst = Array.isArray(content_tree); | ||
const ident = is_lst ? content_tree[0] : content_tree.id; | ||
@@ -141,2 +163,3 @@ const id = ident | 0; | ||
if (! Number.isInteger(ident) || 0 > ident || ident > 255) { | ||
console.log({ident, content_tree}); | ||
throw new Error('Invalid ASN1 identifier') } | ||
@@ -167,6 +190,6 @@ | ||
else { | ||
let octects = 0; | ||
while (0 !== byteLength) { | ||
hdr.push(byteLength & 0xff); | ||
byteLength >>>= 8; | ||
let octects = 0, oct_len = byteLength; | ||
while (0 !== oct_len) { | ||
hdr.push(oct_len & 0xff); | ||
oct_len >>>= 8; | ||
octects ++;} | ||
@@ -179,25 +202,2 @@ hdr[1] = 0x80 | octects;} | ||
const u8_zero = new Uint8Array([0]); | ||
function asn1_der_positive_int(v) { | ||
if (0x80 & v[0]) { | ||
return u8_concat([u8_zero, v]) } | ||
if (0 !== v[0]) {return v} | ||
for (let i=1; i < v.byteLength; i++) { | ||
const b = v[i]; | ||
if (0 !== b) { | ||
if (0x80 & b) {i--;} | ||
return v.subarray(i)} } } | ||
function compact_positive_int(v, len) { | ||
if (v.byteLength <= len) { | ||
return v} | ||
if (0 === v[0] && 0x80 & v[1]) { | ||
return v.subarray(1)} | ||
throw new Error('Unexpected integer construction') } | ||
function utf8_to_u8(utf8) { | ||
@@ -212,6 +212,10 @@ return Uint8Array.from(Buffer.from(utf8, 'utf-8')) } | ||
function u8_to_base64url(u8) { | ||
return u8_to_base64(u8) | ||
.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '')} | ||
function base64_to_u8(str_b64) { | ||
return Uint8Array.from(Buffer.from(str_b64, 'base64')) } | ||
export { asn1_u8_decode, asn1_u8_decode_many, asn1_node, asn1_identifiers_byTag, with_asn1_identifiers, asn1_u8_encode, asn1_der_positive_int, compact_positive_int, utf8_to_u8, u8_to_utf8, u8_to_base64, base64_to_u8, hex_to_u8, u8_to_hex, u8_concat }; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VzIjpbIi4uL2NvZGUvdThfdXRpbHMuanN5IiwiLi4vY29kZS9hc24xX2RlY29kZS5qc3kiLCIuLi9jb2RlL2FzbjFfZW5jb2RlLmpzeSIsIi4uL2NvZGUvbm9kZWpzL3U4X3V0aWxzLmpzeSJdLCJzb3VyY2VzQ29udGVudCI6WyJleH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lBQ0E7OztBQUdKO0FBQ0E7RUFDRSxJQUFFO0lBQ0Esa0JBQW1COztFQUVyQixJQUFFLGFBQWM7O0VBRWhCLEtBQUc7SUFDRDtJQUNBLElBQUU7TUFDQSxJQUFFLFdBQVk7TUFDZDs7QUFFTjtFQUNFLElBQUU7SUFDQTs7RUFFRixJQUFFO0lBQ0E7O0VBRUYsZ0JBQWlCOzs7RUN6RWpCLHVCQUF3QixrQkFBbUIsT0FBTzs7QUFFcEQ7RUFDRSxnQ0FBZ0MsT0FBTzs7QUFFekM7RUFDRSxnQ0FBZ0MsUUFBUTs7QUFFMUM7RUFDRSx1QkFBd0IscUJBQXNCLFFBQVE7Ozs7In0= | ||
export { asn1_u8_decode, asn1_u8_decode_many, asn1_node, asn1_identifiers_byTag, with_asn1_identifiers, asn1_u8_encode, utf8_to_u8, u8_to_utf8, u8_to_base64, u8_to_base64url, base64_to_u8, hex_to_u8, u8_to_hex, u8_concat }; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VzIjpbIi4uL2NvZGUvdThfdXRpbHMuanN5IiwiLi4vY29kZS9hc24xX2RlY29kZS5qc3kiLCIuLi9jb2RlL2FzbjFfZW5jb2RlLmpzeSIsIi4uL2NvZGUvbm9kZWpzL3U4X3V0aWxzLmpzeSJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZnVuY3Rpb24gaGV4X3RvX3U4KGhleCkgOjpcbiAgaGV4ID0gaGV4LnJlcGxhY2UoL1teMC05YS1mQS1GXS9nLCAnJylcbiAgY29uc3QgdTggPSBuZXcgVWludDhBcnJheShoZXgubGVuZ3RoID4+IDEpXG4gIGZvciBsZXQgaT0wLCBpMj0wOyBpPHU4Lmxlbmd0aDsgaSsrLCBpMis9MiA6OlxuICAgIHU4W2ldID0gcGFyc2VJbnQgQCBoZXguc2xpY2UoaTIsIGkyKzIpLCAxNlxuICByZXR1cm4gdTh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sZUFBZSxFQUFFLGVBQWUsRUFBRSxlQUFlO0VBQ3BFLGlCQUFpQixFQUFFLGtCQUFrQixFQUFFLFdBQVc7O0FBRXBEO0VBQ0UsaUJBQWtCO0lBQ2hCOzs7RUNyR0Y7RUFDQTtFQUNBLGlCQUFrQjs7RUFFbEI7SUFDRSxJQUFFO01BQ0E7TUFDQTs7SUFFRjtJQUNBO0lBQ0E7SUFDQTs7SUFFQTtJQUNBOztJQUVBLEtBQUc7TUFDRCxhQUFjO01BQ2QsZ0JBQWlCOztJQUVuQixJQUFFO01BQ0E7Ozs7TUFJQSxJQUFFO1FBQ0EsZ0JBQWlCOztNQUVuQixLQUFHO1FBQ0Q7OztNQUdGO01BQ0EsZUFBZ0I7TUFDaEI7O01BRUEsSUFBRTtRQUNBLGdCQUFpQjs7O0lBR3JCLElBQUU7TUFDQTs7TUFFQTtNQUNBLE9BQUs7UUFDSCxTQUFVO1FBQ1Y7UUFDQTtNQUNGOztJQUVGO0lBQ0E7SUFDQTs7O0VDdERGLHVCQUF3QixrQkFBbUIsT0FBTzs7QUFFcEQ7RUFDRSxnQ0FBZ0MsT0FBTzs7QUFFekM7RUFDRSxnQ0FBZ0MsUUFBUTs7QUFFMUM7RUFDRTthQUNXLEtBQUssRUFBRSxHQUFHLFVBQVUsS0FBSyxFQUFFLEdBQUcsVUFBVSxJQUFJLEVBQUUsRUFBRTs7QUFFN0Q7RUFDRSx1QkFBd0IscUJBQXNCLFFBQVE7Ozs7In0= |
@@ -9,2 +9,5 @@ function hex_to_u8(hex) { | ||
function u8_to_hex(u8, sep) { | ||
if (undefined === u8.buffer) { | ||
u8 = new Uint8Array(u8);} | ||
return Array | ||
@@ -17,2 +20,4 @@ .from(u8, v => v.toString(16).padStart(2, '0')) | ||
for (const b of parts) { | ||
if (! b.byteLength) { | ||
console.log("WA?", b, parts); } | ||
len += b.byteLength;} | ||
@@ -38,6 +43,10 @@ | ||
function u8_to_base64url(u8) { | ||
return u8_to_base64(u8) | ||
.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '')} | ||
function base64_to_u8(str_b64) { | ||
return Uint8Array.from(Buffer.from(str_b64, 'base64')) } | ||
export { utf8_to_u8, u8_to_utf8, u8_to_base64, base64_to_u8, hex_to_u8, u8_to_hex, u8_concat }; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidThfdXRpbHMuanMiLCJzb3VyY2VzIjpbIi4uLy4uL2NvZGUvdThfdXRpbHMuanN5IiwiLi4vLi4vY29kZS9ub2RlanMvdThfdXRpbHMuanN5Il0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBmdW5jdGlvbiBoZXhfdG9fdTgoaGV4KSA6OlxuICBoZXggPSBoZXgucmVwbGFjZSgvW14wLTlhLWZBLUZdL2csICcnKVxuICBjb25zdCB1OCA9IG5ldyBVaW50OEFycmF5KGhleC5sZW5ndGggPj4gMSlcbiAgZm9yIGxldCBpPTAsIGkyPTA7IGk8dTgubGVuZ3RoOyBpKyssIGkyKz0yIDo6XG4gICAgdThbaV0gPSBwYXJzZUludCBAIGhleC5zbGljZShpMiwgaTIrMiksIDE2XG4gIHJldHVybiB1OFxuXG5leHBvcnQgZnVuY3Rpb24gdThfdG9faGV4KHU4LCBzZXApIDo6XG4gIHJldHVybiBBcnJheVxuICAgIC5mcm9tIEAgdTgsIHYgPT4gdi50b1N0cmluZygxNikucGFkU3RhcnQoMiwgJzAnKVxuICAgIC5qb2luIEAgbnVsbCAhPSBzZXAgPyBzZXAgOiAnJ1xuXG5leHBvcnQgZnVuY3Rpb24gdThfY29uY2F0KHBhcnRzKSA6OlxuICBsZXQgaT0wLCBsZW49MFxuICBmb3IgY29uc3QgYiBvZiBwYXJ0cyA6OlxuICAgIGxlbiArPSBiLmJ5dGVMZW5ndGhcblxuICBjb25zdCB1OCA9IG5ldyBVaW50OEFycmF5KGxlbilcbiAgZm9yIGNvbnN0IHU4X3BhcnQgb2YgcGFydHMgOjpcbi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VBQ0Y7OztFQ3JCQSx1QkFBd0Isa0JBQW1CLE9BQU87O0FBRXBEO0VBQ0UsZ0NBQWdDLE9BQU87O0FBRXpDO0VBQ0UsZ0NBQWdDLFFBQVE7O0FBRTFDO0VBQ0UsdUJBQXdCLHFCQUFzQixRQUFROzs7OyJ9 | ||
export { utf8_to_u8, u8_to_utf8, u8_to_base64, u8_to_base64url, base64_to_u8, hex_to_u8, u8_to_hex, u8_concat }; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidThfdXRpbHMuanMiLCJzb3VyY2VzIjpbIi4uLy4uL2NvZGUvdThfdXRpbHMuanN5IiwiLi4vLi4vY29kZS9ub2RlanMvdThfdXRpbHMuanN5Il0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBmdW5jdGlvbiBoZXhfdG9fdTgoaGV4KSA6OlxuICBoZXggPSBoZXgucmVwbGFjZSgvW14wLTlhLWZBLUZdL2csICcnKVxuICBjb25zdCB1OCA9IG5ldyBVaW50OEFycmF5KGhleC5sZW5ndGggPj4gMSlcbiAgZm9yIGxldCBpPTAsIGkyPTA7IGk8dTgubGVuZ3RoOyBpKyssIGkyKz0yIDo6XG4gICAgdThbaV0gPSBwYXJzZUludCBAIGhleC5zbGljZShpMiwgaTIrMiksIDE2XG4gIHJldHVybiB1OFxuXG5leHBvcnQgZnVuY3Rpb24gdThfdG9faGV4KHU4LCBzZXApIDo6XG4gIGlmIHVuZGVmaW5lZCA9PT0gdTguYnVmZmVyIDo6XG4gICAgdTggPSBuZXcgVWludDhBcnJheSh1OClcblxuICByZXR1cm4gQXJyYXlcbiAgICAuZnJvbSBAIHU4LCB2ID0+IHYudG9TdHJpbmcoMTYpLnBhZFN0YXJ0KDIsICcwJylcbiAgICAuam9pbiBAIG51bGwgIT0gc2VwID8gc2VwIDogJydcblxuZXhwb3J0IGZ1bmN0aW9uIHU4X2NvbmNhdChwYXJ0cykgOjpcbiAgbGV0IGk9M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ZXhwb3J0IGZ1bmN0aW9uIGJhc2U2NF90b191OChzdHJfYjY0KSA6OlxuICByZXR1cm4gVWludDhBcnJheS5mcm9tIEAgQnVmZmVyLmZyb20oc3RyX2I2NCwgJ2Jhc2U2NCcpXG5cblxuIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7RUFDRSxrQkFBa0IsZUFBZSxFQUFFLEVBQUU7RUFDckM7RUFDQSxLQUFHO0lBQ0QsaUJBQWtCO0VBQ3BCOztBQUVGO0VBQ0UsSUFBRTtJQUNBOztFQUVGO1VBQ1Msb0NBQXFDLEdBQUc7VUFDeEMsb0JBQXFCOztBQUVoQztFQUNFO0VBQ0EsS0FBRztJQUNELEtBQUc7TUFDRCxZQUFhLEtBQU07SUFDckI7O0VBRUY7RUFDQSxLQUFHO0lBQ0QsS0FBRztNQUNELGdCQUFpQjs7SUFFbkIsT0FBUTtJQUNSO0VBQ0Y7OztFQzFCQSx1QkFBd0Isa0JBQW1CLE9BQU87O0FBRXBEO0VBQ0UsZ0NBQWdDLE9BQU87O0FBRXpDO0VBQ0UsZ0NBQWdDLFFBQVE7O0FBRTFDO0VBQ0U7YUFDVyxLQUFLLEVBQUUsR0FBRyxVQUFVLEtBQUssRUFBRSxHQUFHLFVBQVUsSUFBSSxFQUFFLEVBQUU7O0FBRTdEO0VBQ0UsdUJBQXdCLHFCQUFzQixRQUFROzs7OyJ9 |
@@ -9,2 +9,5 @@ function hex_to_u8(hex) { | ||
function u8_to_hex(u8, sep) { | ||
if (undefined === u8.buffer) { | ||
u8 = new Uint8Array(u8);} | ||
return Array | ||
@@ -17,2 +20,4 @@ .from(u8, v => v.toString(16).padStart(2, '0')) | ||
for (const b of parts) { | ||
if (! b.byteLength) { | ||
console.log("WA?", b, parts); } | ||
len += b.byteLength;} | ||
@@ -30,2 +35,2 @@ | ||
export { hex_to_u8, u8_to_hex, u8_concat }; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWx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0IGk9MCwgbGVuPTBcbiAgZm9yIGNvbnN0IGIgb2YgcGFydHMgOjpcbiAgICBpZiAhIGIuYnl0ZUxlbmd0aCA6OlxuICAgICAgY29uc29sZS5sb2cgQCBcIldBP1wiLCBiLCBwYXJ0c1xuICAgIGxlbiArPSBiLmJ5dGVMZW5ndGhcblxuICBjb25zdCB1OCA9IG5ldyBVaW50OEFycmF5KGxlbilcbiAgZm9yIGNvbnN0IHU4X3BhcnQgb2YgcGFydHMgOjpcbiAgICBpZiAhICh1OF9wYXJ0LmJ1ZmZlciB8fCB1OF9wYXJ0KSBpbnN0YW5jZW9mIEFycmF5QnVmZmVyIDo6XG4gICAgICB0aHJvdyBuZXcgRXJyb3IgQCBcIkludmFsaWQgcGFydCBjb250ZW50XCJcblxuICAgIHU4LnNldCBAIHU4X3BhcnQsIGlcbiAgICBpICs9IHU4X3BhcnQuYnl0ZUxlbmd0aFxuICByZXR1cm4gdThcblxuXG4iXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtFQUNFLGtCQUFrQixlQUFlLEVBQUUsRUFBRTtFQUNyQztFQUNBLEtBQUc7SUFDRCxpQkFBa0I7RUFDcEI7O0FBRUY7RUFDRSxJQUFFO0lBQ0E7O0VBRUY7VUFDUyxvQ0FBcUMsR0FBRztVQUN4QyxvQkFBcUI7O0FBRWhDO0VBQ0U7RUFDQSxLQUFHO0lBQ0QsS0FBRztNQUNELFlBQWEsS0FBTTtJQUNyQjs7RUFFRjtFQUNBLEtBQUc7SUFDRCxLQUFHO01BQ0QsZ0JBQWlCOztJQUVuQixPQUFRO0lBQ1I7RUFDRjs7OzsifQ== |
@@ -9,2 +9,5 @@ function hex_to_u8(hex) { | ||
function u8_to_hex(u8, sep) { | ||
if (undefined === u8.buffer) { | ||
u8 = new Uint8Array(u8);} | ||
return Array | ||
@@ -17,2 +20,4 @@ .from(u8, v => v.toString(16).padStart(2, '0')) | ||
for (const b of parts) { | ||
if (! b.byteLength) { | ||
console.log("WA?", b, parts); } | ||
len += b.byteLength;} | ||
@@ -46,2 +51,6 @@ | ||
function u8_to_base64url(u8) { | ||
return u8_to_base64(u8) | ||
.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '')} | ||
const _charCodeAt = ''.charCodeAt; | ||
@@ -56,3 +65,3 @@ function base64_to_u8(str_b64) { | ||
export { utf8_to_u8, u8_to_utf8, u8_to_base64, base64_to_u8, hex_to_u8, u8_to_hex, u8_concat }; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidThfdXRpbHMuanMiLCJzb3VyY2VzIjpbIi4uLy4uL2NvZGUvdThfdXRpbHMuanN5IiwiLi4vLi4vY29kZS93ZWIvdThfdXRpbHMuanN5Il0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBmdW5jdGlvbiBoZXhfdG9fdTgoaGV4KSA6OlxuICBoZXggPSBoZXgucmVwbGFjZSgvW14wLTlhLWZBLUZdL2csICcnKVxuICBjb25zdCB1OCA9IG5ldyBVaW50OEFycmF5KGhleC5sZW5ndGggPj4gMSlcbiAgZm9yIGxldCBpPTAsIGkyPTA7IGk8dTgubGVuZ3RoOyBpKyssIGkyKz0yIDo6XG4gICAgdThbaV0gPSBwYXJzZUludCBAIGhleC5zbGljZShpMiwgaTIrMiksIDE2XG4gIHJldHVybiB1OFxuXG5leHBvcnQgZnVuY3Rpb24gdThfdG9faGV4KHU4LCBzZXApIDo6XG4gIHJldHVybiBBcnJheVxuICAgIC5mcm9tIEAgdTgsIHYgPT4gdi50b1N0cmluZygxNikucGFkU3RhcnQoMiwgJzAnKVxuICAgIC5qb2luIEAgbnVsbCAhPSBzZXAgPyBzZXAgOiAnJ1xuXG5leHBvcnQgZnVuY3Rpb24gdThfY29uY2F0KHBhcnRzKSA6OlxuICBsZXQgaT0wLCBsZW49MFxuICBmb3IgY29uc3QgYiBvZiBwYXJ0cyA6OlxuICAgIGxlbiArPSBiLmJ5dGVMZW5ndGhcblxuICBjb25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YjY0KSA6OlxuICBjb25zdCBzeiA9IGF0b2IgQCBzdHJfYjY0LnJlcGxhY2UoLy0vZywgJysnKS5yZXBsYWNlKC9fL2csICcvJylcbiAgY29uc3QgbGVuID0gc3oubGVuZ3RoXG4gIGNvbnN0IHJlcyA9IG5ldyBVaW50OEFycmF5KGxlbilcbiAgZm9yIGxldCBpPTA7IGk8bGVuOyBpKysgOjpcbiAgICByZXNbaV0gPSBfY2hhckNvZGVBdC5jYWxsKHN6LCBpKVxuICByZXR1cm4gcmVzXG5cbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0VBQ0Usa0JBQWtCLGVBQWUsRUFBRSxFQUFFO0VBQ3JDO0VBQ0EsS0FBRztJQUNELGlCQUFrQjtFQUNwQjs7QUFFRjtFQUNFO1VBQ1Msb0NBQXFDLEdBQUc7VUFDeEMsb0JBQXFCOztBQUVoQztFQUNFO0VBQ0EsS0FBRztJQUNEOztFQUVGO0VBQ0EsS0FBRztJQUNELEtBQUc7TUFDRCxnQkFBaUI7O0lBRW5CLE9BQVE7SUFDUjtFQUNGOzs7RUNyQkEsdUJBQXVCLE9BQU8sU0FBVSxlQUFnQixNQUFNOztBQUVoRTtFQUNFLHVCQUF1QixPQUFPLFNBQVU7O0FBRTFDO0FBQ0E7RUFDRSxJQUFFO0lBQ0E7O0VBRUYsUUFBUTtFQUNSO0VBQ0EsS0FBRztJQUNEO0VBQ0Y7O0FBRUYsb0JBQW9CLEVBQUU7QUFDdEI7RUFDRSxnQkFBaUIsZ0JBQWlCLElBQUksRUFBRSxHQUFHLFVBQVUsSUFBSSxFQUFFLEdBQUc7RUFDOUQ7RUFDQTtFQUNBLEtBQUc7SUFDRDtFQUNGOzs7OyJ9 | ||
export { utf8_to_u8, u8_to_utf8, u8_to_base64, u8_to_base64url, base64_to_u8, hex_to_u8, u8_to_hex, u8_concat }; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidThfdXRp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FDOUQ7RUFDQTtFQUNBLEtBQUc7SUFDRDtFQUNGOzs7OyJ9 |
{ | ||
"name": "asn1-codec", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "ASN1 Codec for NodeJS and the Web", | ||
@@ -5,0 +5,0 @@ "license": "BSD-2-Clause", |
@@ -15,2 +15,5 @@ (function (global, factory) { | ||
function u8_to_hex(u8, sep) { | ||
if (undefined === u8.buffer) { | ||
u8 = new Uint8Array(u8);} | ||
return Array | ||
@@ -23,2 +26,4 @@ .from(u8, v => v.toString(16).padStart(2, '0')) | ||
for (const b of parts) { | ||
if (! b.byteLength) { | ||
console.log("WA?", b, parts); } | ||
len += b.byteLength;} | ||
@@ -75,3 +80,3 @@ | ||
node.hex = u8_to_hex(content, ' '); | ||
//node.hex = u8_to_hex @ content, ' ' | ||
@@ -88,4 +93,15 @@ yield node;} } | ||
, parse_parts() { | ||
return 0x20 & this.id | ||
, hex() {return u8_to_hex(this.content)} | ||
, dbg() {return `id: ${this.id} len: ${this.byteLength} hex: ${this.hex()}`} | ||
, [Symbol.iterator]() {return this.iter_parts()} | ||
, iter_parts(override) { | ||
if (0x20 & this.id || override) { | ||
return asn1_u8_decode_many(this.content)} | ||
else throw new Error('Not a contructed ASN1 node') } | ||
, first_part(override) { | ||
return asn1_u8_decode(this.content)} | ||
, parse_parts(override) { | ||
return 0x20 & this.id || override | ||
? Array.from(asn1_u8_decode_many(this.content)) | ||
@@ -101,2 +117,5 @@ : null} | ||
, *iter_walk(visitor) { | ||
if (true === visitor) { | ||
console.log(this.dbg()); } | ||
let parts = null; | ||
@@ -108,3 +127,3 @@ if (0x20 & this.id) { | ||
if (visitor) { | ||
if ('function' === typeof visitor) { | ||
return visitor(this, parts) } | ||
@@ -130,4 +149,2 @@ else { | ||
function asn1_u8_encode(content_tree) { | ||
const is_lst = Array.isArray(content_tree); | ||
const all_parts = []; | ||
@@ -138,2 +155,7 @@ encode_next(content_tree); | ||
function encode_next(content_tree) { | ||
if (content_tree.byteLength) { | ||
all_parts.push(content_tree); | ||
return content_tree.byteLength} | ||
const is_lst = Array.isArray(content_tree); | ||
const ident = is_lst ? content_tree[0] : content_tree.id; | ||
@@ -147,2 +169,3 @@ const id = ident | 0; | ||
if (! Number.isInteger(ident) || 0 > ident || ident > 255) { | ||
console.log({ident, content_tree}); | ||
throw new Error('Invalid ASN1 identifier') } | ||
@@ -173,6 +196,6 @@ | ||
else { | ||
let octects = 0; | ||
while (0 !== byteLength) { | ||
hdr.push(byteLength & 0xff); | ||
byteLength >>>= 8; | ||
let octects = 0, oct_len = byteLength; | ||
while (0 !== oct_len) { | ||
hdr.push(oct_len & 0xff); | ||
oct_len >>>= 8; | ||
octects ++;} | ||
@@ -185,25 +208,2 @@ hdr[1] = 0x80 | octects;} | ||
const u8_zero = new Uint8Array([0]); | ||
function asn1_der_positive_int(v) { | ||
if (0x80 & v[0]) { | ||
return u8_concat([u8_zero, v]) } | ||
if (0 !== v[0]) {return v} | ||
for (let i=1; i < v.byteLength; i++) { | ||
const b = v[i]; | ||
if (0 !== b) { | ||
if (0x80 & b) {i--;} | ||
return v.subarray(i)} } } | ||
function compact_positive_int(v, len) { | ||
if (v.byteLength <= len) { | ||
return v} | ||
if (0 === v[0] && 0x80 & v[1]) { | ||
return v.subarray(1)} | ||
throw new Error('Unexpected integer construction') } | ||
function utf8_to_u8(utf8) { | ||
@@ -226,2 +226,6 @@ return new TextEncoder('utf-8').encode(utf8.normalize('NFKC')) } | ||
function u8_to_base64url(u8) { | ||
return u8_to_base64(u8) | ||
.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '')} | ||
const _charCodeAt = ''.charCodeAt; | ||
@@ -242,7 +246,6 @@ function base64_to_u8(str_b64) { | ||
exports.asn1_u8_encode = asn1_u8_encode; | ||
exports.asn1_der_positive_int = asn1_der_positive_int; | ||
exports.compact_positive_int = compact_positive_int; | ||
exports.utf8_to_u8 = utf8_to_u8; | ||
exports.u8_to_utf8 = u8_to_utf8; | ||
exports.u8_to_base64 = u8_to_base64; | ||
exports.u8_to_base64url = u8_to_base64url; | ||
exports.base64_to_u8 = base64_to_u8; | ||
@@ -256,2 +259,2 @@ exports.hex_to_u8 = hex_to_u8; | ||
}))); | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXNuMV9jb2RlYy5kYmcuanMiLCJzb3VyY2VzIjpbIi4uL2NvZGUvdThfdXRpbHMuanN5IiwiLi4vY29kZS9hc24xX2RlY29kZS5qc3kiLCIuLi9jb2RlL2FzbjFfZW5jb2RlLmpzeSIsIi4uL2NvZGUvd2ViL3U4X3V0aWxzLmpzeSJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZnVuY3Rpb24gaGV4X3RvX3U4KGhleCkgOjpcbiAgaGV4ID0gaGV4LnJlcGxhY2UoL1teMC05YS1mQS1GXS9nLCAnJylcbiAgY29uc3QgdTggPSBuZXcgVWludDhBcnJheShoZXgubGVuZ3RoID4+IDEpXG4gIGZvciBsZXQgaT0wLCBpMj0wOyBpPHU4Lmxlbmd0aDsgaSsrLCBpMis9MiA6OlxuICAgIHU4W2ldID0gcGFyc2VJbnQgQCBoZXguc2xpY2UoaTIsIGkyKzIpLCAxNlxuICByZXR1cm4gdThcblxuZXhwb3J0IGZ1bmN0aW9uIHU4X3RvX2hleCh1OCwgc2VwKSA6OlxuICByZXR1cm4gQXJyYXlcbiAgICAuZnJvbSBAIHU4LCB2ID0+IHYudG9TdHJpbmcoMTYpLnBhZFN0YXJ0KDIsICcwJylcbiAgICAuam9pbiBAIG51bGwgIT0gc2VwID8gc2VwIDogJydcblxuZXhwb3J0IGZ1bmN0aW9uIHU4X2NvbmNhdChwYXJ0cykgOjpcbiAgbGV0IGk9MCwgbGVuPTBcbiAgZm9yIGNvbnN0IGIgb2YgcGFydHMgOjpcbiAgICBsZW4gKz0gYi5ieXRlTGVuZ3RoXG5cbiAgY29uc3QgdTggPSBuZXcgVWludDhBcnJheShsZW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Ts7SUFFRixRQUFRO0lBQ1I7SUFDQSxLQUFHO01BQ0Q7SUFDRjs7QUFFRjtJQUNFO2VBQ1csS0FBSyxFQUFFLEdBQUcsVUFBVSxLQUFLLEVBQUUsR0FBRyxVQUFVLElBQUksRUFBRSxFQUFFOztFQUU3RCxvQkFBb0IsRUFBRTtBQUN0QjtJQUNFLGdCQUFpQixnQkFBaUIsSUFBSSxFQUFFLEdBQUcsVUFBVSxJQUFJLEVBQUUsR0FBRztJQUM5RDtJQUNBO0lBQ0EsS0FBRztNQUNEO0lBQ0Y7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7In0= |
@@ -15,2 +15,5 @@ (function (global, factory) { | ||
function u8_to_hex(u8, sep) { | ||
if (undefined === u8.buffer) { | ||
u8 = new Uint8Array(u8);} | ||
return Array | ||
@@ -23,2 +26,4 @@ .from(u8, v => v.toString(16).padStart(2, '0')) | ||
for (const b of parts) { | ||
if (! b.byteLength) { | ||
console.log("WA?", b, parts); } | ||
len += b.byteLength;} | ||
@@ -75,3 +80,3 @@ | ||
node.hex = u8_to_hex(content, ' '); | ||
//node.hex = u8_to_hex @ content, ' ' | ||
@@ -88,4 +93,15 @@ yield node;} } | ||
, parse_parts() { | ||
return 0x20 & this.id | ||
, hex() {return u8_to_hex(this.content)} | ||
, dbg() {return `id: ${this.id} len: ${this.byteLength} hex: ${this.hex()}`} | ||
, [Symbol.iterator]() {return this.iter_parts()} | ||
, iter_parts(override) { | ||
if (0x20 & this.id || override) { | ||
return asn1_u8_decode_many(this.content)} | ||
else throw new Error('Not a contructed ASN1 node') } | ||
, first_part(override) { | ||
return asn1_u8_decode(this.content)} | ||
, parse_parts(override) { | ||
return 0x20 & this.id || override | ||
? Array.from(asn1_u8_decode_many(this.content)) | ||
@@ -101,2 +117,5 @@ : null} | ||
, *iter_walk(visitor) { | ||
if (true === visitor) { | ||
console.log(this.dbg()); } | ||
let parts = null; | ||
@@ -108,3 +127,3 @@ if (0x20 & this.id) { | ||
if (visitor) { | ||
if ('function' === typeof visitor) { | ||
return visitor(this, parts) } | ||
@@ -130,4 +149,2 @@ else { | ||
function asn1_u8_encode(content_tree) { | ||
const is_lst = Array.isArray(content_tree); | ||
const all_parts = []; | ||
@@ -138,2 +155,7 @@ encode_next(content_tree); | ||
function encode_next(content_tree) { | ||
if (content_tree.byteLength) { | ||
all_parts.push(content_tree); | ||
return content_tree.byteLength} | ||
const is_lst = Array.isArray(content_tree); | ||
const ident = is_lst ? content_tree[0] : content_tree.id; | ||
@@ -147,2 +169,3 @@ const id = ident | 0; | ||
if (! Number.isInteger(ident) || 0 > ident || ident > 255) { | ||
console.log({ident, content_tree}); | ||
throw new Error('Invalid ASN1 identifier') } | ||
@@ -173,6 +196,6 @@ | ||
else { | ||
let octects = 0; | ||
while (0 !== byteLength) { | ||
hdr.push(byteLength & 0xff); | ||
byteLength >>>= 8; | ||
let octects = 0, oct_len = byteLength; | ||
while (0 !== oct_len) { | ||
hdr.push(oct_len & 0xff); | ||
oct_len >>>= 8; | ||
octects ++;} | ||
@@ -185,25 +208,2 @@ hdr[1] = 0x80 | octects;} | ||
const u8_zero = new Uint8Array([0]); | ||
function asn1_der_positive_int(v) { | ||
if (0x80 & v[0]) { | ||
return u8_concat([u8_zero, v]) } | ||
if (0 !== v[0]) {return v} | ||
for (let i=1; i < v.byteLength; i++) { | ||
const b = v[i]; | ||
if (0 !== b) { | ||
if (0x80 & b) {i--;} | ||
return v.subarray(i)} } } | ||
function compact_positive_int(v, len) { | ||
if (v.byteLength <= len) { | ||
return v} | ||
if (0 === v[0] && 0x80 & v[1]) { | ||
return v.subarray(1)} | ||
throw new Error('Unexpected integer construction') } | ||
function utf8_to_u8(utf8) { | ||
@@ -226,2 +226,6 @@ return new TextEncoder('utf-8').encode(utf8.normalize('NFKC')) } | ||
function u8_to_base64url(u8) { | ||
return u8_to_base64(u8) | ||
.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '')} | ||
const _charCodeAt = ''.charCodeAt; | ||
@@ -242,7 +246,6 @@ function base64_to_u8(str_b64) { | ||
exports.asn1_u8_encode = asn1_u8_encode; | ||
exports.asn1_der_positive_int = asn1_der_positive_int; | ||
exports.compact_positive_int = compact_positive_int; | ||
exports.utf8_to_u8 = utf8_to_u8; | ||
exports.u8_to_utf8 = u8_to_utf8; | ||
exports.u8_to_base64 = u8_to_base64; | ||
exports.u8_to_base64url = u8_to_base64url; | ||
exports.base64_to_u8 = base64_to_u8; | ||
@@ -249,0 +252,0 @@ exports.hex_to_u8 = hex_to_u8; |
@@ -8,2 +8,5 @@ (function (global, factory) { | ||
function u8_to_hex(u8, sep) { | ||
if (undefined === u8.buffer) { | ||
u8 = new Uint8Array(u8);} | ||
return Array | ||
@@ -53,3 +56,3 @@ .from(u8, v => v.toString(16).padStart(2, '0')) | ||
node.hex = u8_to_hex(content, ' '); | ||
//node.hex = u8_to_hex @ content, ' ' | ||
@@ -66,4 +69,15 @@ yield node;} } | ||
, parse_parts() { | ||
return 0x20 & this.id | ||
, hex() {return u8_to_hex(this.content)} | ||
, dbg() {return `id: ${this.id} len: ${this.byteLength} hex: ${this.hex()}`} | ||
, [Symbol.iterator]() {return this.iter_parts()} | ||
, iter_parts(override) { | ||
if (0x20 & this.id || override) { | ||
return asn1_u8_decode_many(this.content)} | ||
else throw new Error('Not a contructed ASN1 node') } | ||
, first_part(override) { | ||
return asn1_u8_decode(this.content)} | ||
, parse_parts(override) { | ||
return 0x20 & this.id || override | ||
? Array.from(asn1_u8_decode_many(this.content)) | ||
@@ -79,2 +93,5 @@ : null} | ||
, *iter_walk(visitor) { | ||
if (true === visitor) { | ||
console.log(this.dbg()); } | ||
let parts = null; | ||
@@ -86,3 +103,3 @@ if (0x20 & this.id) { | ||
if (visitor) { | ||
if ('function' === typeof visitor) { | ||
return visitor(this, parts) } | ||
@@ -117,2 +134,2 @@ else { | ||
}))); | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoi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FBWSxFQUFFLGNBQWMsRUFBRSxVQUFVLEVBQUUsVUFBVTtJQUNwRCxVQUFVLEVBQUUsS0FBSyxFQUFFLGVBQWUsRUFBRSxpQkFBaUI7SUFDckQsV0FBVyxFQUFFLGdCQUFnQixFQUFFLFdBQVcsRUFBRSxTQUFTO0lBQ3JELGlCQUFpQixFQUFFLGVBQWUsRUFBRSxlQUFlLEVBQUUsZUFBZTtJQUNwRSxpQkFBaUIsRUFBRSxrQkFBa0IsRUFBRSxXQUFXOztBQUVwRDtJQUNFLGlCQUFrQjtNQUNoQjs7Ozs7Ozs7Ozs7Ozs7Ozs7In0= |
@@ -8,2 +8,5 @@ (function (global, factory) { | ||
function u8_to_hex(u8, sep) { | ||
if (undefined === u8.buffer) { | ||
u8 = new Uint8Array(u8);} | ||
return Array | ||
@@ -53,3 +56,3 @@ .from(u8, v => v.toString(16).padStart(2, '0')) | ||
node.hex = u8_to_hex(content, ' '); | ||
//node.hex = u8_to_hex @ content, ' ' | ||
@@ -66,4 +69,15 @@ yield node;} } | ||
, parse_parts() { | ||
return 0x20 & this.id | ||
, hex() {return u8_to_hex(this.content)} | ||
, dbg() {return `id: ${this.id} len: ${this.byteLength} hex: ${this.hex()}`} | ||
, [Symbol.iterator]() {return this.iter_parts()} | ||
, iter_parts(override) { | ||
if (0x20 & this.id || override) { | ||
return asn1_u8_decode_many(this.content)} | ||
else throw new Error('Not a contructed ASN1 node') } | ||
, first_part(override) { | ||
return asn1_u8_decode(this.content)} | ||
, parse_parts(override) { | ||
return 0x20 & this.id || override | ||
? Array.from(asn1_u8_decode_many(this.content)) | ||
@@ -79,2 +93,5 @@ : null} | ||
, *iter_walk(visitor) { | ||
if (true === visitor) { | ||
console.log(this.dbg()); } | ||
let parts = null; | ||
@@ -86,3 +103,3 @@ if (0x20 & this.id) { | ||
if (visitor) { | ||
if ('function' === typeof visitor) { | ||
return visitor(this, parts) } | ||
@@ -89,0 +106,0 @@ else { |
@@ -10,2 +10,4 @@ (function (global, factory) { | ||
for (const b of parts) { | ||
if (! b.byteLength) { | ||
console.log("WA?", b, parts); } | ||
len += b.byteLength;} | ||
@@ -23,4 +25,2 @@ | ||
function asn1_u8_encode(content_tree) { | ||
const is_lst = Array.isArray(content_tree); | ||
const all_parts = []; | ||
@@ -31,2 +31,7 @@ encode_next(content_tree); | ||
function encode_next(content_tree) { | ||
if (content_tree.byteLength) { | ||
all_parts.push(content_tree); | ||
return content_tree.byteLength} | ||
const is_lst = Array.isArray(content_tree); | ||
const ident = is_lst ? content_tree[0] : content_tree.id; | ||
@@ -40,2 +45,3 @@ const id = ident | 0; | ||
if (! Number.isInteger(ident) || 0 > ident || ident > 255) { | ||
console.log({ident, content_tree}); | ||
throw new Error('Invalid ASN1 identifier') } | ||
@@ -66,6 +72,6 @@ | ||
else { | ||
let octects = 0; | ||
while (0 !== byteLength) { | ||
hdr.push(byteLength & 0xff); | ||
byteLength >>>= 8; | ||
let octects = 0, oct_len = byteLength; | ||
while (0 !== oct_len) { | ||
hdr.push(oct_len & 0xff); | ||
oct_len >>>= 8; | ||
octects ++;} | ||
@@ -78,29 +84,4 @@ hdr[1] = 0x80 | octects;} | ||
const u8_zero = new Uint8Array([0]); | ||
function asn1_der_positive_int(v) { | ||
if (0x80 & v[0]) { | ||
return u8_concat([u8_zero, v]) } | ||
if (0 !== v[0]) {return v} | ||
for (let i=1; i < v.byteLength; i++) { | ||
const b = v[i]; | ||
if (0 !== b) { | ||
if (0x80 & b) {i--;} | ||
return v.subarray(i)} } } | ||
function compact_positive_int(v, len) { | ||
if (v.byteLength <= len) { | ||
return v} | ||
if (0 === v[0] && 0x80 & v[1]) { | ||
return v.subarray(1)} | ||
throw new Error('Unexpected integer construction') } | ||
exports.default = asn1_u8_encode; | ||
exports.asn1_u8_encode = asn1_u8_encode; | ||
exports.asn1_der_positive_int = asn1_der_positive_int; | ||
exports.compact_positive_int = compact_positive_int; | ||
@@ -110,2 +91,2 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXNuMV9lbmNvZGUuZGJnLmpzIiwic291cmNlcyI6WyIuLi9jb2RlL3U4X3V0aWxzLmpzeSIsIi4uL2NvZGUvYXNuMV9lbmNvZGUuanN5Il0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBmdW5jdGlvbiBoZXhfdG9fdTgoaGV4KSA6OlxuICBoZXggPSBoZXgucmVwbGFjZSgvW14wLTlhLWZBLUZdL2csICcnKVxuICBjb25zdCB1OCA9IG5ldyBVaW50OEFycmF5KGhleC5sZW5ndGggPj4gMSlcbiAgZm9yIGxldCBpPTAsIGkyPTA7IGk8dTgubGVuZ3RoOyBpKyssIGkyKz0yIDo6XG4gICAgdThbaV0gPSBwYXJzZUludCBAIGhleC5zbGljZShpMiwgaTIrMiksIDE2XG4gIHJldHVybiB1OFxuXG5leHBvcnQgZnVuY3Rpb24gdThfdG9faGV4KHU4LCBzZXApIDo6XG4gIHJldHVybiBBcnJheVxuICAgIC5mcm9tIEAgdTgsIHYgPT4gdi50b1N0cmluZygxNikucGFkU3RhcnQoMiwgJzAnKVxuICAgIC5qb2luIEAgbnVsbCAhPSBzZXAgPyBzZXAgOiAnJ1xuXG5leHBvcnQgZnVuY3Rpb24gdThfY29uY2F0KHBhcnRzKSA6OlxuICBsZXQgaT0wLCBsZW49MFxuICBmb3IgY29uc3QgYiBvZiBwYXJ0cyA6OlxuICAgIGxlbiArPSBiLmJ5dGVMZW5ndGhcblxuICBjb25zdCB1OCA9IG5ldyBVaW50OEFycmF5KGxlbilcbiAgZm9yIGNvbnN0IHU4X3BhcnQgb2YgcGFydHMgOjpcbiAgICBpZiAhICh1OF9wYXJ0LmJ1ZmZlciB8fCB1OF9wYXJ0KSBpbnN0YW5jZW9mIEFycmF5QnVmZmVyIDo6XG4gICAgICB0aHJvdyBuZXcgRXJyb3IgQCBcIkludmFsaWQgcGFydCBjb250ZW50XCJcblx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RQUdGO1FBQ0EsZUFBZ0I7UUFDaEI7O1FBRUEsSUFBRTtVQUNBLGdCQUFpQjs7O01BR3JCLElBQUU7UUFDQTs7UUFFQTtRQUNBLE9BQUs7VUFDSCxTQUFVO1VBQ1Y7VUFDQTtRQUNGOztNQUVGO01BQ0E7TUFDQTs7Ozs7Ozs7Ozs7OzsifQ== |
@@ -10,2 +10,4 @@ (function (global, factory) { | ||
for (const b of parts) { | ||
if (! b.byteLength) { | ||
console.log("WA?", b, parts); } | ||
len += b.byteLength;} | ||
@@ -23,4 +25,2 @@ | ||
function asn1_u8_encode(content_tree) { | ||
const is_lst = Array.isArray(content_tree); | ||
const all_parts = []; | ||
@@ -31,2 +31,7 @@ encode_next(content_tree); | ||
function encode_next(content_tree) { | ||
if (content_tree.byteLength) { | ||
all_parts.push(content_tree); | ||
return content_tree.byteLength} | ||
const is_lst = Array.isArray(content_tree); | ||
const ident = is_lst ? content_tree[0] : content_tree.id; | ||
@@ -40,2 +45,3 @@ const id = ident | 0; | ||
if (! Number.isInteger(ident) || 0 > ident || ident > 255) { | ||
console.log({ident, content_tree}); | ||
throw new Error('Invalid ASN1 identifier') } | ||
@@ -66,6 +72,6 @@ | ||
else { | ||
let octects = 0; | ||
while (0 !== byteLength) { | ||
hdr.push(byteLength & 0xff); | ||
byteLength >>>= 8; | ||
let octects = 0, oct_len = byteLength; | ||
while (0 !== oct_len) { | ||
hdr.push(oct_len & 0xff); | ||
oct_len >>>= 8; | ||
octects ++;} | ||
@@ -78,29 +84,4 @@ hdr[1] = 0x80 | octects;} | ||
const u8_zero = new Uint8Array([0]); | ||
function asn1_der_positive_int(v) { | ||
if (0x80 & v[0]) { | ||
return u8_concat([u8_zero, v]) } | ||
if (0 !== v[0]) {return v} | ||
for (let i=1; i < v.byteLength; i++) { | ||
const b = v[i]; | ||
if (0 !== b) { | ||
if (0x80 & b) {i--;} | ||
return v.subarray(i)} } } | ||
function compact_positive_int(v, len) { | ||
if (v.byteLength <= len) { | ||
return v} | ||
if (0 === v[0] && 0x80 & v[1]) { | ||
return v.subarray(1)} | ||
throw new Error('Unexpected integer construction') } | ||
exports.default = asn1_u8_encode; | ||
exports.asn1_u8_encode = asn1_u8_encode; | ||
exports.asn1_der_positive_int = asn1_der_positive_int; | ||
exports.compact_positive_int = compact_positive_int; | ||
@@ -107,0 +88,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
@@ -8,2 +8,5 @@ (function (global, factory) { | ||
function u8_to_hex(u8, sep) { | ||
if (undefined === u8.buffer) { | ||
u8 = new Uint8Array(u8);} | ||
return Array | ||
@@ -16,2 +19,4 @@ .from(u8, v => v.toString(16).padStart(2, '0')) | ||
for (const b of parts) { | ||
if (! b.byteLength) { | ||
console.log("WA?", b, parts); } | ||
len += b.byteLength;} | ||
@@ -68,3 +73,3 @@ | ||
node.hex = u8_to_hex(content, ' '); | ||
//node.hex = u8_to_hex @ content, ' ' | ||
@@ -81,4 +86,15 @@ yield node;} } | ||
, parse_parts() { | ||
return 0x20 & this.id | ||
, hex() {return u8_to_hex(this.content)} | ||
, dbg() {return `id: ${this.id} len: ${this.byteLength} hex: ${this.hex()}`} | ||
, [Symbol.iterator]() {return this.iter_parts()} | ||
, iter_parts(override) { | ||
if (0x20 & this.id || override) { | ||
return asn1_u8_decode_many(this.content)} | ||
else throw new Error('Not a contructed ASN1 node') } | ||
, first_part(override) { | ||
return asn1_u8_decode(this.content)} | ||
, parse_parts(override) { | ||
return 0x20 & this.id || override | ||
? Array.from(asn1_u8_decode_many(this.content)) | ||
@@ -94,2 +110,5 @@ : null} | ||
, *iter_walk(visitor) { | ||
if (true === visitor) { | ||
console.log(this.dbg()); } | ||
let parts = null; | ||
@@ -101,3 +120,3 @@ if (0x20 & this.id) { | ||
if (visitor) { | ||
if ('function' === typeof visitor) { | ||
return visitor(this, parts) } | ||
@@ -108,4 +127,2 @@ else { | ||
function asn1_u8_encode(content_tree) { | ||
const is_lst = Array.isArray(content_tree); | ||
const all_parts = []; | ||
@@ -116,2 +133,7 @@ encode_next(content_tree); | ||
function encode_next(content_tree) { | ||
if (content_tree.byteLength) { | ||
all_parts.push(content_tree); | ||
return content_tree.byteLength} | ||
const is_lst = Array.isArray(content_tree); | ||
const ident = is_lst ? content_tree[0] : content_tree.id; | ||
@@ -125,2 +147,3 @@ const id = ident | 0; | ||
if (! Number.isInteger(ident) || 0 > ident || ident > 255) { | ||
console.log({ident, content_tree}); | ||
throw new Error('Invalid ASN1 identifier') } | ||
@@ -151,6 +174,6 @@ | ||
else { | ||
let octects = 0; | ||
while (0 !== byteLength) { | ||
hdr.push(byteLength & 0xff); | ||
byteLength >>>= 8; | ||
let octects = 0, oct_len = byteLength; | ||
while (0 !== oct_len) { | ||
hdr.push(oct_len & 0xff); | ||
oct_len >>>= 8; | ||
octects ++;} | ||
@@ -163,7 +186,5 @@ hdr[1] = 0x80 | octects;} | ||
const u8_zero = new Uint8Array([0]); | ||
function asn1_der_positive_int(v) { | ||
if (0x80 & v[0]) { | ||
return u8_concat([u8_zero, v]) } | ||
return u8_concat([new Uint8Array([0]), v]) } | ||
@@ -187,3 +208,3 @@ if (0 !== v[0]) {return v} | ||
function pack_ecdsa_asn1({r, s}) { | ||
function encode_ecdsa_asn1({r, s}) { | ||
return asn1_u8_encode([ | ||
@@ -194,3 +215,3 @@ 0x30, // sequence | ||
function unpack_ecdsa_asn1(ecdsa_asn1) { | ||
function decode_ecdsa_asn1(ecdsa_asn1) { | ||
const node = asn1_u8_decode(ecdsa_asn1); | ||
@@ -212,3 +233,3 @@ const [r_node, s_node] = node.parse_parts(); | ||
function pack_ecdsa_raw({r, s}) { | ||
function encode_ecdsa_raw({r, s}) { | ||
const len_part = ecdsa_raw_len[r.byteLength]; | ||
@@ -226,3 +247,3 @@ if (! len_part) { | ||
function unpack_ecdsa_raw(ecdsa_raw) { | ||
function decode_ecdsa_raw(ecdsa_raw) { | ||
const u8 = new Uint8Array(ecdsa_raw.buffer || ecdsa_raw); | ||
@@ -234,6 +255,6 @@ const n = u8.byteLength >>> 1; | ||
exports.pack_ecdsa_asn1 = pack_ecdsa_asn1; | ||
exports.unpack_ecdsa_asn1 = unpack_ecdsa_asn1; | ||
exports.pack_ecdsa_raw = pack_ecdsa_raw; | ||
exports.unpack_ecdsa_raw = unpack_ecdsa_raw; | ||
exports.encode_ecdsa_asn1 = encode_ecdsa_asn1; | ||
exports.decode_ecdsa_asn1 = decode_ecdsa_asn1; | ||
exports.encode_ecdsa_raw = encode_ecdsa_raw; | ||
exports.decode_ecdsa_raw = decode_ecdsa_raw; | ||
@@ -243,2 +264,2 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZWNkc2EuZGJnLmpzIiwic291cmNlcyI6WyIuLi9jb2RlL3U4X3V0aWxzLmpzeSIsIi4uL2NvZGUvYXNuMV9kZWNvZGUuanN5IiwiLi4vY29kZS9hc24xX2VuY29kZS5qc3kiLCIuLi9jb2RlL2VjZHNhLmpzeSJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZnVuY3Rpb24gaGV4X3RvX3U4KGhleCkgOjpcbiAgaGV4ID0gaGV4LnJlcGxhY2UoL1teMC05YS1mQS1GXS9nLCAnJylcbiAgY29uc3QgdTggPSBuZXcgVWludDhBcnJheShoZXgubGVuZ3RoID4+IDEpXG4gIGZvciBsZXQgaT0wLCBpMj0wOyBpPHU4Lmxlbmd0aDsgaSsrLCBpMis9MiA6OlxuICAgIHU4W2ldID0gcGFyc2VJbnQgQCBoZXguc2xpY2UoaTIsIGkyKzIpLCAxNlxuICByZXR1cm4gdThcblxuZXhwb3J0IGZ1bmN0aW9uIHU4X3RvX2hleCh1OCwgc2VwKSA6OlxuICByZXR1cm4gQXJyYXlcbiAgICAuZnJvbSBAIHU4LCB2ID0+IHYudG9TdHJpbmcoMTYpLnBhZFN0YXJ0KDIsICcwJylcbiAgICAuam9pbiBAIG51bGwgIT0gc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QUdyQixJQUFFO1FBQ0E7O1FBRUE7UUFDQSxPQUFLO1VBQ0gsU0FBVTtVQUNWO1VBQ0E7UUFDRjs7TUFFRjtNQUNBO01BQ0E7OztJQ3RERixJQUFFO01BQ0Esa0JBQW1COztJQUVyQixJQUFFLGFBQWM7O0lBRWhCLEtBQUc7TUFDRDtNQUNBLElBQUU7UUFDQSxJQUFFLFdBQVk7UUFDZDs7QUFFTjtJQUNFLElBQUU7TUFDQTs7SUFFRixJQUFFO01BQ0E7O0lBRUYsZ0JBQWlCOzs7SUNoQmpCO01BQ0U7T0FDRztPQUNBOztBQUVQO0lBQ0UsNEJBQTZCO0lBQzdCO0lBQ0EsUUFBVTs7RUFFWjtLQUNLO0tBQ0E7S0FDQTs7RUFFTDtJQUNFO01BQ0UsS0FBRztRQUNEO01BQ0Y7SUFDRjs7QUFFRjtJQUNFO0lBQ0EsS0FBRztNQUNELGdCQUFpQjs7SUFFbkI7SUFDQTs7SUFFQTtJQUNBLE9BQVE7SUFDUixPQUFRO0lBQ1I7O0FBRUY7SUFDRTtJQUNBO0lBQ0E7SUFDQTtJQUNBOzs7Ozs7Ozs7Ozs7Ozs7In0= |
@@ -8,2 +8,5 @@ (function (global, factory) { | ||
function u8_to_hex(u8, sep) { | ||
if (undefined === u8.buffer) { | ||
u8 = new Uint8Array(u8);} | ||
return Array | ||
@@ -16,2 +19,4 @@ .from(u8, v => v.toString(16).padStart(2, '0')) | ||
for (const b of parts) { | ||
if (! b.byteLength) { | ||
console.log("WA?", b, parts); } | ||
len += b.byteLength;} | ||
@@ -68,3 +73,3 @@ | ||
node.hex = u8_to_hex(content, ' '); | ||
//node.hex = u8_to_hex @ content, ' ' | ||
@@ -81,4 +86,15 @@ yield node;} } | ||
, parse_parts() { | ||
return 0x20 & this.id | ||
, hex() {return u8_to_hex(this.content)} | ||
, dbg() {return `id: ${this.id} len: ${this.byteLength} hex: ${this.hex()}`} | ||
, [Symbol.iterator]() {return this.iter_parts()} | ||
, iter_parts(override) { | ||
if (0x20 & this.id || override) { | ||
return asn1_u8_decode_many(this.content)} | ||
else throw new Error('Not a contructed ASN1 node') } | ||
, first_part(override) { | ||
return asn1_u8_decode(this.content)} | ||
, parse_parts(override) { | ||
return 0x20 & this.id || override | ||
? Array.from(asn1_u8_decode_many(this.content)) | ||
@@ -94,2 +110,5 @@ : null} | ||
, *iter_walk(visitor) { | ||
if (true === visitor) { | ||
console.log(this.dbg()); } | ||
let parts = null; | ||
@@ -101,3 +120,3 @@ if (0x20 & this.id) { | ||
if (visitor) { | ||
if ('function' === typeof visitor) { | ||
return visitor(this, parts) } | ||
@@ -108,4 +127,2 @@ else { | ||
function asn1_u8_encode(content_tree) { | ||
const is_lst = Array.isArray(content_tree); | ||
const all_parts = []; | ||
@@ -116,2 +133,7 @@ encode_next(content_tree); | ||
function encode_next(content_tree) { | ||
if (content_tree.byteLength) { | ||
all_parts.push(content_tree); | ||
return content_tree.byteLength} | ||
const is_lst = Array.isArray(content_tree); | ||
const ident = is_lst ? content_tree[0] : content_tree.id; | ||
@@ -125,2 +147,3 @@ const id = ident | 0; | ||
if (! Number.isInteger(ident) || 0 > ident || ident > 255) { | ||
console.log({ident, content_tree}); | ||
throw new Error('Invalid ASN1 identifier') } | ||
@@ -151,6 +174,6 @@ | ||
else { | ||
let octects = 0; | ||
while (0 !== byteLength) { | ||
hdr.push(byteLength & 0xff); | ||
byteLength >>>= 8; | ||
let octects = 0, oct_len = byteLength; | ||
while (0 !== oct_len) { | ||
hdr.push(oct_len & 0xff); | ||
oct_len >>>= 8; | ||
octects ++;} | ||
@@ -163,7 +186,5 @@ hdr[1] = 0x80 | octects;} | ||
const u8_zero = new Uint8Array([0]); | ||
function asn1_der_positive_int(v) { | ||
if (0x80 & v[0]) { | ||
return u8_concat([u8_zero, v]) } | ||
return u8_concat([new Uint8Array([0]), v]) } | ||
@@ -187,3 +208,3 @@ if (0 !== v[0]) {return v} | ||
function pack_ecdsa_asn1({r, s}) { | ||
function encode_ecdsa_asn1({r, s}) { | ||
return asn1_u8_encode([ | ||
@@ -194,3 +215,3 @@ 0x30, // sequence | ||
function unpack_ecdsa_asn1(ecdsa_asn1) { | ||
function decode_ecdsa_asn1(ecdsa_asn1) { | ||
const node = asn1_u8_decode(ecdsa_asn1); | ||
@@ -212,3 +233,3 @@ const [r_node, s_node] = node.parse_parts(); | ||
function pack_ecdsa_raw({r, s}) { | ||
function encode_ecdsa_raw({r, s}) { | ||
const len_part = ecdsa_raw_len[r.byteLength]; | ||
@@ -226,3 +247,3 @@ if (! len_part) { | ||
function unpack_ecdsa_raw(ecdsa_raw) { | ||
function decode_ecdsa_raw(ecdsa_raw) { | ||
const u8 = new Uint8Array(ecdsa_raw.buffer || ecdsa_raw); | ||
@@ -234,6 +255,6 @@ const n = u8.byteLength >>> 1; | ||
exports.pack_ecdsa_asn1 = pack_ecdsa_asn1; | ||
exports.unpack_ecdsa_asn1 = unpack_ecdsa_asn1; | ||
exports.pack_ecdsa_raw = pack_ecdsa_raw; | ||
exports.unpack_ecdsa_raw = unpack_ecdsa_raw; | ||
exports.encode_ecdsa_asn1 = encode_ecdsa_asn1; | ||
exports.decode_ecdsa_asn1 = decode_ecdsa_asn1; | ||
exports.encode_ecdsa_raw = encode_ecdsa_raw; | ||
exports.decode_ecdsa_raw = decode_ecdsa_raw; | ||
@@ -240,0 +261,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
@@ -15,2 +15,5 @@ (function (global, factory) { | ||
function u8_to_hex(u8, sep) { | ||
if (undefined === u8.buffer) { | ||
u8 = new Uint8Array(u8);} | ||
return Array | ||
@@ -23,2 +26,4 @@ .from(u8, v => v.toString(16).padStart(2, '0')) | ||
for (const b of parts) { | ||
if (! b.byteLength) { | ||
console.log("WA?", b, parts); } | ||
len += b.byteLength;} | ||
@@ -42,2 +47,2 @@ | ||
}))); | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidThfdXRpbHMuZGJnLmpzIiwic291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ydCBmdW5jdGlvbiB1OF9jb25jYXQocGFydHMpIDo6XG4gIGxldCBpPTAsIGxlbj0wXG4gIGZvciBjb25zdCBiIG9mIHBhcnRzIDo6XG4gICAgaWYgISBiLmJ5dGVMZW5ndGggOjpcbiAgICAgIGNvbnNvbGUubG9nIEAgXCJXQT9cIiwgYiwgcGFydHNcbiAgICBsZW4gKz0gYi5ieXRlTGVuZ3RoXG5cbiAgY29uc3QgdTggPSBuZXcgVWludDhBcnJheShsZW4pXG4gIGZvciBjb25zdCB1OF9wYXJ0IG9mIHBhcnRzIDo6XG4gICAgaWYgISAodThfcGFydC5idWZmZXIgfHwgdThfcGFydCkgaW5zdGFuY2VvZiBBcnJheUJ1ZmZlciA6OlxuICAgICAgdGhyb3cgbmV3IEVycm9yIEAgXCJJbnZhbGlkIHBhcnQgY29udGVudFwiXG5cbiAgICB1OC5zZXQgQCB1OF9wYXJ0LCBpXG4gICAgaSArPSB1OF9wYXJ0LmJ5dGVMZW5ndGhcbiAgcmV0dXJuIHU4XG5cblxuIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7SUFDRSxrQkFBa0IsZUFBZSxFQUFFLEVBQUU7SUFDckM7SUFDQSxLQUFHO01BQ0QsaUJBQWtCO0lBQ3BCOztBQUVGO0lBQ0UsSUFBRTtNQUNBOztJQUVGO1lBQ1Msb0NBQXFDLEdBQUc7WUFDeEMsb0JBQXFCOztBQUVoQztJQUNFO0lBQ0EsS0FBRztNQUNELEtBQUc7UUFDRCxZQUFhLEtBQU07TUFDckI7O0lBRUY7SUFDQSxLQUFHO01BQ0QsS0FBRztRQUNELGdCQUFpQjs7TUFFbkIsT0FBUTtNQUNSO0lBQ0Y7Ozs7Ozs7Ozs7Ozs7OyJ9 |
@@ -15,2 +15,5 @@ (function (global, factory) { | ||
function u8_to_hex(u8, sep) { | ||
if (undefined === u8.buffer) { | ||
u8 = new Uint8Array(u8);} | ||
return Array | ||
@@ -23,2 +26,4 @@ .from(u8, v => v.toString(16).padStart(2, '0')) | ||
for (const b of parts) { | ||
if (! b.byteLength) { | ||
console.log("WA?", b, parts); } | ||
len += b.byteLength;} | ||
@@ -25,0 +30,0 @@ |
@@ -15,2 +15,5 @@ (function (global, factory) { | ||
function u8_to_hex(u8, sep) { | ||
if (undefined === u8.buffer) { | ||
u8 = new Uint8Array(u8);} | ||
return Array | ||
@@ -23,2 +26,4 @@ .from(u8, v => v.toString(16).padStart(2, '0')) | ||
for (const b of parts) { | ||
if (! b.byteLength) { | ||
console.log("WA?", b, parts); } | ||
len += b.byteLength;} | ||
@@ -52,2 +57,6 @@ | ||
function u8_to_base64url(u8) { | ||
return u8_to_base64(u8) | ||
.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '')} | ||
const _charCodeAt = ''.charCodeAt; | ||
@@ -65,2 +74,3 @@ function base64_to_u8(str_b64) { | ||
exports.u8_to_base64 = u8_to_base64; | ||
exports.u8_to_base64url = u8_to_base64url; | ||
exports.base64_to_u8 = base64_to_u8; | ||
@@ -74,2 +84,2 @@ exports.hex_to_u8 = hex_to_u8; | ||
}))); | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidThfdXRpbHMuZGJnLmpzIiwic291cmNlcyI6WyIuLi8uLi9jb2RlL3U4X3V0aWxzLmpzeSIsIi4uLy4uL2NvZGUvd2ViL3U4X3V0aWxzLmpzeSJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZnVuY3Rpb24gaGV4X3RvX3U4KGhleCkgOjpcbiAgaGV4ID0gaGV4LnJlcGxhY2UoL1teMC05YS1mQS1GXS9nLCAnJylcbiAgY29uc3QgdTggPSBuZXcgVWludDhBcnJheShoZXgubGVuZ3RoID4+IDEpXG4gIGZvciBsZXQgaT0wLCBpMj0wOyBpPHU4Lmxlbmd0aDsgaSsrLCBpMis9MiA6OlxuICAgIHU4W2ldID0gcGFyc2VJbnQgQCBoZXguc2xpY2UoaTIsIGky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VuQixPQUFRO01BQ1I7SUFDRjs7O0lDMUJBLHVCQUF1QixPQUFPLFNBQVUsZUFBZ0IsTUFBTTs7QUFFaEU7SUFDRSx1QkFBdUIsT0FBTyxTQUFVOztFQUUxQztBQUNBO0lBQ0UsSUFBRTtNQUNBOztJQUVGLFFBQVE7SUFDUjtJQUNBLEtBQUc7TUFDRDtJQUNGOztBQUVGO0lBQ0U7ZUFDVyxLQUFLLEVBQUUsR0FBRyxVQUFVLEtBQUssRUFBRSxHQUFHLFVBQVUsSUFBSSxFQUFFLEVBQUU7O0VBRTdELG9CQUFvQixFQUFFO0FBQ3RCO0lBQ0UsZ0JBQWlCLGdCQUFpQixJQUFJLEVBQUUsR0FBRyxVQUFVLElBQUksRUFBRSxHQUFHO0lBQzlEO0lBQ0E7SUFDQSxLQUFHO01BQ0Q7SUFDRjs7Ozs7Ozs7Ozs7Ozs7Ozs7OzsifQ== |
@@ -15,2 +15,5 @@ (function (global, factory) { | ||
function u8_to_hex(u8, sep) { | ||
if (undefined === u8.buffer) { | ||
u8 = new Uint8Array(u8);} | ||
return Array | ||
@@ -23,2 +26,4 @@ .from(u8, v => v.toString(16).padStart(2, '0')) | ||
for (const b of parts) { | ||
if (! b.byteLength) { | ||
console.log("WA?", b, parts); } | ||
len += b.byteLength;} | ||
@@ -52,2 +57,6 @@ | ||
function u8_to_base64url(u8) { | ||
return u8_to_base64(u8) | ||
.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '')} | ||
const _charCodeAt = ''.charCodeAt; | ||
@@ -65,2 +74,3 @@ function base64_to_u8(str_b64) { | ||
exports.u8_to_base64 = u8_to_base64; | ||
exports.u8_to_base64url = u8_to_base64url; | ||
exports.base64_to_u8 = base64_to_u8; | ||
@@ -67,0 +77,0 @@ exports.hex_to_u8 = hex_to_u8; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
501326
39
6605
1