Go to the documentation of this file.
32 #define TRACE_LEVEL PPP_TRACE_LEVEL
44 #if (PPP_SUPPORT == ENABLED && CHAP_SUPPORT == ENABLED)
60 TRACE_INFO(
"\r\nStarting CHAP authentication...\r\n");
94 TRACE_INFO(
"\r\nAborting CHAP authentication...\r\n");
125 if(context->chapFsm.restartCounter > 0)
225 TRACE_INFO(
"\r\nCHAP Challenge packet received\r\n");
240 context->chapFsm.peerIdentifier = challengePacket->identifier;
249 md5Update(&md5Context, &challengePacket->identifier,
sizeof(uint8_t));
251 md5Update(&md5Context, challengePacket->value, challengePacket->valueSize);
280 TRACE_INFO(
"\r\nCHAP Response packet received\r\n");
292 if(responsePacket->identifier != context->chapFsm.localIdentifier)
304 context->chapFsm.response = responsePacket->value;
307 p = responsePacket->value + responsePacket->valueSize;
316 context->peerName[
length] =
'\0';
319 if(context->settings.authCallback != NULL)
322 status = context->settings.authCallback(context->interface,
342 context->localAuthDone =
TRUE;
345 if(context->localAuthDone && context->peerAuthDone)
353 #if (IPV4_SUPPORT == ENABLED)
357 #if (IPV6_SUPPORT == ENABLED)
392 TRACE_INFO(
"\r\nCHAP Success packet received\r\n");
404 if(successPacket->identifier != context->chapFsm.peerIdentifier)
410 context->peerAuthDone =
TRUE;
413 if(context->localAuthDone && context->peerAuthDone)
421 #if (IPV4_SUPPORT == ENABLED)
425 #if (IPV6_SUPPORT == ENABLED)
449 TRACE_INFO(
"\r\nCHAP Failure packet received\r\n");
461 if(failurePacket->identifier != context->chapFsm.peerIdentifier)
505 challengePacket->identifier = ++context->chapFsm.localIdentifier;
510 if(context->settings.randCallback != NULL)
513 error = context->settings.randCallback(
541 if(context->chapFsm.restartCounter > 0)
542 context->chapFsm.restartCounter--;
587 responsePacket->identifier = context->chapFsm.peerIdentifier;
641 successPacket->identifier = context->chapFsm.localIdentifier;
687 failurePacket->identifier = context->chapFsm.localIdentifier;
724 md5Update(&md5Context, &context->chapFsm.localIdentifier,
sizeof(uint8_t));
__start_packed struct @3 ChapFailurePacket
Failure packet.
error_t chapProcessSuccess(PppContext *context, const ChapSuccessPacket *successPacket, size_t length)
Process Success packet.
Data logging functions for debugging purpose (PPP)
error_t chapSendResponse(PppContext *context, const uint8_t *value)
Send Response packet.
CHAP (Challenge Handshake Authentication Protocol)
@ CHAP_CODE_SUCCESS
Success.
#define CHAP_MAX_CHALLENGES
void chapProcessPacket(PppContext *context, const PppPacket *packet, size_t length)
Process an incoming CHAP packet.
@ PPP_PROTOCOL_CHAP
Challenge Handshake Authentication Protocol.
@ CHAP_STATE_6_SUCCESS_SENT
Structure describing a buffer that spans multiple chunks.
__start_packed struct @1 ChapResponsePacket
Response packet.
IPV6CP (PPP IPv6 Control Protocol)
void chapTick(PppContext *context)
CHAP timer handler.
void md5Final(Md5Context *context, uint8_t *digest)
Finish the MD5 message digest.
#define CHAP_RESTART_TIMER
#define osMemcmp(p1, p2, length)
@ CHAP_CODE_CHALLENGE
Challenge.
@ PPP_PHASE_NETWORK
Network-layer protocol phase.
@ CHAP_STATE_2_CHALLENGE_SENT
@ CHAP_CODE_RESPONSE
Response.
NetBuffer * pppAllocBuffer(size_t length, size_t *offset)
Allocate a buffer to hold a PPP frame.
IPCP (PPP Internet Protocol Control Protocol)
void md5Update(Md5Context *context, const void *data, size_t length)
Update the MD5 context with a portion of the message being hashed.
LCP (PPP Link Control Protocol)
void md5Init(Md5Context *context)
Initialize MD5 message digest context.
#define osMemcpy(dest, src, length)
@ CHAP_CODE_FAILURE
Failure.
void * netBufferAt(const NetBuffer *buffer, size_t offset)
Returns a pointer to the data at the specified position.
error_t chapAbortAuth(PppContext *context)
Abort CHAP authentication.
@ PPP_PHASE_AUTHENTICATE
Authentication phase.
@ ERROR_FAILURE
Generic error code.
@ CHAP_STATE_4_RESPONSE_SENT
void netBufferFree(NetBuffer *buffer)
Dispose a multi-part buffer.
@ CHAP_STATE_7_SUCCESS_RCVD
General definitions for cryptographic algorithms.
error_t chapSendSuccess(PppContext *context)
Send Success packet.
@ CHAP_STATE_9_FAILURE_RCVD
__start_packed struct @0 ChapChallengePacket
Challenge packet.
error_t chapProcessFailure(PppContext *context, const ChapFailurePacket *failurePacket, size_t length)
Process Failure packet.
error_t ipcpOpen(PppContext *context)
IPCP Open event.
uint32_t systime_t
System time.
error_t pppSendFrame(NetInterface *interface, NetBuffer *buffer, size_t offset, uint16_t protocol)
Send a PPP frame.
__start_packed struct @2 ChapSuccessPacket
Success packet.
error_t pppDumpPacket(const PppPacket *packet, size_t length, PppProtocol protocol)
Dump LCP/NCP packet for debugging purpose.
MD5 (Message-Digest Algorithm)
bool_t chapCheckPassword(PppContext *context, const char_t *password)
Password verification.
error_t chapSendChallenge(PppContext *context)
Send Challenge packet.
error_t chapProcessChallenge(PppContext *context, const ChapChallengePacket *challengePacket, size_t length)
Process Challenge packet.
error_t chapProcessResponse(PppContext *context, const ChapResponsePacket *responsePacket, size_t length)
Process Response packet.
error_t ipv6cpOpen(PppContext *context)
IPV6CP Open event.
error_t chapStartAuth(PppContext *context)
Start CHAP authentication.
error_t chapSendFailure(PppContext *context)
Send Failure packet.
error_t lcpClose(PppContext *context)
LCP Close event.
@ CHAP_STATE_8_FAILURE_SENT
systime_t osGetSystemTime(void)
Retrieve system time.
#define PPP_MAX_USERNAME_LEN