-
Notifications
You must be signed in to change notification settings - Fork 673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ecdsa cert support for client through SSH agent #1440
Open
xRemaLx
wants to merge
1
commit into
mscdex:master
Choose a base branch
from
xRemaLx:ssh-agent-cert-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1390,6 +1390,28 @@ function parseDER(data, baseType, comment, fullType) { | |
return new OpenSSH_Public(fullType, comment, pubPEM, pubSSH, algo); | ||
} | ||
|
||
function tryParseAsCert(data, baseType, comment) { | ||
if (!isSupportedCertType(baseType)) | ||
return new Error(`Unsupported OpenSSH cert type: ${baseType}`); | ||
|
||
let algo; | ||
let pubPEM = null; | ||
let pubSSH = null; | ||
|
||
switch (baseType) { | ||
case '[email protected]': | ||
case '[email protected]': | ||
case '[email protected]': | ||
algo = baseType; | ||
pubSSH = data; | ||
break; | ||
default: | ||
return new Error(`Unsupported OpenSSH cert type: ${baseType}`); | ||
} | ||
|
||
return new OpenSSH_Public(baseType, comment, pubPEM, pubSSH, algo); | ||
} | ||
|
||
function isSupportedKeyType(type) { | ||
switch (type) { | ||
case 'ssh-rsa': | ||
|
@@ -1407,6 +1429,17 @@ function isSupportedKeyType(type) { | |
} | ||
} | ||
|
||
function isSupportedCertType(type) { | ||
switch (type) { | ||
case '[email protected]': | ||
case '[email protected]': | ||
case '[email protected]': | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
function isParsedKey(val) { | ||
if (!val) | ||
return false; | ||
|
@@ -1461,10 +1494,14 @@ function parseKey(data, passphrase) { | |
data = binaryKeyParser.readRaw(); | ||
if (data !== undefined) { | ||
ret = parseDER(data, type, '', type); | ||
// Ignore potentially useless errors in case the data was not actually | ||
// in the binary format | ||
if (ret instanceof Error) | ||
ret = null; | ||
// Try parse as cert | ||
if (ret instanceof Error) { | ||
ret = tryParseAsCert(origBuffer, type, ''); | ||
// Ignore potentially useless errors in case the data was not actually | ||
// in the binary format | ||
if (ret instanceof Error) | ||
ret = null; | ||
} | ||
} | ||
} | ||
binaryKeyParser.clear(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -340,6 +340,18 @@ module.exports = { | |
|
||
return signature; | ||
}, | ||
getSignatureAlgo: (keyAlgo, keyType) => { | ||
switch (keyType) { | ||
case '[email protected]': | ||
return 'ecdsa-sha2-nistp256'; | ||
case '[email protected]': | ||
return 'ecdsa-sha2-nistp384'; | ||
case '[email protected]': | ||
return 'ecdsa-sha2-nistp521'; | ||
default: | ||
return keyAlgo; | ||
} | ||
}, | ||
sendPacket: (proto, packet, bypass) => { | ||
if (!bypass && proto._kexinit !== undefined) { | ||
// We're currently in the middle of a handshake | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personal note (dunno if it really makes sense): This is the only caller of
isSupportedCertType
and the code below generates the very same error in itsdefault:
case. So, you could removeisSupportedCertType
and the two lines above without any change in behaviour.Still, it might make sense to keep things like this just for consistency with the rest of the library (there is also
isSupportedKeyType()
). I'll leave that to @mscdex to decide.