diff options
Diffstat (limited to 'vendor/golang.org/x/crypto/openpgp/packet/private_key.go')
-rw-r--r-- | vendor/golang.org/x/crypto/openpgp/packet/private_key.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/vendor/golang.org/x/crypto/openpgp/packet/private_key.go b/vendor/golang.org/x/crypto/openpgp/packet/private_key.go index 34734cc..bd31cce 100644 --- a/vendor/golang.org/x/crypto/openpgp/packet/private_key.go +++ b/vendor/golang.org/x/crypto/openpgp/packet/private_key.go | |||
@@ -64,14 +64,19 @@ func NewECDSAPrivateKey(currentTime time.Time, priv *ecdsa.PrivateKey) *PrivateK | |||
64 | return pk | 64 | return pk |
65 | } | 65 | } |
66 | 66 | ||
67 | // NewSignerPrivateKey creates a sign-only PrivateKey from a crypto.Signer that | 67 | // NewSignerPrivateKey creates a PrivateKey from a crypto.Signer that |
68 | // implements RSA or ECDSA. | 68 | // implements RSA or ECDSA. |
69 | func NewSignerPrivateKey(currentTime time.Time, signer crypto.Signer) *PrivateKey { | 69 | func NewSignerPrivateKey(currentTime time.Time, signer crypto.Signer) *PrivateKey { |
70 | pk := new(PrivateKey) | 70 | pk := new(PrivateKey) |
71 | // In general, the public Keys should be used as pointers. We still | ||
72 | // type-switch on the values, for backwards-compatibility. | ||
71 | switch pubkey := signer.Public().(type) { | 73 | switch pubkey := signer.Public().(type) { |
74 | case *rsa.PublicKey: | ||
75 | pk.PublicKey = *NewRSAPublicKey(currentTime, pubkey) | ||
72 | case rsa.PublicKey: | 76 | case rsa.PublicKey: |
73 | pk.PublicKey = *NewRSAPublicKey(currentTime, &pubkey) | 77 | pk.PublicKey = *NewRSAPublicKey(currentTime, &pubkey) |
74 | pk.PubKeyAlgo = PubKeyAlgoRSASignOnly | 78 | case *ecdsa.PublicKey: |
79 | pk.PublicKey = *NewECDSAPublicKey(currentTime, pubkey) | ||
75 | case ecdsa.PublicKey: | 80 | case ecdsa.PublicKey: |
76 | pk.PublicKey = *NewECDSAPublicKey(currentTime, &pubkey) | 81 | pk.PublicKey = *NewECDSAPublicKey(currentTime, &pubkey) |
77 | default: | 82 | default: |