* Copyright (c) 2002 Google, Inc.
*/
-#define RCSID "$Id: chap_ms.c,v 1.19 2002/04/02 13:54:59 dfs Exp $"
+#define RCSID "$Id: chap_ms.c,v 1.22 2002/09/06 22:11:12 kad Exp $"
#ifdef CHAPMS
{
SHA1_CTX sha1Context;
u_char sha1Hash[SHA1_SIGNATURE_SIZE];
+ char *user;
+
+ /* remove domain from "domain\username" */
+ if ((user = strrchr(username, '\\')) != NULL)
+ ++user;
+ else
+ user = username;
SHA1_Init(&sha1Context);
SHA1_Update(&sha1Context, PeerChallenge, 16);
SHA1_Update(&sha1Context, rchallenge, 16);
- SHA1_Update(&sha1Context, username, strlen(username));
+ SHA1_Update(&sha1Context, user, strlen(user));
SHA1_Final(sha1Hash, &sha1Context);
BCOPY(sha1Hash, Challenge, 8);
#endif
BZERO(response, sizeof(*response));
- /* Calculate both always */
ChapMS_NT(rchallenge, secret, secret_len, response->NTResp);
#ifdef MSLANMAN
ChapMS_LANMan(rchallenge, secret, secret_len, response);
- /* prefered method is set by option */
+ /* preferred method is set by option */
response->UseNT[0] = !ms_lanman;
#else
response->UseNT[0] = 1;
#endif
+ cstate->resp_length = MS_CHAP_RESPONSE_LEN;
+
#ifdef MPPE
Set_Start_Key(rchallenge, secret, secret_len);
#endif
GenerateAuthenticatorResponse(secret, secret_len, response->NTResp,
response->PeerChallenge, rchallenge,
user, authResponse);
+
+ cstate->resp_length = MS_CHAP2_RESPONSE_LEN;
+
#ifdef MPPE
SetMasterKeys(secret, secret_len, response->NTResp, authenticator);
#endif