From b010fd88e848a641c0346dc46561a60d876a99d6 Mon Sep 17 00:00:00 2001 From: n1474335 Date: Fri, 5 May 2017 15:42:24 +0000 Subject: [PATCH] Fix X.509 signature breakout bug --- src/core/operations/PublicKey.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/core/operations/PublicKey.js b/src/core/operations/PublicKey.js index b3e5357d..918535e9 100755 --- a/src/core/operations/PublicKey.js +++ b/src/core/operations/PublicKey.js @@ -124,10 +124,17 @@ const PublicKey = { } // Signature fields - if (r.ASN1HEX.dump(certSig).indexOf("SEQUENCE") === 0) { // DSA or ECDSA + var breakoutSig = false; + try { + breakoutSig = r.ASN1HEX.dump(certSig).indexOf("SEQUENCE") === 0; + } catch(err) { + // Error processing signature, output without further breakout + } + + if (breakoutSig) { // DSA or ECDSA sigStr = " r: " + PublicKey._formatByteStr(r.ASN1HEX.getDecendantHexVByNthList(certSig, 0, [0]), 16, 18) + "\n" + " s: " + PublicKey._formatByteStr(r.ASN1HEX.getDecendantHexVByNthList(certSig, 0, [1]), 16, 18) + "\n"; - } else { // RSA + } else { // RSA or unknown sigStr = " Signature: " + PublicKey._formatByteStr(certSig, 16, 18) + "\n"; }