Handshakes are formal rules governing how two parties can commit to a mutual decision. They occur between a sender (the party initiating the handshake) and a receiver (the other party).
Handshakes are commonly used by humans for mutual decision-making (such as datetime and location for a meeting) and between computing devices to agree on communications parameters (such as transfer rate, protocol version, compression or encryption).
Handshake rules can be distinguished by the number of steps necessary for commitment to a mutual decision.
Three-way handshakes imply commitment if (and only if) the sender proposes something, the receiver replies affirmatively and the sender confirms the receiver's reply.
According to Paul Graham,
Silicon Valley runs on handshake deals
– verbal commitment before legal documents are created and signed.
Computers on a network that set up connections using TCP follow the three-way handshake template, proposition consisting of a number.
This construction is vulnerable to an attack in which a sender sends a large amount of
messages and no
flooding), which leads to the receiver wasting resources waiting for
common defense mechanism
cookies) encodes handshake state in
, then discards
and tries to reconstruct handshake state from
+1 received in
Two-way handshakes imply commitment to a proposition if (and only if) the sender proposes something and the receiver replies affirmatively.
Computers on a network that retrieve resources via HTTP and negotiate content details such as language or format ( HTTP content negotiation) follow the two-way handshake template.
Negotiation success is not defined by sender and receiver agreeing on a proposition, but by both agreeing if they agree on a proposition. Agreeing to disagree is among the possible outcomes of a successful two-way handshake.
Two-way handshakes can be used safely if (and only if) misunderstandings and messages loss are impossible (like with simple yes or no questions) or if misunderstandings or messages loss only lead to harmless outcomes (likely inaction on part of one or both participants).
One-way handshakes imply commitment if the receiver does not reply. The sender expects the receiver to either silently consent or noticeably disagree.
One-way handshakes can be used safely if (and only if) the receiver is capable to disagree and both misunderstandings or messages loss are impossible or if receiver disagreeing or misunderstandings and message loss only lead to harmless outcomes (likely inaction on part of the receiver).
Using one-way handshakes in situations where inaction on part of the receiver causes harm to the sender enables the sender to cause harm to themself and blame it on the receiver.
A two-way handshake can not be distinguished from a partial three-way handshake by observing the messages of sender and receiver. Similarly, a one-way handshake can not be distinguished from a partial two-way or three-way handshake by observing the message of the sender.
Sender and receiver therefore must both know the handshaking mechanism before negotiation takes place. Since they cannot negotiate, the handshake mechanism has to be decided by one party, who then prepends the chosen handshaking mechanism to its first message.