1984not-GmbH / molch

An implementation of the axolotl ratchet based on libsodium.
Other
23 stars 3 forks source link

Weird test failure with low probability #44

Closed FSMaxB closed 8 years ago

FSMaxB commented 8 years ago

About every 20th to 50th time, molch-test fails with ERROR: Failed to start receive conversation.

I'll probably need to bisect this.

Way to reproduce:

$ while ./molch-test; do true; done

And then wait. It happens after about 1 to 3 minutes on my machine.

FSMaxB commented 8 years ago

Currently confirmed for 749ccc5 and later.

TODO:

FSMaxB commented 8 years ago

Traces (8413617):

FSMaxB commented 8 years ago

Bisected to 47ac286fa1e671d080d6fbf50987ba4401749eb3 molch: wire up axolotl to the public API.

Too bad, that's one of the biggest commits.

FSMaxB commented 8 years ago

I found the problem. This bugs happens with a probability of exactly 2%. This happens when either the first or second prekey gets randomly chosen.

This is because the buffer that I use for the list of prekeys starts at the signature, not the actual prekeys. Therefore, if the chosen prekey is 1 or 2, it's either the first or second half of the signature of the prekey list (SIGNATURE_SIZE = 64, PUBLIC_KEY_SIZE = 32).

The fix is easy: Let the buffer start at the correct position. This is one more reason to switch to Googles Protocol buffers instead of doing this kind of stuff by hand.

Update: Actually, it's the second half of the signature and the first half of the identity key, but the point still stands.