@@ -91,13 +91,15 @@ func (t *Entity) AddUserId(name, comment, email string, config *packet.Config) e
91
91
}
92
92
93
93
func writeKeyProperties (selfSignature * packet.Signature , creationTime time.Time , keyLifetimeSecs uint32 , config * packet.Config ) error {
94
+ advertiseAead := config .AEAD () != nil
95
+
94
96
selfSignature .CreationTime = creationTime
95
97
selfSignature .KeyLifetimeSecs = & keyLifetimeSecs
96
98
selfSignature .FlagsValid = true
97
99
selfSignature .FlagSign = true
98
100
selfSignature .FlagCertify = true
99
101
selfSignature .SEIPDv1 = true // true by default, see 5.8 vs. 5.14
100
- selfSignature .SEIPDv2 = config . AEAD () != nil
102
+ selfSignature .SEIPDv2 = advertiseAead
101
103
102
104
// Set the PreferredHash for the SelfSignature from the packet.Config.
103
105
// If it is not the must-implement algorithm from rfc4880bis, append that.
@@ -126,16 +128,19 @@ func writeKeyProperties(selfSignature *packet.Signature, creationTime time.Time,
126
128
selfSignature .PreferredCompression = append (selfSignature .PreferredCompression , uint8 (config .Compression ()))
127
129
}
128
130
129
- // And for DefaultMode.
130
- modes := []uint8 {uint8 (config .AEAD ().Mode ())}
131
- if config .AEAD ().Mode () != packet .AEADModeOCB {
132
- modes = append (modes , uint8 (packet .AEADModeOCB ))
133
- }
131
+ if advertiseAead {
132
+ // Get the preferred AEAD mode from the packet.Config.
133
+ // If it is not the must-implement algorithm from rfc9580, append that.
134
+ modes := []uint8 {uint8 (config .AEAD ().Mode ())}
135
+ if config .AEAD ().Mode () != packet .AEADModeOCB {
136
+ modes = append (modes , uint8 (packet .AEADModeOCB ))
137
+ }
134
138
135
- // For preferred (AES256, GCM), we'll generate (AES256, GCM), (AES256, OCB), (AES128, GCM), (AES128, OCB)
136
- for _ , cipher := range selfSignature .PreferredSymmetric {
137
- for _ , mode := range modes {
138
- selfSignature .PreferredCipherSuites = append (selfSignature .PreferredCipherSuites , [2 ]uint8 {cipher , mode })
139
+ // For preferred (AES256, GCM), we'll generate (AES256, GCM), (AES256, OCB), (AES128, GCM), (AES128, OCB)
140
+ for _ , cipher := range selfSignature .PreferredSymmetric {
141
+ for _ , mode := range modes {
142
+ selfSignature .PreferredCipherSuites = append (selfSignature .PreferredCipherSuites , [2 ]uint8 {cipher , mode })
143
+ }
139
144
}
140
145
}
141
146
return nil
0 commit comments