crypto/ssh: Support turning a crypto.Signer into an ssh.Signer
This adds a NewSignerFromSigner to crypto/ssh which takes a crypto.Signer and turns it into an ssh.Signer, helpful if, e.g., your crypto.Signer is backed by some sort of hardware device. The interfaces are very similar - the biggest differences are that a crypto.Signer accepts hashed data, while an ssh.Signer does not, and some differences in encoding for DSA and ECDSA signatures. This also adjusts NewSignerFromKey to use NewSignerFromSigner where possible, dropping the rsaPrivateKey and ecdsaPrivateKey types in favor of wrappedSigner. (However, because *dsa.PrivateKey is not a crypto.Signer, we still have to keep dsaPrivateKey) Change-Id: Ia2e20ece9c9d3844b4e5a64c1a7d997178ec8781 Reviewed-on: https://go-review.googlesource.com/10953 Reviewed-by: Adam Langley <agl@golang.org>
This commit is contained in:
committed by
Adam Langley
parent
aedad9a179
commit
e74b0352e5
+4
-4
@@ -57,12 +57,12 @@ func TestUnsupportedCurves(t *testing.T) {
|
||||
t.Fatalf("GenerateKey: %v", err)
|
||||
}
|
||||
|
||||
if _, err = NewSignerFromKey(raw); err == nil || !strings.Contains(err.Error(), "only P256") {
|
||||
t.Fatalf("NewPrivateKey should not succeed with P224, got: %v", err)
|
||||
if _, err = NewSignerFromKey(raw); err == nil || !strings.Contains(err.Error(), "only P-256") {
|
||||
t.Fatalf("NewPrivateKey should not succeed with P-224, got: %v", err)
|
||||
}
|
||||
|
||||
if _, err = NewPublicKey(&raw.PublicKey); err == nil || !strings.Contains(err.Error(), "only P256") {
|
||||
t.Fatalf("NewPublicKey should not succeed with P224, got: %v", err)
|
||||
if _, err = NewPublicKey(&raw.PublicKey); err == nil || !strings.Contains(err.Error(), "only P-256") {
|
||||
t.Fatalf("NewPublicKey should not succeed with P-224, got: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user