Keyple Card Calypso C++ Library 2.2.5.6
Reference Terminal Reader API for C++
Classes | Public Member Functions | List of all members
keyple::card::calypso::CmdCardOpenSession Class Referencefinal

#include <CmdCardOpenSession.h>

Inheritance diagram for keyple::card::calypso::CmdCardOpenSession:
Inheritance graph
[legend]
Collaboration diagram for keyple::card::calypso::CmdCardOpenSession:
Collaboration graph
[legend]

Public Member Functions

 CmdCardOpenSession (const std::shared_ptr< CalypsoCardAdapter > calypsoCard, const uint8_t keyIndex, const std::vector< uint8_t > &samChallenge, const uint8_t sfi, const uint8_t recordNumber, const uint8_t recordSize, const bool isExtendedModeAllowed)
 
void createRev3 (const uint8_t keyIndex, const std::vector< uint8_t > &samChallenge, const uint8_t sfi, const uint8_t recordNumber)
 
void createRev24 (const uint8_t keyIndex, const std::vector< uint8_t > &samChallenge, const uint8_t sfi, const uint8_t recordNumber)
 
void createRev10 (const uint8_t keyIndex, const std::vector< uint8_t > &samChallenge, const uint8_t sfi, const uint8_t recordNumber)
 
void buildLegacyApduRequest (const uint8_t keyIndex, const std::vector< uint8_t > &samChallenge, const uint8_t sfi, const uint8_t recordNumber, const uint8_t p1)
 
bool isSessionBufferUsed () const override
 
uint8_t getSfi () const
 
uint8_t getRecordNumber () const
 
void parseApduResponse (const std::shared_ptr< ApduResponseApi > apduResponse) override
 
void parseRev3 (const std::vector< uint8_t > &apduResponseData)
 
void parseRev24 (const std::vector< uint8_t > &apduResponseData)
 
void parseRev10 (const std::vector< uint8_t > &apduResponseData)
 
const std::vector< uint8_t > & getCardChallenge () const
 
bool isManageSecureSessionAuthorized () const
 
const std::shared_ptr< uint8_t > getSelectedKif () const
 
const std::shared_ptr< uint8_t > getSelectedKvc () const
 
const std::map< const int, const std::shared_ptr< StatusProperties > > & getStatusTable () const override
 
- Public Member Functions inherited from keyple::card::calypso::AbstractCardCommand
 AbstractCardCommand (const CalypsoCardCommand &commandRef, const int expectedResponseLength, const std::shared_ptr< CalypsoCardAdapter > calypsoCard)
 
const CalypsoCardCommandgetCommandRef () const override
 
const CalypsoApduCommandException buildCommandException (const std::type_info &exceptionClass, const std::string &message) const final
 
const CalypsoApduCommandException buildUnexpectedResponseLengthException (const std::string &message) const final
 
std::shared_ptr< CalypsoCardAdaptergetCalypsoCard () const
 
void parseApduResponse (const std::shared_ptr< ApduResponseApi > apduResponse, const std::shared_ptr< CalypsoCardAdapter > calypsoCard)
 
- Public Member Functions inherited from keyple::card::calypso::AbstractApduCommand
 AbstractApduCommand (const CardCommand &commandRef, const int expectedResponseLength)
 
virtual void addSubName (const std::string &subName) final
 
virtual const std::string & getName () const final
 
virtual void setExpectedResponseLength (const int expectedResponseLength) final
 
virtual void setApduRequest (const std::shared_ptr< ApduRequestAdapter > apduRequest) final
 
virtual const std::shared_ptr< ApduRequestAdaptergetApduRequest () const final
 
virtual const std::shared_ptr< ApduResponseApi > getApduResponse () const final
 
virtual bool isSuccessful () const final
 
virtual const std::string getStatusInformation () const final
 

Additional Inherited Members

- Static Public Attributes inherited from keyple::card::calypso::AbstractApduCommand
static const std::map< const int, const std::shared_ptr< StatusProperties > > STATUS_TABLE
 

Detailed Description

(package-private)
Builds the Open Secure Session APDU command.

Since
2.0.1

Definition at line 47 of file CmdCardOpenSession.h.

Constructor & Destructor Documentation

◆ CmdCardOpenSession()

