/** * @file * @author NXP Semiconductors * @version 1.0 * @par License * * Copyright 2017 NXP * SPDX-License-Identifier: Apache-2.0 * * @par Description * Command line handling main entry */ #include #include #include #include // project specific include files #include "sm_types.h" #include "sm_apdu.h" #include "tst_sm_util.h" #include "tst_a71ch_util.h" #include "probeAxUtil.h" #include "configCli.h" #include "axHostCrypto.h" #include "tstHostCrypto.h" #define FLOW_VERBOSE_PROBE_A70 #ifdef FLOW_VERBOSE_PROBE_A70 #define FPRINTF(...) printf (__VA_ARGS__) #else #define FPRINTF(...) #endif // #define DBG_PROBE_A70 #ifdef DBG_PROBE_A70 #define DBGPRINTF(...) printf (__VA_ARGS__) #else #define DBGPRINTF(...) #endif /** * @brief Usage of the A71CH Config Tool * * Simply invoking the tool in standalone mode on an MCIMX6UL-EVKB board results in the following * output (some output edited away) * * root@imx6ulevk:~# ./a71chConfig_i2c_imx * a71chConfig (Rev 1.00) .. connect to A71CH. Chunksize at link layer = 256. * ... * Applet-Rev:SecureBox-Rev : 0x0131:0x0000 * **************************** * Usage: a71chConfig [apdu|debug|erase|gen|info|interactive|lock|rcrt|scp|set|wcrt|help] * apdu -cmd -sw * debug [permanently_disable_debug|reset] * ecrt -x * erase [cnt|pair|pub|sym] -x * gen pair -x * get pub -c -x -k * info [all|cnt|device|objects|pair|pub|status] * info gp -h -n * interactive * lock [pair|pub] -x * lock gp -h -n * lock inject_plain * obj erase -x * obj get -x [-h ] [-s ] [-f -t [hex_16|hex_32]] * obj update -x -h [-f -t [hex_16|hex_32] | -h ] * obj write -x [-f -t [hex_16|hex_32] | -h | -n ] * rcrt -x [-c ] * refpem -c -x [-k ] -r * script -f * scp [put|auth] -h -k * set gp -h -h * set pair -x [-k | -h -h ] [-w ] * set pub -x [-k | -h ] [-w ] * set [cfg|cnt|sym] -x -h [-w ] * transport [lock|unlock -h ] * ucrt -x [-c | -h | -p ] * wcrt -x [-c | -h | -p ] [-n ] * **************************** */ int a7xConfigCliHelp(char *szName) { if ( strcmp(szName, "interactive") == 0) { printf("[apdu|debug|erase|gen|info|lock|scp|set|help|quit] \n"); } else { printf("****************************\n"); printf("Usage: %s ", szName); #if defined(SMCOM_JRCP_V1) printf("[ip-address:8050] "); #endif printf("[apdu|debug|erase|gen|info|interactive|lock|scp|set|help|...] \n"); } printf(" apdu -cmd -sw \n"); if ( strcmp(szName, "interactive") == 0) { printf(" connect [close|open]\n"); } printf(" debug [permanently_disable_debug|reset]\n"); printf(" ecrt -x \n"); printf(" erase [cnt|pair|pub|sym] -x \n"); printf(" gen pair -x \n"); printf(" get pub -c -x -k \n"); printf(" info [all|cnt|device|objects|pair|pub|status]\n"); printf(" info gp -h -n \n"); if ( strcmp(szName, "interactive") != 0) { printf(" interactive\n"); } printf(" lock [pair|pub] -x \n"); printf(" lock gp -h -n \n"); printf(" lock inject_plain\n"); printf(" obj erase -x \n"); printf(" obj get -x [-h ] [-s ] [-f -t [hex_16|hex_32]]\n"); printf(" obj update -x -h [-f -t [hex_16|hex_32] | -h ]\n"); printf(" obj write -x [-f -t [hex_16|hex_32] | -h | -n ]\n"); printf(" rcrt -x [-c ]\n"); printf(" refpem -c -x [-k ] -r \n"); printf(" script -f \n"); printf(" scp [put|auth] -h -k \n"); if ( strcmp(szName, "interactive") == 0) { printf(" scp clear_host\n"); } printf(" set gp -h -h \n"); printf(" set gp -h -c \n"); // deprecated printf(" set pair -x [-k | -h -h ] [-w ]\n"); printf(" set pub -x [-k | -h ] [-w ]\n"); printf(" set [cfg|cnt|sym] -x -h [-w ]\n"); printf(" transport [lock|unlock -h ]\n"); printf(" ucrt -x [-c | -h | -p ]\n"); printf(" wcrt -x [-c | -h | -p ] [-n ]\n"); if ( strcmp(szName, "interactive") != 0) { printf("****************************\n"); } return AX_CLI_CHECK_USAGE; } // Parses commandline and invokes proper command // \note Before this is called the optional IP:PORT argument has been stripped. // \returns Returns ::AX_CLI_EXEC_OK upon success int a7xConfigCli(char *progname, int argc, char **argv) { int nRet = AX_CLI_EXEC_OK; #ifdef DBG_PROBE_A70 int i = 0; #endif U16 sw = 0; DBGPRINTF("a7xConfigCli (%s): %d arguments left to parse.\n", progname, argc); #ifdef DBG_PROBE_A70 for (i=0; i