ike_eap_mschapv2.c File Reference

EAP MS-CHAP-V2 authentication method. More...

#include "ike/ike.h"
#include "ike/ike_eap.h"
#include "ike/ike_eap_mschapv2.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   IKE_TRACE_LEVEL
 

Functions

error_t ikeProcessEapMschapv2Request (IkeSaEntry *sa, const IkeEapMschapv2Packet *request, size_t length)
 Process EAP MS-CHAP-V2 request. More...
 
error_t ikeProcessEapMschapv2Challenge (IkeSaEntry *sa, const IkeEapMschapv2Challenge *challenge, size_t length)
 Process EAP MS-CHAP-V2 Challenge packet. More...
 
error_t ikeProcessEapMschapv2SuccessRequest (IkeSaEntry *sa, const IkeEapMschapv2SuccessRequest *request, size_t length)
 Process EAP MS-CHAP-V2 Success Request packet. More...
 
error_t ikeProcessEapMschapv2FailureRequest (IkeSaEntry *sa, const IkeEapMschapv2FailureRequest *request, size_t length)
 Process EAP MS-CHAP-V2 Failure Request packet. More...
 
error_t ikeFormatEapMschapv2Response (IkeSaEntry *sa, uint8_t *p, size_t *written)
 Format EAP MS-CHAP-V2 Response packet. More...
 
error_t ikeFormatEapMschapv2SuccessResponse (IkeSaEntry *sa, uint8_t *p, size_t *written)
 Format EAP MS-CHAP-V2 Success Response packet. More...
 
error_t ikeFormatEapMschapv2FailureResponse (IkeSaEntry *sa, uint8_t *p, size_t *written)
 Format EAP MS-CHAP-V2 Failure Response packet. More...
 
void ikeEapMschapv2GenerateNtResponse (const uint8_t *authChallenge, const uint8_t *peerChallenge, const char_t *username, const char_t *password, uint8_t *response)
 GenerateNTResponse routine. More...
 
void ikeEapMschapv2ChallengeHash (const uint8_t *peerChallenge, const uint8_t *authChallenge, const char_t *username, uint8_t *challenge)
 ChallengeHash routine. More...
 
void ikeEapMschapv2NtPasswordHash (const char_t *password, uint8_t *passwordHash)
 NtPasswordHash routine. More...
 
void ikeEapMschapv2HashNtPasswordHash (const uint8_t *passwordHash, uint8_t *passwordHashHash)
 HashNtPasswordHash routine. More...
 
void ikeEapMschapv2ChallengeResponse (const uint8_t *challenge, const uint8_t *passwordHash, uint8_t *response)
 ChallengeResponse routine. More...
 
void ikeEapMschapv2GenerateAuthResponse (const char_t *password, const uint8_t *ntResponse, const uint8_t *peerChallenge, const uint8_t *authChallenge, const char_t *username, uint8_t *authResponse)
 GenerateAuthenticatorResponse routine. More...
 
bool_t ikeEapMschapv2CheckAuthResponse (const char_t *password, const uint8_t *ntResponse, const uint8_t *peerChallenge, const uint8_t *authChallenge, const char_t *username, const uint8_t *receivedResponse)
 CheckAuthenticatorResponse routine. More...
 
void ikeEapMschapv2GenerateMasterSessionKey (const char_t *password, const uint8_t *ntResponse, uint8_t *masterSessionKey)
 Generate master session key. More...
 
void ikeEapMschapv2GetMasterKey (const uint8_t *passwordHashHash, const uint8_t *ntResponse, uint8_t *masterKey)
 GetMasterKey routine. More...
 
void ikeEapMschapv2GetAsymmetricStartKey (const uint8_t *masterKey, uint8_t *sessionKey, size_t sessionKeyLen, bool_t isSend)
 GetAsymmetricStartKey routine. More...
 

Detailed Description

EAP MS-CHAP-V2 authentication method.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2022-2026 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneIPSEC Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.6.8

Definition in file ike_eap_mschapv2.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   IKE_TRACE_LEVEL

Definition at line 32 of file ike_eap_mschapv2.c.

Function Documentation

◆ ikeEapMschapv2ChallengeHash()

void ikeEapMschapv2ChallengeHash ( const uint8_t *  peerChallenge,
const uint8_t *  authChallenge,
const char_t *  username,
uint8_t *  challenge 
)

ChallengeHash routine.

Parameters
[in]peerChallengePeer challenge (16 bytes)
[in]authChallengeAuthenticator challenge (16 bytes)
[in]usernameNULL-terminated string containing the user name
[out]challengeResulting challenge (8 bytes)

