package dsakey
import (
- "crypto/sha1"
+ "crypto"
"crypto/dsa"
"crypto/openpgp"
"crypto/openpgp/packet"
"crypto/rand"
- "crypto"
+ "crypto/sha1"
"fmt"
"io"
"math/big"
func PrivKey(r []byte) *dsa.PrivateKey {
priv := new(dsa.PrivateKey)
- priv.Parameters.P,_ = new(big.Int).SetString(P, 16)
- priv.Parameters.Q,_ = new(big.Int).SetString(Q, 16)
- priv.Parameters.G,_ = new(big.Int).SetString(G, 16)
+ priv.Parameters.P, _ = new(big.Int).SetString(P, 16)
+ priv.Parameters.Q, _ = new(big.Int).SetString(Q, 16)
+ priv.Parameters.G, _ = new(big.Int).SetString(G, 16)
// q > 2^159 prime
// x = sha1(r)
IssuerKeyId: &e.PrimaryKey.KeyId,
},
}
-/*
- e.Subkeys = make([]Subkey, 1)
- e.Subkeys[0] = Subkey{
- PublicKey: packet.NewRSAPublicKey(t, &encryptingPriv.PublicKey, true),
- PrivateKey: packet.NewRSAPrivateKey(t, encryptingPriv, true),
- Sig: &packet.Signature{
- CreationTime: t,
- SigType: packet.SigTypeSubkeyBinding,
- PubKeyAlgo: packet.PubKeyAlgoRSA,
- Hash: crypto.SHA256,
- FlagsValid: true,
- FlagEncryptStorage: true,
- FlagEncryptCommunications: true,
- IssuerKeyId: &e.PrimaryKey.KeyId,
- },
- }
-*/
+ /*
+ e.Subkeys = make([]Subkey, 1)
+ e.Subkeys[0] = Subkey{
+ PublicKey: packet.NewRSAPublicKey(t, &encryptingPriv.PublicKey, true),
+ PrivateKey: packet.NewRSAPrivateKey(t, encryptingPriv, true),
+ Sig: &packet.Signature{
+ CreationTime: t,
+ SigType: packet.SigTypeSubkeyBinding,
+ PubKeyAlgo: packet.PubKeyAlgoRSA,
+ Hash: crypto.SHA256,
+ FlagsValid: true,
+ FlagEncryptStorage: true,
+ FlagEncryptCommunications: true,
+ IssuerKeyId: &e.PrimaryKey.KeyId,
+ },
+ }
+ */
return
}
}
// simple key generation for obligation holder clients
func NewHolderEntity(r []byte, issuer, denomination string) (e *openpgp.Entity, err error) {
- return NewEntity(PrivKey(r), 0, "Holder of " + issuer, denomination, "")
+ return NewEntity(PrivKey(r), 0, "Holder of "+issuer, denomination, "")
}
// check the issuer and denomination associated with the given pgp key