Skip to content

Commit

Permalink
fix: allow importing simpler passphrases as oct keys
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Mar 5, 2020
1 parent 5ca357c commit f86bda3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/jwk/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions test/jwk/oct.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})

0 comments on commit f86bda3

Please sign in to comment.