keyple::card::calypso::CmdCardOpenSession::CmdCardOpenSession ( const std::shared_ptr< CalypsoCardAdapter calypsoCard,
const uint8_t  keyIndex,
const std::vector< uint8_t > &  samChallenge,
const uint8_t  sfi,
const uint8_t  recordNumber,
const uint8_t  recordSize,
const bool  isExtendedModeAllowed 
)

(package-private)
Instantiates a new CmdCardOpenSession.

Parameters
calypsoCardThe Calypso card.
keyIndexThe key index.
samChallengeThe SAM challenge.
sfiThe optional SFI of the file to read.
recordNumberThe optional record number to read.
isExtendedModeAllowedTrue if the extended mode is allowed.
Exceptions
IllegalArgumentExceptionIf the key index is 0 and rev is 2.4
Since
2.0.1

Definition at line 106 of file CmdCardOpenSession.cpp.

Member Function Documentation

◆ buildLegacyApduRequest()

void keyple::card::calypso::CmdCardOpenSession::buildLegacyApduRequest ( const uint8_t  keyIndex,
const std::vector< uint8_t > &  samChallenge,
const uint8_t  sfi,
const uint8_t  recordNumber,
const uint8_t  p1 
)

(private)
Build legacy apdu request.

Parameters
keyIndexthe key index.
samChallengethe sam challenge returned by the SAM Get Challenge APDU command.
sfithe sfi to select.
recordNumberthe record number to read.
p1P1.
Exceptions
IllegalArgumentExceptionIf the request is inconsistent

Definition at line 219 of file CmdCardOpenSession.cpp.

◆ createRev10()

void keyple::card::calypso::CmdCardOpenSession::createRev10 ( const uint8_t  keyIndex,
const std::vector< uint8_t > &  samChallenge,
const uint8_t  sfi,
const uint8_t  recordNumber 
)

(private)
Create Rev 1.0

Parameters
keyIndexthe key index.
samChallengethe sam challenge returned by the SAM Get Challenge APDU command.
sfithe sfi to select.
recordNumberthe record number to read.
Exceptions
IllegalArgumentExceptionIf key index is 0 (rev 1.0)
IllegalArgumentExceptionIf the request is inconsistent

Definition at line 202 of file CmdCardOpenSession.cpp.

◆ createRev24()

void keyple::card::calypso::CmdCardOpenSession::createRev24 ( const uint8_t  keyIndex,
const std::vector< uint8_t > &  samChallenge,
const uint8_t  sfi,
const uint8_t  recordNumber 
)

(private)
Create Rev 2.4

Parameters
keyIndexthe key index.
samChallengethe sam challenge returned by the SAM Get Challenge APDU command.
sfithe sfi to select.
recordNumberthe record number to read.
Exceptions
IllegalArgumentExceptionIf key index is 0 (rev 2.4)
IllegalArgumentExceptionIf the request is inconsistent

Definition at line 185 of file CmdCardOpenSession.cpp.

◆ createRev3()

void keyple::card::calypso::CmdCardOpenSession::createRev3 ( const uint8_t  keyIndex,
const std::vector< uint8_t > &  samChallenge,
const uint8_t  sfi,
const uint8_t  recordNumber 
)

(private)
Create Rev 3

Parameters
keyIndexthe key index.
samChallengethe sam challenge returned by the SAM Get Challenge APDU command.
sfithe sfi to select.
recordNumberthe record number to read.
Exceptions
IllegalArgumentExceptionIf the request is inconsistent

Definition at line 140 of file CmdCardOpenSession.cpp.

◆ getCardChallenge()

const std::vector< uint8_t > & keyple::card::calypso::CmdCardOpenSession::getCardChallenge ( ) const

(package-private)

Returns
A non empty value.
Since
2.0.1

Definition at line 429 of file CmdCardOpenSession.cpp.

◆ getRecordNumber()

uint8_t keyple::card::calypso::CmdCardOpenSession::getRecordNumber ( ) const

(package-private)

Returns
the record number to read
Since
2.0.1

Definition at line 258 of file CmdCardOpenSession.cpp.

◆ getSelectedKif()

const std::shared_ptr< uint8_t > keyple::card::calypso::CmdCardOpenSession::getSelectedKif ( ) const

(package-private)

Returns
The current KIF.
Since
2.0.1

Definition at line 439 of file CmdCardOpenSession.cpp.

◆ getSelectedKvc()

const std::shared_ptr< uint8_t > keyple::card::calypso::CmdCardOpenSession::getSelectedKvc ( ) const

(package-private)

Returns
The current KVC.
Since
2.0.1

