RADIUS with MS-CHAPv2 Explanation

Shaul picture Shaul · May 19, 2015 · Viewed 9.5k times · Source

Can't find any flowcharts on how communication works between peers. I know how it works in Radius with PAP enabled, but it appears that with MS-Chapv2 there's a whole lot of work to be developed.

I'm trying to develop a RADIUS server to receive and authenticate user requests. Please help me in the form of Information not code.

Answer

red picture red · May 19, 2015

MSCHAPv2 is pretty complicated and is typically performed within another EAP method such as EAP-TLS, EAP-TTLS or PEAP. These outer methods encrypt the MSCHAPv2 exchange using TLS. The figure below for example, shows a PEAP flowchart where a client or supplicant establishes a TLS tunnel with the RADIUS server (the Authentication Server) and performs the MSCHAPv2 exchange.

enter image description here

The MSCHAPv2 exchange itself can be summarized as follows:

  • The AS starts by generating a 16-byte random server challenge and sends it to the Supplicant.
  • The Supplicant also generates a random 16-byte peer challenge. Then the challenge response is calculated based on the user's password. This challenge response is transmitted back to the AS, along with the peer challenge.
  • The AS checks the challenge response.
  • The AS calculates a peer challenge response based on the password and peer challenge.
  • The Supplicant checks the peer challenge response, completing the MSCHAPv2 authentication.

If you'd like to learn about the details and precise calculations involved, feel free to check out my thesis here. Sections 4.5.4 and 4.5.3 should contain all information you need in order to implement a RADIUS server capable of performing an MSCHAP exchange.

As you can see in the figure, many different keys are derived and used. This document provides a very untuitive insight into their functionality. However, the CSK is not explained in this document. This key is optionally used for "cryptobinding", i.e. in order to prove to the AS that both the TLS tunnel and MSCHAPv2 exchange were performed by the same peer. It is possible to derive the MSK from only the TLS master secret, but then you will be vulnerable to a relay attack (the thesis also contains a research paper which gives an example of such an attack).

Finally, the asleap readme gives another good and general step by step description of the MSCHAPv2 protocol, which might help you further.