15#include "keyple/card/calypso/crypto/legacysam/CommandSelectDiversifier.hpp"
21#include "keyple/card/calypso/crypto/legacysam/AccessForbiddenException.hpp"
22#include "keyple/card/calypso/crypto/legacysam/CommandRef.hpp"
23#include "keyple/card/calypso/crypto/legacysam/IllegalParameterException.hpp"
24#include "keyple/core/util/ApduUtil.hpp"
25#include "keyple/core/util/cpp/System.hpp"
33using keyple::card::calypso::crypto::legacysam::CommandRef;
34using keyple::core::util::ApduUtil;
35using keyple::core::util::cpp::System;
37const std::map<int, const std::shared_ptr<StatusProperties>>
38 CommandSelectDiversifier::STATUS_TABLE = [] {
39 std::map<int, const std::shared_ptr<StatusProperties>> m(
40 Command::STATUS_TABLE);
44 std::make_shared<StatusProperties>(
45 "Incorrect Lc",
typeid(IllegalParameterException))});
48 std::make_shared<StatusProperties>(
49 "Preconditions not satisfied: the SAM is locked",
50 typeid(AccessForbiddenException))});
55CommandSelectDiversifier::CommandSelectDiversifier(
56 std::shared_ptr<DtoAdapters::CommandContextDto> context,
57 const std::vector<uint8_t>& diversifier)
58: Command(CommandRef::SELECT_DIVERSIFIER, 0, context)
60 auto _diversifier = diversifier;
63 if (diversifier.size() != 4 && diversifier.size() != 8) {
64 const int newLength = diversifier.size() < 4 ? 4 : 8;
65 std::vector<uint8_t> tmp(newLength);
70 newLength - diversifier.size(),
76 std::make_shared<ApduRequestAdapter>(ApduUtil::build(
77 context->getTargetSam()->getClassByte(),
78 getCommandRef().getInstructionByte(),
85CommandSelectDiversifier::finalizeRequest()
91CommandSelectDiversifier::isControlSamRequiredToFinalizeRequest()
const
97CommandSelectDiversifier::parseResponse(
98 std::shared_ptr<ApduResponseApi> apduResponse)
100 setResponseAndCheckStatus(apduResponse);
103const std::map<int, const std::shared_ptr<StatusProperties>>&
104CommandSelectDiversifier::getStatusTable()
const