Sample code for SIM Authentication
#define NEW_PIN_TEST "5678"#define FAIL_PIN_TEST "4321"#define FAIL_PUK_TEST "87654321"
//--------------------------------------------------------------------------------------------------/*** Test: Authentication (pin/puk).**///--------------------------------------------------------------------------------------------------void simTest_Authentication(le_sim_Id_t simId,const char* pinPtr,const char* pukPtr){le_result_t res;bool ready = false;int32_t remainingPinTries = 0;int32_t tries = 0;uint32_t remainingPukTries = 0;uint32_t pukTries = 0;char string[100];memset(string, 0, 100);// Get the remaining PIN entriesremainingPinTries = le_sim_GetRemainingPINTries(simId);// Enter PIN coderes = le_sim_EnterPIN(simId, FAIL_PIN_TEST);// Get the remaining PIN entriestries = le_sim_GetRemainingPINTries(simId);LE_ASSERT((remainingPinTries-tries) == 1);// Check that the SIM is not readyready = le_sim_IsReady(simId);LE_ASSERT(!ready);// Enter PIN coderes = le_sim_EnterPIN(simId, pinPtr);// Check that the SIM is readyready = le_sim_IsReady(simId);LE_ASSERT(ready);// Change PINres = le_sim_ChangePIN(simId, FAIL_PIN_TEST, NEW_PIN_TEST);// Change the PIN coderes = le_sim_ChangePIN(simId, pinPtr, NEW_PIN_TEST);// block the SIM:// while remaining PIN entries not null, enter a wrong PIN codewhile((remainingPinTries = le_sim_GetRemainingPINTries(simId)) > 0){// Enter PIN coderes = le_sim_EnterPIN(simId, FAIL_PIN_TEST);}if(remainingPinTries < 0){sprintf(string, "\nle_sim_GetRemainingPINTries error, res.%d (should be >=0)\n",remainingPinTries);Print(string);}// Get the remaining PUK entriesLE_ASSERT_OK(le_sim_GetRemainingPUKTries(simId, &remainingPukTries));// Unblock the SIM using a wrong PUK code (error expected)res = le_sim_Unblock(simId, FAIL_PUK_TEST, NEW_PIN_TEST);// Get the remaining PUK entriesLE_ASSERT_OK(le_sim_GetRemainingPUKTries(simId, &pukTries));LE_ASSERT(1 == (remainingPukTries-pukTries));// Unblock the SIM using the correct PUK coderes = le_sim_Unblock(simId, pukPtr, NEW_PIN_TEST);// Get the remaining PUK entriesLE_ASSERT_OK(le_sim_GetRemainingPUKTries(simId, &pukTries));LE_ASSERT((0 == remainingPukTries-pukTries));Print("End simTest_Authentication");}