39 #if (defined(__ENABLE_MOCANA_EAP_PEER__) || defined(__ENABLE_MOCANA_EAP_AUTH__)) 41 #define EAP_SIM_AT_RAND (1) 42 #define EAP_AKA_AT_AUTN (2) 43 #define EAP_AKA_AT_RES (3) 44 #define EAP_AKA_AT_AUTS (4) 45 #define EAP_SIM_AT_PADDING (6) 46 #define EAP_SIM_AT_NONCE_MT (7) 47 #define EAP_SIM_AT_PERMANENT_ID_REQ (10) 48 #define EAP_SIM_AT_MAC (11) 49 #define EAP_SIM_AT_NOTIFICATION (12) 50 #define EAP_SIM_AT_ANY_ID_REQ (13) 51 #define EAP_SIM_AT_IDENTITY (14) 52 #define EAP_SIM_AT_VERSION_LIST (15) 53 #define EAP_SIM_AT_SELECTED_VERSION (16) 54 #define EAP_SIM_AT_FULLAUTH_ID_REQ (17) 55 #define EAP_SIM_AT_COUNTER (19) 56 #define EAP_SIM_AT_COUNTER_TOO_SMALL (20) 57 #define EAP_SIM_AT_NONCE_S (21) 58 #define EAP_SIM_AT_CLIENT_ERROR_CODE (22) 59 #define EAP_SIM_AT_IV (129) 60 #define EAP_SIM_AT_ENCR_DATA (130) 61 #define EAP_SIM_AT_NEXT_PSEUDONYM (132) 62 #define EAP_SIM_AT_NEXT_REAUTH_ID (133) 63 #define EAP_AKA_AT_CHECKCODE (134) 64 #define EAP_SIM_AT_RESULT_IND (135) 66 #define EAP_SIM_AT_RAND_PRESENT (0x1) 67 #define EAP_SIM_AT_PADDING_PRESENT (0x2) 68 #define EAP_SIM_AT_NONCE_MT_PRESENT (0x4) 69 #define EAP_SIM_AT_PERMANENT_ID_REQ_PRESENT (0x8) 70 #define EAP_SIM_AT_MAC_PRESENT (0x10) 71 #define EAP_SIM_AT_NOTIFICATION_PRESENT (0x20) 72 #define EAP_SIM_AT_ANY_ID_REQ_PRESENT (0x40) 73 #define EAP_SIM_AT_IDENTITY_PRESENT (0x80) 74 #define EAP_SIM_AT_VERSION_LIST_PRESENT (0x100) 75 #define EAP_SIM_AT_SELECTED_VERSION_PRESENT (0x200) 76 #define EAP_SIM_AT_FULLAUTH_ID_REQ_PRESENT (0x400) 77 #define EAP_SIM_AT_COUNTER_PRESENT (0x800) 78 #define EAP_SIM_AT_COUNTER_TOO_SMALL_PRESENT (0x1000) 79 #define EAP_SIM_AT_NONCE_S_PRESENT (0x2000) 80 #define EAP_SIM_AT_CLIENT_ERROR_CODE_PRESENT (0x4000) 81 #define EAP_SIM_AT_IV_PRESENT (0x8000) 82 #define EAP_SIM_AT_ENCR_DATA_PRESENT (0x10000) 83 #define EAP_SIM_AT_NEXT_PSEUDONYM_PRESENT (0x20000) 84 #define EAP_SIM_AT_NEXT_REAUTH_ID_PRESENT (0x40000) 85 #define EAP_SIM_AT_RESULT_IND_PRESENT (0x80000) 86 #define EAP_AKA_AT_AUTN_PRESENT (0x100000) 87 #define EAP_AKA_AT_RES_PRESENT (0x200000) 88 #define EAP_AKA_AT_AUTS_PRESENT (0x400000) 89 #define EAP_AKA_AT_CHECKCODE_PRESENT (0x800000) 91 #define EAP_AKA_SUBTYPE_CHALLENGE (1) 92 #define EAP_AKA_SUBTYPE_AUTH_REJECT (2) 93 #define EAP_AKA_SUBTYPE_SYNC_FAIL (4) 94 #define EAP_AKA_SUBTYPE_IDENTITY (5) 95 #define EAP_SIM_SUBTYPE_START (10) 96 #define EAP_SIM_SUBTYPE_CHALLENGE (11) 97 #define EAP_SIM_SUBTYPE_NOTIFICATION (12) 98 #define EAP_AKA_SUBTYPE_NOTIFICATION (12) 99 #define EAP_SIM_SUBTYPE_REAUTHENTICATION (13) 100 #define EAP_AKA_SUBTYPE_REAUTHENTICATION (13) 101 #define EAP_SIM_SUBTYPE_CLIENT_ERROR (14) 102 #define EAP_AKA_SUBTYPE_CLIENT_ERROR (14) 104 #define EAP_SIM_MAC_LEN (16) 105 #define EAP_SIM_KAUT_LEN (16) 106 #define EAP_SIM_KENCR_LEN (16) 107 #define EAP_SIM_MK_LEN (20) 108 #define EAP_SIM_MSK_LEN (64) 109 #define EAP_SIM_EMSK_LEN (64) 110 #define EAP_SIM_KC_LEN (8) 111 #define EAP_SIM_SRES_LEN (4) 112 #define EAP_SIM_MAX_RAND (3) 113 #define EAP_SIM_RAND_LEN (16) 114 #define EAP_SIM_NONCE_MT_LEN (16) 115 #define EAP_SIM_NONCE_S_LEN (16) 116 #define EAP_SIM_IV_LEN (16) 117 #define EAP_AKA_AUTN_LEN (16) 118 #define EAP_AKA_AUTS_LEN (14) 119 #define EAP_AKA_MAX_RES_LEN (16) 120 #define EAP_AKA_IK_LEN (16) 121 #define EAP_AKA_CK_LEN (16) 123 #define EAP_SIM_NOTIF_S_BIT (0x8000) 124 #define EAP_SIM_NOTIF_P_BIT (0x4000) 126 #define EAP_SIM_PACKET_SIZE (1024) 132 typedef enum eapSimKeyType_e
134 EAP_SIM_MASTER_KEY = 1,
135 EAP_SIM_ENCR_KEY = 2,
138 EAP_SIM_EMSK_KEY = 5,
143 typedef enum eapSimNotifCode_e
145 EAP_SIM_NOTIF_GENERAL_ERROR = 0,
146 EAP_SIM_NOTIF_DENIED_ACCESS=1026,
147 EAP_SIM_NOTIF_NOT_SUBSCRIBED=1031,
148 EAP_SIM_NOTIF_GENERAL_FAILURE = 16384,
149 EAP_SIM_NOTIF_SUCCESS=32768
154 typedef enum eapSimClientErrCode_e
156 EAP_SIM_CLERR_PROCESSING = 0,
157 EAP_SIM_CLERR_UNSUPPORT_VER=1,
158 EAP_SIM_CLERR_LESS_CHALLENGES=2,
159 EAP_SIM_CLERR_STALE_RAND = 3
161 } eapSimClientErrCode;
164 typedef enum eapSimIdType_e
166 EAP_SIM_PERMANENT_ID_TYPE = 1,
167 EAP_SIM_FULLAUTH_ID_TYPE,
168 EAP_SIM_FASTREAUTH_ID_TYPE
173 typedef enum eapSimPdus_e {
176 EAP_SIM_CHALLENGE_REQ,
177 EAP_SIM_CHALLENGE_RESP,
178 EAP_SIM_NOTIFICATION_REQ,
179 EAP_SIM_NOTIFICATION_RESP,
180 EAP_SIM_CLIENT_ERROR,
183 EAP_AKA_IDENTITY_REQ,
184 EAP_AKA_IDENTITY_RESP,
185 EAP_AKA_AUTH_REJECT_RESP,
186 EAP_AKA_SYNC_FAIL_RESP
191 typedef enum eapSimStatus_e {
193 EAP_SIM_STATUS_RECV_START_RESP,
194 EAP_SIM_STATUS_RECV_START_REQ,
195 EAP_SIM_STATUS_RECV_CHALLENGE_RESP,
196 EAP_SIM_STATUS_RECV_CHALLENGE_REQ,
197 EAP_SIM_STATUS_RECV_NOTIFICATION_RESP,
198 EAP_SIM_STATUS_RECV_NOTIFICATION_REQ,
199 EAP_SIM_STATUS_RECV_NOTIFICATION_ERROR,
200 EAP_SIM_STATUS_RECV_REAUTH_REQ,
201 EAP_SIM_STATUS_RECV_REAUTH_RESP,
202 EAP_SIM_STATUS_RECV_CLIENT_ERROR_CODE,
203 EAP_AKA_STATUS_RECV_IDENTITY_REQ,
204 EAP_AKA_STATUS_RECV_IDENTITY_RESP,
205 EAP_AKA_STATUS_RECV_AUTH_REJECT_RESP,
206 EAP_AKA_STATUS_RECV_SYNC_FAIL_RESP
228 typedef struct eapSimConfig_s
265 MSTATUS(*getSresKc)(
void * appCb,
void *eapSim,ubyte *rand,ubyte numRand,
266 ubyte *Sres,ubyte *Kc);
300 MSTATUS(*getAKARes)(
void * appCb,
void *eapSim,ubyte *rand,ubyte *autn,
301 ubyte *ik,ubyte * ck,
302 ubyte *Res,ubyte2 *resLen,ubyte *auts);
333 typedef struct eapSimCb_s {
336 ubyte* permanentIdentity;
337 ubyte2 permanentIdentityLen;
346 ubyte sRes[EAP_SIM_SRES_LEN* EAP_SIM_MAX_RAND];
347 ubyte kC[EAP_SIM_KC_LEN* EAP_SIM_MAX_RAND];
348 ubyte2* versionListImpl;
349 ubyte2 numVersionListImpl;
351 ubyte2 numVersionList;
352 ubyte2 selectedVersion;
353 ubyte nonce_mt[EAP_SIM_NONCE_MT_LEN];
354 ubyte nonce_s[EAP_SIM_NONCE_S_LEN];
356 ubyte rand[EAP_SIM_MAX_RAND][EAP_SIM_RAND_LEN];
357 ubyte mac[EAP_SIM_MAC_LEN];
358 ubyte autn[EAP_AKA_AUTN_LEN];
359 ubyte auts[EAP_AKA_AUTS_LEN];
360 ubyte res[EAP_AKA_MAX_RES_LEN];
362 ubyte authRes[EAP_AKA_MAX_RES_LEN];
364 ubyte masterKey[EAP_SIM_MK_LEN];
365 ubyte k_aut[EAP_SIM_KAUT_LEN];
366 ubyte k_encr[EAP_SIM_KENCR_LEN];
367 ubyte k_msk[EAP_SIM_MSK_LEN];
368 ubyte k_emsk[EAP_SIM_EMSK_LEN];
369 ubyte IK[EAP_AKA_IK_LEN];
370 ubyte CK[EAP_AKA_CK_LEN];
373 ubyte iv[EAP_SIM_IV_LEN];
377 ubyte2 clientErrCode;
379 eapSimStatus sessionStatus;
381 ubyte reAuthRoundSuccess;
382 ubyte attemptreAuthRound;
383 ubyte fullAuthRoundSuccess;
384 ubyte attemptfullAuthRound;
385 ubyte counterTooSmall;
445 ubyte *rand, ubyte2 num_rand,
446 ubyte *kC, ubyte *sRes,
447 ubyte *at_next_psuedo, ubyte2 at_psuedo_len,
448 ubyte *at_next_reauthid, ubyte2 at_reauthid_len,
498 ubyte4 notification_code, ubyte
id);
540 ubyte **resp, ubyte4 *respLen, eapSimStatus *state);
660 ubyte id_type, ubyte
id);
706 ubyte *at_next_reauthid, ubyte2 at_reauthid_len,
886 ubyte2 *versionList, ubyte2 numVersion);
1107 ubyte id_type, ubyte
id);
1158 ubyte *rand, ubyte *autn,
1159 ubyte *ck, ubyte *ik, ubyte* res, ubyte2 resLen,
1160 ubyte *at_next_psuedo, ubyte2 at_psuedo_len,
1161 ubyte *at_next_reauthid, ubyte2 at_reauthid_len,
1205 ubyte **resp, ubyte4 *respLen, eapSimStatus *state);
1209 EAP_AKAGetAuts(eapSimCb *eapSim, ubyte **auts);
1246 ubyte **key, ubyte4 *keyLen);
MOC_EXTERN MSTATUS EAP_SIMSendChallengeReq(eapSimCb *eapSim, ubyte **pkt, ubyte4 *pktLen, ubyte *rand, ubyte2 num_rand, ubyte *kC, ubyte *sRes, ubyte *at_next_psuedo, ubyte2 at_psuedo_len, ubyte *at_next_reauthid, ubyte2 at_reauthid_len, ubyte id)
Build a Sim Challenge Request packet.
MOC_EXTERN MSTATUS EAP_SIMSendNotificationReq(eapSimCb *eapSim, ubyte **pkt, ubyte4 *pktLen, ubyte2 at_counter, ubyte4 notification_code, ubyte id)
Build a Sim Notification Request packet.
MOC_EXTERN MSTATUS EAP_SIMInitSession(void *appCb, void **eapSim, eapSimConfig eapSimCfg)
Create and initialize an EAP-SIM or EAP-AKA session.
eapSessionType sessionType
EAP session type.
Definition: eap_sim.h:310
MOC_EXTERN MSTATUS EAP_SIMSetImplementedVersion(eapSimCb *eapSim, ubyte2 *versionList, ubyte2 numVersion)
Add version(s) to an EAP-SIM session's supported versions list.
MOC_EXTERN MSTATUS EAP_SIMGetIdentity(eapSimCb *eapSim, ubyte **identity, ubyte4 *len)
Get the EAP-SIM session ID returned by the peer.
MOC_EXTERN MSTATUS EAP_SIMGetSessionStatus(void *eap_sim, eapSimStatus *status)
Get an EAP-SIM session's session status.
MOC_EXTERN MSTATUS EAP_SIMSetIdentity(eapSimCb *eapSim, ubyte *id, ubyte2 idLen)
Set the EAP-SIM session's final identity.
ubyte aka
AKA Session.
Definition: eap_sim.h:328
MOC_EXTERN MSTATUS EAP_AKASendChallengeReq(eapSimCb *eapSim, ubyte **pkt, ubyte4 *pktLen, ubyte *rand, ubyte *autn, ubyte *ck, ubyte *ik, ubyte *res, ubyte2 resLen, ubyte *at_next_psuedo, ubyte2 at_psuedo_len, ubyte *at_next_reauthid, ubyte2 at_reauthid_len, ubyte id)
Send EAP-AKA Challenge Request.
MOC_EXTERN MSTATUS EAP_AKAProcessPkt(eapSimCb *eapSim, ubyte *pkt, ubyte2 pktLen, ubyte **resp, ubyte4 *respLen, eapSimStatus *state)
Process received EAP-AKA packet.
MOC_EXTERN MSTATUS EAP_SIMSendStartReq(eapSimCb *eapSim, ubyte **pkt, ubyte4 *pktLen, ubyte id_type, ubyte id)
Build a Sim Start Request packet.
MOC_EXTERN MSTATUS EAP_SIMGetClientErrorCode(eapSimCb *eapSim, ubyte2 *clCode)
Get the client error code returned by the peer.
MSTATUS EAP_SIMSendReauthReq(eapSimCb *eapSim, ubyte **pkt, ubyte4 *pktLen, ubyte *at_next_reauthid, ubyte2 at_reauthid_len, ubyte id)
Build a SIM FAST Reauthentication Request packet.
ubyte minNumRand
Minimum number of Rands that the Auth needs to send.
Definition: eap_sim.h:316
MOC_EXTERN MSTATUS EAP_SIMgetKey(eapSimCb *eapSim, eapSimKeyType keyType, ubyte **key, ubyte4 *keyLen)
Get an EAP-SIM session key.
MOC_EXTERN MSTATUS EAP_SIMProcessPkt(eapSimCb *eapSim, ubyte *pkt, ubyte2 pktLen, ubyte **resp, ubyte4 *respLen, eapSimStatus *state)
Process a received packet and build a response.
MOC_EXTERN MSTATUS EAP_SIMGetNotification(eapSimCb *eapSim, ubyte2 *notifCode)
Get the authenticator's notification code.
ubyte dontSendPerm
Deny the PERM ID attribute to the server.
Definition: eap_sim.h:322
Configuration settings and callback function pointers for EAP-SIM EAP-AKA methods.
Definition: eap_sim.h:228
MOC_EXTERN MSTATUS EAP_SIMGetResultInd(void *eap_sim, ubyte *rInd)
Determine whether a challenge negotiation included a RESULT_IND attribute.
ubyte send_result_ind
Support Result_IND Attribute.
Definition: eap_sim.h:234
MOC_EXTERN MSTATUS EAP_SIMGetSelectedVersion(void *eap_sim, ubyte2 *rVer)
Get the version selected during negotiation.
MOC_EXTERN MSTATUS EAP_AKASendIdentityReq(eapSimCb *eapSim, ubyte **pkt, ubyte4 *pktLen, ubyte id_type, ubyte id)
Send EAP-AKA Start Request.
MOC_EXTERN MSTATUS EAP_SIMDeleteSession(eapSimCb *eapSim)
Delete an EAP-SIM connection.
MOC_EXTERN MSTATUS EAP_SIMSetPermIdentity(eapSimCb *eapSim, ubyte *id, ubyte2 idLen)
Set the EAP-SIM session's permanent identity.
MOC_EXTERN MSTATUS EAP_SIMGetSuccessNotifCode(void *eap_sim, ubyte *rCode)
Determine whether an authenticator Notification's S Bit is set.