This repository has been archived by the owner on Oct 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.9.21: Exporting cipher and algo variables
This release exports cipher and algo variables for consumption in modules that need to interact with SSH.
- Loading branch information
Janos Pasztor
committed
Mar 24, 2021
1 parent
2c3a7a5
commit f8252ab
Showing
7 changed files
with
82 additions
and
103 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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package sshserver | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
var supportedHostKeyAlgos = []stringer{ | ||
KeyAlgoSSHRSACertv01, KeyAlgoSSHDSSCertv01, KeyAlgoECDSASHA2NISTp256Certv01, | ||
KeyAlgoECDSASHA2NISTp384Certv01, KeyAlgoECDSASHA2NISTp521Certv01, KeyAlgoSSHED25519Certv01, | ||
KeyAlgoSSHRSA, KeyAlgoSSHDSS, KeyAlgoSSHED25519, | ||
} | ||
|
||
// KeyAlgo are supported key algorithms. | ||
type KeyAlgo string | ||
|
||
// KeyAlgo are supported key algorithms. | ||
const ( | ||
KeyAlgoSSHRSACertv01 KeyAlgo = "[email protected]" | ||
KeyAlgoSSHDSSCertv01 KeyAlgo = "[email protected]" | ||
KeyAlgoECDSASHA2NISTp256Certv01 KeyAlgo = "[email protected]" | ||
KeyAlgoECDSASHA2NISTp384Certv01 KeyAlgo = "[email protected]" | ||
KeyAlgoECDSASHA2NISTp521Certv01 KeyAlgo = "[email protected]" | ||
KeyAlgoSSHED25519Certv01 KeyAlgo = "[email protected]" | ||
KeyAlgoSSHRSA KeyAlgo = "ssh-rsa" | ||
KeyAlgoSSHDSS KeyAlgo = "ssh-dss" | ||
KeyAlgoSSHED25519 KeyAlgo = "ssh-ed25519" | ||
) | ||
|
||
// String creates a string representation. | ||
func (h KeyAlgo) String() string { | ||
return string(h) | ||
} | ||
|
||
// Validate checks if a given key algorithm is valid. | ||
func (h KeyAlgo) Validate() error { | ||
if h == "" { | ||
return fmt.Errorf("empty host key algorithm") | ||
} | ||
for _, algo := range supportedHostKeyAlgos { | ||
if algo == h { | ||
return nil | ||
} | ||
} | ||
return fmt.Errorf("unsupported host key algorithm: %s", h) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package sshserver | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
// KeyAlgoList is a list of key algorithms. | ||
type KeyAlgoList []KeyAlgo | ||
|
||
// Validate validates the list of ciphers to contain only supported items. | ||
func (h KeyAlgoList) Validate() error { | ||
if len(h) == 0 { | ||
return fmt.Errorf("host key algorithm list cannot be empty") | ||
} | ||
for _, algo := range h { | ||
if err := algo.Validate(); err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
// StringList returns a list of cipher names. | ||
func (h KeyAlgoList) StringList() []string { | ||
algos := make([]string, len(h)) | ||
for i, v := range h { | ||
algos[i] = v.String() | ||
} | ||
return algos | ||
} |