]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add tracing to mschap_challenge_hash
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 30 Sep 2019 19:46:21 +0000 (14:46 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 30 Sep 2019 19:48:03 +0000 (14:48 -0500)
src/modules/rlm_mschap/mschap.c
src/modules/rlm_mschap/mschap.h

index 48ad9f886027b3b5be9115cce5a815b8934a75a9..9c39e0ce98f025712c9cb41fa0dbd696f268ff39 100644 (file)
@@ -70,19 +70,27 @@ int mschap_nt_password_hash(uint8_t *out, char const *password)
  *     generates 64 bit challenge
  */
 void mschap_challenge_hash(uint8_t challenge[static MSCHAP_CHALLENGE_LENGTH],
-                          uint8_t const *peer_challenge,
-                          uint8_t const *auth_challenge,
+                          uint8_t const peer_challenge[static MSCHAP_PEER_CHALLENGE_LENGTH],
+                          uint8_t const auth_challenge[static MSCHAP_PEER_AUTHENTICATOR_CHALLENGE_LENGTH],
                           char const *user_name, size_t user_name_len)
 {
        fr_sha1_ctx Context;
-       uint8_t hash[20];
+       uint8_t hash[SHA1_DIGEST_LENGTH];
+
+       FR_PROTO_TRACE("RFC2759 ChallengeHash");
+       FR_PROTO_HEX_DUMP(peer_challenge, MSCHAP_PEER_CHALLENGE_LENGTH, "PeerChallenge");
+       FR_PROTO_HEX_DUMP(auth_challenge, MSCHAP_PEER_AUTHENTICATOR_CHALLENGE_LENGTH, "AuthenticatorChallenge");
+       FR_PROTO_HEX_DUMP((uint8_t const *)user_name, user_name_len, "UserName");
 
        fr_sha1_init(&Context);
-       fr_sha1_update(&Context, peer_challenge, 16);
-       fr_sha1_update(&Context, auth_challenge, 16);
+       fr_sha1_update(&Context, peer_challenge, MSCHAP_PEER_CHALLENGE_LENGTH);
+       fr_sha1_update(&Context, auth_challenge, MSCHAP_PEER_AUTHENTICATOR_CHALLENGE_LENGTH);
        fr_sha1_update(&Context, (uint8_t const *) user_name, user_name_len);
        fr_sha1_final(hash, &Context);
-       memcpy(challenge, hash, 8);                     //-V512
+
+       memcpy(challenge, hash, MSCHAP_CHALLENGE_LENGTH);               //-V512
+
+       FR_PROTO_HEX_DUMP(challenge, MSCHAP_CHALLENGE_LENGTH, "Challenge");
 }
 
 /*
index 90af7cffbca866ddbfd04990a9c7e49964e4c904..728f21b3e8459ff164d3913c482f3d0142228ed6 100644 (file)
@@ -4,16 +4,18 @@
 
 RCSIDH(mschap_h, "$Id$")
 
-#define NT_DIGEST_LENGTH 16
-#define LM_DIGEST_LENGTH 16
-#define MSCHAP_CHALLENGE_LENGTH 8
+#define NT_DIGEST_LENGTH                               16
+#define LM_DIGEST_LENGTH                               16
+#define MSCHAP_CHALLENGE_LENGTH                                8
+#define MSCHAP_PEER_CHALLENGE_LENGTH                   16
+#define MSCHAP_PEER_AUTHENTICATOR_CHALLENGE_LENGTH     16
 
 int    mschap_nt_password_hash(uint8_t out[static NT_DIGEST_LENGTH], char const *password);
 
 
 void   mschap_challenge_hash(uint8_t challenge[static MSCHAP_CHALLENGE_LENGTH],
-                             uint8_t const *peer_challenge,
-                             uint8_t const *auth_challenge,
+                             uint8_t const peer_challenge[static MSCHAP_PEER_CHALLENGE_LENGTH],
+                             uint8_t const auth_challenge[static MSCHAP_PEER_AUTHENTICATOR_CHALLENGE_LENGTH],
                              char const *user_name, size_t user_name_len);
 
 void   mschap_auth_response(char const *use_rname, size_t user_name_len,