14#include "keyple/card/calypso/crypto/legacysam/CommandGiveRandom.hpp"
20#include "keyple/card/calypso/crypto/legacysam/IllegalParameterException.hpp"
21#include "keyple/core/util/ApduUtil.hpp"
22#include "keyple/core/util/cpp/exception/IllegalArgumentException.hpp"
30using keyple::core::util::ApduUtil;
31using keyple::core::util::cpp::exception::IllegalArgumentException;
33const std::map<int, const std::shared_ptr<StatusProperties>>
34 CommandGiveRandom::STATUS_TABLE = [] {
35 std::map<int, const std::shared_ptr<StatusProperties>> m(
36 Command::STATUS_TABLE);
40 std::make_shared<StatusProperties>(
41 "Incorrect Lc",
typeid(IllegalParameterException))}});
46CommandGiveRandom::CommandGiveRandom(
47 std::shared_ptr<DtoAdapters::CommandContextDto> context,
48 const std::vector<uint8_t>& random)
50: Command(CommandRef::GIVE_RANDOM, 0, context)
52 const uint8_t cla = context->getTargetSam()->getClassByte();
53 const uint8_t p1 = 0x00;
54 const uint8_t p2 = 0x00;
56 if (random.size() != 8) {
57 throw IllegalArgumentException(
58 "Random value is an incorrect length. Expected 8 bytes, got "
59 + std::to_string(random.size()));
62 std::make_shared<ApduRequestAdapter>(ApduUtil::build(
63 cla, getCommandRef().getInstructionByte(), p1, p2, random)));
67CommandGiveRandom::finalizeRequest()
73CommandGiveRandom::isControlSamRequiredToFinalizeRequest()
const
79CommandGiveRandom::parseResponse(std::shared_ptr<ApduResponseApi> apduResponse)
81 setResponseAndCheckStatus(apduResponse);
84const std::map<int, const std::shared_ptr<StatusProperties>>&
85CommandGiveRandom::getStatusTable()
const