Definition at line 444 of file CmdCardOpenSession.cpp.

◆ getSfi()

uint8_t keyple::card::calypso::CmdCardOpenSession::getSfi ( ) const

(package-private)

Returns
the SFI of the file read while opening the secure session
Since
2.0.1

Definition at line 253 of file CmdCardOpenSession.cpp.

◆ getStatusTable()

const std::map< const int, const std::shared_ptr< StatusProperties > > & keyple::card::calypso::CmdCardOpenSession::getStatusTable ( ) const
overridevirtual

(package-private)
Returns the internal status table

Returns
A not null reference
Since
2.0.1

Since
2.0.1

Reimplemented from keyple::card::calypso::AbstractApduCommand.

Definition at line 499 of file CmdCardOpenSession.cpp.

◆ isManageSecureSessionAuthorized()

bool keyple::card::calypso::CmdCardOpenSession::isManageSecureSessionAuthorized ( ) const

(package-private)

Returns
True if the managed secure session is authorized.
Since
2.0.1

Definition at line 434 of file CmdCardOpenSession.cpp.

◆ isSessionBufferUsed()

bool keyple::card::calypso::CmdCardOpenSession::isSessionBufferUsed ( ) const
overridevirtual

(package-private)
Indicates if the session buffer is used when executing this command.Allows the management of the overflow of this buffer.

Returns
True if this command uses the session buffer
Since
2.0.1

Returns
False
Since
2.0.1

Implements keyple::card::calypso::AbstractCardCommand.

Definition at line 248 of file CmdCardOpenSession.cpp.

◆ parseApduResponse()

void keyple::card::calypso::CmdCardOpenSession::parseApduResponse ( const std::shared_ptr< ApduResponseApi >  apduResponse)
overridevirtual

(package-private)
Parses the response ApduResponseApi and check the status word.

Parameters
apduResponseThe APDU response.
Exceptions
CalypsoApduCommandExceptionif status is not successful or if the length of the response is not equal to the LE field in the request.
Since
2.0.1
Since
2.0.1

Since
2.0.1

Reimplemented from keyple::card::calypso::AbstractCardCommand.

Definition at line 263 of file CmdCardOpenSession.cpp.

◆ parseRev10()

void keyple::card::calypso::CmdCardOpenSession::parseRev10 ( const std::vector< uint8_t > &  apduResponseData)

(private)
Parse Rev 1.0

In rev 1.0 mode, the response to the Open Secure Session command is as follows:

CC CC CC CC [RR RR] [NN..NN]

Where:

  • CC CC CC CC = card challenge
  • RR RR = ratification bytes (may be absent)
  • NN..NN = record data (29 bytes)

Legal length values are:

  • 4: ratified, 4-byte challenge, no data
  • 33: ratified, 4-byte challenge, 29 bytes of data
  • 6: not ratified (2 ratification bytes), 4-byte challenge, no data
  • 35 not ratified (2 ratification bytes), 4-byte challenge, 29 bytes of data
Parameters
apduResponseDataThe response data.

Definition at line 383 of file CmdCardOpenSession.cpp.

◆ parseRev24()

void keyple::card::calypso::CmdCardOpenSession::parseRev24 ( const std::vector< uint8_t > &  apduResponseData)

(private)
Parse Rev 2.4

In rev 2.4 mode, the response to the Open Secure Session command is as follows:

KK CC CC CC CC [RR RR] [NN..NN]

Where:

  • KK = KVC byte CC
  • CC CC CC CC = card challenge
  • RR RR = ratification bytes (may be absent)
  • NN..NN = record data (29 bytes)

Legal length values are:

  • 5: ratified, 1-byte KCV, 4-byte challenge, no data
  • 34: ratified, 1-byte KCV, 4-byte challenge, 29 bytes of data
  • 7: not ratified (2 ratification bytes), 1-byte KCV, 4-byte challenge, no data
  • 35 not ratified (2 ratification bytes), 1-byte KCV, 4-byte challenge, 29 bytes of data
Parameters
apduResponseDataThe response data.

Definition at line 336 of file CmdCardOpenSession.cpp.

◆ parseRev3()

void keyple::card::calypso::CmdCardOpenSession::parseRev3 ( const std::vector< uint8_t > &  apduResponseData)

(private)
Parse Rev 3

Parameters
apduResponseDataThe response data.

Definition at line 296 of file CmdCardOpenSession.cpp.


The documentation for this class was generated from the following files: