14#include "keyple/card/calypso/crypto/legacysam/CommandReadParameters.hpp"
20#include "keyple/card/calypso/crypto/legacysam/CounterOverflowException.hpp"
21#include "keyple/card/calypso/crypto/legacysam/IllegalParameterException.hpp"
22#include "keyple/card/calypso/crypto/legacysam/LegacySamConstants.hpp"
23#include "keyple/core/util/ApduUtil.hpp"
24#include "keyple/core/util/cpp/System.hpp"
32using keyple::core::util::ApduUtil;
33using keyple::core::util::cpp::System;
34const int CommandReadParameters::SW_DATA_NOT_SIGNED_WARNING = 0x6200;
36const std::map<int, const std::shared_ptr<StatusProperties>>
37 CommandReadParameters::STATUS_TABLE = [] {
38 std::map<int, const std::shared_ptr<StatusProperties>> m(
39 Command::STATUS_TABLE);
43 std::make_shared<StatusProperties>(
44 "An event counter cannot be incremented",
45 typeid(CounterOverflowException))},
47 std::make_shared<StatusProperties>(
48 "Incorrect P1 or P2",
typeid(IllegalParameterException))},
50 std::make_shared<StatusProperties>(
51 "Correct execution with warning: data not signed")}});
55CommandReadParameters::CommandReadParameters(
56 std::shared_ptr<DtoAdapters::CommandContextDto> context)
57: Command(CommandRef::READ_PARAMETERS, 48, context)
59 const uint8_t cla = context->getTargetSam()->getClassByte();
60 const uint8_t p1 = 0x00;
61 const uint8_t p2 = 0xA0;
64 std::make_shared<ApduRequestAdapter>(ApduUtil::build(
65 cla, getCommandRef().getInstructionByte(), p1, p2)));
69CommandReadParameters::finalizeRequest()
75CommandReadParameters::isControlSamRequiredToFinalizeRequest()
const
81CommandReadParameters::parseResponse(
82 std::shared_ptr<ApduResponseApi> apduResponse)
84 setResponseAndCheckStatus(apduResponse);
85 std::vector<uint8_t> keyParameter(
86 LegacySamConstants::SAM_PARAMETERS_LENGTH);
88 apduResponse->getApdu(),
92 LegacySamConstants::SAM_PARAMETERS_LENGTH);
93 getContext()->getTargetSam()->setSamParameters(
94 std::make_shared<SamParametersAdapter>(keyParameter));
97const std::map<int, const std::shared_ptr<StatusProperties>>&
98CommandReadParameters::getStatusTable()
const