Keyple Card Calypso C++ Library 2.2.2
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::vector<uint8_t>& digestData)
41: AbstractSamCommand(mCommand, 0)
42{
43 const uint8_t cla = SamUtilAdapter::getClassByte(productType);
44 const uint8_t p1 = 0x80;
45 const uint8_t p2 = 0x00;
46
47 if (digestData.empty() || digestData.size() > 255) {
48 throw IllegalArgumentException("Digest data null or too long!");
49 }
50
52 std::make_shared<ApduRequestAdapter>(
53 ApduUtil::build(cla, mCommand.getInstructionByte(), p1, p2, digestData)));
54}
55
56const std::map<const int, const std::shared_ptr<StatusProperties>>
57 CmdSamDigestUpdateMultiple::initStatusTable()
58{
59 std::map<const int, const std::shared_ptr<StatusProperties>> m =
61
62 m.insert({0x6700,
63 std::make_shared<StatusProperties>("Incorrect Lc.",
65 m.insert({0x6985,
66 std::make_shared<StatusProperties>("Preconditions not satisfied.",
67 typeid(CalypsoSamAccessForbiddenException))});
68 m.insert({0x6A80,
69 std::make_shared<StatusProperties>("Incorrect value in the incoming data: incorrect" \
70 "structure.",
71 typeid(CalypsoSamIncorrectInputDataException))});
72 m.insert({0x6B00,
73 std::make_shared<StatusProperties>("Incorrect P1.",
74 typeid(CalypsoSamIllegalParameterException))});
75
76 return m;
77}
78
79const std::map<const int, const std::shared_ptr<StatusProperties>>&
81{
82 return STATUS_TABLE;
83}
84
85}
86}
87}
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
CmdSamDigestUpdateMultiple(const CalypsoSam::ProductType productType, const std::vector< uint8_t > &digestData)
const std::map< const int, const std::shared_ptr< StatusProperties > > & getStatusTable() const override
static uint8_t getClassByte(const ProductType productType)
CalypsoSam::ProductType ProductType