diff options
author | Neal H. Walfield <neal@pep.foundation> | 2020-05-05 11:25:31 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2020-05-05 11:25:31 +0200 |
commit | 6e182cad61c49dae93ce067cf360555ee4e00520 (patch) | |
tree | 83bd237295ac30d34e747c9a2b37a611976169cf | |
parent | 494ecc43b1e8e222847cfd053c1c6d5b96b05f42 (diff) |
openpgp: Make sure the two User IDs are different
- Arbitrary could generate identical user ids, but we rely on the
fact that they are different. Make sure that is the case.
-rw-r--r-- | openpgp/src/cert/mod.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/openpgp/src/cert/mod.rs b/openpgp/src/cert/mod.rs index 1797e1b6..ee289f91 100644 --- a/openpgp/src/cert/mod.rs +++ b/openpgp/src/cert/mod.rs @@ -3524,9 +3524,16 @@ mod test { let mut gen = StdThreadGen::new(16); let p = &P::new(); + let userid1 = UserID::arbitrary(&mut gen); + // The two user ids need to be unique. + let mut userid2 = UserID::arbitrary(&mut gen); + while userid1 == userid2 { + userid2 = UserID::arbitrary(&mut gen); + } + let (cert, _) = CertBuilder::general_purpose( - None, Some(UserID::arbitrary(&mut gen))) - .add_userid(UserID::arbitrary(&mut gen)) + None, Some(userid1)) + .add_userid(userid2) .generate()?; let primary_uid = cert.with_policy(p, None)?.primary_userid()?.userid().clone(); assert_eq!(cert.clone().into_packet_pile().children().count(), |