LibLogicalAccess  2.5.0
An Open Source RFID Library
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
logicalaccess::MifareSTidSTRCommands Class Reference

The Mifare commands class for STidSTR reader. More...

#include <mifarestidstrcommands.hpp>

Inheritance diagram for logicalaccess::MifareSTidSTRCommands:
logicalaccess::MifareCommands logicalaccess::Commands logicalaccess::ICommands

Public Member Functions

 MifareSTidSTRCommands ()
 Constructor.
 
 MifareSTidSTRCommands (std::string ct)
 
virtual ~MifareSTidSTRCommands ()
 Destructor.
 
std::shared_ptr< STidSTRReaderCardAdaptergetSTidSTRReaderCardAdapter () const
 Get the STidSTR reader/card adapter.
 
ByteVector scanMifare () const
 Scan the RFID field for Mifare tag.
 
void releaseRFIDField () const
 Release the RFID field.
 
void loadKey (std::shared_ptr< Location > location, MifareKeyType keytype, std::shared_ptr< MifareKey > key) override
 Load a key on a given location.
 
bool loadKey (unsigned char keyno, MifareKeyType keytype, std::shared_ptr< MifareKey > key, bool vol=true) override
 Load a key to the reader.
 
void authenticate (unsigned char blockno, unsigned char keyno, MifareKeyType keytype) override
 Authenticate a block, given a key number.
 
void authenticate (unsigned char blockno, std::shared_ptr< KeyStorage > key_storage, MifareKeyType keytype) override
 Authenticate a block, given a key number.
 
ByteVector readBinary (unsigned char blockno, size_t len) override
 Read bytes from the card.
 
void updateBinary (unsigned char blockno, const ByteVector &buf) override
 Write bytes to the card.
 
void increment (unsigned char blockno, uint32_t value) override
 Increment a block value.
 
void decrement (unsigned char blockno, uint32_t value) override
 Decrement a block value.
 
- Public Member Functions inherited from logicalaccess::MifareCommands
 MifareCommands ()
 
 MifareCommands (std::string ct)
 
virtual ByteVector readSector (int sector, int start_block, std::shared_ptr< MifareKey > keyA, std::shared_ptr< MifareKey > keyB, const MifareAccessInfo::SectorAccessBits &sab, bool readtrailer=false) final
 
virtual void writeSector (int sector, int start_block, const ByteVector &buf, std::shared_ptr< MifareKey > keyA, std::shared_ptr< MifareKey > keyB, const MifareAccessInfo::SectorAccessBits &sab, unsigned char userbyte=0x00, MifareAccessInfo::SectorAccessBits *newsab=nullptr, std::shared_ptr< MifareKey > newkeyA=std::shared_ptr< MifareKey >(), std::shared_ptr< MifareKey > newkeyB=std::shared_ptr< MifareKey >()) final
 
virtual ByteVector readSectors (int start_sector, int stop_sector, int start_block, std::shared_ptr< MifareKey > keyA, std::shared_ptr< MifareKey > keyB, const MifareAccessInfo::SectorAccessBits &sab) final
 
virtual void writeSectors (int start_sector, int stop_sector, int start_block, const ByteVector &buf, std::shared_ptr< MifareKey > keyA, std::shared_ptr< MifareKey > keyB, const MifareAccessInfo::SectorAccessBits &sab, unsigned char userbyte=0x00, MifareAccessInfo::SectorAccessBits *newsab=nullptr, std::shared_ptr< MifareKey > newkeyA=std::shared_ptr< MifareKey >(), std::shared_ptr< MifareKey > newkeyB=std::shared_ptr< MifareKey >()) final
 
unsigned int getSectorFromMAD (long aid, std::shared_ptr< MifareKey > madKeyA)
 Get the sector referenced by the AID from the MAD.
 
void setSectorToMAD (long aid, unsigned int sector, std::shared_ptr< MifareKey > madKeyA, std::shared_ptr< MifareKey > madKeyB)
 Set the sector referenced by the AID to the MAD.
 
void authenticate (std::shared_ptr< Location > location, std::shared_ptr< AccessInfo > ai, bool write=false)
 Authenticate on a given location.
 
void changeKeys (MifareKeyType keytype, std::shared_ptr< MifareKey > key, std::shared_ptr< MifareKey > newkeyA, std::shared_ptr< MifareKey > newkeyB, unsigned int sector, MifareAccessInfo::SectorAccessBits *newsab, unsigned char userbyte=0x00)
 
void changeKeys (std::shared_ptr< MifareKey > newkeyA, std::shared_ptr< MifareKey > newkeyB, unsigned int sector, MifareAccessInfo::SectorAccessBits *newsab, unsigned char userbyte=0x00)
 
void authenticate (MifareKeyType keyType, std::shared_ptr< MifareKey > key, int sector, int block, bool write)
 Authenticate for a targeted block.
 
