chap.h File Reference

CHAP (Challenge Handshake Authentication Protocol) More...

#include "core/net.h"
#include "ppp/ppp.h"

Go to the source code of this file.

Data Structures

struct  ChapFsm
 CHAP finite state machine. More...
 

Macros

#define CHAP_SUPPORT   DISABLED
 
#define CHAP_RESTART_TIMER   3000
 
#define CHAP_MAX_CHALLENGES   5
 

Typedefs

struct {
   uint8_t   code
 
   uint8_t   identifier
 
   uint16_t   length
 
   uint8_t   valueSize
 
   uint8_t   value []
 
ChapChallengePacket
 Challenge packet. More...
 
struct {
   uint8_t   code
 
   uint8_t   identifier
 
   uint16_t   length
 
   uint8_t   valueSize
 
   uint8_t   value []
 
ChapResponsePacket
 Response packet. More...
 
struct {
   uint8_t   code
 
   uint8_t   identifier
 
   uint16_t   length
 
   uint8_t   message []
 
ChapSuccessPacket
 Success packet. More...
 
struct {
   uint8_t   code
 
   uint8_t   identifier
 
   uint16_t   length
 
   uint8_t   message []
 
ChapFailurePacket
 Failure packet. More...
 

Enumerations

enum  ChapState {
  CHAP_STATE_0_INITIAL = 0, CHAP_STATE_1_STARTED = 1, CHAP_STATE_2_CHALLENGE_SENT = 2, CHAP_STATE_3_CHALLENGE_RCVD = 3,
  CHAP_STATE_4_RESPONSE_SENT = 4, CHAP_STATE_5_RESPONSE_RCVD = 5, CHAP_STATE_6_SUCCESS_SENT = 6, CHAP_STATE_7_SUCCESS_RCVD = 7,
  CHAP_STATE_8_FAILURE_SENT = 8, CHAP_STATE_9_FAILURE_RCVD = 9
}
 CHAP states. More...
 
enum  ChapCode { CHAP_CODE_CHALLENGE = 1, CHAP_CODE_RESPONSE = 2, CHAP_CODE_SUCCESS = 3, CHAP_CODE_FAILURE = 4 }
 Code field values. More...
 
enum  ChapAlgoId { CHAP_ALGO_ID_CHAP_MD5 = 5, CHAP_ALGO_ID_MS_CHAP = 128, CHAP_ALGO_ID_MS_CHAP_V2 = 129 }
 CHAP algorithm identifiers. More...
 

Functions

error_t chapStartAuth (PppContext *context)
 Start CHAP authentication. More...
 
error_t chapAbortAuth (PppContext *context)
 Abort CHAP authentication. More...
 
void chapTick (PppContext *context)
 CHAP timer handler. More...
 
void chapProcessPacket (PppContext *context, const PppPacket *packet, size_t length)
 Process an incoming CHAP packet. More...
 
error_t chapProcessChallenge (PppContext *context, const ChapChallengePacket *challengePacket, size_t length)
 Process Challenge packet. More...
 
error_t chapProcessResponse (PppContext *context, const ChapResponsePacket *responsePacket, size_t length)
 Process Response packet. More...
 
error_t chapProcessSuccess (PppContext *context, const ChapSuccessPacket *successPacket, size_t length)
 Process Success packet. More...
 
error_t chapProcessFailure (PppContext *context, const ChapFailurePacket *failurePacket, size_t length)
 Process Failure packet. More...
 
error_t chapSendChallenge (PppContext *context)
 Send Challenge packet. More...
 
error_t chapSendResponse (PppContext *context, const uint8_t *value)
 Send Response packet. More...
 
error_t chapSendSuccess (PppContext *context)
 Send Success packet. More...
 
error_t chapSendFailure (PppContext *context)
 Send Failure packet. More...
 
bool_t chapCheckPassword (PppContext *context, const char_t *password)
 Password verification. More...
 

Detailed Description

CHAP (Challenge Handshake Authentication Protocol)

License

Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP 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
1.9.0

Definition in file chap.h.

Macro Definition Documentation

◆ CHAP_MAX_CHALLENGES

#define CHAP_MAX_CHALLENGES   5

Definition at line 52 of file chap.h.

◆ CHAP_RESTART_TIMER

#define CHAP_RESTART_TIMER   3000

Definition at line 45 of file chap.h.

◆ CHAP_SUPPORT

#define CHAP_SUPPORT   DISABLED

Definition at line 38 of file chap.h.

Typedef Documentation

◆ ChapChallengePacket

typedef { ... } ChapChallengePacket

Challenge packet.

◆ ChapFailurePacket

typedef { ... } ChapFailurePacket

Failure packet.

◆ ChapResponsePacket

typedef { ... } ChapResponsePacket

Response packet.

◆ ChapSuccessPacket

typedef { ... } ChapSuccessPacket

Success packet.

Enumeration Type Documentation

◆ ChapAlgoId

enum ChapAlgoId

CHAP algorithm identifiers.

Enumerator
CHAP_ALGO_ID_CHAP_MD5 
CHAP_ALGO_ID_MS_CHAP 
CHAP_ALGO_ID_MS_CHAP_V2 

Definition at line 99 of file chap.h.

◆ ChapCode

enum ChapCode

Code field values.

Enumerator
CHAP_CODE_CHALLENGE 

Challenge.

CHAP_CODE_RESPONSE 

Response.

CHAP_CODE_SUCCESS 

Success.

CHAP_CODE_FAILURE 

Failure.

Definition at line 86 of file chap.h.

◆ ChapState

enum ChapState

CHAP states.

Enumerator
CHAP_STATE_0_INITIAL 
CHAP_STATE_1_STARTED 
CHAP_STATE_2_CHALLENGE_SENT 
CHAP_STATE_3_CHALLENGE_RCVD 
CHAP_STATE_4_RESPONSE_SENT 
CHAP_STATE_5_RESPONSE_RCVD 
CHAP_STATE_6_SUCCESS_SENT 
CHAP_STATE_7_SUCCESS_RCVD 
CHAP_STATE_8_FAILURE_SENT 
CHAP_STATE_9_FAILURE_RCVD 

Definition at line 67 of file chap.h.

Function Documentation

◆ chapAbortAuth()

error_t chapAbortAuth ( PppContext context)

Abort CHAP authentication.

Parameters
[in]contextPPP context
Returns
Error code

Definition at line 89 of file chap.c.

◆ chapCheckPassword()

bool_t chapCheckPassword ( PppContext context,
const char_t password 
)

Password verification.

Parameters
[in]contextPPP context
[in]passwordNULL-terminated string containing the password to be checked
Returns
TRUE if the password is valid, else FALSE

Definition at line 710 of file chap.c.

◆ chapProcessChallenge()

error_t chapProcessChallenge ( PppContext context,
const ChapChallengePacket challengePacket,
size_t  length 
)

Process Challenge packet.

Parameters
[in]contextPPP context
[in]challengePacketPacket received from the peer
[in]lengthLength of the packet, in bytes
Returns
Error code

Definition at line 216 of file chap.c.

◆ chapProcessFailure()

error_t chapProcessFailure ( PppContext context,
const ChapFailurePacket failurePacket,
size_t  length 
)

Process Failure packet.

Parameters
[in]contextPPP context
[in]failurePacketPacket received from the peer
[in]lengthLength of the packet, in bytes
Returns
Error code

Definition at line 443 of file chap.c.

◆ chapProcessPacket()

void chapProcessPacket ( PppContext context,
const PppPacket packet,
size_t  length 
)

Process an incoming CHAP packet.

Parameters
[in]contextPPP context
[in]packetCHAP packet received from the peer
[in]lengthLength of the packet, in bytes

Definition at line 147 of file chap.c.

◆ chapProcessResponse()

error_t chapProcessResponse ( PppContext context,
const ChapResponsePacket responsePacket,
size_t  length 
)

Process Response packet.

Parameters
[in]contextPPP context
[in]responsePacketPacket received from the peer
[in]lengthLength of the packet, in bytes
Returns
Error code

Definition at line 271 of file chap.c.

◆ chapProcessSuccess()

error_t chapProcessSuccess ( PppContext context,
const ChapSuccessPacket successPacket,
size_t  length 
)

Process Success packet.

Parameters
[in]contextPPP context
[in]successPacketPacket received from the peer
[in]lengthLength of the packet, in bytes
Returns
Error code

Definition at line 386 of file chap.c.

◆ chapSendChallenge()

error_t chapSendChallenge ( PppContext context)

Send Challenge packet.

Parameters
[in]contextPPP context
Returns
Error code

Definition at line 478 of file chap.c.

◆ chapSendFailure()

error_t chapSendFailure ( PppContext context)

Send Failure packet.

Parameters
[in]contextPPP context
Returns
Error code

Definition at line 663 of file chap.c.

◆ chapSendResponse()

error_t chapSendResponse ( PppContext context,
const uint8_t *  value 
)

Send Response packet.

Parameters
[in]contextPPP context
[in]valueResponse value
Returns
Error code

Definition at line 560 of file chap.c.

◆ chapSendSuccess()

error_t chapSendSuccess ( PppContext context)

Send Success packet.

Parameters
[in]contextPPP context
Returns
Error code

Definition at line 617 of file chap.c.

◆ chapStartAuth()

error_t chapStartAuth ( PppContext context)

Start CHAP authentication.

Parameters
[in]contextPPP context
Returns
Error code

Definition at line 55 of file chap.c.

◆ chapTick()

void chapTick ( PppContext context)

CHAP timer handler.

Parameters
[in]contextPPP context

Definition at line 108 of file chap.c.

Variable Documentation

◆ code

uint8_t code

Definition at line 119 of file chap.h.

◆ identifier

uint8_t identifier

Definition at line 120 of file chap.h.

◆ length

uint16_t length

Definition at line 121 of file chap.h.

◆ message

uint8_t message[]

Definition at line 150 of file chap.h.

◆ value

uint8_t value[]

Definition at line 123 of file chap.h.

◆ valueSize

uint8_t valueSize

Definition at line 122 of file chap.h.