Definition at line 468 of file ike_eap_mschapv2.c.

◆ ikeEapMschapv2ChallengeResponse()

void ikeEapMschapv2ChallengeResponse ( const uint8_t *  challenge,
const uint8_t *  passwordHash,
uint8_t *  response 
)

ChallengeResponse routine.

Parameters
[in]challengeChallenge (8 bytes)
[in]passwordHashPassword hash (16 bytes)
[out]responseResulting response (24 bytes)

Definition at line 551 of file ike_eap_mschapv2.c.

◆ ikeEapMschapv2CheckAuthResponse()

bool_t ikeEapMschapv2CheckAuthResponse ( const char_t *  password,
const uint8_t *  ntResponse,
const uint8_t *  peerChallenge,
const uint8_t *  authChallenge,
const char_t *  username,
const uint8_t *  receivedResponse 
)

CheckAuthenticatorResponse routine.

Parameters
[in]passwordNULL-terminated string containing the password
[out]ntResponseNT-Response field (24 bytes)
[in]peerChallengePeer challenge (16 bytes)
[in]authChallengeAuthenticator challenge (16 bytes)
[in]usernameNULL-terminated string containing the user name
[in]receivedResponseReceived response (42 bytes)
Returns
TRUE if the authenticator response is correct, else FASE

Definition at line 690 of file ike_eap_mschapv2.c.

◆ ikeEapMschapv2GenerateAuthResponse()

void ikeEapMschapv2GenerateAuthResponse ( const char_t *  password,
const uint8_t *  ntResponse,
const uint8_t *  peerChallenge,
const uint8_t *  authChallenge,
const char_t *  username,
uint8_t *  authResponse 
)

GenerateAuthenticatorResponse routine.

Parameters
[in]passwordNULL-terminated string containing the password
[out]ntResponseNT-Response field (24 bytes)
[in]peerChallengePeer challenge (16 bytes)
[in]authChallengeAuthenticator challenge (16 bytes)
[in]usernameNULL-terminated string containing the user name
[out]authResponseResulting authenticator response (42 bytes)

Definition at line 595 of file ike_eap_mschapv2.c.

◆ ikeEapMschapv2GenerateMasterSessionKey()

void ikeEapMschapv2GenerateMasterSessionKey ( const char_t *  password,
const uint8_t *  ntResponse,
uint8_t *  masterSessionKey 
)

Generate master session key.

Parameters
[in]passwordNULL-terminated string containing the password
[in]ntResponseNT-Response field (24 bytes)
[out]masterSessionKeyResulting master session key (64 bytes)

Definition at line 725 of file ike_eap_mschapv2.c.

◆ ikeEapMschapv2GenerateNtResponse()

void ikeEapMschapv2GenerateNtResponse ( const uint8_t *  authChallenge,
const uint8_t *  peerChallenge,
const char_t *  username,
const char_t *  password,
uint8_t *  response 
)

GenerateNTResponse routine.

Parameters
[in]authChallengeAuthenticator challenge (16 bytes)
[in]peerChallengePeer challenge (16 bytes)
[in]usernameNULL-terminated string containing the user name
[in]passwordNULL-terminated string containing the password
[out]responseResulting NT-Response field (24 bytes)

Definition at line 439 of file ike_eap_mschapv2.c.

◆ ikeEapMschapv2GetAsymmetricStartKey()

void ikeEapMschapv2GetAsymmetricStartKey ( const uint8_t *  masterKey,
uint8_t *  sessionKey,
size_t  sessionKeyLen,
bool_t  isSend 
)

GetAsymmetricStartKey routine.

Parameters
[in]masterKeyMaster key (16 bytes)
[out]sessionKeySession key
[in]sessionKeyLenLength of the session key, in bytes
[in]isSendSend or receive direction

Definition at line 809 of file ike_eap_mschapv2.c.

◆ ikeEapMschapv2GetMasterKey()

void ikeEapMschapv2GetMasterKey ( const uint8_t *  passwordHashHash,
const uint8_t *  ntResponse,
uint8_t *  masterKey 
)

GetMasterKey routine.

Parameters
[in]passwordHashHashHash value (16 bytes)
[in]ntResponseNT-Response field (24 bytes)
[out]masterKeyResulting master key (16 bytes)

Definition at line 771 of file ike_eap_mschapv2.c.

◆ ikeEapMschapv2HashNtPasswordHash()

void ikeEapMschapv2HashNtPasswordHash ( const uint8_t *  passwordHash,
uint8_t *  passwordHashHash 
)