virtual ByteVector readBinary (unsigned char blockno, size_t len)=0
 Read bytes from the card.
 
virtual void updateBinary (unsigned char blockno, const ByteVector &buf)=0
 Write bytes to the card.
 
virtual bool loadKey (unsigned char keyno, MifareKeyType keytype, std::shared_ptr< MifareKey > key, bool vol=false)=0
 Load a key to the reader.
 
virtual void loadKey (std::shared_ptr< Location > location, MifareKeyType keytype, std::shared_ptr< MifareKey > key)=0
 Load a key on a given location.
 
virtual void authenticate (unsigned char blockno, unsigned char keyno, MifareKeyType keytype)=0
 Authenticate a block, given a key number.
 
virtual void authenticate (unsigned char blockno, std::shared_ptr< KeyStorage > key_storage, MifareKeyType keytype)=0
 Authenticate a block, given a key number.
 
virtual void increment (uint8_t blockno, uint32_t value)=0
 
virtual void decrement (uint8_t blockno, uint32_t value)=0
 
bool writeValueBlock (uint8_t blockno, int32_t value, uint8_t backup_blockno)
 
bool readValueBlock (uint8_t blockno, int32_t &value, uint8_t &backup_block)
 
- Public Member Functions inherited from logicalaccess::Commands
 Commands ()=delete
 Constructor.
 
virtual ~Commands ()
 
std::shared_ptr< ChipgetChip () const override
 Get the chip.
 
virtual void setChip (std::shared_ptr< Chip > chip)
 Set the chip.
 
std::shared_ptr< ReaderCardAdaptergetReaderCardAdapter () const override
 Get the reader/card adapter.
 
virtual void setReaderCardAdapter (std::shared_ptr< ReaderCardAdapter > adapter)
 Set the reader/card adapter.
 
virtual const std::string & getCmdType () const
 Get the cmd name.
 
virtual void setCmdType (const std::string &command_type)
 Set the cmd name.
 
- Public Member Functions inherited from logicalaccess::ICommands
virtual ~ICommands ()=default
 
virtual std::shared_ptr< ChipgetChip () const =0
 Get the chip.
 
virtual std::shared_ptr< ReaderCardAdaptergetReaderCardAdapter () const =0
 Get the reader/card adapter.
 

Protected Member Functions

virtual ByteVector readBinaryIndex (unsigned char keyindex, unsigned char blockno, size_t len)
 Read bytes from the card.
 
virtual void updateBinaryIndex (unsigned char keyindex, unsigned char blockno, const ByteVector &buf)
 Write bytes to the card.
 
- Protected Member Functions inherited from logicalaccess::MifareCommands
std::shared_ptr< MifareChipgetMifareChip () const
 
- Protected Member Functions inherited from logicalaccess::Commands
 Commands (std::string commandtype)
 Constructor.
 

Protected Attributes

bool d_useSKB
 Use SKB for read/write operation, or not.
 
unsigned char d_skbIndex
 The SKB key index if SKB use.
 
MifareKeyType d_lastKeyType
 The last key type used;.
 
- Protected Attributes inherited from logicalaccess::Commands
std::shared_ptr< ReaderCardAdapterd_readerCardAdapter
 The reader/card adapter.
 
std::weak_ptr< Chipd_chip
 The chip.
 
std::string d_commandtype
 The command type.
 

Additional Inherited Members

- Static Public Member Functions inherited from logicalaccess::MifareCommands
static unsigned char calculateMADCrc (const unsigned char *madbuf, size_t madbuflen)
 Calculate the MAD crc.
 
static unsigned int findReferencedSector (long aid, unsigned char *madbuf, size_t madbuflen)
 Find the referenced sector in the MAD.
 
static MifareKeyType getKeyType (const MifareAccessInfo::SectorAccessBits &sab, int sector, int block, bool write)
 
static unsigned char getNbBlocks (int sector)
 Get number of data blocks for a sector.
 
static unsigned char getSectorStartBlock (int sector)
 Get the sector start block.
 

Detailed Description

The Mifare commands class for STidSTR reader.

Constructor & Destructor Documentation

◆ MifareSTidSTRCommands() [1/2]

logicalaccess::MifareSTidSTRCommands::MifareSTidSTRCommands ( )

Constructor.

◆ MifareSTidSTRCommands() [2/2]

logicalaccess::MifareSTidSTRCommands::MifareSTidSTRCommands ( std::string  ct)
explicit

◆ ~MifareSTidSTRCommands()

logicalaccess::MifareSTidSTRCommands::~MifareSTidSTRCommands ( )
virtual

Destructor.

Member Function Documentation

◆ authenticate() [1/2]

void logicalaccess::MifareSTidSTRCommands::authenticate ( unsigned char  blockno,
std::shared_ptr< KeyStorage key_storage,
MifareKeyType  keytype 
)
overridevirtual

