14#include "keyple/card/calypso/CommandGetChallenge.hpp"
20#include "keyple/card/calypso/CalypsoCardAdapter.hpp"
21#include "keyple/core/util/ApduUtil.hpp"
27using keyple::core::util::ApduUtil;
29CommandGetChallenge::CommandGetChallenge(
30 const std::shared_ptr<DtoAdapters::TransactionContextDto>&
32 const std::shared_ptr<DtoAdapters::CommandContextDto>& commandContext)
34 CardCommandRef::GET_CHALLENGE,
35 std::unique_ptr<int>(new int(8)),
41 std::make_shared<DtoAdapters::ApduRequestAdapter>(ApduUtil::build(
42 getTransactionContext()->getCard()->getCardClass().getValue(),
43 getCommandRef().getInstructionByte(),
46 static_cast<std::uint8_t
>(8))));
50CommandGetChallenge::finalizeRequest()
52 encryptRequestAndUpdateTerminalSessionMacIfNeeded();
56CommandGetChallenge::isCryptoServiceRequiredToFinalizeRequest()
const
58 return getCommandContext()->isEncryptionActive();
62CommandGetChallenge::synchronizeCryptoServiceBeforeCardProcessing()
69CommandGetChallenge::parseResponse(
70 std::shared_ptr<ApduResponseApi> apduResponse)
72 decryptResponseAndUpdateTerminalSessionMacIfNeeded(apduResponse);
73 Command::setApduResponseAndCheckStatus(apduResponse);
74 getTransactionContext()->getCard()->setChallenge(
75 getApduResponse()->getDataOut());
76 updateTerminalSessionIfNeeded();