X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/6b5105bea972d055bb2069bf8ca2c6d105b2ee8f..4d8a07c829139419f05fbce09135c89cbb3c512f:/client/fido/fidocore.c?ds=inline diff --git a/client/fido/fidocore.c b/client/fido/fidocore.c index 4d973737..6e021ea6 100644 --- a/client/fido/fidocore.c +++ b/client/fido/fidocore.c @@ -22,7 +22,10 @@ #include "crypto/libpcrypto.h" #include "fido/additional_ca.h" #include "fido/cose.h" +#include "emv/dump.h" #include "protocols.h" +#include "ui.h" +#include "util.h" typedef struct { @@ -176,43 +179,43 @@ int FIDOSelect(bool ActivateField, bool LeaveFieldON, uint8_t *Result, size_t Ma } int FIDOExchange(uint8_t* apdu, int apdulen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw) { - int res = EMVExchange(ECC_CONTACTLESS, true, apdu, apdulen, Result, MaxResultLen, ResultLen, sw, NULL); - if (res == 5) // apdu result (sw) not a 0x9000 - res = 0; - // software chaining - while (!res && (*sw >> 8) == 0x61) { - uint8_t La = *sw & 0xff; - uint8_t get_response_APDU[5] = {apdu[0], ISO7816_GET_RESPONSE, 0x00, 0x00, La}; - size_t oldlen = *ResultLen; - res = EMVExchange(ECC_CONTACTLESS, true, get_response_APDU, sizeof(get_response_APDU), &Result[oldlen], MaxResultLen - oldlen, ResultLen, sw, NULL); - if (res == 5) // apdu result (sw) not a 0x9000 - res = 0; + int res = EMVExchangeEx(ECC_CONTACTLESS, false, true, apdu, apdulen, Result, MaxResultLen, ResultLen, sw, NULL); + // if (res == 5) // apdu result (sw) not a 0x9000 + // res = 0; + // // software chaining + // while (!res && (*sw >> 8) == 0x61) { + // uint8_t La = *sw & 0xff; + // uint8_t get_response_APDU[5] = {apdu[0], ISO7816_GET_RESPONSE, 0x00, 0x00, La}; + // size_t oldlen = *ResultLen; + // res = EMVExchange(ECC_CONTACTLESS, true, get_response_APDU, sizeof(get_response_APDU), &Result[oldlen], MaxResultLen - oldlen, ResultLen, sw, NULL); + // if (res == 5) // apdu result (sw) not a 0x9000 + // res = 0; - *ResultLen += oldlen; - if (*ResultLen > MaxResultLen) - return 100; - } + // *ResultLen += oldlen; + // if (*ResultLen > MaxResultLen) + // return 100; + // } return res; } int FIDORegister(uint8_t *params, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw) { - uint8_t APDU[4 + 64] = {0x00, 0x01, 0x03, 0x00, 64, 0x00}; - memcpy(APDU, params, 64); - return FIDOExchange(APDU, 4 + 64, Result, MaxResultLen, ResultLen, sw); + uint8_t APDU[5 + 64] = {0x00, 0x01, 0x03, 0x00, 64, 0x00}; + memcpy(APDU + 5, params, 64); + return FIDOExchange(APDU, 5 + 64, Result, MaxResultLen, ResultLen, sw); } int FIDOAuthentication(uint8_t *params, uint8_t paramslen, uint8_t controlb, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw) { uint8_t APDU[APDU_COMMAND_LEN] = {0x00, 0x02, controlb, 0x00, paramslen, 0x00}; - memcpy(APDU+5, params, paramslen); + memcpy(APDU + 5, params, paramslen); int apdu_len = 5 + paramslen; return FIDOExchange(APDU, apdu_len, Result, MaxResultLen, ResultLen, sw); } int FIDO2GetInfo(uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw) { - uint8_t APDU[5] = {0x80, 0x10, 0x00, 0x00, fido2CmdGetInfo}; + uint8_t APDU[6] = {0x80, 0x10, 0x00, 0x00, 0x01, fido2CmdGetInfo}; return FIDOExchange(APDU, sizeof(APDU), Result, MaxResultLen, ResultLen, sw); } @@ -264,9 +267,9 @@ int FIDOCheckDERAndGetKey(uint8_t *der, size_t derLen, bool verbose, uint8_t *pu uint32_t verifyflags = 0; res = mbedtls_x509_crt_verify(&cert, &cacert, NULL, NULL, &verifyflags, NULL, NULL); if (res) { - PrintAndLog("ERROR: DER verify returned 0x%x - %s", (res<0)?-res:res, ecdsa_get_error(res)); + PrintAndLog("ERROR: DER verify returned 0x%x - %s\n", (res<0)?-res:res, ecdsa_get_error(res)); } else { - PrintAndLog("Certificate OK."); + PrintAndLog("Certificate OK.\n"); } if (verbose) {