15#include "keyple/card/calypso/crypto/legacysam/CommandSvCheck.hpp"
21#include "keyple/card/calypso/crypto/legacysam/AccessForbiddenException.hpp"
22#include "keyple/card/calypso/crypto/legacysam/IllegalParameterException.hpp"
23#include "keyple/card/calypso/crypto/legacysam/LegacySamConstants.hpp"
24#include "keyple/card/calypso/crypto/legacysam/SecurityDataException.hpp"
25#include "keyple/core/util/ApduUtil.hpp"
26#include "keyple/core/util/ByteArrayUtil.hpp"
27#include "keyple/core/util/cpp/Arrays.hpp"
28#include "keyple/core/util/cpp/System.hpp"
29#include "keyple/core/util/cpp/exception/IllegalArgumentException.hpp"
30#include "keypop/calypso/crypto/legacysam/transaction/InvalidSignatureException.hpp"
38using keyple::core::util::ApduUtil;
39using keyple::core::util::ByteArrayUtil;
40using keyple::core::util::cpp::Arrays;
41using keyple::core::util::cpp::System;
42using keyple::core::util::cpp::exception::IllegalArgumentException;
43using keypop::calypso::crypto::legacysam::transaction::
44 InvalidSignatureException;
46const std::map<int, const std::shared_ptr<StatusProperties>>
47 CommandSvCheck::STATUS_TABLE = [] {
48 std::map<int, const std::shared_ptr<StatusProperties>> m(
49 Command::STATUS_TABLE);
53 std::make_shared<StatusProperties>(
54 "Incorrect Lc",
typeid(IllegalParameterException))},
56 std::make_shared<StatusProperties>(
57 "Preconditions not satisfied",
58 typeid(AccessForbiddenException))},
60 std::make_shared<StatusProperties>(
61 "Incorrect signature",
typeid(SecurityDataException))}});
65CommandSvCheck::CommandSvCheck(std::shared_ptr<CommandContextDto> context)
66: Command(CommandRef::SV_CHECK, 0, context)
68 const std::uint8_t cla = context->getTargetSam()->getClassByte();
69 const std::uint8_t p1 = 0x00;
70 const std::uint8_t p2 = 0x00;
73 const std::vector<std::uint8_t> noInput = {0};
75 std::make_shared<ApduRequestAdapter>(ApduUtil::build(
77 getCommandRef().getInstructionByte(),
83CommandSvCheck::CommandSvCheck(
84 std::shared_ptr<CommandContextDto> context,
85 const std::vector<std::uint8_t>& svCardSignature)
86: Command(CommandRef::SV_CHECK, 0, context)
88 if (svCardSignature.size() != 3 && svCardSignature.size() != 6) {
89 throw IllegalArgumentException(
90 "Invalid SV card signature. Expected 3 or 6 bytes, got "
91 + std::to_string(svCardSignature.size()));
94 const std::uint8_t cla = context->getTargetSam()->getClassByte();
95 const std::uint8_t p1 = 0x00;
96 const std::uint8_t p2 = 0x00;
100 std::make_shared<ApduRequestAdapter>(ApduUtil::build(
102 getCommandRef().getInstructionByte(),
109CommandSvCheck::finalizeRequest()
115CommandSvCheck::isControlSamRequiredToFinalizeRequest()
const
121CommandSvCheck::parseResponse(std::shared_ptr<ApduResponseApi> apduResponse)
123 setResponseAndCheckStatus(apduResponse);
126const std::map<int, const std::shared_ptr<StatusProperties>>&
127CommandSvCheck::getStatusTable()
const