User Level Access Sample Clauses
User Level Access. Except for the basic operations, there is actually only one access in user level: executing internal EXF. In the sample codes as given below, we continue to use the OpenSense4() function as mentioned above. #include <stdio.h> #include <stdlib.h> #include <conio.h> #include "sense4.h" #include "psense4.h" int main(int argc, char **argv) { SENSE4_CONTEXT s4ctx = {0}; unsigned char fid_exe[] = "d001"; // exe file ID unsigned char user_pin[] = "12345678"; unsigned ▇▇▇▇ ▇▇▇ = 0; unsigned ret = 0; unsigned char input[256] = {0}; unsigned long input_len = 128; unsigned char output[256] = {0}; unsigned long output_len = 251; /* Open first Senselock ELif exists. */ ret = OpenSense4(&s4ctx, 0); if (ret != S4_SUCCESS) { printf("Open Senselock ELfailed! <error code = 0x%08x>\n", ret); return 1; } /* Change to root dir if exists. */ ret = S4ChangeDir(&s4ctx, "\\"); if (ret != S4_FILE_NOT_FOUND && ret != S4_SUCCESS) { printf("Change to root dir failed! <error code = 0x%08x>\n", ret); S4Close(&s4ctx);
return 1; Verify user PIN to get invoking privilege. */ ret = S4VerifyPin(&s4ctx, user_pin, 8, S4_USER_PIN); if (ret != S4_SUCCESS) { printf("Verify user PIN failed! <error code = 0x%08x>\n", ret); S4Close(&s4ctx);
return 1; Invoke exf 0xd001. */ ret = S4Execute(&s4ctx, “d001”, input, input_len, output, output_len, &len); if (ret != S4_SUCCESS) { printf("Invoke 0xd001 failed! <error code = 0x%08x>\n", ret); S4Close(&s4ctx); return 1; } /* Close SenseLock EL. */ S4Close(&s4ctx); /* everything done! */ printf("Congratulations!\n"); return 0; } If you hope to use XA running mode, it is necessary to use the newer function S4ExecuteEx(). If you hope the software accesses the dongle in an exclusive mode, please replace S4Open() with the S4OpenEx() function. For details, see Chapter 9 ―API Reference‖. Important reminder: In actual application, try mixing or encrypting communication data so as to get higher randomness to thwart malicious decryption analysis.
