Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Commit

Permalink
Merge pull request #30 from eclipse/develop
Browse files Browse the repository at this point in the history
feat: merge develop (0.8.2) into master
  • Loading branch information
jeanpierrefortune committed Dec 28, 2020
2 parents e52fa1a + a306ddd commit 4f77563
Show file tree
Hide file tree
Showing 253 changed files with 6,329 additions and 3,859 deletions.
23 changes: 23 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!groovy
@Library('keyple-ops') _
def keypleVersion
pipeline {
agent {
kubernetes {
label 'keyple-cpp'
yaml cppBuilder('7')
}
}
stages {
stage('Keyple Cpp: Build') {
steps{
container('java-builder') {
dir('build') {
sh 'cmake -DCMAKE_TOOLCHAIN_FILE=../toolchain/gcc-linux.cmake ..'
sh 'make'
}
}
}
}
}
}
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,12 @@ Here are the prerequisites to build the keyple components (dynamic libraries)
- libpcsclite1 package installed (Linux) to build the PC/SC plugin

#### Windows, Linux or Macos
On Linux and macOS, the following command will build all the artifacts at once
On Linux and macOS, the following commands will build all the artifacts at once
```
mkdir build; cd build; cmake .. && make
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=../toolchain/<toolchain>.cmake ..
make
```

If using Windows or IDEs, CMake support must be installed. Compilation should automatically be handled.
Expand Down
24 changes: 13 additions & 11 deletions component/keyple-calypso/src/main/KeyReference.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
/********************************************************************************
* Copyright (c) 2018 Calypso Networks Association https://www.calypsonet-asso.org/
*
* See the NOTICE file(s) distributed with this work for additional information regarding copyright
* ownership.
*
* This program and the accompanying materials are made available under the terms of the Eclipse
* Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
/******************************************************************************
* Copyright (c) 2018 Calypso Networks Association *
* https://www.calypsonet-asso.org/ *
* *
* See the NOTICE file(s) distributed with this work for additional *
* information regarding copyright ownership. *
* *
* This program and the accompanying materials are made available under the *
* terms of the Eclipse Public License 2.0 which is available at *
* http://www.eclipse.org/legal/epl-2.0 *
* *
* SPDX-License-Identifier: EPL-2.0 *
******************************************************************************/

#include "KeyReference.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ namespace command {
namespace po {

using namespace keyple::core::command;
using namespace keyple::calypso::command::po;

class KEYPLECALYPSO_API CalypsoPoCommands final : public CommandsTable {
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class KEYPLECALYPSO_API PoBuilderParser
*/
virtual std::shared_ptr<AbstractPoResponseParser> getResponseParser()
{
return poResponseParser;
return mPoResponseParser;
}

/**
Expand All @@ -75,7 +75,7 @@ class KEYPLECALYPSO_API PoBuilderParser
virtual void setResponseParser(
std::shared_ptr<AbstractPoResponseParser> poResponseParser)
{
this->poResponseParser = poResponseParser;
mPoResponseParser = poResponseParser;
}

private:
Expand All @@ -87,7 +87,7 @@ class KEYPLECALYPSO_API PoBuilderParser
/**
*
*/
std::shared_ptr<AbstractPoResponseParser> poResponseParser;
std::shared_ptr<AbstractPoResponseParser> mPoResponseParser;
};

}
Expand Down
25 changes: 13 additions & 12 deletions component/keyple-calypso/src/main/command/po/PoSendableInSession.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
/********************************************************************************
* Copyright (c) 2018 Calypso Networks Association https://www.calypsonet-asso.org/
*
* See the NOTICE file(s) distributed with this work for additional information regarding copyright
* ownership.
*
* This program and the accompanying materials are made available under the terms of the Eclipse
* Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
/******************************************************************************
* Copyright (c) 2018 Calypso Networks Association *
* https://www.calypsonet-asso.org/ *
* *
* See the NOTICE file(s) distributed with this work for additional *
* information regarding copyright ownership. *
* *
* This program and the accompanying materials are made available under the *
* terms of the Eclipse Public License 2.0 which is available at *
* http://www.eclipse.org/legal/epl-2.0 *
* *
* SPDX-License-Identifier: EPL-2.0 *
******************************************************************************/