HashNtPasswordHash routine.

Parameters
[in]passwordHashPassword hash (16 bytes)
[out]passwordHashHashResulting hash (16 bytes)

Definition at line 530 of file ike_eap_mschapv2.c.

◆ ikeEapMschapv2NtPasswordHash()

void ikeEapMschapv2NtPasswordHash ( const char_t *  password,
uint8_t *  passwordHash 
)

NtPasswordHash routine.

Parameters
[in]passwordNULL-terminated string containing the password
[out]passwordHashPassword hash (16 bytes)

Definition at line 493 of file ike_eap_mschapv2.c.

◆ ikeFormatEapMschapv2FailureResponse()

error_t ikeFormatEapMschapv2FailureResponse ( IkeSaEntry *  sa,
uint8_t *  p,
size_t *  written 
)

Format EAP MS-CHAP-V2 Failure Response packet.

Parameters
[in]saPointer to the IKE SA
[out]pBuffer where to format the EAP MS-CHAP-V2 packet
[out]writtenLength of the resulting EAP MS-CHAP-V2 packet
Returns
Error code

Definition at line 404 of file ike_eap_mschapv2.c.

◆ ikeFormatEapMschapv2Response()

error_t ikeFormatEapMschapv2Response ( IkeSaEntry *  sa,
uint8_t *  p,
size_t *  written 
)

Format EAP MS-CHAP-V2 Response packet.

Parameters
[in]saPointer to the IKE SA
[out]pBuffer where to format the EAP MS-CHAP-V2 packet
[out]writtenLength of the resulting EAP MS-CHAP-V2 packet
Returns
Error code

Definition at line 292 of file ike_eap_mschapv2.c.

◆ ikeFormatEapMschapv2SuccessResponse()

error_t ikeFormatEapMschapv2SuccessResponse ( IkeSaEntry *  sa,
uint8_t *  p,
size_t *  written 
)

Format EAP MS-CHAP-V2 Success Response packet.

Parameters
[in]saPointer to the IKE SA
[out]pBuffer where to format the EAP MS-CHAP-V2 packet
[out]writtenLength of the resulting EAP MS-CHAP-V2 packet
Returns
Error code

Definition at line 370 of file ike_eap_mschapv2.c.

◆ ikeProcessEapMschapv2Challenge()

error_t ikeProcessEapMschapv2Challenge ( IkeSaEntry *  sa,
const IkeEapMschapv2Challenge *  challenge,
size_t  length 
)

Process EAP MS-CHAP-V2 Challenge packet.

Parameters
[in]saPointer to the IKE SA
[in]challengePointer to the EAP MS-CHAP-V2 Challenge packet
[in]lengthLength of the EAP MS-CHAP-V2 Challenge packet, in bytes
Returns
Error code

Definition at line 101 of file ike_eap_mschapv2.c.

◆ ikeProcessEapMschapv2FailureRequest()

error_t ikeProcessEapMschapv2FailureRequest ( IkeSaEntry *  sa,
const IkeEapMschapv2FailureRequest *  request,
size_t  length 
)

Process EAP MS-CHAP-V2 Failure Request packet.

Parameters
[in]saPointer to the IKE SA
[in]requestPointer to the EAP MS-CHAP-V2 Failure Request packet
[in]lengthLength of the EAP MS-CHAP-V2 Failure Request packet, in bytes
Returns
Error code

Definition at line 254 of file ike_eap_mschapv2.c.

◆ ikeProcessEapMschapv2Request()

error_t ikeProcessEapMschapv2Request ( IkeSaEntry *  sa,
const IkeEapMschapv2Packet *  request,
size_t  length 
)

Process EAP MS-CHAP-V2 request.

Parameters
[in]saPointer to the IKE SA
[in]requestPointer to the EAP MS-CHAP-V2 request
[in]lengthLength of the EAP MS-CHAP-V2 request, in bytes
Returns
Error code

Definition at line 52 of file ike_eap_mschapv2.c.

◆ ikeProcessEapMschapv2SuccessRequest()

error_t ikeProcessEapMschapv2SuccessRequest ( IkeSaEntry *  sa,
const IkeEapMschapv2SuccessRequest *  request,
size_t  length 
)

Process EAP MS-CHAP-V2 Success Request packet.

Parameters
[in]saPointer to the IKE SA
[in]requestPointer to the EAP MS-CHAP-V2 Success Request packet
[in]lengthLength of the EAP MS-CHAP-V2 Success Request packet, in bytes
Returns
Error code

Definition at line 177 of file ike_eap_mschapv2.c.