@@ -34,20 +34,26 @@ func NewEntity(name, comment, email string, config *packet.Config) (*Entity, err
3434 return nil , err
3535 }
3636 primary := packet .NewSignerPrivateKey (creationTime , primaryPrivRaw )
37+ if config != nil && config .V5Keys {
38+ primary .UpgradeToV5 ()
39+ }
3740
3841 isPrimaryId := true
3942 selfSignature := & packet.Signature {
40- SigType : packet .SigTypePositiveCert ,
41- PubKeyAlgo : primary .PublicKey .PubKeyAlgo ,
42- Hash : config .Hash (),
43- CreationTime : creationTime ,
44- IssuerKeyId : & primary .PublicKey .KeyId ,
45- IsPrimaryId : & isPrimaryId ,
46- FlagsValid : true ,
47- FlagSign : true ,
48- FlagCertify : true ,
49- MDC : true , // true by default, see 5.8 vs. 5.14
50- AEAD : config .AEAD () != nil ,
43+ Version : primary .PublicKey .Version ,
44+ SigType : packet .SigTypePositiveCert ,
45+ PubKeyAlgo : primary .PublicKey .PubKeyAlgo ,
46+ Hash : config .Hash (),
47+ CreationTime : creationTime ,
48+ IssuerKeyId : & primary .PublicKey .KeyId ,
49+ IssuerFingerprint : primary .PublicKey .Fingerprint ,
50+ IsPrimaryId : & isPrimaryId ,
51+ FlagsValid : true ,
52+ FlagSign : true ,
53+ FlagCertify : true ,
54+ MDC : true , // true by default, see 5.8 vs. 5.14
55+ AEAD : config .AEAD () != nil ,
56+ V5Keys : config != nil && config .V5Keys ,
5157 }
5258
5359 // Set the PreferredHash for the SelfSignature from the packet.Config.
@@ -83,11 +89,15 @@ func NewEntity(name, comment, email string, config *packet.Config) (*Entity, err
8389 sub := packet .NewDecrypterPrivateKey (creationTime , subPrivRaw )
8490 sub .IsSubkey = true
8591 sub .PublicKey .IsSubkey = true
92+ if config != nil && config .V5Keys {
93+ sub .UpgradeToV5 ()
94+ }
8695
8796 subKey := Subkey {
8897 PublicKey : & sub .PublicKey ,
8998 PrivateKey : sub ,
9099 Sig : & packet.Signature {
100+ Version : primary .PublicKey .Version ,
91101 CreationTime : creationTime ,
92102 SigType : packet .SigTypeSubkeyBinding ,
93103 PubKeyAlgo : primary .PublicKey .PubKeyAlgo ,
@@ -136,6 +146,7 @@ func (e *Entity) AddSigningSubkey(config *packet.Config) error {
136146 PublicKey : & sub .PublicKey ,
137147 PrivateKey : sub ,
138148 Sig : & packet.Signature {
149+ Version : e .PrimaryKey .Version ,
139150 CreationTime : creationTime ,
140151 KeyLifetimeSecs : & keyLifetimeSecs ,
141152 SigType : packet .SigTypeSubkeyBinding ,
@@ -145,6 +156,7 @@ func (e *Entity) AddSigningSubkey(config *packet.Config) error {
145156 FlagSign : true ,
146157 IssuerKeyId : & e .PrimaryKey .KeyId ,
147158 EmbeddedSignature : & packet.Signature {
159+ Version : e .PrimaryKey .Version ,
148160 CreationTime : creationTime ,
149161 SigType : packet .SigTypePrimaryKeyBinding ,
150162 PubKeyAlgo : sub .PublicKey .PubKeyAlgo ,
@@ -153,6 +165,9 @@ func (e *Entity) AddSigningSubkey(config *packet.Config) error {
153165 },
154166 },
155167 }
168+ if config != nil && config .V5Keys {
169+ subkey .PublicKey .UpgradeToV5 ()
170+ }
156171
157172 err = subkey .Sig .EmbeddedSignature .CrossSignKey (subkey .PublicKey , e .PrimaryKey , subkey .PrivateKey , config )
158173 if err != nil {
@@ -185,6 +200,7 @@ func (e *Entity) AddEncryptionSubkey(config *packet.Config) error {
185200 PublicKey : & sub .PublicKey ,
186201 PrivateKey : sub ,
187202 Sig : & packet.Signature {
203+ Version : e .PrimaryKey .Version ,
188204 CreationTime : creationTime ,
189205 KeyLifetimeSecs : & keyLifetimeSecs ,
190206 SigType : packet .SigTypeSubkeyBinding ,
@@ -196,6 +212,9 @@ func (e *Entity) AddEncryptionSubkey(config *packet.Config) error {
196212 IssuerKeyId : & e .PrimaryKey .KeyId ,
197213 },
198214 }
215+ if config != nil && config .V5Keys {
216+ subkey .PublicKey .UpgradeToV5 ()
217+ }
199218
200219 subkey .PublicKey .IsSubkey = true
201220 subkey .PrivateKey .IsSubkey = true
0 commit comments