Authenticate a block, given a key number.

Parameters
blocknoThe block number.
key_storageThe key storage used for authentication.
keytypeThe key type.

Implements logicalaccess::MifareCommands.

◆ authenticate() [2/2]

void logicalaccess::MifareSTidSTRCommands::authenticate ( unsigned char  blockno,
unsigned char  keyno,
MifareKeyType  keytype 
)
overridevirtual

Authenticate a block, given a key number.

Parameters
blocknoThe block number.
keynoThe key number, previously loaded with Mifare::loadKey().
keytypeThe key type.

Implements logicalaccess::MifareCommands.

◆ decrement()

void logicalaccess::MifareSTidSTRCommands::decrement ( unsigned char  blockno,
uint32_t  value 
)
override

Decrement a block value.

Parameters
blocknoThe block number.
valueThe decrement value.

◆ getSTidSTRReaderCardAdapter()

std::shared_ptr< STidSTRReaderCardAdapter > logicalaccess::MifareSTidSTRCommands::getSTidSTRReaderCardAdapter ( ) const
inline

Get the STidSTR reader/card adapter.

Returns
The STidSTR reader/card adapter.

◆ increment()

void logicalaccess::MifareSTidSTRCommands::increment ( unsigned char  blockno,
uint32_t  value 
)
override

Increment a block value.

Parameters
blocknoThe block number.
valueThe increment value.

◆ loadKey() [1/2]

void logicalaccess::MifareSTidSTRCommands::loadKey ( std::shared_ptr< Location location,
MifareKeyType  keytype,
std::shared_ptr< MifareKey key 
)
overridevirtual

Load a key on a given location.

Parameters
locationThe location.
keyThe key.
keytypeThe mifare key type.

Implements logicalaccess::MifareCommands.

◆ loadKey() [2/2]

bool logicalaccess::MifareSTidSTRCommands::loadKey ( unsigned char  keyno,
MifareKeyType  keytype,
std::shared_ptr< MifareKey key,
bool  vol = true 
)
overridevirtual

Load a key to the reader.

Parameters
keynoThe key number.
keytypeThe key type.
keyThe key.
volUse volatile memory.
Returns
true on success, false otherwise.

Implements logicalaccess::MifareCommands.

◆ readBinary()

ByteVector logicalaccess::MifareSTidSTRCommands::readBinary ( unsigned char  blockno,
size_t  len 
)
overridevirtual

Read bytes from the card.

Parameters
blocknoThe block number.
lenThe count of bytes to read. (0 <= len < 16)
bufThe buffer in which to place the data.
buflenThe length of buffer.
Returns
The count of bytes red.

Implements logicalaccess::MifareCommands.

◆ readBinaryIndex()

ByteVector logicalaccess::MifareSTidSTRCommands::readBinaryIndex ( unsigned char  keyindex,
unsigned char  blockno,
size_t  len 
)
protectedvirtual

Read bytes from the card.

Parameters
keyindexThe key index.
blocknoThe block number.
lenThe count of bytes to read. (0 <= len < 16)
bufThe buffer in which to place the data.
buflenThe length of buffer.
Returns
The count of bytes red.

◆ releaseRFIDField()

void logicalaccess::MifareSTidSTRCommands::releaseRFIDField ( ) const

Release the RFID field.

◆ scanMifare()

ByteVector logicalaccess::MifareSTidSTRCommands::scanMifare ( ) const

Scan the RFID field for Mifare tag.

Returns
The tag uid if present.

◆ updateBinary()

void logicalaccess::MifareSTidSTRCommands::updateBinary ( unsigned char  blockno,
const ByteVector buf 
)
overridevirtual

Write bytes to the card.

Parameters
blocknoThe block number.
bufThe buffer containing the data.
buflenThe length of buffer.
Returns
The count of bytes written.

Implements logicalaccess::MifareCommands.

◆ updateBinaryIndex()

void logicalaccess::MifareSTidSTRCommands::updateBinaryIndex ( unsigned char  keyindex,
unsigned char  blockno,
const ByteVector buf 
)
protectedvirtual

Write bytes to the card.

Parameters
keyindexThe key index.
blocknoThe block number.
bufThe buffer containing the data.
buflenThe length of buffer.
Returns
The count of bytes written.

Member Data Documentation

◆ d_lastKeyType

MifareKeyType logicalaccess::MifareSTidSTRCommands::d_lastKeyType
protected

The last key type used;.

◆ d_skbIndex

unsigned char logicalaccess::MifareSTidSTRCommands::d_skbIndex
protected

The SKB key index if SKB use.

◆ d_useSKB

bool logicalaccess::MifareSTidSTRCommands::d_useSKB
protected

Use SKB for read/write operation, or not.


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