15#include "keyple/card/calypso/CommandGetDataCardPublicKey.hpp"
20#include "keyple/card/calypso/CalypsoCardAdapter.hpp"
21#include "keyple/card/calypso/CalypsoCardConstant.hpp"
22#include "keyple/card/calypso/CardDataAccessException.hpp"
23#include "keyple/core/util/ApduUtil.hpp"
24#include "keyple/core/util/cpp/Arrays.hpp"
25#include "keyple/core/util/cpp/System.hpp"
31using keyple::core::util::ApduUtil;
32using keyple::core::util::cpp::Arrays;
33using keyple::core::util::cpp::System;
35const std::map<int, const std::shared_ptr<Command::StatusProperties>>
36 CommandGetDataCardPublicKey::STATUS_TABLE = [] {
37 std::map<int, const std::shared_ptr<Command::StatusProperties>> m(
38 Command::STATUS_TABLE);
42 std::make_shared<StatusProperties>(
43 "Data object not found (optional mode not available)",
44 typeid(CardDataAccessException))},
46 std::make_shared<StatusProperties>(
47 "P1 or P2 value not supported",
48 typeid(CardDataAccessException))}});
52CommandGetDataCardPublicKey::CommandGetDataCardPublicKey(
53 const std::shared_ptr<DtoAdapters::TransactionContextDto>&
55 const std::shared_ptr<DtoAdapters::CommandContextDto>& commandContext)
56: Command(CardCommandRef::GET_DATA, nullptr, transactionContext, commandContext)
58 const std::uint8_t cardClass
59 = transactionContext->getCard() !=
nullptr
60 ? transactionContext->getCard()->getCardClass().getValue()
61 : CalypsoCardClass::ISO.getValue();
65 std::make_shared<DtoAdapters::ApduRequestAdapter>(ApduUtil::build(
67 getCommandRef().getInstructionByte(),
68 CalypsoCardConstant::TAG_CARD_PUBLIC_KEY_MSB,
69 CalypsoCardConstant::TAG_CARD_PUBLIC_KEY_LSB)));
71 addSubName(
"ECC_PUBLIC_KEY");
75CommandGetDataCardPublicKey::finalizeRequest()
81CommandGetDataCardPublicKey::isCryptoServiceRequiredToFinalizeRequest()
const
87CommandGetDataCardPublicKey::synchronizeCryptoServiceBeforeCardProcessing()
93CommandGetDataCardPublicKey::parseResponse(
94 std::shared_ptr<ApduResponseApi> apduResponse)
96 Command::setApduResponseAndCheckStatus(apduResponse);
98 getTransactionContext()->getCard()->setCardPublicKey(
100 apduResponse->getDataOut(),
101 CalypsoCardConstant::TAG_CARD_PUBLIC_KEY_HEADER_SIZE,
102 apduResponse->getDataOut().size()));
105const std::map<int, const std::shared_ptr<Command::StatusProperties>>&
106CommandGetDataCardPublicKey::getStatusTable()
const