Keyple Card Calypso C++ Library 2.2.5.6
Reference Terminal Reader API for C++
CmdSamDigestUpdateMultiple.cpp
Go to the documentation of this file.
1/**************************************************************************************************
2 * Copyright (c) 2023 Calypso Networks Association https://calypsonet.org/ *
3 * *
4 * See the NOTICE file(s) distributed with this work for additional information regarding *
5 * copyright ownership. *
6 * *
7 * This program and the accompanying materials are made available under the terms of the Eclipse *
8 * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 *
9 * *
10 * SPDX-License-Identifier: EPL-2.0 *
11 **************************************************************************************************/
12
14
15/* Keyple Card Calypso */
20#include "SamUtilAdapter.h"
21
22/* Keyple Core Util */
23#include "ApduUtil.h"
24#include "IllegalArgumentException.h"
25
26namespace keyple {
27namespace card {
28namespace calypso {
29
30using namespace keyple::core::util;
31using namespace keyple::core::util::cpp::exception;
32
33const CalypsoSamCommand CmdSamDigestUpdateMultiple::mCommand =
35
36const std::map<const int, const std::shared_ptr<StatusProperties>>
37 CmdSamDigestUpdateMultiple::STATUS_TABLE = initStatusTable();
38
40 const std::shared_ptr<CalypsoSamAdapter> calypsoSam,
41 const std::vector<uint8_t>& digestData)
42: AbstractSamCommand(mCommand, -1, calypsoSam)
43{
44 const uint8_t cla = SamUtilAdapter::getClassByte(calypsoSam->getProductType());
45 const uint8_t p1 = 0x80;
46 const uint8_t p2 = 0x00;
47
48 if (digestData.empty() || digestData.size() > 255) {
49
50 throw IllegalArgumentException("Digest data null or too long!");
51 }
52
54 std::make_shared<ApduRequestAdapter>(
55 ApduUtil::build(cla, mCommand.getInstructionByte(), p1, p2, digestData)));
56}
57
58const std::map<const int, const std::shared_ptr<StatusProperties>>
59 CmdSamDigestUpdateMultiple::initStatusTable()
60{
61 std::map<const int, const std::shared_ptr<StatusProperties>> m =
63
64 m.insert({0x6700,
65 std::make_shared<StatusProperties>("Incorrect Lc.",
67 m.insert({0x6985,
68 std::make_shared<StatusProperties>("Preconditions not satisfied.",
69 typeid(CalypsoSamAccessForbiddenException))});
70 m.insert({0x6A80,
71 std::make_shared<StatusProperties>("Incorrect value in the incoming data: incorrect" \
72 "structure.",
73 typeid(CalypsoSamIncorrectInputDataException))});
74 m.insert({0x6B00,
75 std::make_shared<StatusProperties>("Incorrect P1.",
76 typeid(CalypsoSamIllegalParameterException))});
77
78 return m;
79}
80
81const std::map<const int, const std::shared_ptr<StatusProperties>>&
83{
84 return STATUS_TABLE;
85}
86
87}
88}
89}
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 DIGEST_UPDATE_MULTIPLE
const std::map< const int, const std::shared_ptr< StatusProperties > > & getStatusTable() const override
CmdSamDigestUpdateMultiple(const std::shared_ptr< CalypsoSamAdapter > calypsoSam, const std::vector< uint8_t > &digestData)
static uint8_t getClassByte(const ProductType productType)