diff options
author | Neal H. Walfield <neal@pep.foundation> | 2020-05-13 16:20:37 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2020-05-13 17:56:33 +0200 |
commit | dc8ea94ab33c0ad5521a98c6b2b74097104bb5c0 (patch) | |
tree | eaa777d893cac1af3f86e9fe57842aa0ac7c36b1 /openpgp/src/cert/builder.rs | |
parent | 9c8c144b9aeadd0b97991642605a601587f57153 (diff) |
openpgp: Set the primary User ID flag on the first User ID
- The documentation for `CertBuilder` says that the first User ID
that is added will be the primary User ID.
- Make the implementation match the documentation by setting the
primary User ID flag for the first User ID.
Diffstat (limited to 'openpgp/src/cert/builder.rs')
-rw-r--r-- | openpgp/src/cert/builder.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/openpgp/src/cert/builder.rs b/openpgp/src/cert/builder.rs index 35941c0c..1ef60e71 100644 --- a/openpgp/src/cert/builder.rs +++ b/openpgp/src/cert/builder.rs @@ -329,11 +329,14 @@ impl CertBuilder { let mut cert = Cert::try_from(packets)?; // Sign UserIDs. - for uid in self.userids.into_iter() { - let builder = sig.clone() + for (i, uid) in self.userids.into_iter().enumerate() { + let mut builder = sig.clone() .set_type(SignatureType::PositiveCertification) // GnuPG wants at least a 512-bit hash for P521 keys. .set_hash_algo(HashAlgorithm::SHA512); + if i == 0 { + builder = builder.set_primary_userid(true)?; + } let signature = uid.bind(&mut signer, &cert, builder)?; cert = cert.merge_packets( vec![Packet::from(uid), signature.into()])?; |