2

Let's assume that pppd returns following message:

 rcvd [CHAP Challenge id=0x1 <12345>, name = ""] 

and password is "test". What string should I use to calculate MD5 hash for CHAP Response? [https://www.cisco.com/c/en/us/support/docs/wan/point-to-point-protocol-ppp/25647-understanding-ppp-chap.html] - here there is general description. But I still miss the details... I know that I should concatenate challenge, ID and password, but what is the correct order of concatenating those strings? Should I convert password from ASCII to hex before calculating hash?

1 Answer 1

4

CHAP is defined in RFC 1994.

You concatenate the identifier, the password (secret), and the challenge, in ASCII, in that order. The response is hashMD5(identifier.secret.challenge), sent in binary (16 bytes for MD5).

For your example, that should be in hex 0x017465737412345 hashed.

Note that MD5 is not cryptographically safe any more due to advances in processing power and methods. On an unsafe channel, you'll need to provide additional password protection (like SSL/TLS or VPN).

4
  • Thank you. Could you please confirm if my understanding is correct? Following the example from my question, the string will contain following parts: 0x1 (interpreted as binary data), test, 0x12345 (interpreted as binary data, so there is a mistake in my example, it should be even number of characters)
    – Adam
    Commented Oct 27, 2018 at 15:46
  • 1
    I think 12345 is rather a string than a hex number. The challenge has an arbitrary length, so it's a string. The ID must be the same byte as in the challenge - I've added that to the answer.
    – Zac67
    Commented Oct 27, 2018 at 16:51
  • 1
    I found example with pppd logs here. ` [CHAP Challenge id=0x3 <bf2b15282cf4f6672f1b809a251bd731>, name = "HiPer"] [CHAP Response id=0x3 <69cd88a27098f6c3e961f49f0cec74fb>, name = "Sunrise"]` The password was 'freesurf'. Using online hex to MD5 converter following string gave me the same response as in the logs: 036672656573757266bf2b15282cf4f6672f1b809a251bd731. So it seems pppd returns data in hex format. Thanks for the help!
    – Adam
    Commented Oct 27, 2018 at 21:51
  • You're welcome - don't forget to accept the answer if it helped you.
    – Zac67
    Commented Oct 28, 2018 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.