M5Unit-NFC 0.0.3 git rev:59f5362
Loading...
Searching...
No Matches
m5::nfc::FileSystem Class Reference

ISO/IEC 7816-4 file system. More...

#include <file_system.hpp>

Inheritance diagram for m5::nfc::FileSystem:
m5::nfc::NFCBFileSystem m5::nfc::a::mifare::desfire::DESFireFileSystem

Public Member Functions

 FileSystem (m5::nfc::isodep::IsoDEP &isoDEP)
 
const std::vector< uint8_t > & lastSelectData () const
 Last SELECT response data (SW excluded)
 
ISO/IEC 7816-4 Standard commands
bool createFile (const uint8_t *fcp, const uint16_t fcp_len)
 CREATE FILE.
 
bool createFile (const FCP &fcp)
 CREATE FILE.
 
bool createFile (const uint16_t fid, const uint16_t file_size)
 CREATE FILE.
 
bool selectFile (const m5::nfc::apdu::SelectBy by, const m5::nfc::apdu::SelectOccurrence occ, const m5::nfc::apdu::SelectResponse res, const uint8_t *param, const uint8_t param_len)
 SELECT FILE (generic)
 
bool selectByFileId (const uint16_t fid, const m5::nfc::apdu::SelectResponse res=m5::nfc::apdu::SelectResponse::FCI, const m5::nfc::apdu::SelectOccurrence occ=m5::nfc::apdu::SelectOccurrence::FirstOrOnly)
 SELECT by File ID with explicit response type.
 
bool selectFileIdAuto (const uint16_t fid, const m5::nfc::apdu::SelectOccurrence occ=m5::nfc::apdu::SelectOccurrence::FirstOrOnly)
 SELECT by File ID with auto response fallback (None->FCI->FCP)
 
bool selectByDfName (const uint8_t *aid, const uint8_t aid_len, const m5::nfc::apdu::SelectResponse res=m5::nfc::apdu::SelectResponse::FCI, const m5::nfc::apdu::SelectOccurrence occ=m5::nfc::apdu::SelectOccurrence::FirstOrOnly)
 SELECT by DF Name with explicit response type.
 
bool selectDfNameAuto (const uint8_t *aid, const uint8_t aid_len, const m5::nfc::apdu::SelectOccurrence occ=m5::nfc::apdu::SelectOccurrence::FirstOrOnly)
 SELECT by DF Name with auto response fallback (FCI->None->FCP)
 
bool selectByPath (const uint8_t *path, const uint8_t path_len, const bool from_mf=true, const m5::nfc::apdu::SelectResponse res=m5::nfc::apdu::SelectResponse::FCI, const m5::nfc::apdu::SelectOccurrence occ=m5::nfc::apdu::SelectOccurrence::FirstOrOnly)
 SELECT by path (MF or current DF)
 
bool selectParent (const m5::nfc::apdu::SelectResponse res=m5::nfc::apdu::SelectResponse::FCI, const m5::nfc::apdu::SelectOccurrence occ=m5::nfc::apdu::SelectOccurrence::FirstOrOnly)
 SELECT parent DF.
 
bool selectMasterFile ()
 SELECT MF (Master File)
 
bool verify (const uint8_t *password, const uint16_t pass_len, const uint8_t param2)
 VERIFY (generic)
 
bool verifyGlobal (const uint8_t *password, const uint16_t pass_len)
 VERIFY global reference data.
 
bool verifySpecific (const uint8_t *password, const uint16_t pass_len)
 VERIFY specific reference data.
 
bool readBinary (std::vector< uint8_t > &out, const uint16_t offset, const uint16_t le)
 READ BINARY.
 
bool updateBinary (const uint16_t offset, const uint8_t *data, const uint16_t data_len)
 UPDATE BINARY.
 

Protected Attributes

m5::nfc::isodep::IsoDEP_isoDEP
 
std::vector< uint8_t > _last_select_fci {}
 

Detailed Description

ISO/IEC 7816-4 file system.

Member Function Documentation

◆ createFile() [1/3]

bool m5::nfc::FileSystem::createFile ( const FCP & fcp)

CREATE FILE.

Parameters
fcpFile control parameters
Returns
True if successful

◆ createFile() [2/3]

bool m5::nfc::FileSystem::createFile ( const uint16_t fid,
const uint16_t file_size )

CREATE FILE.

Parameters
fidFileID
file_sizeFile size
Returns
True if successful

◆ createFile() [3/3]

bool m5::nfc::FileSystem::createFile ( const uint8_t * fcp,
const uint16_t fcp_len )

CREATE FILE.

Parameters
fcpFile control parameters
fcp_lenfcp length
Returns
True if successful

◆ lastSelectData()

