78 #if PPP_SUPPORT && MSCHAP_SUPPORT 85 #include <sys/types.h> 100 #if LWIP_INCLUDED_POLARSSL_MD4 106 #if LWIP_INCLUDED_POLARSSL_SHA1 112 #if LWIP_INCLUDED_POLARSSL_DES 118 #define SHA1_SIGNATURE_SIZE 20 119 #define MD4_SIGNATURE_SIZE 16 120 #define MAX_NT_PASSWORD 256 122 #define MS_CHAP_RESPONSE_LEN 49 123 #define MS_CHAP2_RESPONSE_LEN 49 124 #define MS_AUTH_RESPONSE_LENGTH 40 128 #define MS_CHAP_ERROR_RESTRICTED_LOGON_HOURS 646 129 #define MS_CHAP_ERROR_ACCT_DISABLED 647 130 #define MS_CHAP_ERROR_PASSWD_EXPIRED 648 131 #define MS_CHAP_ERROR_NO_DIALIN_PERMISSION 649 132 #define MS_CHAP_ERROR_AUTHENTICATION_FAILURE 691 133 #define MS_CHAP_ERROR_CHANGING_PASSWORD 709 138 #define MS_CHAP_LANMANRESP 0 139 #define MS_CHAP_LANMANRESP_LEN 24 140 #define MS_CHAP_NTRESP 24 141 #define MS_CHAP_NTRESP_LEN 24 142 #define MS_CHAP_USENT 48 147 #define MS_CHAP2_PEER_CHALLENGE 0 148 #define MS_CHAP2_PEER_CHAL_LEN 16 149 #define MS_CHAP2_RESERVED_LEN 8 150 #define MS_CHAP2_NTRESP 24 151 #define MS_CHAP2_NTRESP_LEN 24 152 #define MS_CHAP2_FLAGS 48 157 #define MPPE_ENC_POL_ENC_ALLOWED 1 158 #define MPPE_ENC_POL_ENC_REQUIRED 2 159 #define MPPE_ENC_TYPES_RC4_40 2 160 #define MPPE_ENC_TYPES_RC4_128 4 163 extern void set_mppe_enc_types(
int,
int);
168 #define MS_CHAP2_AUTHENTICATEE 0 169 #define MS_CHAP2_AUTHENTICATOR 1 171 static void ascii2unicode (
const char[],
int, u_char[]);
172 static void NTPasswordHash (u_char *,
int, u_char[MD4_SIGNATURE_SIZE]);
173 static void ChallengeResponse (
const u_char *,
const u_char *, u_char[24]);
174 static void ChallengeHash (
const u_char[16],
const u_char *,
const char *, u_char[8]);
175 static void ChapMS_NT (
const u_char *,
const char *,
int, u_char[24]);
176 static void ChapMS2_NT (
const u_char *,
const u_char[16],
const char *,
const char *,
int,
178 static void GenerateAuthenticatorResponsePlain
179 (
const char*,
int, u_char[24],
const u_char[16],
const u_char *,
180 const char *, u_char[41]);
182 static void ChapMS_LANMan (u_char *,
char *,
int, u_char *);
185 static void GenerateAuthenticatorResponse(
const u_char PasswordHashHash[MD4_SIGNATURE_SIZE],
186 u_char NTResponse[24],
const u_char PeerChallenge[16],
187 const u_char *rchallenge,
const char *username,
188 u_char authResponse[MS_AUTH_RESPONSE_LENGTH+1]);
191 static void Set_Start_Key (ppp_pcb *pcb,
const u_char *,
const char *,
int);
192 static void SetMasterKeys (ppp_pcb *pcb,
const char *,
int, u_char[24],
int);
195 static void ChapMS (ppp_pcb *pcb,
const u_char *,
const char *,
int, u_char *);
196 static void ChapMS2 (ppp_pcb *pcb,
const u_char *,
const u_char *,
const char *,
const char *,
int,
197 u_char *, u_char[MS_AUTH_RESPONSE_LENGTH+1],
int);
208 static char *mschap_challenge =
NULL;
210 static char *mschap2_peer_challenge =
NULL;
221 static option_t chapms_option_list[] = {
223 {
"ms-lanman", o_bool, &ms_lanman,
224 "Use LanMan passwd when using MS-CHAP", 1 },
227 {
"mschap-challenge", o_string, &mschap_challenge,
228 "specify CHAP challenge" },
229 {
"mschap2-peer-challenge", o_string, &mschap2_peer_challenge,
230 "specify CHAP peer challenge" },
243 static void chapms_generate_challenge(ppp_pcb *pcb,
unsigned char *challenge) {
248 if (mschap_challenge && strlen(mschap_challenge) == 8)
249 memcpy(challenge, mschap_challenge, 8);
252 magic_random_bytes(challenge, 8);
255 static void chapms2_generate_challenge(ppp_pcb *pcb,
unsigned char *challenge) {
260 if (mschap_challenge && strlen(mschap_challenge) == 16)
261 memcpy(challenge, mschap_challenge, 16);
264 magic_random_bytes(challenge, 16);
267 static int chapms_verify_response(ppp_pcb *pcb,
int id,
const char *name,
268 const unsigned char *secret,
int secret_len,
269 const unsigned char *challenge,
const unsigned char *response,
270 char *message,
int message_space) {
271 unsigned char md[MS_CHAP_RESPONSE_LEN];
273 int challenge_len, response_len;
277 challenge_len = *challenge++;
278 response_len = *response++;
279 if (response_len != MS_CHAP_RESPONSE_LEN)
283 if (!response[MS_CHAP_USENT]) {
285 ppp_notice(
"Peer request for LANMAN auth not supported");
291 ChapMS(pcb, (
const u_char *)challenge, (
const char *)secret, secret_len, md);
295 if (!response[MS_CHAP_USENT])
296 diff = memcmp(&response[MS_CHAP_LANMANRESP],
297 &md[MS_CHAP_LANMANRESP], MS_CHAP_LANMANRESP_LEN);
300 diff = memcmp(&response[MS_CHAP_NTRESP], &md[MS_CHAP_NTRESP],
304 ppp_slprintf(message, message_space,
"Access granted");
310 ppp_slprintf(message, message_space,
"E=691 R=1 C=%0.*B V=0",
311 challenge_len, challenge);
315 static int chapms2_verify_response(ppp_pcb *pcb,
int id,
const char *name,
316 const unsigned char *secret,
int secret_len,
317 const unsigned char *challenge,
const unsigned char *response,
318 char *message,
int message_space) {
319 unsigned char md[MS_CHAP2_RESPONSE_LEN];
320 char saresponse[MS_AUTH_RESPONSE_LENGTH+1];
321 int challenge_len, response_len;
324 challenge_len = *challenge++;
325 response_len = *response++;
326 if (response_len != MS_CHAP2_RESPONSE_LEN)
330 ChapMS2(pcb, (
const u_char*)challenge, (
const u_char*)&response[MS_CHAP2_PEER_CHALLENGE], name,
331 (
const char *)secret, secret_len, md,
332 (
unsigned char *)saresponse, MS_CHAP2_AUTHENTICATOR);
354 if (memcmp(&md[MS_CHAP2_NTRESP], &response[MS_CHAP2_NTRESP],
355 MS_CHAP2_NTRESP_LEN) == 0) {
356 if (response[MS_CHAP2_FLAGS])
357 ppp_slprintf(message, message_space,
"S=%s", saresponse);
359 ppp_slprintf(message, message_space,
"S=%s M=%s",
360 saresponse,
"Access granted");
386 ppp_slprintf(message, message_space,
"E=691 R=1 C=%0.*B V=0 M=%s",
387 challenge_len, challenge,
"Access denied");
392 static void chapms_make_response(ppp_pcb *pcb,
unsigned char *response,
int id,
const char *our_name,
393 const unsigned char *challenge,
const char *secret,
int secret_len,
394 unsigned char *private_) {
399 *response++ = MS_CHAP_RESPONSE_LEN;
400 ChapMS(pcb, challenge, secret, secret_len, response);
403 static void chapms2_make_response(ppp_pcb *pcb,
unsigned char *response,
int id,
const char *our_name,
404 const unsigned char *challenge,
const char *secret,
int secret_len,
405 unsigned char *private_) {
408 *response++ = MS_CHAP2_RESPONSE_LEN;
409 ChapMS2(pcb, challenge,
411 mschap2_peer_challenge,
415 our_name, secret, secret_len, response, private_,
416 MS_CHAP2_AUTHENTICATEE);
419 static int chapms2_check_success(ppp_pcb *pcb,
unsigned char *msg,
int len,
unsigned char *private_) {
422 if ((len < MS_AUTH_RESPONSE_LENGTH + 2) ||
423 strncmp((
char *)msg,
"S=", 2) != 0) {
425 ppp_error(
"MS-CHAPv2 Success packet is badly formed.");
430 if (len < MS_AUTH_RESPONSE_LENGTH
431 || memcmp(msg, private_, MS_AUTH_RESPONSE_LENGTH)) {
433 ppp_error(
"MS-CHAPv2 mutual authentication failed.");
437 msg += MS_AUTH_RESPONSE_LENGTH;
438 len -= MS_AUTH_RESPONSE_LENGTH;
439 if ((len >= 3) && !strncmp((
char *)msg,
" M=", 3)) {
443 ppp_error(
"MS-CHAPv2 Success packet is badly formed.");
449 static void chapms_handle_failure(ppp_pcb *pcb,
unsigned char *inp,
int len) {
467 if (!strncmp(p,
"E=", 2))
468 err = strtol(p+2,
NULL, 10);
472 if (len && ((p = strstr(p,
" M=")) !=
NULL)) {
478 case MS_CHAP_ERROR_RESTRICTED_LOGON_HOURS:
479 p =
"E=646 Restricted logon hours";
482 case MS_CHAP_ERROR_ACCT_DISABLED:
483 p =
"E=647 Account disabled";
486 case MS_CHAP_ERROR_PASSWD_EXPIRED:
487 p =
"E=648 Password expired";
490 case MS_CHAP_ERROR_NO_DIALIN_PERMISSION:
491 p =
"E=649 No dialin permission";
494 case MS_CHAP_ERROR_AUTHENTICATION_FAILURE:
495 p =
"E=691 Authentication failure";
498 case MS_CHAP_ERROR_CHANGING_PASSWORD:
500 p =
"E=709 Error changing password";
504 ppp_error(
"Unknown MS-CHAP authentication failure: %.*v",
511 ppp_error(
"MS-CHAP authentication failed: %v", p);
514 static void ChallengeResponse(
const u_char *challenge,
515 const u_char PasswordHash[MD4_SIGNATURE_SIZE],
516 u_char response[24]) {
517 u_char ZPasswordHash[21];
521 BZERO(ZPasswordHash,
sizeof(ZPasswordHash));
522 MEMCPY(ZPasswordHash, PasswordHash, MD4_SIGNATURE_SIZE);
525 dbglog(
"ChallengeResponse - ZPasswordHash %.*B",
526 sizeof(ZPasswordHash), ZPasswordHash);
529 pppcrypt_56_to_64_bit_key(ZPasswordHash + 0, des_key);
530 des_setkey_enc(&des, des_key);
531 des_crypt_ecb(&des, challenge, response +0);
533 pppcrypt_56_to_64_bit_key(ZPasswordHash + 7, des_key);
534 des_setkey_enc(&des, des_key);
535 des_crypt_ecb(&des, challenge, response +8);
537 pppcrypt_56_to_64_bit_key(ZPasswordHash + 14, des_key);
538 des_setkey_enc(&des, des_key);
539 des_crypt_ecb(&des, challenge, response +16);
542 dbglog(
"ChallengeResponse - response %.24B", response);
546 static void ChallengeHash(
const u_char PeerChallenge[16],
const u_char *rchallenge,
547 const char *username, u_char Challenge[8]) {
548 sha1_context sha1Context;
549 u_char sha1Hash[SHA1_SIGNATURE_SIZE];
553 if ((user = strrchr(username,
'\\')) !=
NULL)
558 sha1_starts(&sha1Context);
559 sha1_update(&sha1Context, PeerChallenge, 16);
560 sha1_update(&sha1Context, rchallenge, 16);
561 sha1_update(&sha1Context, (
const unsigned char*)user, strlen(user));
562 sha1_finish(&sha1Context, sha1Hash);
564 MEMCPY(Challenge, sha1Hash, 8);
574 static void ascii2unicode(
const char ascii[],
int ascii_len, u_char unicode[]) {
577 BZERO(unicode, ascii_len * 2);
578 for (i = 0; i < ascii_len; i++)
579 unicode[i * 2] = (u_char) ascii[i];
582 static void NTPasswordHash(u_char *secret,
int secret_len, u_char hash[MD4_SIGNATURE_SIZE]) {
583 md4_context md4Context;
585 md4_starts(&md4Context);
586 md4_update(&md4Context, secret, secret_len);
587 md4_finish(&md4Context, hash);
590 static void ChapMS_NT(
const u_char *rchallenge,
const char *secret,
int secret_len,
591 u_char NTResponse[24]) {
592 u_char unicodePassword[MAX_NT_PASSWORD * 2];
593 u_char PasswordHash[MD4_SIGNATURE_SIZE];
596 ascii2unicode(secret, secret_len, unicodePassword);
597 NTPasswordHash(unicodePassword, secret_len * 2, PasswordHash);
599 ChallengeResponse(rchallenge, PasswordHash, NTResponse);
602 static void ChapMS2_NT(
const u_char *rchallenge,
const u_char PeerChallenge[16],
const char *username,
603 const char *secret,
int secret_len, u_char NTResponse[24]) {
604 u_char unicodePassword[MAX_NT_PASSWORD * 2];
605 u_char PasswordHash[MD4_SIGNATURE_SIZE];
608 ChallengeHash(PeerChallenge, rchallenge, username, Challenge);
611 ascii2unicode(secret, secret_len, unicodePassword);
612 NTPasswordHash(unicodePassword, secret_len * 2, PasswordHash);
614 ChallengeResponse(Challenge, PasswordHash, NTResponse);
618 static u_char *StdText = (u_char *)
"KGS!@#$%";
620 static void ChapMS_LANMan(u_char *rchallenge,
char *secret,
int secret_len,
621 unsigned char *response) {
623 u_char UcasePassword[MAX_NT_PASSWORD];
624 u_char PasswordHash[MD4_SIGNATURE_SIZE];
629 BZERO(UcasePassword,
sizeof(UcasePassword));
630 for (i = 0; i < secret_len; i++)
631 UcasePassword[i] = (u_char)toupper(secret[i]);
633 pppcrypt_56_to_64_bit_key(UcasePassword +0, des_key);
634 des_setkey_enc(&des, des_key);
635 des_crypt_ecb(&des, StdText, PasswordHash +0);
637 pppcrypt_56_to_64_bit_key(UcasePassword +7, des_key);
638 des_setkey_enc(&des, des_key);
639 des_crypt_ecb(&des, StdText, PasswordHash +8);
641 ChallengeResponse(rchallenge, PasswordHash, &response[MS_CHAP_LANMANRESP]);
646 static void GenerateAuthenticatorResponse(
const u_char PasswordHashHash[MD4_SIGNATURE_SIZE],
647 u_char NTResponse[24],
const u_char PeerChallenge[16],
648 const u_char *rchallenge,
const char *username,
649 u_char authResponse[MS_AUTH_RESPONSE_LENGTH+1]) {
653 static const u_char Magic1[39] =
654 { 0x4D, 0x61, 0x67, 0x69, 0x63, 0x20, 0x73, 0x65, 0x72, 0x76,
655 0x65, 0x72, 0x20, 0x74, 0x6F, 0x20, 0x63, 0x6C, 0x69, 0x65,
656 0x6E, 0x74, 0x20, 0x73, 0x69, 0x67, 0x6E, 0x69, 0x6E, 0x67,
657 0x20, 0x63, 0x6F, 0x6E, 0x73, 0x74, 0x61, 0x6E, 0x74 };
658 static const u_char Magic2[41] =
659 { 0x50, 0x61, 0x64, 0x20, 0x74, 0x6F, 0x20, 0x6D, 0x61, 0x6B,
660 0x65, 0x20, 0x69, 0x74, 0x20, 0x64, 0x6F, 0x20, 0x6D, 0x6F,
661 0x72, 0x65, 0x20, 0x74, 0x68, 0x61, 0x6E, 0x20, 0x6F, 0x6E,
662 0x65, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6F,
666 sha1_context sha1Context;
667 u_char Digest[SHA1_SIGNATURE_SIZE];
670 sha1_starts(&sha1Context);
671 sha1_update(&sha1Context, PasswordHashHash, MD4_SIGNATURE_SIZE);
672 sha1_update(&sha1Context, NTResponse, 24);
673 sha1_update(&sha1Context, Magic1,
sizeof(Magic1));
674 sha1_finish(&sha1Context, Digest);
676 ChallengeHash(PeerChallenge, rchallenge, username, Challenge);
678 sha1_starts(&sha1Context);
679 sha1_update(&sha1Context, Digest,
sizeof(Digest));
680 sha1_update(&sha1Context, Challenge,
sizeof(Challenge));
681 sha1_update(&sha1Context, Magic2,
sizeof(Magic2));
682 sha1_finish(&sha1Context, Digest);
685 for (i = 0; i <
LWIP_MAX((MS_AUTH_RESPONSE_LENGTH / 2), (
int)
sizeof(Digest)); i++)
686 sprintf((
char *)&authResponse[i * 2],
"%02X", Digest[i]);
690 static void GenerateAuthenticatorResponsePlain(
691 const char *secret,
int secret_len,
692 u_char NTResponse[24],
const u_char PeerChallenge[16],
693 const u_char *rchallenge,
const char *username,
694 u_char authResponse[MS_AUTH_RESPONSE_LENGTH+1]) {
695 u_char unicodePassword[MAX_NT_PASSWORD * 2];
696 u_char PasswordHash[MD4_SIGNATURE_SIZE];
697 u_char PasswordHashHash[MD4_SIGNATURE_SIZE];
700 ascii2unicode(secret, secret_len, unicodePassword);
701 NTPasswordHash(unicodePassword, secret_len * 2, PasswordHash);
702 NTPasswordHash(PasswordHash,
sizeof(PasswordHash),
705 GenerateAuthenticatorResponse(PasswordHashHash, NTResponse, PeerChallenge,
706 rchallenge, username, authResponse);
714 static void Set_Start_Key(ppp_pcb *pcb,
const u_char *rchallenge,
const char *secret,
int secret_len) {
715 u_char unicodePassword[MAX_NT_PASSWORD * 2];
716 u_char PasswordHash[MD4_SIGNATURE_SIZE];
717 u_char PasswordHashHash[MD4_SIGNATURE_SIZE];
718 sha1_context sha1Context;
719 u_char Digest[SHA1_SIGNATURE_SIZE];
722 ascii2unicode(secret, secret_len, unicodePassword);
723 NTPasswordHash(unicodePassword, secret_len * 2, PasswordHash);
724 NTPasswordHash(PasswordHash,
sizeof(PasswordHash), PasswordHashHash);
726 sha1_starts(&sha1Context);
727 sha1_update(&sha1Context, PasswordHashHash, MD4_SIGNATURE_SIZE);
728 sha1_update(&sha1Context, PasswordHashHash, MD4_SIGNATURE_SIZE);
729 sha1_update(&sha1Context, rchallenge, 8);
730 sha1_finish(&sha1Context, Digest);
733 mppe_set_key(pcb, &pcb->mppe_comp, Digest);
734 mppe_set_key(pcb, &pcb->mppe_decomp, Digest);
736 pcb->mppe_keys_set = 1;
742 static void SetMasterKeys(ppp_pcb *pcb,
const char *secret,
int secret_len, u_char NTResponse[24],
int IsServer) {
743 u_char unicodePassword[MAX_NT_PASSWORD * 2];
744 u_char PasswordHash[MD4_SIGNATURE_SIZE];
745 u_char PasswordHashHash[MD4_SIGNATURE_SIZE];
746 sha1_context sha1Context;
747 u_char MasterKey[SHA1_SIGNATURE_SIZE];
748 u_char Digest[SHA1_SIGNATURE_SIZE];
752 static const u_char Magic1[27] =
753 { 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74,
754 0x68, 0x65, 0x20, 0x4d, 0x50, 0x50, 0x45, 0x20, 0x4d,
755 0x61, 0x73, 0x74, 0x65, 0x72, 0x20, 0x4b, 0x65, 0x79 };
758 static const u_char Magic2[84] =
759 { 0x4f, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6c, 0x69,
760 0x65, 0x6e, 0x74, 0x20, 0x73, 0x69, 0x64, 0x65, 0x2c, 0x20,
761 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68,
762 0x65, 0x20, 0x73, 0x65, 0x6e, 0x64, 0x20, 0x6b, 0x65, 0x79,
763 0x3b, 0x20, 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73,
764 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x73, 0x69, 0x64, 0x65,
765 0x2c, 0x20, 0x69, 0x74, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68,
766 0x65, 0x20, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x20,
767 0x6b, 0x65, 0x79, 0x2e };
770 static const u_char Magic3[84] =
771 { 0x4f, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6c, 0x69,
772 0x65, 0x6e, 0x74, 0x20, 0x73, 0x69, 0x64, 0x65, 0x2c, 0x20,
773 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68,
774 0x65, 0x20, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x20,
775 0x6b, 0x65, 0x79, 0x3b, 0x20, 0x6f, 0x6e, 0x20, 0x74, 0x68,
776 0x65, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x73,
777 0x69, 0x64, 0x65, 0x2c, 0x20, 0x69, 0x74, 0x20, 0x69, 0x73,
778 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x65, 0x6e, 0x64, 0x20,
779 0x6b, 0x65, 0x79, 0x2e };
782 ascii2unicode(secret, secret_len, unicodePassword);
783 NTPasswordHash(unicodePassword, secret_len * 2, PasswordHash);
784 NTPasswordHash(PasswordHash,
sizeof(PasswordHash), PasswordHashHash);
786 sha1_starts(&sha1Context);
787 sha1_update(&sha1Context, PasswordHashHash, MD4_SIGNATURE_SIZE);
788 sha1_update(&sha1Context, NTResponse, 24);
789 sha1_update(&sha1Context, Magic1,
sizeof(Magic1));
790 sha1_finish(&sha1Context, MasterKey);
799 sha1_starts(&sha1Context);
800 sha1_update(&sha1Context, MasterKey, 16);
801 sha1_update(&sha1Context, mppe_sha1_pad1, SHA1_PAD_SIZE);
802 sha1_update(&sha1Context, s, 84);
803 sha1_update(&sha1Context, mppe_sha1_pad2, SHA1_PAD_SIZE);
804 sha1_finish(&sha1Context, Digest);
806 mppe_set_key(pcb, &pcb->mppe_comp, Digest);
815 sha1_starts(&sha1Context);
816 sha1_update(&sha1Context, MasterKey, 16);
817 sha1_update(&sha1Context, mppe_sha1_pad1, SHA1_PAD_SIZE);
818 sha1_update(&sha1Context, s, 84);
819 sha1_update(&sha1Context, mppe_sha1_pad2, SHA1_PAD_SIZE);
820 sha1_finish(&sha1Context, Digest);
822 mppe_set_key(pcb, &pcb->mppe_decomp, Digest);
824 pcb->mppe_keys_set = 1;
830 static void ChapMS(ppp_pcb *pcb,
const u_char *rchallenge,
const char *secret,
int secret_len,
831 unsigned char *response) {
835 BZERO(response, MS_CHAP_RESPONSE_LEN);
837 ChapMS_NT(rchallenge, secret, secret_len, &response[MS_CHAP_NTRESP]);
840 ChapMS_LANMan(rchallenge, secret, secret_len,
841 &response[MS_CHAP_LANMANRESP]);
844 response[MS_CHAP_USENT] = !ms_lanman;
846 response[MS_CHAP_USENT] = 1;
850 Set_Start_Key(pcb, rchallenge, secret, secret_len);
865 static void ChapMS2(ppp_pcb *pcb,
const u_char *rchallenge,
const u_char *PeerChallenge,
866 const char *user,
const char *secret,
int secret_len,
unsigned char *response,
867 u_char authResponse[],
int authenticator) {
874 BZERO(response, MS_CHAP2_RESPONSE_LEN);
878 magic_random_bytes(&response[MS_CHAP2_PEER_CHALLENGE], MS_CHAP2_PEER_CHAL_LEN);
880 MEMCPY(&response[MS_CHAP2_PEER_CHALLENGE], PeerChallenge,
881 MS_CHAP2_PEER_CHAL_LEN);
884 ChapMS2_NT(rchallenge, &response[MS_CHAP2_PEER_CHALLENGE], user,
885 secret, secret_len, &response[MS_CHAP2_NTRESP]);
888 GenerateAuthenticatorResponsePlain(secret, secret_len,
889 &response[MS_CHAP2_NTRESP],
890 &response[MS_CHAP2_PEER_CHALLENGE],
891 rchallenge, user, authResponse);
894 SetMasterKeys(pcb, secret, secret_len,
895 &response[MS_CHAP2_NTRESP], authenticator);
904 void set_mppe_enc_types(
int policy,
int types) {
906 if (policy != MPPE_ENC_POL_ENC_ALLOWED ||
907 policy != MPPE_ENC_POL_ENC_REQUIRED)
911 if (policy == MPPE_ENC_POL_ENC_ALLOWED && !ccp_wantoptions[0].mppe)
919 case MPPE_ENC_TYPES_RC4_40:
920 ccp_wantoptions[0].mppe &= ~MPPE_OPT_128;
922 case MPPE_ENC_TYPES_RC4_128:
923 ccp_wantoptions[0].mppe &= ~MPPE_OPT_40;
932 const struct chap_digest_type chapms_digest = {
935 chapms_generate_challenge,
936 chapms_verify_response,
938 chapms_make_response,
940 chapms_handle_failure,
943 const struct chap_digest_type chapms2_digest = {
946 chapms2_generate_challenge,
947 chapms2_verify_response,
949 chapms2_make_response,
950 chapms2_check_success,
951 chapms_handle_failure,
#define MEMCPY(dst, src, len)
#define LWIP_UNUSED_ARG(x)