Keyple Card Calypso C++ Library 2.2.5.6
Reference Terminal Reader API for C++
CmdCardGetChallenge.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
13#include "CmdCardGetChallenge.h"
14
15#include <sstream>
16
17/* Keyple Core Util */
18#include "ApduUtil.h"
19#include "Arrays.h"
20#include "System.h"
21
22/* Keyple Card Calypso */
29
30namespace keyple {
31namespace card {
32namespace calypso {
33
34using namespace keyple::core::util;
35using namespace keyple::core::util::cpp;
36
37const CalypsoCardCommand CmdCardGetChallenge::mCommand = CalypsoCardCommand::GET_CHALLENGE;
38
39CmdCardGetChallenge::CmdCardGetChallenge(const std::shared_ptr<CalypsoCardAdapter> calypsoCard)
40: AbstractCardCommand(mCommand, 0x08, calypsoCard)
41{
42 const uint8_t p1 = 0x00;
43 const uint8_t p2 = 0x00;
44 const uint8_t le = 0x08;
45
46 // APDU Case 2
48 std::make_shared<ApduRequestAdapter>(
49 ApduUtil::build(calypsoCard->getCardClass().getValue(),
50 mCommand.getInstructionByte(),
51 p1,
52 p2,
53 le)));
54}
55
56void CmdCardGetChallenge::parseApduResponse(const std::shared_ptr<ApduResponseApi> apduResponse)
57{
59
60 getCalypsoCard()->setCardChallenge(getApduResponse()->getDataOut());
61}
62
63
65{
66 return false;
67}
68
69}
70}
71}
virtual const std::shared_ptr< ApduResponseApi > getApduResponse() const final
virtual void setApduRequest(const std::shared_ptr< ApduRequestAdapter > apduRequest) final
void parseApduResponse(const std::shared_ptr< ApduResponseApi > apduResponse) override
std::shared_ptr< CalypsoCardAdapter > getCalypsoCard() const
static const CalypsoCardCommand GET_CHALLENGE
CmdCardGetChallenge(const std::shared_ptr< CalypsoCardAdapter > calypsoCard)
void parseApduResponse(const std::shared_ptr< ApduResponseApi > apduResponse) override