diff options
Diffstat (limited to 'libgo/go/crypto/openpgp/packet/private_key.go')
-rw-r--r-- | libgo/go/crypto/openpgp/packet/private_key.go | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/libgo/go/crypto/openpgp/packet/private_key.go b/libgo/go/crypto/openpgp/packet/private_key.go index c0ff82b4135..d67e9688617 100644 --- a/libgo/go/crypto/openpgp/packet/private_key.go +++ b/libgo/go/crypto/openpgp/packet/private_key.go @@ -17,6 +17,7 @@ import ( "io/ioutil" "math/big" "strconv" + "time" ) // PrivateKey represents a possibly encrypted private key. See RFC 4880, @@ -32,9 +33,9 @@ type PrivateKey struct { iv []byte } -func NewRSAPrivateKey(currentTimeSecs uint32, priv *rsa.PrivateKey, isSubkey bool) *PrivateKey { +func NewRSAPrivateKey(currentTime time.Time, priv *rsa.PrivateKey, isSubkey bool) *PrivateKey { pk := new(PrivateKey) - pk.PublicKey = *NewRSAPublicKey(currentTimeSecs, &priv.PublicKey, isSubkey) + pk.PublicKey = *NewRSAPublicKey(currentTime, &priv.PublicKey, isSubkey) pk.PrivateKey = priv return pk } @@ -99,13 +100,9 @@ func (pk *PrivateKey) parse(r io.Reader) (err error) { } func mod64kHash(d []byte) uint16 { - h := uint16(0) - for i := 0; i < len(d); i += 2 { - v := uint16(d[i]) << 8 - if i+1 < len(d) { - v += uint16(d[i+1]) - } - h += v + var h uint16 + for _, b := range d { + h += uint16(b) } return h } @@ -195,7 +192,7 @@ func (pk *PrivateKey) Decrypt(passphrase []byte) error { } h := sha1.New() h.Write(data[:len(data)-sha1.Size]) - sum := h.Sum() + sum := h.Sum(nil) if !bytes.Equal(sum, data[len(data)-sha1.Size:]) { return error_.StructuralError("private key checksum failure") } |