ike_eap_mschapv2.h File Reference

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

#include "ike/ike.h"

Go to the source code of this file.

Enumerations

enum  IkeEapMschapv2Code {
  IKE_EAP_MSCHAPV2_CODE_INVALID = 0, IKE_EAP_MSCHAPV2_CODE_CHALLENGE = 1, IKE_EAP_MSCHAPV2_CODE_RESPONSE = 2, IKE_EAP_MSCHAPV2_CODE_SUCCESS = 3,
  IKE_EAP_MSCHAPV2_CODE_FAILURE = 4
}
 MS-CHAP-V2 opcodes. More...
 

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...
 

Variables

typedef __packed_struct
 EAP MS-CHAP-V2 packet. More...
 
uint8_t identifier
 
uint16_t length
 
uint8_t type
 
uint8_t opcode
 
 IkeEapMschapv2Packet
 
uint8_t mschapv2Id
 
uint16_t msLength
 
uint8_t valueSize
 
uint8_t challenge [16]
 
uint8_t name []
 
 IkeEapMschapv2Challenge
 
uint8_t peerChallenge [16]
 
uint8_t reserved [8]
 
uint8_t ntResponse [24]
 
uint8_t flags
 
 IkeEapMschapv2Response
 
uint8_t message []
 
 IkeEapMschapv2SuccessRequest
 
 IkeEapMschapv2SuccessResponse
 
 IkeEapMschapv2FailureRequest
 
 IkeEapMschapv2FailureResponse
 
uint8_t data []
 
 IkeEapMschapv2ChangePassword
 

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.h.

Enumeration Type Documentation

◆ IkeEapMschapv2Code

MS-CHAP-V2 opcodes.

Enumerator
IKE_EAP_MSCHAPV2_CODE_INVALID 
IKE_EAP_MSCHAPV2_CODE_CHALLENGE 

Challenge.

IKE_EAP_MSCHAPV2_CODE_RESPONSE 

Response.

IKE_EAP_MSCHAPV2_CODE_SUCCESS 

Success.

IKE_EAP_MSCHAPV2_CODE_FAILURE 

Failure.

Definition at line 47 of file ike_eap_mschapv2.h.

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.

Variable Documentation

◆ __packed_struct

typedef __packed_struct
Initial value:
{
uint8_t code

EAP MS-CHAP-V2 packet.

EAP MS-CHAP-V2 Change-Password packet.

EAP MS-CHAP-V2 Failure Response packet.

EAP MS-CHAP-V2 Failure Request packet.

EAP MS-CHAP-V2 Success Response packet.

EAP MS-CHAP-V2 Success Request packet.

EAP MS-CHAP-V2 Response packet.

EAP MS-CHAP-V2 Challenge packet.

Definition at line 69 of file ike_eap_mschapv2.h.

◆ challenge

uint8_t challenge[16]

Definition at line 93 of file ike_eap_mschapv2.h.

◆ data

uint8_t data[]

Definition at line 195 of file ike_eap_mschapv2.h.

◆ flags

uint8_t flags

Definition at line 115 of file ike_eap_mschapv2.h.

◆ identifier

uint8_t identifier

Definition at line 72 of file ike_eap_mschapv2.h.

◆ IkeEapMschapv2Challenge

IkeEapMschapv2Challenge

Definition at line 95 of file ike_eap_mschapv2.h.

◆ IkeEapMschapv2ChangePassword

IkeEapMschapv2ChangePassword

Definition at line 196 of file ike_eap_mschapv2.h.

◆ IkeEapMschapv2FailureRequest

IkeEapMschapv2FailureRequest

Definition at line 165 of file ike_eap_mschapv2.h.

◆ IkeEapMschapv2FailureResponse

IkeEapMschapv2FailureResponse

Definition at line 179 of file ike_eap_mschapv2.h.

◆ IkeEapMschapv2Packet

IkeEapMschapv2Packet

Definition at line 76 of file ike_eap_mschapv2.h.

◆ IkeEapMschapv2Response

IkeEapMschapv2Response

Definition at line 117 of file ike_eap_mschapv2.h.

◆ IkeEapMschapv2SuccessRequest

IkeEapMschapv2SuccessRequest

Definition at line 134 of file ike_eap_mschapv2.h.

◆ IkeEapMschapv2SuccessResponse

IkeEapMschapv2SuccessResponse

Definition at line 148 of file ike_eap_mschapv2.h.

◆ length

uint16_t length

Definition at line 73 of file ike_eap_mschapv2.h.

◆ message

uint8_t message[]

Definition at line 133 of file ike_eap_mschapv2.h.

◆ mschapv2Id

uint8_t mschapv2Id

Definition at line 90 of file ike_eap_mschapv2.h.

◆ msLength

uint16_t msLength

Definition at line 91 of file ike_eap_mschapv2.h.

◆ name

uint8_t name[]

Definition at line 94 of file ike_eap_mschapv2.h.

◆ ntResponse

uint8_t ntResponse[24]

Definition at line 114 of file ike_eap_mschapv2.h.

◆ opcode

uint8_t opcode

Definition at line 75 of file ike_eap_mschapv2.h.

◆ peerChallenge

uint8_t peerChallenge[16]

Definition at line 112 of file ike_eap_mschapv2.h.

◆ reserved

uint8_t reserved[8]

Definition at line 113 of file ike_eap_mschapv2.h.

◆ type

uint8_t type

Definition at line 74 of file ike_eap_mschapv2.h.

◆ valueSize

uint8_t valueSize

Definition at line 92 of file ike_eap_mschapv2.h.

uint8_t code
Definition: coap_common.h:179