This assumes the use of a
public-key encryption algorithm. Here, Alice (A) and Bob (B) use a trusted server (S) to distribute public keys on request. These keys are: • K_{PA} and {{tmath|1= K_{SA} }}, respectively public and private halves of an encryption key-pair belonging to A (S stands for "secret key" here) • K_{PB} and {{tmath|1= K_{SB} }}, similar belonging to B • K_{PS} and {{tmath|1= K_{SS} }}, similar belonging to . (Note that this key-pair will be used for
digital signatures, i.e., K_{SS} used for signing a message and K_{PS} used for verification. K_{PS} must be known to A and B before the protocol starts.) The protocol runs as follows: : A \rightarrow S: \left . A, B \right . :: A requests 's public keys from . : S \rightarrow A: \{K_{PB}, B\}_{K_{SS}} :: S responds with public key K_{PB} alongside 's identity, signed by the server for authentication purposes. : A \rightarrow B: \{N_A, A\}_{K_{PB}} :: A chooses a random N_A and sends it to . : B \rightarrow S: \left. B, A \right . :: B now knows A wants to communicate, so B requests 's public keys. : S \rightarrow B: \{K_{PA}, A\}_{K_{SS}} :: Server responds. : B \rightarrow A: \{N_A, N_B\}_{K_{PA}} :: B chooses a random , and sends it to A along with N_A to prove ability to decrypt with {{tmath|1= K_{SB} }}. : A \rightarrow B: \{N_B\}_{K_{PB}} :: A confirms N_B to , to prove ability to decrypt with {{tmath|1= K_{SA} }}. At the end of the protocol, A and B know each other's identities, and know both N_A and . These nonces are not known to eavesdroppers.
An attack on the protocol This protocol is vulnerable to a
man-in-the-middle attack. If an impostor I can persuade A to initiate a session with them, they can relay the messages to B and convince B that he is communicating with . Ignoring the traffic to and from S, which is unchanged, the attack runs as follows: : A \rightarrow I: \{N_A, A\}_{K_{PI}} :: A sends N_A to , who decrypts the message with {{tmath|1= K_{SI} }}. : I \rightarrow B: \{N_A, A\}_{K_{PB}} :: I relays the message to , pretending that A is communicating. : B \rightarrow I: \{N_A, N_B\}_{K_{PA}} :: B sends N_B. : I \rightarrow A: \{N_A, N_B\}_{K_{PA}} :: I relays it to . : A \rightarrow I: \{N_B\}_{K_{PI}} :: A decrypts N_B and confirms it to , who learns it. : I \rightarrow B: \{N_B\}_{K_{PB}} :: I re-encrypts , and convinces B that she's decrypted it. At the end of the attack, B falsely believes that A is communicating with him, and that N_A and N_B are known only to A and . The following example illustrates the attack. Alice () would like to contact her bank (). We assume that an impostor () successfully convinces A that they are the bank. As a consequence, A uses the public key of I instead of using the public key of B to encrypt the messages she intends to send to her bank. Therefore, A sends I her nonce encrypted with the public key of . I decrypts the message using their private key and contacts B sending it the nonce of A encrypted with the public key of B. B has no way to know that this message was actually sent by . B responds with their own nonce and encrypts the message with the public key of . Since I is not in possession of the private key of A they have to relay the message to A without knowing the content. A decrypts the message with her private key and respond with the nonce of B encrypted with the public key of . I decrypts the message using their private key and is now in possession of nonce A and . Therefore, they can now impersonate the bank and the client respectively.
Fixing the man-in-the-middle attack The attack was first described in a 1995 paper by
Gavin Lowe. The paper also describes a fixed version of the scheme, referred to as the
Needham–Schroeder–Lowe protocol. The fix involves the modification of message six to include the responder's identity, that is we replace: : B \rightarrow A: \{N_A, N_B\}_{K_{PA}} with the fixed version: : B \rightarrow A: \{N_A, N_B, B\}_{K_{PA}} and the intruder cannot successfully replay the message because is expecting a message containing the identity of whereas the message will have identity of . == See also ==