RAPDU ICard::transceive(const CAPDU &cmd) { debug_CAPDU("Outgoing", cmd); RAPDU rapdu(m_subSystem->transceive(cmd.asBuffer())); debug_RAPDU("Incoming", rapdu); return rapdu; }
std::vector<std::vector<unsigned char> > ICard::get_buffers(std::vector<CAPDU> apdus) { std::vector<std::vector<unsigned char> > buffers; for (std::vector<CAPDU>::const_iterator i = apdus.begin(); i < apdus.end(); ++i) { debug_CAPDU("Outgoing", *i); buffers.push_back(i->asBuffer()); } return buffers; }
CAPDU ePACard::applySM(const CAPDU &capdu) { std::vector<unsigned char> do87_, do8E_, do97_, Le, sm_data; debug_CAPDU("Unencrypted", capdu); CAPDU sm_apdu = CAPDU(capdu.getCLA() | CAPDU::CLA_SM, capdu.getINS(), capdu.getP1(), capdu.getP2()); m_ssc++; if (!capdu.getData().empty()) { do87_ = buildDO87_AES(m_kEnc, capdu.getData(), m_ssc); } Le = capdu.encodedLe(); if (!Le.empty()) { if (Le.size() > 2) { Le.erase(Le.begin()); } do97_ = TLV_encode(0x97, Le); } /* here, sm_apdu is still a case 1 APDU with header only. */ do8E_ = buildDO8E_AES(m_kMac, sm_apdu.asBuffer(), do87_, do97_, m_ssc); sm_data = do87_; sm_data.insert(sm_data.end(), do97_.begin(), do97_.end()); sm_data.insert(sm_data.end(), do8E_.begin(), do8E_.end()); sm_apdu.setData(sm_data); if (sm_apdu.isExtended() || capdu.isExtended()) sm_apdu.setNe(CAPDU::DATA_EXTENDED_MAX); else sm_apdu.setNe(CAPDU::DATA_SHORT_MAX); return sm_apdu; }