-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#10 want to be able to make openssh certs with ed25519
#11 openssh RSA certs being produced with SHA256 signatures Reviewed by: Cody Mello <[email protected]>
- Loading branch information
Alex Wilson
committed
Jul 28, 2016
1 parent
bf3f83c
commit 079f792
Showing
5 changed files
with
58 additions
and
8 deletions.
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 |
---|---|---|
|
@@ -58,6 +58,8 @@ function fromBuffer(data, algo, partial) { | |
var innerAlgo = sshbuf.readString(); | ||
if (algo !== undefined && innerAlgo !== algo) | ||
throw (new Error('SSH certificate algorithm mismatch')); | ||
if (algo === undefined) | ||
algo = innerAlgo; | ||
|
||
var cert = {}; | ||
cert.signatures = {}; | ||
|
@@ -168,15 +170,22 @@ function dateToInt64(date) { | |
} | ||
|
||
function sign(cert, key) { | ||
assert.ok(PrivateKey.isPrivateKey(key, [1, 2])); | ||
if (cert.signatures.openssh === undefined) | ||
cert.signatures.openssh = {}; | ||
try { | ||
var blob = toBuffer(cert, true); | ||
} catch (e) { | ||
delete (cert.signatures.openssh); | ||
return (false); | ||
} | ||
var sig = cert.signatures.openssh; | ||
|
||
var blob = toBuffer(cert, true); | ||
var signer = key.createSign(); | ||
var hashAlgo = undefined; | ||
if (key.type === 'rsa' || key.type === 'dsa') | ||
hashAlgo = 'sha1'; | ||
var signer = key.createSign(hashAlgo); | ||
signer.write(blob); | ||
sig.signature = signer.sign(); | ||
return (true); | ||
} | ||
|
||
function write(cert, options) { | ||
|
@@ -262,6 +271,8 @@ function getAlg(certType) { | |
return ('dsa'); | ||
if (certType.match(ECDSA_ALGO)) | ||
return ('ecdsa'); | ||
if (certType === '[email protected]') | ||
return ('ed25519'); | ||
throw (new Error('Unsupported cert type ' + certType)); | ||
} | ||
|
||
|
@@ -272,5 +283,7 @@ function getCertType(key) { | |
return ('[email protected]'); | ||
if (key.type === 'ecdsa') | ||
return ('ecdsa-sha2-' + key.curve + '[email protected]'); | ||
if (key.type === 'ed25519') | ||
return ('[email protected]'); | ||
throw (new Error('Unsupported key type ' + key.type)); | ||
} |
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
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