Skip to content

Commit 21daa12

Browse files
committed
Ensure positive, unique (signed_)pre_key_id values.
1 parent af7bb85 commit 21daa12

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

rust/protocol/fuzz/fuzz_targets/interaction.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ struct Participant {
1919
store: InMemSignalProtocolStore,
2020
message_queue: Vec<(CiphertextMessage, Box<[u8]>)>,
2121
archive_count: u8,
22+
pre_key_count: u32,
2223
}
2324

2425
impl Participant {
@@ -40,7 +41,9 @@ impl Participant {
4041
.calculate_signature(&their_signed_pre_key_public, rng)
4142
.unwrap();
4243

43-
let signed_pre_key_id: SignedPreKeyId = rng.gen_range(0, 0xFF_FFFF).into();
44+
let _: SignedPreKeyId = rng.gen_range(0, 0xFF_FFFF).into();
45+
them.pre_key_count += 1;
46+
let signed_pre_key_id: SignedPreKeyId = them.pre_key_count.into();
4447

4548
them.store
4649
.save_signed_pre_key(
@@ -56,8 +59,11 @@ impl Participant {
5659
.await
5760
.unwrap();
5861

62+
them.pre_key_count += 1;
63+
let pre_key_id: PreKeyId = them.pre_key_count.into();
64+
5965
let pre_key_info = if use_one_time_pre_key {
60-
let pre_key_id: PreKeyId = rng.gen_range(0, 0xFF_FFFF).into();
66+
let _: PreKeyId = rng.gen_range(0, 0xFF_FFFF).into();
6167
let one_time_pre_key = KeyPair::generate(rng);
6268

6369
them.store
@@ -197,6 +203,7 @@ fuzz_target!(|data: (u64, &[u8])| {
197203
.unwrap(),
198204
message_queue: Vec::new(),
199205
archive_count: 0,
206+
pre_key_count: 0,
200207
};
201208
let mut bob = Participant {
202209
name: "bob",
@@ -208,6 +215,7 @@ fuzz_target!(|data: (u64, &[u8])| {
208215
.unwrap(),
209216
message_queue: Vec::new(),
210217
archive_count: 0,
218+
pre_key_count: 0,
211219
};
212220

213221
for action in actions {

0 commit comments

Comments
 (0)