const std::vector< uint8_t > & m5::nfc::FileSystem::lastSelectData ( ) const
inline

Last SELECT response data (SW excluded)

Returns
Response data

◆ readBinary()

bool m5::nfc::FileSystem::readBinary ( std::vector< uint8_t > & out,
const uint16_t offset,
const uint16_t le )

READ BINARY.

Parameters
[out]outOutput buffer
offsetFile offset
leExpected length (1..256 recommended)
Returns
True if successful

◆ selectByDfName()

bool m5::nfc::FileSystem::selectByDfName ( const uint8_t * aid,
const uint8_t aid_len,
const m5::nfc::apdu::SelectResponse res = m5::nfc::apdu::SelectResponse::FCI,
const m5::nfc::apdu::SelectOccurrence occ = m5::nfc::apdu::SelectOccurrence::FirstOrOnly )

SELECT by DF Name with explicit response type.

Parameters
aidDF name (AID)
aid_lenAID length
resResponse format
occSelection occurrence
Returns
True if successful

◆ selectByFileId()

bool m5::nfc::FileSystem::selectByFileId ( const uint16_t fid,
const m5::nfc::apdu::SelectResponse res = m5::nfc::apdu::SelectResponse::FCI,
const m5::nfc::apdu::SelectOccurrence occ = m5::nfc::apdu::SelectOccurrence::FirstOrOnly )

SELECT by File ID with explicit response type.

Parameters
fidFile ID
resResponse format
occSelection occurrence
Returns
True if successful

◆ selectByPath()

bool m5::nfc::FileSystem::selectByPath ( const uint8_t * path,
const uint8_t path_len,
const bool from_mf = true,
const m5::nfc::apdu::SelectResponse res = m5::nfc::apdu::SelectResponse::FCI,
const m5::nfc::apdu::SelectOccurrence occ = m5::nfc::apdu::SelectOccurrence::FirstOrOnly )

SELECT by path (MF or current DF)

Parameters
pathPath data
path_lenPath length
from_mfUse MF as origin if true
resResponse format
occSelection occurrence
Returns
True if successful

◆ selectDfNameAuto()

bool m5::nfc::FileSystem::selectDfNameAuto ( const uint8_t * aid,
const uint8_t aid_len,
const m5::nfc::apdu::SelectOccurrence occ = m5::nfc::apdu::SelectOccurrence::FirstOrOnly )

SELECT by DF Name with auto response fallback (FCI->None->FCP)

Parameters
aidDF name (AID)
aid_lenAID length
occSelection occurrence
Returns
True if successful

◆ selectFile()

bool m5::nfc::FileSystem::selectFile ( const m5::nfc::apdu::SelectBy by,
const m5::nfc::apdu::SelectOccurrence occ,
const m5::nfc::apdu::SelectResponse res,
const uint8_t * param,
const uint8_t param_len )

SELECT FILE (generic)

Parameters
bySelection method
occSelection occurrence
resResponse format
paramIdentifier data
param_lenIdentifier length
Returns
True if successful

◆ selectFileIdAuto()

bool m5::nfc::FileSystem::selectFileIdAuto ( const uint16_t fid,
const m5::nfc::apdu::SelectOccurrence occ = m5::nfc::apdu::SelectOccurrence::FirstOrOnly )

SELECT by File ID with auto response fallback (None->FCI->FCP)

Parameters
fidFile ID
occSelection occurrence
Returns
True if successful

◆ selectMasterFile()

bool m5::nfc::FileSystem::selectMasterFile ( )
inline

SELECT MF (Master File)

Returns
True if successful

◆ selectParent()

SELECT parent DF.

Parameters
resResponse format
occSelection occurrence
Returns
True if successful

◆ updateBinary()

bool m5::nfc::FileSystem::updateBinary ( const uint16_t offset,
const uint8_t * data,
const uint16_t data_len )

UPDATE BINARY.

Parameters
offsetFile offset
dataData to write
data_lenLength to write
Returns
True if successful

◆ verify()

bool m5::nfc::FileSystem::verify ( const uint8_t * password,
const uint16_t pass_len,
const uint8_t param2 )

VERIFY (generic)

Parameters
passwordPassword data
pass_lenPassword length
param2P2 (reference data type)
Returns
True if successful

◆ verifyGlobal()

bool m5::nfc::FileSystem::verifyGlobal ( const uint8_t * password,
const uint16_t pass_len )
inline

VERIFY global reference data.

Parameters
passwordPassword data
pass_lenPassword length
Returns
True if successful

◆ verifySpecific()

bool m5::nfc::FileSystem::verifySpecific ( const uint8_t * password,
const uint16_t pass_len )
inline

VERIFY specific reference data.

Parameters
passwordPassword data
pass_lenPassword length
Returns
True if successful