I am a student.I learned go 10 days ago and now I m hooked.As apart of the project I have to do the following.
I want to read a key from ascii armor and then sign the key with my key to show that I trust the key from armor.
var priKey *packet.PrivateKey
read1 := bytes.NewReader([]byte(pks_pri_key_armor))
entityList, _ := openpgp.ReadArmoredKeyRing(read1)
for _, can_pri := range entityList {
priKey = can_pri.PrivateKey
}
//private key is encrypted hence call decrypt first
priKey.Decrypt([]byte(pripwd))
sig := new(packet.Signature)
//Prepare sign with our configs/////IS IT A MUST ??
sig.Hash = crypto.SHA1
sig.PubKeyAlgo = priKey.PubKeyAlgo
sig.CreationTime = time.Now()
dur := new(uint32)
*dur = uint32(365 * 24 * 60 * 60)
sig.SigLifetimeSecs = dur //a year
issuerUint := new(uint64)
*issuerUint = priKey.KeyId
sig.IssuerKeyId = issuerUint
sig.SigType = packet.SigTypeGenericCert
usrIdstring = usrId.uID //contains openpgp user id string (name,email,comments)
I tried following two methods
sig.SignKey(reqPubKey, priKey, nil)
sig.SignUserId(usrIdstring, reqPubKey, priKey, nil)
Using any of the above method the generated signature gets added to the subkey of the publickey not to the uid when checked on sks and gpg.
e.g.
On SKS it SHOULD show following output for signing key with ID ABCD4321 (Data changed for privacy)
Type bits/keyID cr. time exp time key expir
pub 1024D/1234ABCD 2012-03-30
uid Cookie monster <coo...@example.com>
sig sig3 1234ABCD 2002-03-30 __________ __________ [selfsig]
sig sig ABCD4321 2014-01-26 __________ __________ dough dealer <do...@example.com>
sub 2048g/1234ABCD 2012-03-30
sig sbind 1234ABCD 2012-03-30 __________ __________ []
But It shows following output
Type bits/keyID cr. time exp time key expir
pub 1024D/1234ABCD 2012-03-30
uid Cookie monster <coo...@example.com>
sig sig3 1234ABCD 2012-03-30 __________ __________ [selfsig]
sub 2048g/1234ABCD 2012-03-30
sig sbind 1234ABCD 2012-03-30 __________ __________ []
Can any of the gpg blackbelts here can tell me what i m doing wrong over here.