diff --git a/lib/jwk/import.js b/lib/jwk/import.js index 46aa42b8cc..c07d71d723 100644 --- a/lib/jwk/import.js +++ b/lib/jwk/import.js @@ -26,7 +26,7 @@ const mergedParameters = (target = {}, source = {}) => { } } -const openSSHpublicKey = /^[a-zA-Z0-9-]+ (?:[a-zA-Z0-9+/])*(?:==|=)?(?: .*)?$/ +const openSSHpublicKey = /^[a-zA-Z0-9-]+ AAAA(?:[0-9A-Za-z+/])+(?:==|=)?(?: .*)?$/ const asKey = (key, parameters, { calculateMissingRSAPrimes = false } = {}) => { let privateKey, publicKey, secret diff --git a/test/jwk/oct.test.js b/test/jwk/oct.test.js index 1bbba1ef9b..27244884d7 100644 --- a/test/jwk/oct.test.js +++ b/test/jwk/oct.test.js @@ -204,3 +204,11 @@ b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW` }, { instanceOf: errors.JWKImportFailed, message: 'key import failed' }) }) }) + +test('some phrases do not fall through to openssh check', t => { + asKey('secret') + asKey('secret phrase') + asKey('longer secret phrase') + asKey('very long secret phrase') + t.pass() +})