sshpk
Advanced tools
Comparing version 1.10.1 to 1.10.2
@@ -119,2 +119,13 @@ // Copyright 2016 Joyent, Inc. | ||
/* | ||
* These are from X.680 -- PrintableString allowed chars are in section 37.4 | ||
* table 8. Spec for IA5Strings is "1,6 + SPACE + DEL" where 1 refers to | ||
* ISO IR #001 (standard ASCII control characters) and 6 refers to ISO IR #006 | ||
* (the basic ASCII character set). | ||
*/ | ||
/* JSSTYLED */ | ||
var NOT_PRINTABLE = /[^a-zA-Z0-9 '(),+.\/:=?-]/; | ||
/* JSSTYLED */ | ||
var NOT_IA5 = /[^\x00-\x7f]/; | ||
Identity.prototype.toAsn1 = function (der, tag) { | ||
@@ -126,3 +137,14 @@ der.startSequence(tag); | ||
der.writeOID(c.oid); | ||
der.writeString(c.value, asn1.Ber.PrintableString); | ||
/* | ||
* If we fit in a PrintableString, use that. Otherwise use an | ||
* IA5String or UTF8String. | ||
*/ | ||
if (c.value.match(NOT_IA5)) { | ||
var v = new Buffer(c.value, 'utf8'); | ||
der.writeBuffer(v, asn1.Ber.Utf8String); | ||
} else if (c.value.match(NOT_PRINTABLE)) { | ||
der.writeString(c.value, asn1.Ber.IA5String); | ||
} else { | ||
der.writeString(c.value, asn1.Ber.PrintableString); | ||
} | ||
der.endSequence(); | ||
@@ -129,0 +151,0 @@ der.endSequence(); |
{ | ||
"name": "sshpk", | ||
"version": "1.10.1", | ||
"version": "1.10.2", | ||
"description": "A library for finding and using SSH public keys", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
173750
4345