"fmt"
"io"
"math/big"
+ "time"
)
// TODO: keep denomination only in issuer key?
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 {
// 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 */ ),
// 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)