14#include "keyple/card/calypso/crypto/legacysam/CommandDigestUpdateMultiple.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/IncorrectInputDataException.hpp"
24#include "keyple/core/util/ApduUtil.hpp"
25#include "keyple/core/util/cpp/exception/IllegalArgumentException.hpp"
33using keyple::core::util::ApduUtil;
34using keyple::core::util::cpp::exception::IllegalArgumentException;
36const std::map<int, const std::shared_ptr<StatusProperties>>
37 CommandDigestUpdateMultiple::STATUS_TABLE = [] {
38 std::map<int, const std::shared_ptr<StatusProperties>> m(
39 Command::STATUS_TABLE);
43 std::make_shared<StatusProperties>(
44 "Incorrect Lc",
typeid(IllegalParameterException))},
46 std::make_shared<StatusProperties>(
47 "Preconditions not satisfied",
48 typeid(AccessForbiddenException))},
50 std::make_shared<StatusProperties>(
51 "Incorrect value in the incoming data: incorrect structure",
52 typeid(IncorrectInputDataException))},
54 std::make_shared<StatusProperties>(
55 "Incorrect P1 or P2",
typeid(IllegalParameterException))}});
59CommandDigestUpdateMultiple::CommandDigestUpdateMultiple(
60 std::shared_ptr<CommandContextDto> context,
61 const std::vector<uint8_t>& digestData)
62: Command(CommandRef::DIGEST_UPDATE_MULTIPLE, 0, context)
64 const std::uint8_t cla = context->getTargetSam()->getClassByte();
65 const std::uint8_t p1 = 0x80;
66 const std::uint8_t p2 = 0x00;
68 if (digestData.size() > 255) {
69 throw IllegalArgumentException(
70 "Digest data is too long. Expected 0-255 bytes, got "
71 + std::to_string(digestData.size()));
75 std::make_shared<ApduRequestAdapter>(ApduUtil::build(
76 cla, getCommandRef().getInstructionByte(), p1, p2, digestData)));
80CommandDigestUpdateMultiple::finalizeRequest()
86CommandDigestUpdateMultiple::isControlSamRequiredToFinalizeRequest()
const
92CommandDigestUpdateMultiple::parseResponse(
93 const std::shared_ptr<ApduResponseApi> apduResponse)
95 setResponseAndCheckStatus(apduResponse);
98const std::map<int, const std::shared_ptr<StatusProperties>>&
99CommandDigestUpdateMultiple::getStatusTable()
const