* added `hf emv scan` command and options
* add tlv tag save to json
* added tlv tree navigation
* added kernel id and moved some parts of code in ppse
* save gpo result
* added read records
* extract childs from tlv works
* added application data list
* added work with application data section
* flag --extract works
* refactoring: move json functions to emvjson.h/c
* added path.c to jansson
* refactoring: move ParamLoadFromJson
* refactoring: move defparams.json to tag-name-value structure
* refactoring and add key recovering
* added some codes to appdata list
* refactoring: process response format 1 from GPO
* added save mode
* added RID to app data
* add file name handling and small refactoring in argtable string processing
* added finalization logic to `emv scan` and option to remove hash checking in key recovery
This commit is contained in:
Oleg Moiseenko 2018-10-17 21:53:34 +03:00 committed by pwpiwi
commit 95b697f017
20 changed files with 1209 additions and 241 deletions

View file

@ -153,23 +153,14 @@ void CLIParserFree() {
// convertors
int CLIParamHexToBuf(struct arg_str *argstr, uint8_t *data, int maxdatalen, int *datalen) {
*datalen = 0;
if (!argstr->count)
return 0;
char buf[256] = {0};
int ibuf = 0;
uint8_t buf[256] = {0};
int res = CLIParamStrToBuf(argstr, buf, maxdatalen, &ibuf);
if (res || !ibuf)
return res;
for (int i = 0; i < argstr->count; i++) {
int len = strlen(argstr->sval[i]);
memcpy(&buf[ibuf], argstr->sval[i], len);
ibuf += len;
}
buf[ibuf] = 0;
if (!ibuf)
return 0;
switch(param_gethex_to_eol(buf, 0, data, maxdatalen, datalen)) {
switch(param_gethex_to_eol((char *)buf, 0, data, maxdatalen, datalen)) {
case 1:
printf("Parameter error: Invalid HEX value.\n");
return 1;
@ -184,5 +175,31 @@ int CLIParamHexToBuf(struct arg_str *argstr, uint8_t *data, int maxdatalen, int
return 0;
}
int CLIParamStrToBuf(struct arg_str *argstr, uint8_t *data, int maxdatalen, int *datalen) {
*datalen = 0;
if (!argstr->count)
return 0;
uint8_t buf[256] = {0};
int ibuf = 0;
for (int i = 0; i < argstr->count; i++) {
int len = strlen(argstr->sval[i]);
memcpy(&buf[ibuf], argstr->sval[i], len);
ibuf += len;
}
buf[ibuf] = 0;
if (!ibuf)
return 0;
if (ibuf > maxdatalen)
return 2;
memcpy(data, buf, ibuf);
*datalen = ibuf;
return 0;
}