From 53aa292b7e28b3d96cf71756601563dd009186dd Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Tue, 5 Jul 2022 14:21:24 +0200 Subject: [PATCH] Support more query types - long - short - 0xlong - 0xshort - fingerprint Signed-off-by: Georg Pfuetzenreuter --- src/route/hkp.js | 2 +- src/service/public-key.js | 6 +++++- src/service/util.js | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/route/hkp.js b/src/route/hkp.js index dcf7a4a..25dca3a 100644 --- a/src/route/hkp.js +++ b/src/route/hkp.js @@ -97,7 +97,7 @@ class HKP { if (!util.isString(id)) { return false; } - return /^0x[a-fA-F0-9]{16,40}$/.test(id); + return /^(?:0x)?[a-fA-F0-9]{8,40}$/.test(id); } /** diff --git a/src/service/public-key.js b/src/service/public-key.js index 36efcde..0fb37b2 100644 --- a/src/service/public-key.js +++ b/src/service/public-key.js @@ -261,8 +261,12 @@ class PublicKey { } // query by key id (to prevent key id collision) if (keyId) { + keyId = keyId.toLowerCase(); + if (keyId.length === 8) { + keyId = new RegExp('[a-fA-F0-9]{8}' + keyId); + } queries.push({ - keyId: keyId.toLowerCase(), + keyId: keyId, 'userIds.verified': true }); } diff --git a/src/service/util.js b/src/service/util.js index b3330c5..15b28ad 100644 --- a/src/service/util.js +++ b/src/service/util.js @@ -50,7 +50,7 @@ exports.isKeyId = function(data) { if (!this.isString(data)) { return false; } - return /^[a-fA-F0-9]{16}$/.test(data); + return /^[a-fA-F0-9]{8,16}$/.test(data); }; /**