#pragma once

Expand All @@ -24,7 +26,6 @@ namespace command {
namespace po {

using namespace keyple::calypso::command;
using namespace keyple::calypso::command::po;

class PoSendableInSession
: public SendableInSession<AbstractPoCommandBuilder<AbstractPoResponseParser>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ using namespace keyple::calypso::command::po;
using namespace keyple::calypso::command::po::parser;
using namespace keyple::core::seproxy::message;

ReadRecordsCmdBuild::ReadRecordsCmdBuild(PoClass poClass, char sfi,
ReadRecordsCmdBuild::ReadRecordsCmdBuild(PoClass poClass, uint8_t sfi,
ReadDataStructure readDataStructure,
char firstRecordNumber,
uint8_t firstRecordNumber,
bool readJustOneRecord,
char expectedLength,
uint8_t expectedLength,
const std::string& extraInfo)
: AbstractPoCommandBuilder<ReadRecordsRespPars>(CalypsoPoCommands::READ_RECORDS,
nullptr),
Expand All @@ -55,9 +55,9 @@ ReadRecordsCmdBuild::ReadRecordsCmdBuild(PoClass poClass, char sfi,
}
}

ReadRecordsCmdBuild::ReadRecordsCmdBuild(PoClass poClass, char sfi,
ReadRecordsCmdBuild::ReadRecordsCmdBuild(PoClass poClass, uint8_t sfi,
ReadDataStructure readDataStructure,
char firstRecordNumber,
uint8_t firstRecordNumber,
bool readJustOneRecord,
const std::string& extraInfo)
: ReadRecordsCmdBuild(poClass, sfi, readDataStructure, firstRecordNumber,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,36 +67,38 @@ class KEYPLECALYPSO_API ReadRecordsCmdBuild final
* @param poClass indicates which CLA byte should be used for the Apdu
* @param sfi the sfi top select
* @param readDataStructure file structure type (used to create the parser)
* @param firstRecordNumber the record number to read (or first record to read in case of
* several records)
* @param firstRecordNumber the record number to read (or first record to
* read in case of several records)
* @param readJustOneRecord the read just one record
* @param expectedLength the expected length of the record(s)
* @param extraInfo extra information included in the logs (can be null or empty)
* @param extraInfo extra information included in the logs (can be null or
empty)
* @throws IllegalArgumentException - if record number &lt; 1
* @throws IllegalArgumentException - if the request is inconsistent
*/
ReadRecordsCmdBuild(PoClass poClass, char sfi,
ReadRecordsCmdBuild(PoClass poClass, uint8_t sfi,
ReadDataStructure readDataStructure,
char firstRecordNumber, bool readJustOneRecord,
char expectedLength, const std::string& extraInfo);
uint8_t firstRecordNumber, bool readJustOneRecord,
uint8_t expectedLength, const std::string& extraInfo);

/**
* Instantiates a new read records cmd build without specifying the expected length. This
* constructor is allowed only in contactless mode.
* Instantiates a new read records cmd build without specifying the expected
* length. This constructor is allowed only in contactless mode.
*
* @param poClass indicates which CLA byte should be used for the Apdu
* @param readDataStructure file structure type
* @param sfi the sfi top select
* @param firstRecordNumber the record number to read (or first record to read in case of
* several records)
* @param firstRecordNumber the record number to read (or first record to
* read in case of several records)
* @param readJustOneRecord the read just one record
* @param extraInfo extra information included in the logs (can be null or empty)
* @param extraInfo extra information included in the logs (can be null or
* empty)
* @throws IllegalArgumentException - if record number &lt; 1
* @throws IllegalArgumentException - if the request is inconsistent
*/
ReadRecordsCmdBuild(PoClass poClass, char sfi,
ReadRecordsCmdBuild(PoClass poClass, uint8_t sfi,
ReadDataStructure readDataStructure,
char firstRecordNumber, bool readJustOneRecord,
uint8_t firstRecordNumber, bool readJustOneRecord,
const std::string& extraInfo);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ using namespace keyple::calypso::command::po;
using namespace keyple::calypso::command;
using namespace keyple::calypso::command::po::parser;
using namespace keyple::core::seproxy::message;
using namespace keyple::calypso::command::po::builder;

SelectFileCmdBuild::SelectFileCmdBuild(PoClass poClass,
SelectControl selectControl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ namespace builder {
namespace security {

using namespace keyple::calypso::command::po;
using namespace keyple::calypso::command::po::builder::security;
using namespace keyple::calypso::command::po::parser::security;
using namespace keyple::core::command;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ namespace po {
namespace builder {
namespace security {

using namespace keyple::calypso::command::po::builder::security;
using namespace keyple::calypso::command::po::parser::security;
using namespace keyple::core::seproxy::message;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,24 @@ std::vector<int> const
311743, 370727, 440871, 524288, 623487, 741455, 881743, 1048576};

const std::shared_ptr<Tag> GetDataFciRespPars::TAG_FCI_TEMPLATE =
std::make_shared<Tag>(0x0F, Tag::APPLICATION, Tag::TagType::CONSTRUCTED);
std::make_shared<Tag>(0x0F, Tag::TagClass::APPLICATION,
Tag::TagType::CONSTRUCTED);
const std::shared_ptr<Tag> GetDataFciRespPars::TAG_DF_NAME =
std::make_shared<Tag>(0x04, Tag::CONTEXT, Tag::TagType::PRIMITIVE);
std::make_shared<Tag>(0x04, Tag::TagClass::CONTEXT,
Tag::TagType::PRIMITIVE);
const std::shared_ptr<Tag> GetDataFciRespPars::TAG_FCI_PROPRIETARY_TEMPLATE =
std::make_shared<Tag>(0x05, Tag::CONTEXT, Tag::TagType::CONSTRUCTED);
std::make_shared<Tag>(0x05, Tag::TagClass::CONTEXT,
Tag::TagType::CONSTRUCTED);
const std::shared_ptr<Tag>
GetDataFciRespPars::TAG_FCI_ISSUER_DISCRETIONARY_DATA =
std::make_shared<Tag>(0x0C, Tag::CONTEXT, Tag::TagType::CONSTRUCTED);
std::make_shared<Tag>(0x0C, Tag::TagClass::CONTEXT,
Tag::TagType::CONSTRUCTED);
const std::shared_ptr<Tag> GetDataFciRespPars::TAG_APPLICATION_SERIAL_NUMBER =
std::make_shared<Tag>(0x07, Tag::PRIVATE, Tag::TagType::PRIMITIVE);
std::make_shared<Tag>(0x07, Tag::TagClass::PRIVATE,
Tag::TagType::PRIMITIVE);
const std::shared_ptr<Tag> GetDataFciRespPars::TAG_DISCRETIONARY_DATA =
std::make_shared<Tag>(0x13, Tag::APPLICATION, Tag::TagType::PRIMITIVE);
std::make_shared<Tag>(0x13, Tag::TagClass::APPLICATION,
Tag::TagType::PRIMITIVE);

GetDataFciRespPars::GetDataFciRespPars(
std::shared_ptr<ApduResponse> selectApplicationResponse)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,16 @@ ReadRecordsRespPars::getRecords()
std::shared_ptr<std::map<int, std::vector<uint8_t>>> records =
std::make_shared<std::map<int, std::vector<uint8_t>>>();

if (!response->isSuccessful()) {
if (!mResponse->isSuccessful()) {
/* return an empty map */
// TODO should we raise an exception?
return records;
}
if (readDataStructure == ReadDataStructure::SINGLE_RECORD_DATA) {
records->emplace(static_cast<int>(recordNumber),
response->getDataOut());
mResponse->getDataOut());
} else if (readDataStructure == ReadDataStructure::MULTIPLE_RECORD_DATA) {
std::vector<uint8_t> apdu = response->getDataOut();
std::vector<uint8_t> apdu = mResponse->getDataOut();
int apduLen = apdu.size();
int index = 0;
while (apduLen > 0) {
Expand All @@ -134,15 +134,15 @@ std::shared_ptr<std::map<int, int>> ReadRecordsRespPars::getCounters()
std::shared_ptr<std::map<int, int>> counters =
std::make_shared<std::map<int, int>>();

if (!response->isSuccessful()) {
if (!mResponse->isSuccessful()) {
/* return an empty map */
// TODO should we raise an exception?
return counters;
}

if (readDataStructure == ReadDataStructure::SINGLE_COUNTER ||
readDataStructure == ReadDataStructure::MULTIPLE_COUNTER) {
std::vector<uint8_t> apdu = response->getDataOut();
std::vector<uint8_t> apdu = mResponse->getDataOut();
int numberOfCounters = apdu.size() / 3;
int index = 0;
int key = 1; // the first counter is indexed 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ SelectFileRespPars::StaticConstructor SelectFileRespPars::staticConstructor;

void SelectFileRespPars::parseResponse()
{
std::vector<uint8_t> inFileParameters = response->getDataOut();
std::vector<uint8_t> inFileParameters = mResponse->getDataOut();
int iter = 0;

if (!response->isSuccessful()) {
if (!mResponse->isSuccessful()) {
// the command was not successful, we stop here
return;
}
Expand Down Expand Up @@ -242,7 +242,7 @@ std::vector<uint8_t> SelectFileRespPars::getKifInfo()

std::vector<uint8_t> SelectFileRespPars::getSelectionData()
{
return response->getDataOut();
return mResponse->getDataOut();
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ AbstractOpenSessionRespPars::SecureSession::SecureSession(
challengeRandomNumber(challengeRandomNumber),
previousSessionRatified(previousSessionRatified),
manageSecureSessionAuthorized(manageSecureSessionAuthorized),
kif(static_cast<char>(0xFF)), kvc(kvc), originalData(originalData),
kif(0xff), kvc(kvc), originalData(originalData),
secureSessionData(secureSessionData)
{
}
Expand All @@ -203,7 +203,7 @@ AbstractOpenSessionRespPars::SecureSession::SecureSession(
challengeRandomNumber(challengeRandomNumber),
previousSessionRatified(previousSessionRatified),
manageSecureSessionAuthorized(manageSecureSessionAuthorized),
kif(static_cast<char>(0xFF)), kvc(kvc), secureSessionData(secureSessionData)
kif(0xff), kvc(kvc), secureSessionData(secureSessionData)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ namespace security {
using namespace keyple::common;
using namespace keyple::calypso::command::po;
using namespace keyple::core::seproxy::message;
using namespace keyple::calypso::command::po::parser::security;

OpenSession24RespPars::OpenSession24RespPars(
std::shared_ptr<ApduResponse> response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ OpenSession31RespPars::OpenSession31RespPars(
: AbstractOpenSessionRespPars(response, PoRevision::REV3_1)
{
std::vector<uint8_t> data = response->getDataOut();
this->secureSession = toSecureSession(data);
secureSession = toSecureSession(data);
}

std::shared_ptr<AbstractOpenSessionRespPars::SecureSession>
OpenSession31RespPars::toSecureSession(
const std::vector<uint8_t>& apduResponseData)
{
std::shared_ptr<SecureSession> secureSession;
bool previousSessionRatified = (apduResponseData[4] == 0x00);
bool manageSecureSessionAuthorized = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ namespace security {

using namespace keyple::calypso::command::po;
using namespace keyple::core::seproxy::message;
using namespace keyple::calypso::command::po::parser::security;

OpenSession32RespPars::OpenSession32RespPars(
std::shared_ptr<ApduResponse> response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ namespace command {
namespace sam {

using namespace keyple::calypso::command;
using namespace keyple::calypso::command::sam;

class SamBuilderParser
: public std::enable_shared_from_this<SamBuilderParser>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ namespace command {
namespace sam {

using namespace keyple::calypso::command;
using namespace keyple::calypso::command::sam;

class SamSendableInSession
: public SendableInSession<AbstractSamCommandBuilder> {
Expand Down
Loading

0 comments on commit 4f77563

Please sign in to comment.