Question

I'm writing a peer to peer network protocol based on private/public key pair trust. To verify and deduplicate messages sent by a host, I use timestamp verification. A host does not trust another host's message if the signed timestamp has a delta (to the current) of greater than 30 seconds or so.

I just ran into the interesting problem that my test server and my second client are about 40 seconds out of sync (fixed by updating ntp).

I was wondering what an acceptable time difference would be, and if there is a better way of preventing replay attacks? Supposedly I could have one client supply a random text to hash and sign, but unfortunately this wont work as in this situation I have to write messages once.

Was it helpful?

Solution

A host does not trust another host's message if the signed timestamp has a delta (to the current) of greater than 30 seconds or so.

Time based is notoriously difficult. I can't tell you the problems I had with mobile devices that would not or could not sync their clock with the network.

Counter based is usually easier and does not DoS itself.


I was wondering what an acceptable time difference would be...

Microsoft's Active Directory uses 5 minutes.


if there is a better way of preventing replay attacks

Counter based with a challenge/response.


I could have one client supply a random text to hash and sign, but unfortunately this wont work as in this situation I have to write messages once...

Perhaps you could use a {time,nonce} pair. If the nonce has not been previously recorded, then act on the message if its within the time delta. Then hold the message (with {time,nonce}) for a windows (5 minutes?).

If you encounter the same nonce again, don't act on it. If you encounter an unseen nonce but its out of the time delta, then don't act on it. Purge your list of nonces on occasion (every 5 minutes?).


I'm writing a peer to peer network protocol based...

If you look around, then you will probably find a protocol in the academic literature.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top