chap.h

来自「基于单片机的 snmp协议解析的一些原代码 给有用的 同行」· C头文件 代码 · 共 60 行

H
60
字号
//---------------------------------------------------------------------------
#ifndef chapH
#define chapH
//#include <string>
#include "md5.h"
//---------------------------------------------------------------------------
enum Authenticate_State {AUTHENTICATED, CHALLENGING, BEING_CHALLENGED, INSECURE};
class CHAP
{
	public:
    	CHAP();
        ~CHAP();
    	void SetSecret(string theSecret);
        void GetSecret(string &theSecret);
        unsigned char GetIdentifier();
        long DecodeCHAP();
        Authenticate_State GetAuthenticateState();

    	void FillCHAP(string &data);
        void AssignChallenge();
        void AssignChallengeResponse(CHAP challengeCHAP);
        void AssignSuccess(CHAP receivedCHAP);
        void AssignFailure(CHAP receivedCHAP);

        long DetermineSuccessFailure(CHAP sentCHAP);

        void GetResponseValue(string &theValue);
        long GetPacket(string &packet);
        void SetPacketTime();
        unsigned long GetPacketTime();
        void SetChallengeValue();
        void GetChallengeValue(string &theChallengeValue);
        void SetName(string theName);
        void GetName(string &theName);

        void Test();

        string GetHash(const char *theHash, unsigned int len);
        long GetLength();
        
    private:
    	unsigned char code;
        unsigned short length;
		string data;
        unsigned char identifier;

        static unsigned char identifierCounter;

    	string secret;
    	string challengeValue;
        string name;

        unsigned long timeOfPacket;

        unsigned char hash[16];
		Authenticate_State	authState; //overall authentication state
};
unsigned char CHAP::identifierCounter=0;
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?