24#include "IllegalArgumentException.h"
31using namespace keyple::core::util;
32using namespace keyple::core::util::cpp;
33using namespace keyple::core::util::cpp::exception;
37const std::map<const int, const std::shared_ptr<StatusProperties>>
38 CmdSamCardCipherPin::STATUS_TABLE = initStatusTable();
41 const uint8_t cipheringKif,
42 const uint8_t cipheringKvc,
43 const std::vector<uint8_t>& currentPin,
44 const std::vector<uint8_t>& newPin)
47 if (currentPin.size() != 4) {
49 throw IllegalArgumentException(
"Bad current PIN value.");
52 if (!newPin.empty() && newPin.size() != 4) {
54 throw IllegalArgumentException(
"Bad new PIN value.");
61 std::vector<uint8_t> data;
66 data = std::vector<uint8_t>(6);
70 data = std::vector<uint8_t>(10);
71 System::arraycopy(newPin, 0, data, 6, 4);
75 data[0] = cipheringKif;
76 data[1] = cipheringKvc;
78 System::arraycopy(currentPin, 0, data, 2, 4);
81 std::make_shared<ApduRequestAdapter>(
90const std::map<const int, const std::shared_ptr<StatusProperties>>
91 CmdSamCardCipherPin::initStatusTable()
93 std::map<const int, const std::shared_ptr<StatusProperties>> m =
97 std::make_shared<StatusProperties>(
"Incorrect Lc.",
100 std::make_shared<StatusProperties>(
"An event counter cannot be incremented.",
101 typeid(CalypsoSamCounterOverflowException))});
103 std::make_shared<StatusProperties>(
"Preconditions not satisfied.",
104 typeid(CalypsoSamAccessForbiddenException))});
106 std::make_shared<StatusProperties>(
"Incorrect P1 or P2",
107 typeid(CalypsoSamIllegalParameterException))});
109 std::make_shared<StatusProperties>(
"Record not found: ciphering key not found",
110 typeid(CalypsoSamDataAccessException))});
115const std::map<const int, const std::shared_ptr<StatusProperties>>&
virtual const std::shared_ptr< ApduResponseApi > getApduResponse() const final
virtual void setApduRequest(const std::shared_ptr< ApduRequestAdapter > apduRequest) final
static const std::map< const int, const std::shared_ptr< StatusProperties > > STATUS_TABLE
static const CalypsoSamCommand CARD_CIPHER_PIN
uint8_t getInstructionByte() const override
const std::vector< uint8_t > getCipheredData() const
const std::map< const int, const std::shared_ptr< StatusProperties > > & getStatusTable() const override
CmdSamCardCipherPin(const std::shared_ptr< CalypsoSamAdapter > calypsoSam, const uint8_t cipheringKif, const uint8_t cipheringKvc, const std::vector< uint8_t > ¤tPin, const std::vector< uint8_t > &newPin)
static uint8_t getClassByte(const ProductType productType)