add consts

This commit is contained in:
nganhkhoa 2023-03-01 10:49:08 +07:00
parent db603398f4
commit bb63081736

67
app/src/main/cpp/consts.h Normal file
View File

@ -0,0 +1,67 @@
//
// Created by ACER on 2023/02/24.
//
#ifndef CCCC_CONSTS_H
#define CCCC_CONSTS_H
#include <vector>
#include <stdint.h>
// Definition of ISO/IEC 7816-4 Basic interindustry commands (BIC) classes
class ISO7816_CLA {
public:
// SM - Secure Messaging
constexpr static int NO_SM = 0x00;
constexpr static int PROPRIETARY_SM = 0x04;
constexpr static int SM_NO_HEADER_AUTHN = 0x08;
constexpr static int SM_HEADER_AUTHN = 0x0C;
constexpr static int COMMAND_CHAINING = 0x10;
};
// Definition of ISO/IEC 7816-4 BIC instructions
class ISO7816_INS {
public:
constexpr static int GET_CHALLENGE = 0x84; // changed from 0xB4
constexpr static int EXTERNAL_AUTHENTICATE = 0x82;
constexpr static int INTERNAL_AUTHENTICATE = 0x88;
constexpr static int READ_BINARY = 0xB0;
constexpr static int READ_BINARY_EXT = 0xB1; // read instruction when file chunk offset is larger than 32767 bytes
constexpr static int SELECT_FILE = 0xA4;
};
// Class defines P1 values of ISO/IEC 7816-4 SELECT FILE command
// ref: https://cardwerk.com/smart-card-standard-iso7816-4-section-6-basic-interindustry-commands/#table58
class ISO97816_SelectFileP1 {
public:
constexpr static int byID = 0x00; // Select MF, DF or EF (data field=identifier or empty)
constexpr static int byChildDFID = 0x01; // Select child DF (data field=DF identifier)
constexpr static int byEFID = 0x02; // Select EF under current DF (data field=EF identifier)
constexpr static int parentDF = 0x03; // Select parent DF of the current DF
constexpr static int byDFName = 0x04; // Direct selection by DF name (data field=DF name)
constexpr static int byPathFromMF = 0x08; // Select from MF (data field=path without the identifier of the MF)
constexpr static int byPath = 0x09; // Select from current DF (data field=path without the identifier of the current DF)
};
// Class defines P2 values of ISO/IEC 7816-4 SELECT FILE command
// ref: https://cardwerk.com/smart-card-standard-iso7816-4-section-6-basic-interindustry-commands/#table59
class ISO97816_SelectFileP2 {
public:
constexpr static int firstRecord = 0x00;
constexpr static int lastRecord = 0x01;
constexpr static int nextRecord = 0x02;
constexpr static int previousRecord = 0x03;
// File control information option
constexpr static int returnFCI = 0x00; // Return FCI, optional template
constexpr static int returnFCP = 0x04; // Return FCP template
constexpr static int returnFMD = 0x08; // Return FMD template
};
constexpr uint8_t APDUsuccess = 0x90;
constexpr int defaultSelectP2 = (ISO97816_SelectFileP2::returnFCP | ISO97816_SelectFileP2::returnFMD);
constexpr uint8_t Df1Name[] = {0xA0,0x00,0x00,0x02,0x47,0x10,0x01};
#endif //CCCC_CONSTS_H