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) {
48 throw IllegalArgumentException(
"Bad current PIN value.");
51 if (!newPin.empty() && newPin.size() != 4) {
52 throw IllegalArgumentException(
"Bad new PIN value.");
59 std::vector<uint8_t> data;
64 data = std::vector<uint8_t>(6);
68 data = std::vector<uint8_t>(10);
69 System::arraycopy(newPin, 0, data, 6, 4);
73 data[0] = cipheringKif;
74 data[1] = cipheringKvc;
76 System::arraycopy(currentPin, 0, data, 2, 4);
79 std::make_shared<ApduRequestAdapter>(
88const std::map<const int, const std::shared_ptr<StatusProperties>>
89 CmdSamCardCipherPin::initStatusTable()
91 std::map<const int, const std::shared_ptr<StatusProperties>> m =
95 std::make_shared<StatusProperties>(
"Incorrect Lc.",
98 std::make_shared<StatusProperties>(
"An event counter cannot be incremented.",
99 typeid(CalypsoSamCounterOverflowException))});
101 std::make_shared<StatusProperties>(
"Preconditions not satisfied.",
102 typeid(CalypsoSamAccessForbiddenException))});
104 std::make_shared<StatusProperties>(
"Incorrect P1 or P2",
105 typeid(CalypsoSamIllegalParameterException))});
107 std::make_shared<StatusProperties>(
"Record not found: ciphering key not found",
108 typeid(CalypsoSamDataAccessException))});
113const 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 CalypsoSam::ProductType productType, 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)
CalypsoSam::ProductType ProductType