update the codebase to latest go src (time, hash, strconv)
[epoint] / pkg / key / key.go
index d02d91c..6f2a322 100644 (file)
@@ -26,6 +26,7 @@ import (
        "fmt"
        "io"
        "math/big"
+       "time"
 )
 
 // TODO: keep denomination only in issuer key?
@@ -47,7 +48,7 @@ func DsaKey(r []byte) *dsa.PrivateKey {
 loop:
        h := sha1.New()
        h.Write(r)
-       r = h.Sum()
+       r = h.Sum(nil)
        x.SetBytes(r)
        // TODO: zero out r and h ?
        if x.Sign() == 0 || x.Cmp(priv.Q) >= 0 {
@@ -71,12 +72,11 @@ func RandomDsaKey() (priv *dsa.PrivateKey, err error) {
 // New returns an openpgp.Entity that contains a fresh DSA private key with a
 // single identity composed of the given full name, comment and email, any of
 // which may be empty but must not contain any of "()<>\x00".
-func New(priv *dsa.PrivateKey, currentTimeSecs int64, name, comment, email string) (e *openpgp.Entity, err error) {
+func New(priv *dsa.PrivateKey, t time.Time, name, comment, email string) (e *openpgp.Entity, err error) {
        uid := packet.NewUserId(name, comment, email)
        if uid == nil {
                return nil, fmt.Errorf("NewEntity: invalid argument: user id field contained invalid characters")
        }
-       t := uint32(currentTimeSecs)
        e = &openpgp.Entity{
                PrimaryKey: packet.NewDSAPublicKey(t, &priv.PublicKey, false /* not a subkey */ ),
                PrivateKey: packet.NewDSAPrivateKey(t, priv, false /* not a subkey */ ),
@@ -122,11 +122,11 @@ func Parse(d []byte) (e *openpgp.Entity, err error) {
 
 // Issuer generates a key for obligation issuer clients from random seed r
 func Issuer(r []byte, denomination string) (e *openpgp.Entity, err error) {
-       return New(DsaKey(r), 0, "Issuer", denomination, "")
+       return New(DsaKey(r), time.Unix(0,0), "Issuer", denomination, "")
 }
 // Holder generates a key for obligation holder clients from random seed r
 func Holder(r []byte, issuer, denomination string) (e *openpgp.Entity, err error) {
-       return New(DsaKey(r), 0, "Holder of "+issuer, denomination, "")
+       return New(DsaKey(r), time.Unix(0,0), "Holder of "+issuer, denomination, "")
 }
 
 // Key id (fingerprint)