chore: update vendor
This commit is contained in:
23
vendor/github.com/google/certificate-transparency-go/tls/types.go
generated
vendored
23
vendor/github.com/google/certificate-transparency-go/tls/types.go
generated
vendored
@ -14,7 +14,13 @@
|
||||
|
||||
package tls
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"crypto"
|
||||
"crypto/dsa"
|
||||
"crypto/ecdsa"
|
||||
"crypto/rsa"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// DigitallySigned gives information about a signature, including the algorithm used
|
||||
// and the signature value. Defined in RFC 5246 s4.7.
|
||||
@ -94,3 +100,18 @@ func (s SignatureAlgorithm) String() string {
|
||||
return fmt.Sprintf("UNKNOWN(%d)", s)
|
||||
}
|
||||
}
|
||||
|
||||
// SignatureAlgorithmFromPubKey returns the algorithm used for this public key.
|
||||
// ECDSA, RSA, and DSA keys are supported. Other key types will return Anonymous.
|
||||
func SignatureAlgorithmFromPubKey(k crypto.PublicKey) SignatureAlgorithm {
|
||||
switch k.(type) {
|
||||
case *ecdsa.PublicKey:
|
||||
return ECDSA
|
||||
case *rsa.PublicKey:
|
||||
return RSA
|
||||
case *dsa.PublicKey:
|
||||
return DSA
|
||||
default:
|
||||
return Anonymous
|
||||
}
|
||||
}
|
||||
|
25
vendor/github.com/google/certificate-transparency-go/tls/types_test.go
generated
vendored
25
vendor/github.com/google/certificate-transparency-go/tls/types_test.go
generated
vendored
@ -14,7 +14,13 @@
|
||||
|
||||
package tls
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"crypto"
|
||||
"crypto/dsa"
|
||||
"crypto/ecdsa"
|
||||
"crypto/rsa"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestHashAlgorithmString(t *testing.T) {
|
||||
var tests = []struct {
|
||||
@ -75,3 +81,20 @@ func TestDigitallySignedString(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSignatureAlgorithm(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
name string
|
||||
key crypto.PublicKey
|
||||
want SignatureAlgorithm
|
||||
}{
|
||||
{name: "ECDSA", key: new(ecdsa.PublicKey), want: ECDSA},
|
||||
{name: "RSA", key: new(rsa.PublicKey), want: RSA},
|
||||
{name: "DSA", key: new(dsa.PublicKey), want: DSA},
|
||||
{name: "Other", key: "foo", want: Anonymous},
|
||||
} {
|
||||
if got := SignatureAlgorithmFromPubKey(test.key); got != test.want {
|
||||
t.Errorf("%v: SignatureAlgorithm() = %v, want %v", test.name, got, test.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user