sdi_if.h
Last updated: 02-Oct-2025
Go to the documentation of this file.
1Â /**************************************************************************** 2Â * Product: ADK Secure Data Interface (SDI) 3Â * Company: Verifone 4Â * Author: GSS R&D Germany 5Â * Content: Client (structure) interface - non-EMV part 6Â ****************************************************************************/ 7Â #ifndef CLIENT_SDI_IF_H_ 8Â #define CLIENT_SDI_IF_H_ 9Â 10Â #ifndef DOXYGEN 11Â #ifdef __cplusplus 12Â #endif 13Â #include <vector> 14Â #include <string> 15Â #include <stdint.h> 16Â #include <emv/EMV_Common_Interface.h> // for EMV_ADK_INFO 17Â #include <sysinfo/sysinfo.h> // for property enumerations 18Â #include <html/prt.h> // for printer property enumerations 19Â 20Â namespace libsdi { 21Â 25Â enum SDI_SW12 26Â { 27Â SDI_SW12_NONE = 0, 28Â SDI_SW12_SUCCESS = 0x9000, 29Â 30Â SDI_SW12_TAG_ERROR = 0x6200, 31Â SDI_SW12_TAG_LENGTH_ERROR = 0x6300, 32Â SDI_SW12_EXEC_ERROR = 0x6400, 33Â SDI_SW12_CANCELED_BY_USER = 0x6405, 34Â SDI_SW12_BUSY = 0x640A, 35Â SDI_SW12_TIMEOUT_PIN_ENTRY = 0x640C, 36Â SDI_SW12_TIMEOUT_NO_MSR_DATA = 0x64F6, 37Â SDI_SW12_TIMEOUT_CARD_REMOVAL = 0x64F7, 38Â SDI_SW12_INTERCHAR_PIN_ENTRY = 0x64F8, 39Â SDI_SW12_COMMAND_NOT_ALLOWED = 0x64F9, 40Â SDI_SW12_MAIN_CONNECTION_USED = 0x64FA, 41Â SDI_SW12_INVALID_FILE_CONTENT = 0x64FB, 42Â SDI_SW12_FILE_ACCESS_ERROR = 0x64FC, 43Â SDI_SW12_LOGIC_ERROR = 0x64FD, 44Â SDI_SW12_SDI_PARAMETER_ERROR = 0x64FE, 45Â SDI_SW12_LUHN_CHECK_FAILED = 0x64FF, 46Â SDI_SW12_EXECUTION_ABORTED = 0x6500, 47Â SDI_SW12_EXECUTION_TIMEOUT = 0x6600, 48Â SDI_SW12_MESSAGE_LENGTH_ERROR = 0x6700, 49Â 50Â SDI_SW12_NO_SDI_PLUGIN_AVAILABLE = 0x6800, 51Â SDI_SW12_UNKNOWN_PLUGIN_ID = 0x6801, 52Â SDI_SW12_UNKNOWN_PLUGING_ID = 0x6801, 53Â SDI_SW12_INVALID_PLUGIN_RESPONSE = 0x6802, 54Â 55Â SDI_SW12_EPP_CONNECTION_ERROR = 0x6900, 56Â 57Â SDI_SW12_UNKNOWN_INS_BYTE = 0x6D00, 58Â SDI_SW12_UNKNOWN_CLA_BYTE = 0x6E00, 59Â 60Â SDI_SW12_CMAC_ERROR = 0x6FB0, 61Â SDI_SW12_CMAC_LENGTH_ERROR = 0x6FB1, 62Â SDI_SW12_CMAC_MISSING_ERROR = 0x6FB2, 63Â SDI_SW12_ENCRYPTION_ERROR = 0x6FB4, 64Â SDI_SW12_ENCRYPTION_LENGTH_ERROR = 0x6FB5, 65Â SDI_SW12_ENCRYPTION_MISSING_ERROR = 0x6FB6, 66Â SDI_SW12_DECRYPTION_ERROR = 0x6FB8, 67Â SDI_SW12_DECRYPTION_LENGTH_ERROR = 0x6FB9, 68Â SDI_SW12_DECRYPTION_MISSING_ERROR = 0x6FBA, 69Â 70Â SDI_SW12_EXCESSIVE_PIN_REQUESTS = 0x6FC0, 71Â SDI_SW12_LOW_BATTERY = 0x6FD0, 72Â SDI_SW12_NO_DUKPT_KEYS_LOADED = 0x6FE0, 73Â SDI_SW12_UNIT_TAMPERED = 0x6FF0, 74Â SDI_SW12_RECOVERY_MODE = 0x6FF1, 75Â 76Â SDI_SW12_PIN_BYPASSED = 0x9070, 77Â SDI_SW12_NO_MACTCH_FOR_CARD_VALIDATION = 0x9071, 78Â SDI_SW12_SMART_CARD_REMOVED = 0x9401, 79Â SDI_SW12_SMART_CARD_ERROR_TRM = 0x9402, 80Â SDI_SW12_SMART_CARD_ERROR = 0x9403, 81Â SDI_SW12_TWO_CARDS = 0x9404, 82Â SDI_SW12_SMART_CARD_ERR_INIT = 0x9405, 83Â SDI_SW12_SMART_CARD_ERR_PARAM = 0x9406, 84Â SDI_SW12_EMV_TLV_ERROR = 0x94F3, // error In TLV data object (only in relation with EMV commands) 85Â 86Â // There are from previous header version and kept for backward compatibility 87Â SDI_SW12_ERROR = 0x6400, 88Â SDI_SW12_TIMEOUT = 0x6600, 89Â SDI_SW12_NOT_ALLOWED = 0x64FD, 90Â SDI_SW12_PARAMETER_ERROR = 0x90E6 91Â }; 92Â 100Â enum SDICLIENT_ERROR 101Â { 102Â SDICLIENT_ERROR_NONE = 0, 103Â SDICLIENT_ERROR_COMMUNICATION = -1, 104Â SDICLIENT_ERROR_CONCURRENT_USE = -2, 105Â SDICLIENT_ERROR_CONNECT = -3, 106Â SDICLIENT_ERROR_OVERFLOW = -4, 107Â SDICLIENT_ERROR_PARAM = -5, 108Â SDICLIENT_ERROR_OTHER = -6, 109Â SDICLIENT_ERROR_NO_RECEIVE = -7, 110Â SDICLIENT_ERROR_NOT_SUPPORTED = -10, 112Â SDICLIENT_ERROR_NOT_ALLOWED = -11 113Â }; 114Â 115Â #define MSR_CLIENT_ERROR_OFFSET 100 116Â 117Â #define VALIDATION_CHECK_OPTION_RETURN_ALL_MATCHING_RANGES 0x01 //Return all matching card ranges. per default only the best match is returned 118Â 122Â enum SDICLIENT_ERROR getNfcClientError(); 123Â 127Â enum SDI_SW12 getNfcSW12(); 128Â 129Â struct MatchingRecord 130Â { 131Â std::string json; 132Â unsigned char expirycheck_result; 133Â unsigned char luhncheck_result; 134Â unsigned char activationcheck_result; 135Â MatchingRecord(const std::string &_json): json(_json), expirycheck_result(0xFF), luhncheck_result(0xFF), activationcheck_result(0xFF){}; 136Â }; 137Â 139Â enum SYSUploadType 140Â { 141Â SYS_UPLOAD_SOFTWARE_UPDATE = 0, 142Â SYS_UPLOAD_CONFIG_WHITELIST = 1, 143Â SYS_UPLOAD_CONFIG_SENSITIVE_TAGS = 2, 144Â SYS_UPLOAD_CONFIG_CARD_RANGES = 3, 145Â SYS_UPLOAD_INSTALL_CP_PACKAGE = 11, 146Â SYS_UPLOAD_EMV_CONFIGURATION = 12, 147Â SYS_UPLOAD_UVRK_PACKAGE = 13, 148Â }; 149Â 150Â 154Â class SdiBase 155Â { 156Â protected: 157Â unsigned short sw12; 158Â int additionalResultValue; 159Â SDICLIENT_ERROR clientErr; 160Â void setSdiSw12(enum SDI_SW12 s) {sw12=s;} 161Â 168Â void setClientError(int libsdiprotocol_result); 169Â 170Â public: 171Â SdiBase() : sw12(0), additionalResultValue(0), clientErr(SDICLIENT_ERROR_NONE){} 172Â enum SDI_SW12 getSdiSw12(); 173Â 178Â int getAdditionalResultValue(){return additionalResultValue;} 179Â 186Â SDICLIENT_ERROR getClientError(){return clientErr;} 187Â 198Â enum SDI_SW12 receiveSW12(); 199Â 203Â void clear() 204Â { 205Â sw12 = SDI_SW12_NONE; 206Â additionalResultValue = 0; 207Â clientErr = SDICLIENT_ERROR_NONE; 208Â }; 209Â 213Â void importResults(const SdiBase& intermediate) 214Â { 215Â sw12 = intermediate.sw12; 216Â additionalResultValue = intermediate.additionalResultValue; 217Â clientErr = intermediate.clientErr; 218Â } 219Â 220Â struct PluginResult 221Â { 222Â int32_t pluginId; 223Â int32_t responseCode; 226Â std::vector<unsigned char> responseData; 228Â }; 229Â 230Â private: 231Â // make SdiBase non-copyable because some subclasses hold pointers and should not be copied 232Â SdiBase(const SdiBase&); 233Â SdiBase& operator=(const SdiBase&); 234Â // since C++11 we have to avoid the move, too 235Â #if __cplusplus >= 201103L 236Â SdiBase(const SdiBase&&); 237Â SdiBase& operator=(SdiBase&&); 238Â #endif 239Â }; 240Â 241Â 242Â 268Â class SdiCmd: public SdiBase 269Â { 270Â protected: 271Â void* dataIn; 272Â void* dataOut; 273Â 274Â public: 275Â SdiCmd(); 276Â virtual ~SdiCmd(); 277Â 295Â enum SDI_SW12 sendReceive(unsigned char cla, unsigned char ins, 296Â unsigned char p1 = 0, unsigned char p2 = 0, 297Â unsigned maxResponseSize = 2048); 298Â 311Â int send(unsigned char cla, unsigned char ins, 312Â unsigned char p1 = 0, unsigned char p2 = 0); 313Â 322Â enum SDI_SW12 receive(unsigned maxResponseSize = 2048); 323Â 324Â // generic setters modify #dataIn before command execution 337Â void set(const char* path, int value, unsigned fixedLength = 0); 338Â 351Â void set(const char* path, uint32_t value, unsigned fixedLength = 0); 352Â 363Â void set(const char* path, const unsigned char* data, unsigned dataLen); 364Â 374Â inline void set(const char* path, unsigned char byteValue) 375Â { 376Â set(path, &byteValue, 1); 377Â } 378Â 388Â void set(const char* path, const std::vector<unsigned char>& data); 389Â 399Â void set(const char* path, const std::string& value); 400Â 409Â void setCommandDestination(bool epp, bool force = false); 410Â 414Â virtual void clear(); 415Â 422Â virtual void clear(const char* path); 423Â 427Â virtual void clearResults(); 428Â 436Â void importResults(const SdiCmd& intermediate); 437Â 445Â void importResults(const unsigned char* sw12, const unsigned char* tlvData, unsigned tlvSize); 446Â 447Â // generic getter to read from dataOut after command execution 455Â bool get(const char* path, int& value); 456Â 464Â bool get(const char* path, uint32_t& value); 465Â 474Â int get(const char* path, unsigned char* buffer, unsigned bufferSize); 475Â 483Â inline bool get(const char* path, unsigned char& value) 484Â { 485Â return get(path, &value, 1) == 1; 486Â } 487Â 495Â bool get(const char* path, std::vector<unsigned char>& buffer); 496Â 504Â bool get(const char* path, std::string& value); 505Â 512Â std::string getString(const char* path); 513Â }; 514Â 515Â class SDI: public SdiBase 516Â { 517Â public: 518Â 528Â bool getDateTime(unsigned char* buffer); 529Â 539Â bool setDateTime(const unsigned char* dateTime); 540Â 548Â unsigned char getLanguage(); 549Â 557Â bool setLanguage(unsigned char languageId); 558Â 571Â unsigned char getCardDataEntryDeactivation(); 572Â 585Â bool setCardDataEntryDeactivation(unsigned char value); 586Â 596Â unsigned char getCardDataEntryMode(); 597Â 607Â bool setCardDataEntryMode(unsigned char value); 608Â 616Â bool setIdleText(std::string text, bool epp = true); 617Â 626Â bool showMacDesktop(bool epp = true); 627Â 638Â int getProperty(enum vfisysinfo::SYSPropertyInt p, bool epp = false); // 20 1A 00 00 639Â 650Â enum vfisysinfo::sysError getProperty(enum vfisysinfo::SYSPropertyInt p, int& value, bool epp = false); // 20 1A 00 00 651Â 662Â enum vfisysinfo::sysError setProperty(enum vfisysinfo::SYSPropertyInt p, int value, bool epp = false); // 20 19 00 00 663Â 674Â std::string getProperty(enum vfisysinfo::SYSPropertyString p, bool epp = false); // 20 1A 00 01 675Â 686Â enum vfisysinfo::sysError getProperty(enum vfisysinfo::SYSPropertyString p, std::string& value, bool epp = false); 687Â 698Â enum vfisysinfo::sysError setProperty(enum vfisysinfo::SYSPropertyString p, const std::string& value, bool epp = false); // 20 19 00 01 699Â 706Â std::string getVersionInfo(bool epp = false); 707Â 714Â bool checkForUpdate(unsigned char updateKind); 715Â 722Â bool waitCardRemoval(unsigned seconds); 723Â 732Â int sendWaitCardRemoval(unsigned seconds); 733Â 734Â // Data Interface (without crypto handle) 735Â 739Â void clearDataStore(); 740Â 751Â bool vclRegistartSRED(std::vector<unsigned char>& track1, 752Â std::vector<unsigned char>& track2, 753Â std::vector<unsigned char>& track3); 754Â 762Â bool vclStatusRequest(std::vector<unsigned char>& vclStatus); 763Â 774Â bool vclAdvanceDDK(std::vector<unsigned char>& track1, 775Â std::vector<unsigned char>& track2, 776Â std::vector<unsigned char>& track3); 777Â 789Â bool vclRequestEParms(std::vector <unsigned char>& eParms); 790Â 801Â std::string vclGetDiagnosticData(unsigned char format = 1, 802Â unsigned char pageNumber = 0); 803Â 810Â int vclGetKeyDerivationMode(); 811Â 822Â bool vclOverrideMessageQuery(std::vector<unsigned char>& track1, 823Â std::vector<unsigned char>& track2, 824Â std::vector<unsigned char>& track3); 825Â 834Â bool vclKsnRequest(std::string& ksn); 835Â 843Â bool vclKmailinRequest(); 844Â 855Â libsdi::SDI_SW12 pluginCommand(const unsigned char plugin, const unsigned char cmd, 856Â const std::vector<unsigned char>& data, 857Â std::vector<unsigned char>& response); 858Â 868Â bool setManualPAN(const std::vector<unsigned char>& pan); 869Â 879Â bool setManualPAN(const std::string& pan); 880Â 894Â libsdi::SDI_SW12 performValidationChecks(std::vector<MatchingRecord>& records, 895Â const std::vector<unsigned char>& currentDate, 896Â const unsigned char options = 0, 897Â const std::vector<unsigned char> IIN = std::vector<unsigned char>()); 898Â 906Â libsdi::SDI_SW12 getValidationInfo(std::string& info); 907Â 917Â bool sysRegisterLoggingCallback(void (*logCallback)(const char*, void*), 918Â void* context, 919Â unsigned char options = 0); 920Â 930Â libsdi::SDI_SW12 sysUploadStart(const std::string& filename, 931Â SYSUploadType type, 932Â bool epp = false); 933Â 942Â libsdi::SDI_SW12 sysUploadTransfer(const std::vector<unsigned char>& packet, 943Â unsigned packet_no, 944Â bool epp = false); 945Â 957Â libsdi::SDI_SW12 sysUploadFinalize(const std::vector<unsigned char>* md5 = NULL, 958Â const std::vector<unsigned char>* mac = NULL, 959Â bool epp = false); 960Â 967Â bool sysShutdown(bool epp = false); 968Â 975Â bool sysReboot(bool epp = false); 976Â 984Â bool sysSleep(bool epp = false); 985Â 993Â bool sysHybernate(bool epp = false); 994Â 1000Â bool installSponsorCert(const std::vector<unsigned char>& cert); 1001Â 1011Â bool getLastInstallError(std::string& json, std::string& bundle, std::string& package, bool epp = false); 1012Â 1013Â 1018Â void externalButton(void); 1019Â 1032Â bool enableEpp(int& status); 1033Â 1046Â bool disableEpp(int& status); 1047Â 1052Â bool factoryReset(); 1053Â 1060Â bool readCertificate(const std::string& name, std::vector<unsigned char>& certificate); 1061Â 1068Â bool setUseCurrencyAbbreviation(const unsigned char* currency, bool useAbbreviation); 1069Â 1076Â bool setUseCurrencyAbbreviation(unsigned currency, bool useAbbreviation); 1077Â 1087Â bool msrSwitchLeds(int led1, int led2, int led3, int duration); 1088Â 1095Â bool msrSetSensitivty(unsigned char level, bool epp = false); 1096Â 1097Â 1107Â enum vfiprt::PrtError setPrinterProperty(enum vfiprt::PrtPropertyInt p, int value); // 25 00 00 00 1108Â 1118Â enum vfiprt::PrtError setPrinterProperty(enum vfiprt::PrtPropertyString p, const std::string& value); // 25 00 00 01 1119Â 1129Â enum vfiprt::PrtError getPrinterProperty(enum vfiprt::PrtPropertyInt p, int& value); // 25 01 00 00 1130Â 1140Â enum vfiprt::PrtError getPrinterProperty(enum vfiprt::PrtPropertyString p, std::string& value); // 25 01 00 01 1141Â 1149Â enum vfiprt::PrtError printHtml(const std::string& html, bool landscape = false); 1150Â 1159Â enum vfiprt::PrtError printBitmap(const int width, const int height, const std::vector<unsigned char>& data); 1160Â 1161Â private: 1162Â bool sysPower(unsigned char p2, bool epp); 1163Â bool enableEpp(int& status, unsigned char p2); 1164Â 1165Â }; // class SDI 1166Â 1167Â 1186Â class CardDetection: public SdiCmd 1187Â { 1188Â public: 1189Â const static unsigned char SDI_TEC_CHIP = 1; // ISO 7816 1190Â const static unsigned char SDI_TEC_MAGN = 2; // ISO 7810 1191Â const static unsigned char SDI_TEC_CTLS = 4; // ISO 14443 1192Â const static unsigned char SDI_TEC_MANU = 8; // ITU-T E.161 1193Â 1198Â enum DetectionMode { 1199Â DETECTION_MODE_BLOCKING, 1200Â DETECTION_MODE_POLLING, 1201Â DETECTION_MODE_CALLBACK 1202Â }; 1203Â 1209Â void setDetectionMode(const enum DetectionMode mode); 1210Â 1216Â void setTecStartOptions(const std::vector<unsigned char>& opts); // see cts_StartSelection 1217Â 1223Â void setTecConfig(const std::vector<unsigned char>& opts); // see cts_SetOptions 1224Â 1230Â void setCancelButton(bool enable); 1231Â 1237Â void setCardEntryValueDeativation(unsigned char b); 1238Â 1244Â void setAlternativeInputFormat(const char* f); 1245Â 1256Â void setCardRemovalTimeout(unsigned timeout_ms); 1257Â 1264Â void setCallback(void (*cb)(unsigned char technology, void* context), void* ctx); 1265Â 1266Â 1273Â void cardDetectedCallback(unsigned char *dataIn, unsigned short sizeIn); 1274Â 1275Â 1306Â int startSelection(unsigned char supportedTechnologies, unsigned seconds); 1307Â 1324Â enum libsdi::SDI_SW12 stopSelection(); 1325Â 1363Â unsigned char receiveTechnology(); 1364Â 1373Â bool cardReadAtEpp(); 1374Â 1383Â unsigned char pollTechnology(); 1384Â 1392Â enum libsdi::SDI_SW12 addTechnology(unsigned char technology, const std::vector<unsigned char>& opts); 1393Â 1400Â enum libsdi::SDI_SW12 removeTechnology(unsigned char technology); 1401Â 1406Â std::string getPan(); 1407Â 1412Â std::string getTrack2(); 1413Â 1419Â int getTrack2Bin(std::vector<unsigned char>& data); 1420Â 1425Â std::string getCardholderName(); 1426Â 1431Â std::string getServiceCode(); 1432Â 1437Â std::string getTrack1(); 1438Â 1447Â int getPluginResponseData(std::vector<unsigned char>& data); 1448Â 1462Â int getPluginResponseData(unsigned index, 1463Â int32_t& pluginId, 1464Â int32_t& pluginResponseCode, 1465Â std::vector<unsigned char>& data); 1466Â 1473Â bool getPluginResponseData(std::vector<PluginResult>& results); 1474Â 1481Â std::string getString(unsigned CTS_DATA_TAG); 1482Â 1498Â unsigned char getValue(unsigned CTS_DATA_TAG, unsigned char defaultValue); 1499Â 1507Â unsigned char getValue(unsigned CTS_DATA_TAG, int n, unsigned char defaultValue); 1508Â 1514Â int getData(std::vector<unsigned char>& data); 1515Â 1523Â int getData(unsigned CTS_DATA_TAG, std::vector<unsigned char>& data); 1524Â 1534Â int getData(unsigned CTS_DATA_TAG, int n, std::vector<unsigned char>& data); 1535Â 1544Â int getTecselData(std::vector<unsigned char>& data); 1545Â 1560Â int startMsrRead(unsigned timeout_sec); 1561Â 1573Â int msrSetOptions(const std::vector<unsigned char>& opts); 1574Â 1583Â int msrGetTrackStatus(int track); 1584Â 1591Â int msrGetCardSpecificToken(std::vector<unsigned char>& token); 1592Â 1593Â CardDetection(); 1594Â ~CardDetection(); 1595Â 1603Â virtual void clear(); 1604Â 1605Â private: 1606Â void (*callback)(unsigned char technology, void* context); 1607Â void* context; 1608Â enum DetectionMode mode; 1609Â }; 1610Â 1614Â class PED: public SdiCmd 1615Â { 1616Â public: 1620Â enum NavigatorMode 1621Â { 1622Â NAVIGATOR_MODE_OFF, 1623Â NAVIGATOR_MODE_DOUBLE_TAB, 1624Â NAVIGATOR_MODE_TACTILE_BUTTON 1625Â }; 1626Â 1635Â void setTimeout(unsigned seconds); 1636Â 1644Â bool setDefaultTimeout(unsigned seconds); 1645Â 1661Â void setTouchCoordinates(const unsigned char* array, unsigned size); 1662Â 1667Â void setNavigatorMode(enum NavigatorMode mode); 1668Â 1679Â void setPinDigitCountMinMax(unsigned char min, unsigned char max); 1680Â 1687Â void setLanguage(unsigned char lang); 1688Â 1695Â void setAmount(const unsigned char* amount); 1696Â 1703Â void setCurrency(const unsigned char* currency); 1704Â 1712Â void setAppLabel(const std::string& appLabel); 1713Â 1714Â 1741Â int startPinInput(); 1742Â 1753Â int startPinInput(bool enablePinBypass); 1754Â 1774Â bool startPinEntry(unsigned pinBypassKey = 0); 1775Â 1782Â bool pollPinEntry(std::vector<unsigned char>& status); 1783Â 1789Â bool stopPinEntry(); 1790Â 1799Â bool setPinInputClearKeyMode(bool clearAllDigits); 1800Â 1807Â void setClearKeyMode(bool clearAllDigits); 1808Â 1815Â void setPinBypassKeyAndMode(unsigned char value); 1816Â 1823Â void setAutoConfirmation(bool enable); 1824Â 1831Â void setDialogOptions(uint32_t options); 1832Â 1839Â void setIntercharTimeout(uint32_t millis); 1840Â 1849Â void setHeaderLabel(const std::string& label); 1850Â 1857Â void setEchoChar(uint32_t unicode); 1858Â 1877Â bool sendPinInputParameters(bool epp = true); 1878Â 1885Â enum SDI_SW12 receiveGetPinResult(); 1886Â 1895Â bool getPinBypassKey(unsigned char& value); 1896Â }; 1897Â 1906Â class SdiCrypt: public SdiBase 1907Â { 1908Â public: 1909Â // SDI Crypto Interface 1910Â SdiCrypt(); 1911Â ~SdiCrypt(); 1912Â 1921Â bool open(const char* hostName); 1922Â 1929Â bool close(); 1930Â 1936Â bool isOpen() const; 1937Â 1944Â uint32_t getCryptoHandle(); 1945Â 1957Â bool encrypt(const std::vector<unsigned char>& data, 1958Â std::vector<unsigned char>& encrypted); 1959Â 1971Â bool decrypt(const std::vector<unsigned char>& encrypted, 1972Â std::vector<unsigned char>& decrypted); 1973Â 1985Â bool sign(const std::vector<unsigned char>& data, 1986Â std::vector<unsigned char>& signature); 1987Â 1999Â bool verify(const std::vector<unsigned char>& data, 2000Â const std::vector<unsigned char>& signature); 2001Â 2016Â bool updateKey(unsigned char keyType, const std::vector<unsigned char>& keyData, 2017Â std::vector<unsigned char>* proprietaryData = NULL, 2018Â const unsigned char AS2805 = 0, 2019Â std::vector<unsigned char>* KCV = NULL); 2020Â 2032Â bool setKeySetId(uint32_t ksid, uint32_t mksid = 0, bool asAttribute = false); 2033Â 2042Â bool getEncryptedPin(unsigned char pinBlockFormat, 2043Â std::vector<unsigned char>& pinBlock, 2044Â bool requestZeroPinBlock = false); 2045Â 2051Â std::string getKeyInventory(); 2052Â 2061Â bool getKeyData(unsigned char keyType, std::vector<unsigned char>& keyData, unsigned char kekFlag = 0); 2062Â 2069Â std::string getStatus(); 2070Â 2080Â std::string getStatus(std::string hostName); 2081Â 2082Â 2089Â static std::string getVersions(int& additionalResult); 2090Â 2101Â void setInitialVector(const std::vector<unsigned char>& iv) 2102Â { 2103Â initialVector = iv; 2104Â } 2105Â 2111Â void getInitialVector(std::vector<unsigned char>& iv) const 2112Â { 2113Â iv = initialVector; 2114Â } 2115Â 2116Â 2122Â void getKeySerialNumber(std::vector<unsigned char>& ksn) const 2123Â { 2124Â ksn = keySerialNumber; 2125Â } 2126Â 2130Â struct Placeholder 2131Â { 2132Â std::vector<unsigned char> tagList; 2133Â std::vector<unsigned char> applicationData; 2134Â std::vector<unsigned char> dataOptions; 2135Â }; 2136Â 2151Â bool getEncData(const Placeholder& descriptor, 2152Â std::vector<unsigned char>& encrypted, 2153Â bool useStoredData = false, 2154Â bool incrementKSN = false); 2155Â 2171Â bool getEncMsgData(const std::vector<unsigned char>& messageTemplate, 2172Â const std::vector<Placeholder>& placeholder, 2173Â std::vector<unsigned char>& encrypted, 2174Â bool useStoredData = false, 2175Â bool incrementKSN = false); 2176Â 2192Â bool getMsgSignature(const std::vector<unsigned char>& messageTemplate, 2193Â const std::vector<Placeholder>& placeholder, 2194Â std::vector<unsigned char>& signature, 2195Â bool useStoredData = false, 2196Â bool incrementKSN = false); 2197Â 2205Â bool getEncTrxData(const std::vector<unsigned long> tags, std::vector<unsigned char>& data); 2206Â 2213Â bool setEncTrxData(const std::vector<unsigned char> data); 2214Â 2220Â bool endEncTrxData(); 2221Â 2222Â private: 2223Â unsigned char cryptoHandle[4]; 2224Â std::vector<unsigned char> initialVector; 2225Â std::vector<unsigned char> keySerialNumber; 2226Â uint32_t keySetId; 2227Â uint32_t masterKeySetId; 2228Â }; 2229Â 2239Â class ManualEntry: public SdiCmd 2240Â { 2241Â public: 2242Â ManualEntry(); 2243Â ~ManualEntry(); 2244Â 2251Â void setLanguage(unsigned char language); 2252Â 2253Â 2260Â int setTimeout(unsigned seconds); 2261Â 2275Â int setCvvEntryDeactivation(unsigned char cvvEntry); 2276Â 2277Â 2286Â int setCardDataEntryMode(unsigned char mode); 2287Â 2288Â 2295Â int setCvvInputString(const std::string &inputString); 2296Â 2312Â int setTouchCoordinates(const unsigned char* array, unsigned size); 2313Â 2323Â int setMimimumDigits(unsigned char minimumDigits); 2324Â 2333Â int setDoubleConfirmationMode(unsigned char mode); 2334Â 2355Â int start(); 2356Â 2373Â int receiveResult(std::string& obfuscatedPAN, std::vector<unsigned char>& token); 2374Â 2383Â int getPluginResponseData(std::vector<unsigned char>& data); 2384Â 2398Â int getPluginResponseData(unsigned index, 2399Â int32_t& pluginId, 2400Â int32_t& pluginResponseCode, 2401Â std::vector<unsigned char>& data); 2402Â 2409Â bool getPluginResponseData(std::vector<PluginResult>& results); 2410Â }; 2411Â 2457Â class Dialog: public SdiCmd 2458Â { 2459Â public: 2460Â 2467Â 2473Â const static int DIALOG_SUCCESS = 0; 2474Â 2480Â const static int DIALOG_CANCEL_PRESSED = -1; 2481Â 2487Â const static int DIALOG_TIMEOUT = -3; 2488Â 2495Â const static int DIALOG_SYS_ABORT = -8; 2496Â 2502Â const static int DIALOG_CLIENT_ERROR = -14; 2503Â 2509Â const static int DIALOG_SDI_SW12 = -15; 2510Â 2515Â const static int DIALOG_NO_ASYNC_DIALOG = 1; 2516Â 2521Â const static int DIALOG_IN_PROGRESS = 2; 2522Â 2524Â 2531Â const static unsigned DLG_DisplayOnly = 0x00000000; 2532Â const static unsigned DLG_CancelKey = 0x00000002; 2533Â const static unsigned DLG_ClearKey = 0x00000004; 2534Â const static unsigned DLG_EnterKey = 0x00000008; 2535Â const static unsigned DLG_NoLEDs = 0x00000010; 2536Â const static unsigned DLG_CtlsLogo = 0x00000020; 2537Â const static unsigned DLG_QuestionLogo = 0x00000040; 2538Â const static unsigned DLG_WarningLogo = 0x00000080; 2539Â const static unsigned DLG_ErrorLogo = 0x00000100; 2540Â const static unsigned DLG_SuccessLogo = 0x00000200; 2541Â const static unsigned DLG_WaitLogo = 0x00000400; 2542Â const static unsigned DLG_Async = 0x00000800; 2543Â const static unsigned DLG_StoreAsyncResult = 0x00001000; 2544Â const static unsigned DLG_HideSoftKeys = 0x00002000; 2545Â const static unsigned DLG_TextAlignLeft = 0x00004000; 2546Â const static unsigned DLG_TextAlignRight = 0x00008000; 2547Â const static unsigned DLG_TextAlignTop = 0x00010000; 2548Â const static unsigned DLG_TextAlignButton = 0x00020000; 2549Â const static unsigned DLG_NoHeader = 0x00040000; 2550Â const static unsigned DLG_ClearOnReturn = 0x00100000; 2551Â const static unsigned DLG_AbortOnCardRemove = 0x00200000; 2552Â const static unsigned DLG_IgnoreExtAbort = 0x00400000; 2554Â 2561Â const static unsigned MENU_NoOpts = 0x00000000; 2562Â const static unsigned MENU_NoLEDs = 0x00000002; 2563Â const static unsigned MENU_ClearOnReturn = 0x00000004; 2564Â const static unsigned MENU_AbortOnCardRemove= 0x00000008; 2565Â const static unsigned MENU_IgnoreExtAbort = 0x00000010; 2566Â const static unsigned MENU_NoHeader = 0x00000020; 2568Â 2572Â enum REQUEST_CARD_MODE 2573Â { 2574Â REQUEST_CARD_STANDARD = 0, 2575Â REQUEST_CARD_FALLBACK = 1, 2576Â REQUEST_CARD_RETRY = 2 2577Â }; 2578Â 2587Â bool clearScreen(bool epp = true); 2588Â 2612Â int display(const std::string& text, bool epp = true); 2613Â 2637Â int secureInput(bool epp = true); 2638Â 2670Â int menu(bool epp = true); 2671Â 2689Â int requestCard(unsigned char technology, 2690Â enum REQUEST_CARD_MODE mode = REQUEST_CARD_STANDARD, 2691Â bool epp = true); 2692Â 2699Â bool idleScreen(bool epp = true); 2700Â 2716Â int captureSignature(std::vector<unsigned char>& signature, std::string& format, 2717Â bool epp = true); 2718Â 2725Â static void showLedArea(bool show); 2726Â 2748Â int htmlDialog(const std::string& fname, bool epp = true); 2749Â 2761Â int getAsyncResult(bool epp = true); 2762Â 2766Â static void abort(); 2767Â 2776Â void setTemplate(unsigned char id); 2777Â 2786Â void setInputTemplate(unsigned char id); 2787Â 2797Â void setLanguage(unsigned char language); 2798Â 2810Â void addData(const std::string& name, const std::string& value); 2811Â 2822Â void setTimeout(int seconds); 2823Â 2836Â void setOptions(unsigned options); 2837Â 2847Â void setEnterKeyLabel(const std::string& label); 2848Â 2858Â void setClearKeyLabel(const std::string& label); 2859Â 2869Â void setCancelKeyLabel(const std::string& label); 2870Â 2880Â void setUpKeyLabel(const std::string& label); 2881Â 2890Â void setDownKeyLabel(const std::string& label); 2891Â 2900Â void setHeader(const std::string& text); 2901Â 2910Â void setBeep(bool active = true); 2911Â 2921Â void addAction(const std::string& key, const std::string& action); 2922Â 2931Â void setMaskingCharacter(char c); 2932Â 2941Â void setAlternativeInputFormat(const char* f); 2942Â 2951Â void setAmount(const unsigned char* amount); 2952Â 2963Â void setCurrency(const unsigned char* currency); 2964Â 2975Â void setTransactionType(unsigned char txnType); 2976Â 2985Â void setMenuText(const std::string& text); 2986Â 2995Â void addMenuItem(const std::string& item); 2996Â 3007Â void setPreSelected(unsigned char itemNumber); 3008Â 3023Â void setAdminMenu(unsigned char adminMenu); 3024Â 3033Â unsigned char getSelected(); 3034Â 3044Â std::string get(const std::string& name); 3045Â 3058Â std::vector<std::string> getInputFieldNames(); 3059Â 3060Â private: 3061Â int startDialog(unsigned char instruction, bool epp); 3062Â }; 3063Â 3064Â } // namespace sdi 3065Â 3066Â #ifndef DOXYGEN 3067Â #endif // C++ 3068Â #endif 3069Â #endif /* CLIENT_SDI_IF_H_ */
Rate this article: