crypto: catch more overly entusiast casting
This commit is contained in:
@@ -66,7 +66,11 @@ func PublicKeyFromX509DER(bytes []byte) (*PublicKey, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &PublicKey{k: pub.(*ecdsa.PublicKey)}, nil
|
||||
ecdsaPub, ok := pub.(*ecdsa.PublicKey)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid public key")
|
||||
}
|
||||
return &PublicKey{k: ecdsaPub}, nil
|
||||
}
|
||||
|
||||
// PublicKeyFromX509PEM decodes an X.509 PEM (string) encoded public key.
|
||||
|
||||
@@ -66,7 +66,11 @@ func PublicKeyFromX509DER(bytes []byte) (*PublicKey, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &PublicKey{k: pub.(*ecdsa.PublicKey)}, nil
|
||||
ecdsaPub, ok := pub.(*ecdsa.PublicKey)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid public key")
|
||||
}
|
||||
return &PublicKey{k: ecdsaPub}, nil
|
||||
}
|
||||
|
||||
// PublicKeyFromX509PEM decodes an X.509 PEM (string) encoded public key.
|
||||
|
||||
@@ -66,7 +66,11 @@ func PublicKeyFromX509DER(bytes []byte) (*PublicKey, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &PublicKey{k: pub.(*ecdsa.PublicKey)}, nil
|
||||
ecdsaPub, ok := pub.(*ecdsa.PublicKey)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid public key")
|
||||
}
|
||||
return &PublicKey{k: ecdsaPub}, nil
|
||||
}
|
||||
|
||||
// PublicKeyFromX509PEM decodes an X.509 PEM (string) encoded public key.
|
||||
|
||||
@@ -54,7 +54,10 @@ func PrivateKeyFromPKCS8DER(bytes []byte) (*PrivateKey, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rsaPriv := priv.(*rsa.PrivateKey)
|
||||
rsaPriv, ok := priv.(*rsa.PrivateKey)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid private key type")
|
||||
}
|
||||
return &PrivateKey{k: rsaPriv}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,11 @@ func PublicKeyFromX509DER(bytes []byte) (*PublicKey, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &PublicKey{k: pub.(*rsa.PublicKey)}, nil
|
||||
rsaPub, ok := pub.(*rsa.PublicKey)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid public key")
|
||||
}
|
||||
return &PublicKey{k: rsaPub}, nil
|
||||
}
|
||||
|
||||
// PublicKeyFromX509PEM decodes an X.509 PEM (string) encoded public key.
|
||||
|
||||
Reference in New Issue
Block a user