bool ICard::readFile( unsigned char sfid, size_t chunk_size, std::vector<unsigned char>& result) { ReadBinary read = ReadBinary(0, sfid); read.setNe(chunk_size); RAPDU response = transceive(read); while (response.isOK() && response.getData().size() == chunk_size) { result.insert(result.end(), response.getData().begin(), response.getData().end()); read = ReadBinary(result.size()); read.setNe(chunk_size); response = transceive(read); } result.insert(result.end(), response.getData().begin(), response.getData().end()); if (result.empty()) { return response.isOK(); } return true; }
void ICard::debug_RAPDU(const char *label, const RAPDU& rapdu) const { eCardCore_info(DEBUG_LEVEL_APDU, "%s%sR-APDU: SW=%04X Nr=%u", label, label ? " " : "", rapdu.getSW(), rapdu.getData().size()); if (!rapdu.getData().empty()) hexdump(DEBUG_LEVEL_APDU, NULL, DATA(rapdu.getData()), rapdu.getData().size()); }
bool ICard::readFile( std::vector<unsigned char>& result) { ReadBinary read = ReadBinary(); read.setNe(CAPDU::DATA_EXTENDED_MAX); RAPDU response = transceive(read); result = response.getData(); return response.isOK(); }
ECARD_STATUS process_CA_Step_C(const RAPDU rapdu, std::vector<unsigned char>& GeneralAuthenticationResult) { if (rapdu.getSW() != RAPDU::ISO_SW_NORMAL) return EAC_CA_STEP_B_FAILED; GeneralAuthenticationResult = rapdu.getData(); return EAC_SUCCESS; }
bool ICard::selectEF( unsigned short FID, std::vector<unsigned char>& fcp) { SelectFile select(SelectFile::P1_SELECT_EF, SelectFile::P2_FCP_TEMPLATE, FID); select.setNe(CAPDU::DATA_SHORT_MAX); RAPDU response = transceive(select); fcp = response.getData(); return response.isOK(); }
RAPDU ePACard::removeSM(const RAPDU &sm_rapdu) { std::vector<unsigned char> response; std::vector<unsigned char> sm_rdata; sm_rdata = sm_rapdu.getData(); m_ssc++; if (!verifyResponse_AES(m_kMac, sm_rdata, m_ssc)) throw WrongSM(); response = decryptResponse_AES(m_kEnc, sm_rdata, m_ssc); /* TODO compare DO99 with SW */ RAPDU rapdu(response, sm_rapdu.getSW()); debug_RAPDU("Decrypted", rapdu); return rapdu; }