Initial commit
This commit is contained in:
167
Emoney Info/Classes/smartCard/CardErrorCodes.swift
Executable file
167
Emoney Info/Classes/smartCard/CardErrorCodes.swift
Executable file
@ -0,0 +1,167 @@
|
||||
/*
|
||||
* Copyright 2018-2020 TON DEV SOLUTIONS LTD.
|
||||
*
|
||||
* Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use
|
||||
* this file except in compliance with the License.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific TON DEV software governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
class CardErrorCodes {
|
||||
|
||||
/* Standard status words that may be returned by any Java card */
|
||||
|
||||
static let SW_SUCCESS :UInt16 = 0x9000;
|
||||
static let SW_WRONG_LENGTH :UInt16 = 0x6700;
|
||||
static let SW_APPLET_SELECT_FAILED :UInt16 = 0x6999;
|
||||
static let SW_RESPONSE_BYTES_REMAINING :UInt16 = 0x6100;
|
||||
static let SW_CLA_NOT_SUPPORTED :UInt16 = 0x6E00;
|
||||
static let SW_COMMAND_CHAINING_NOT_SUPPORTED :UInt16 = 0x6884;
|
||||
static let SW_COMMAND_NOT_ALLOWED :UInt16 = 0x6986;
|
||||
static let SW_CONDITIONS_OF_USE_NOT_SATISFIED :UInt16 = 0x6985;
|
||||
static let SW_CORRECT_EXPECTED_LENGTH :UInt16 = 0x6C00;
|
||||
static let SW_DATA_INVALID :UInt16 = 0x6984;
|
||||
static let SW_NOT_ENOUGH_MEMORY_SPACE_IN_FILE :UInt16 = 0x6A84;
|
||||
static let SW_FILE_INVALID :UInt16 = 0x6983;
|
||||
static let SW_FILE_NOT_FOUND :UInt16 = 0x6A82;
|
||||
static let SW_FUNCTION_NOT_SUPPORTED :UInt16 = 0x6A81;
|
||||
static let SW_INCORRECT_P1_P2 :UInt16 = 0x6A86;
|
||||
static let SW_INS_NOT_SUPPORTED :UInt16 = 0x6D00;
|
||||
/*static let SW_LAST_COMMAND_IN_CHAIN_EXPECTED :UInt16 = 0x6883;*/
|
||||
static let SW_LOGICAL_CHANNEL_NOT_SUPPORTED :UInt16 = 0x6881;
|
||||
static let SW_RECORD_NOT_FOUND :UInt16 = 0x6883;
|
||||
static let SW_SECURE_MESSAGING_NOT_SUPPORTED :UInt16 = 0x6882;
|
||||
static let SW_SECURITY_CONDITION_NOT_SATISFIED :UInt16 = 0x6982;
|
||||
static let SW_COMMAND_ABORTED :UInt16 = 0x6F00;
|
||||
static let SW_WRONG_DATA :UInt16 = 0x6A80;
|
||||
static let SW_WRONG_P1_P2 :UInt16 = 0x6B00;
|
||||
|
||||
|
||||
/* Status words that may be returned by TonWalletApplet */
|
||||
|
||||
// Common errors
|
||||
static let SW_INTERNAL_BUFFER_IS_NULL_OR_TOO_SMALL :UInt16 = 0x4F00;
|
||||
static let SW_PERSONALIZATION_NOT_FINISHED :UInt16 = 0x4F01;
|
||||
static let SW_INCORRECT_OFFSET :UInt16 = 0x4F02;
|
||||
static let SW_INCORRECT_PAYLOAD :UInt16 = 0x4F03;
|
||||
|
||||
// Password authentication errors
|
||||
static let SW_INCORRECT_PASSWORD_FOR_CARD_AUTHENICATION :UInt16 = 0x5F00;
|
||||
static let SW_INCORRECT_PASSWORD_CARD_IS_BLOCKED :UInt16 = 0x5F01;
|
||||
|
||||
// Signature errors
|
||||
static let SW_SET_COIN_TYPE_FAILED :UInt16 = 0x6F01;
|
||||
static let SW_SET_CURVE_FAILED :UInt16 = 0x6F02;
|
||||
static let SW_GET_COIN_PUB_DATA_FAILED :UInt16 = 0x6F03;
|
||||
static let SW_SIGN_DATA_FAILED :UInt16 = 0x6F04;
|
||||
|
||||
// Pin verification errors
|
||||
static let SW_COIN_MANAGER_INCORRECT_PIN :UInt16 = 0x9B01;
|
||||
static let SW_COIN_MANAGER_UPDATE_PIN_ERROR :UInt16 = 0x9B02;
|
||||
// static let SW_PIN_TRIES_EXPIRED :UInt16 = 0x9F08;
|
||||
static let SW_INCORRECT_PIN :UInt16 = 0x6F07;
|
||||
static let SW_PIN_TRIES_EXPIRED :UInt16 = 0x6F08;
|
||||
|
||||
static let SW_LOAD_SEED_ERROR :UInt16 = 0x9F03;
|
||||
|
||||
// Key chain errors
|
||||
static let SW_INCORRECT_KEY_INDEX :UInt16 = 0x7F00;
|
||||
static let SW_INCORRECT_KEY_CHUNK_START_OR_LEN :UInt16 = 0x7F01;
|
||||
static let SW_INCORRECT_KEY_CHUNK_LEN :UInt16 = 0x7F02;
|
||||
static let SW_NOT_ENOUGH_SPACE :UInt16 = 0x7F03;
|
||||
static let SW_KEY_SIZE_UNKNOWN :UInt16 = 0x7F04;
|
||||
static let SW_KEY_LEN_INCORRECT :UInt16 = 0x7F05;
|
||||
static let SW_HMAC_EXISTS :UInt16 = 0x7F06;
|
||||
static let SW_INCORRECT_KEY_INDEX_TO_CHANGE :UInt16 = 0x7F07;
|
||||
static let SW_MAX_KEYS_NUMBER_EXCEEDED :UInt16 = 0x7F08;
|
||||
static let SW_DELETE_KEY_CHUNK_IS_NOT_FINISHED :UInt16 = 0x7F09;
|
||||
|
||||
// Hmac errors
|
||||
static let SW_INCORRECT_SAULT :UInt16 = 0x8F01;
|
||||
static let SW_DATA_INTEGRITY_CORRUPTED :UInt16 = 0x8F02;
|
||||
static let SW_INCORRECT_APDU_HMAC :UInt16 = 0x8F03;
|
||||
static let SW_HMAC_VERIFICATION_TRIES_EXPIRED :UInt16 = 0x8F04;
|
||||
|
||||
// Recovery errors
|
||||
static let SW_RECOVERY_DATA_TOO_LONG :UInt16 = 0x6F09;
|
||||
static let SW_INCORRECT_START_POS_OR_LE :UInt16 = 0x6F0A;
|
||||
static let SW_INTEGRITY_OF_RECOVERY_DATA_CORRUPTED :UInt16 = 0x6F0B;
|
||||
static let SW_RECOVERY_DATA_ALREADY_EXISTS :UInt16 = 0x6F0C;
|
||||
static let SW_RECOVERY_DATA_IS_NOT_SET:UInt16 = 0x6F0D;
|
||||
|
||||
static func convertSw1Sw2IntoOneSw(sw1 : UInt8, sw2 : UInt8) -> Int {
|
||||
Int(256) * Int(sw1) + Int(sw2)
|
||||
}
|
||||
|
||||
static let CARD_ERROR_MSGS = [SW_SUCCESS: "No error.",
|
||||
SW_APPLET_SELECT_FAILED : "Applet select failed.",
|
||||
SW_RESPONSE_BYTES_REMAINING : "Response bytes remaining.",
|
||||
SW_CLA_NOT_SUPPORTED : "CLA value not supported.",
|
||||
SW_COMMAND_CHAINING_NOT_SUPPORTED : "Command chaining not supported.",
|
||||
SW_COMMAND_NOT_ALLOWED : "Command not allowed (no current EF).",
|
||||
SW_CONDITIONS_OF_USE_NOT_SATISFIED : "Conditions of use not satisfied.",
|
||||
SW_CORRECT_EXPECTED_LENGTH : "Correct Expected Length (Le).",
|
||||
SW_DATA_INVALID : "Data invalid.",
|
||||
SW_NOT_ENOUGH_MEMORY_SPACE_IN_FILE : "Not enough memory space in the file.",
|
||||
SW_FILE_INVALID : "File invalid.",
|
||||
SW_FILE_NOT_FOUND : "File not found.",
|
||||
SW_FUNCTION_NOT_SUPPORTED : "Function not supported.",
|
||||
SW_INCORRECT_P1_P2 : "Incorrect parameters (P1,P2).",
|
||||
SW_INS_NOT_SUPPORTED : "INS value not supported.",
|
||||
/* SW_LAST_COMMAND_IN_CHAIN_EXPECTED : "Last command in chain expected.",*/
|
||||
SW_LOGICAL_CHANNEL_NOT_SUPPORTED : "Card does not support the operation on the specified logical channel.",
|
||||
SW_RECORD_NOT_FOUND : "Record not found.",
|
||||
SW_SECURE_MESSAGING_NOT_SUPPORTED : "Card does not support secure messaging.",
|
||||
SW_SECURITY_CONDITION_NOT_SATISFIED : "Security condition not satisfied.",
|
||||
SW_COMMAND_ABORTED : "Command aborted, No precise diagnosis.",
|
||||
SW_WRONG_DATA : "Wrong data.",
|
||||
SW_WRONG_LENGTH : "Wrong length.",
|
||||
SW_WRONG_P1_P2 : "Wrong parameter(s) P1-P2",
|
||||
|
||||
SW_INTERNAL_BUFFER_IS_NULL_OR_TOO_SMALL : "Internal buffer is null or too small.",
|
||||
SW_PERSONALIZATION_NOT_FINISHED : "Personalization is not finished.",
|
||||
SW_INCORRECT_OFFSET : "Internal error: incorrect offset.",
|
||||
SW_INCORRECT_PAYLOAD : "Internal error: incorrect payload value.",
|
||||
SW_INCORRECT_PASSWORD_FOR_CARD_AUTHENICATION : "Incorrect password for card authentication.",
|
||||
SW_INCORRECT_PASSWORD_CARD_IS_BLOCKED : "Incorrect password, card is locked.",
|
||||
SW_SET_COIN_TYPE_FAILED : "Set coin type failed.",
|
||||
SW_SET_CURVE_FAILED : "Set curve failed.",
|
||||
SW_GET_COIN_PUB_DATA_FAILED : "Get coin pub data failed.",
|
||||
SW_SIGN_DATA_FAILED : "Sign data failed.",
|
||||
SW_INCORRECT_PIN : "Incorrect PIN.",
|
||||
SW_COIN_MANAGER_INCORRECT_PIN : "Incorrect PIN.",
|
||||
SW_COIN_MANAGER_UPDATE_PIN_ERROR : "Update PIN error (for CHANGE_PIN) or wallet status not support to export (for GENERATE SEED).",
|
||||
SW_PIN_TRIES_EXPIRED : "PIN tries expired.",
|
||||
SW_LOAD_SEED_ERROR : "Load seed error.",
|
||||
SW_INCORRECT_KEY_INDEX : "Incorrect key index.",
|
||||
SW_INCORRECT_KEY_CHUNK_START_OR_LEN : "Incorrect key chunk start or length.",
|
||||
SW_INCORRECT_KEY_CHUNK_LEN : "Incorrect key chunk length.",
|
||||
SW_NOT_ENOUGH_SPACE : "Not enough space.",
|
||||
SW_KEY_SIZE_UNKNOWN : "Key size unknown.",
|
||||
SW_KEY_LEN_INCORRECT : "Key length incorrect.",
|
||||
SW_HMAC_EXISTS : "Hmac exists already.",
|
||||
SW_INCORRECT_KEY_INDEX_TO_CHANGE: "Incorrect key index to change.",
|
||||
SW_MAX_KEYS_NUMBER_EXCEEDED : "Max number of keys (1023) is exceeded.",
|
||||
SW_DELETE_KEY_CHUNK_IS_NOT_FINISHED : "Delete key chunk is not finished.",
|
||||
SW_INCORRECT_SAULT : "Incorrect sault.",
|
||||
SW_DATA_INTEGRITY_CORRUPTED : "Data integrity corrupted.",
|
||||
SW_INCORRECT_APDU_HMAC : "Incorrect apdu hmac. ",
|
||||
SW_HMAC_VERIFICATION_TRIES_EXPIRED : "Apdu Hmac verification tries expired.",
|
||||
SW_RECOVERY_DATA_TOO_LONG : "Too big length of recovery data.",
|
||||
SW_INCORRECT_START_POS_OR_LE : "Incorrect start or length of recovery data piece in internal buffer.",
|
||||
SW_INTEGRITY_OF_RECOVERY_DATA_CORRUPTED : "Hash of recovery data is incorrect. ",
|
||||
SW_RECOVERY_DATA_ALREADY_EXISTS : "Recovery data already exists.",
|
||||
SW_RECOVERY_DATA_IS_NOT_SET : "Recovery data does not exist"
|
||||
]
|
||||
|
||||
static func getErrorMsg(sw : UInt16) -> String? {
|
||||
return CARD_ERROR_MSGS[sw]
|
||||
}
|
||||
|
||||
}
|
||||
39
Emoney Info/Classes/smartCard/CommonConstants.swift
Executable file
39
Emoney Info/Classes/smartCard/CommonConstants.swift
Executable file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2018-2020 TON DEV SOLUTIONS LTD.
|
||||
*
|
||||
* Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use
|
||||
* this file except in compliance with the License.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific TON DEV software governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
func debugLog(
|
||||
_ items: Any...,
|
||||
separator: String = " ",
|
||||
terminator: String = "\n"
|
||||
) {
|
||||
#if DEBUG
|
||||
let output = items.map { String(describing: $0) }.joined(separator: separator)
|
||||
Swift.print(output, terminator: terminator)
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
Here there are some contants related to all APDU commands
|
||||
*/
|
||||
public class CommonConstants {
|
||||
static let CLA_SELECT: UInt8 = 0x00
|
||||
static let INS_SELECT : UInt8 = 0xA4
|
||||
static let SELECT_P1 : UInt8 = 0x04
|
||||
static let SELECT_P2 : UInt8 = 0x00
|
||||
static let LE_NO_RESPONSE_DATA = -1 // Use this LE if you do not wait any response data from card (except of status word)
|
||||
static let LE_GET_ALL_RESPONSE_DATA = 256 // This is standard 0x00 value of LE. Use this LE if you want to take all response bytes from applet that it produced
|
||||
|
||||
|
||||
}
|
||||
72
Emoney Info/Classes/smartCard/EmoneyApduCommands.swift
Executable file
72
Emoney Info/Classes/smartCard/EmoneyApduCommands.swift
Executable file
@ -0,0 +1,72 @@
|
||||
//
|
||||
// EmoneyApduCommands.swift
|
||||
// Emoney Info
|
||||
//
|
||||
// Created by Wira Irawan on 23/07/24.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreNFC
|
||||
|
||||
|
||||
@available(iOS 13.0, *)
|
||||
class EmoneyApduCommands{
|
||||
static let TAPCASH_INIT_DATA : [UInt8] = [0xA0, 0x00, 0x42, 0x4e, 0x49, 0x10, 0x00, 0x01]
|
||||
static let BRIZZI_INIT_DATA : [UInt8] = [0x01, 0x00, 0x00]
|
||||
static let EMONEY_INIT_DATA : [UInt8] = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01]
|
||||
static let FLAZZ_INIT_DATA : [UInt8] = [0xA0, 0x00, 0x00, 0x00, 0x18, 0x0F, 0x00, 0x00, 0x01, 0x80, 0x01]
|
||||
static let JACKCARD_INIT_DATA : [UInt8] = [0xA0, 0x00, 0x00, 0x05, 0x71, 0x4e, 0x4a, 0x43]
|
||||
static let MEGA_DATA : [UInt8] = [0x01, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00]
|
||||
static let BRI_DATA_01 : [UInt8] = [0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00]
|
||||
|
||||
static let TAPCASH_INIT_APDU = NFCISO7816APDU(instructionClass : CommonConstants.CLA_SELECT, instructionCode : CommonConstants.INS_SELECT, p1Parameter : CommonConstants.SELECT_P1, p2Parameter : CommonConstants.SELECT_P2, data : Data(_ : TAPCASH_INIT_DATA), expectedResponseLength : CommonConstants.LE_NO_RESPONSE_DATA)
|
||||
|
||||
static let BRIZZI_INIT_APDU = NFCISO7816APDU(instructionClass : 0x90, instructionCode : 0x5A, p1Parameter : 0x00, p2Parameter : 0x00, data : Data(_ : BRIZZI_INIT_DATA), expectedResponseLength : CommonConstants.LE_GET_ALL_RESPONSE_DATA)
|
||||
|
||||
static let EMONEY_INIT_APDU = NFCISO7816APDU(instructionClass : CommonConstants.CLA_SELECT, instructionCode : CommonConstants.INS_SELECT, p1Parameter : CommonConstants.SELECT_P1, p2Parameter : CommonConstants.SELECT_P2, data : Data(_ : EMONEY_INIT_DATA), expectedResponseLength : CommonConstants.LE_NO_RESPONSE_DATA)
|
||||
|
||||
static let FLAZZ_INIT_APDU = NFCISO7816APDU(instructionClass : CommonConstants.CLA_SELECT, instructionCode : CommonConstants.INS_SELECT, p1Parameter : CommonConstants.SELECT_P1, p2Parameter : CommonConstants.SELECT_P2, data : Data(_ : FLAZZ_INIT_DATA), expectedResponseLength : CommonConstants.LE_NO_RESPONSE_DATA)
|
||||
|
||||
static let JACKCARD_INIT_APDU = NFCISO7816APDU(instructionClass : CommonConstants.CLA_SELECT, instructionCode : CommonConstants.INS_SELECT, p1Parameter : CommonConstants.SELECT_P1, p2Parameter : CommonConstants.SELECT_P2, data : Data(_ : JACKCARD_INIT_DATA), expectedResponseLength : CommonConstants.LE_NO_RESPONSE_DATA)
|
||||
|
||||
static let TAPCASH_APDU01 = NFCISO7816APDU(instructionClass : 0x90, instructionCode : 0x32, p1Parameter : 0x03, p2Parameter : 0x00, data : Data(), expectedResponseLength : CommonConstants.LE_GET_ALL_RESPONSE_DATA)
|
||||
//00 a4 01 00 02 02 00
|
||||
static let BCA_APDU01 = NFCISO7816APDU(instructionClass : 0x00, instructionCode : 0xA4, p1Parameter : 0x01, p2Parameter : 0x00, data : Data(_ : [0x02, 0x00]), expectedResponseLength : CommonConstants.LE_GET_ALL_RESPONSE_DATA)
|
||||
//00 b0 81 00 8e
|
||||
static let BCA_APDU02 = NFCISO7816APDU(instructionClass : 0x00, instructionCode : 0xb0, p1Parameter : 0x81, p2Parameter : 0x00, data : Data(), expectedResponseLength : 142)
|
||||
//80 32 00 03 04 00 00 00 00 //00 b0 81 00 00
|
||||
static let BCA_APDU03 = NFCISO7816APDU(instructionClass : 0x80, instructionCode : 0x32, p1Parameter : 0x00, p2Parameter : 0x03, data : Data(_ : [0x00, 0x00, 0x00, 0x00]), expectedResponseLength : CommonConstants.LE_GET_ALL_RESPONSE_DATA)
|
||||
//00 b0 81 00 00
|
||||
static let BCA_APDU04 = NFCISO7816APDU(instructionClass : 0x00, instructionCode : 0xB0, p1Parameter : 0x81, p2Parameter : 0x00, data : Data(), expectedResponseLength : CommonConstants.LE_GET_ALL_RESPONSE_DATA)
|
||||
|
||||
|
||||
|
||||
//00 b3 00 00 3f
|
||||
static let MANDIRI_APDU01 = NFCISO7816APDU(instructionClass : 0x00, instructionCode : 0xB3, p1Parameter : 0x00, p2Parameter : 0x00, data : Data(), expectedResponseLength : 63)
|
||||
//00 b5 00 00 0a
|
||||
static let MANDIRI_APDU02 = NFCISO7816APDU(instructionClass : 0x00, instructionCode : 0xB5, p1Parameter : 0x00, p2Parameter : 0x00, data : Data(), expectedResponseLength : 10)
|
||||
//90 4c 00 00 04
|
||||
static let DKI_APDU01 = NFCISO7816APDU(instructionClass : 0x90, instructionCode : 0x4C, p1Parameter : 0x00, p2Parameter : 0x00, data : Data(), expectedResponseLength : 4)
|
||||
//90 bd 00 00 07 01 00 00 00 0a 00 00 00
|
||||
static let MEGA_APDU01 = NFCISO7816APDU(instructionClass : 0x90, instructionCode : 0xBD, p1Parameter : 0x00, p2Parameter : 0x00, data : Data(_ : MEGA_DATA), expectedResponseLength : CommonConstants.LE_GET_ALL_RESPONSE_DATA)
|
||||
//90 6c 00 00 01 02 00
|
||||
static let MEGA_APDU02 = NFCISO7816APDU(instructionClass : 0x90, instructionCode : 0x6C, p1Parameter : 0x00, p2Parameter : 0x00, data : Data(_ : [0x02]), expectedResponseLength : CommonConstants.LE_GET_ALL_RESPONSE_DATA)
|
||||
//90 60 00 00 00
|
||||
static let BRI_UID01 = NFCISO7816APDU(instructionClass : 0x90, instructionCode : 0x60, p1Parameter : 0x00, p2Parameter : 0x00, data : Data(), expectedResponseLength : CommonConstants.LE_GET_ALL_RESPONSE_DATA)
|
||||
//90 AF 00 00 00
|
||||
static let BRI_UID02 = NFCISO7816APDU(instructionClass : 0x90, instructionCode : 0xAF, p1Parameter : 0x00, p2Parameter : 0x00, data : Data(), expectedResponseLength : CommonConstants.LE_GET_ALL_RESPONSE_DATA)
|
||||
|
||||
|
||||
//90 bd 00 00 07 00 00 00 00 17 00 00 00
|
||||
static let BRI_APDU01 = NFCISO7816APDU(instructionClass : 0x90, instructionCode : 0xBD, p1Parameter : 0x00, p2Parameter : 0x00, data : Data(_: BRI_DATA_01), expectedResponseLength : CommonConstants.LE_GET_ALL_RESPONSE_DATA)
|
||||
//90 5A 00 00 03 03 00 00 00
|
||||
static let BRI_APDU02 = NFCISO7816APDU(instructionClass : 0x90, instructionCode : 0x5A, p1Parameter : 0x00, p2Parameter : 0x00, data : Data(_: [0x03, 0x00, 0x00]), expectedResponseLength : CommonConstants.LE_GET_ALL_RESPONSE_DATA)
|
||||
//90 0a 00 00 01 00 00
|
||||
static let BRI_APDU03 = NFCISO7816APDU(instructionClass : 0x90, instructionCode : 0x0A, p1Parameter : 0x00, p2Parameter : 0x00, data : Data(_: [0x00]), expectedResponseLength : CommonConstants.LE_GET_ALL_RESPONSE_DATA)
|
||||
//90 6C 00 00 01 00 00
|
||||
static let BRI_APDU05 = NFCISO7816APDU(instructionClass : 0x90, instructionCode : 0x6C, p1Parameter : 0x00, p2Parameter : 0x00, data : Data(_: [0x00]), expectedResponseLength : CommonConstants.LE_GET_ALL_RESPONSE_DATA)
|
||||
//90 BB 00 00 07 01 00 00 00 00 00 00 00
|
||||
static let BRI_LOG01 = NFCISO7816APDU(instructionClass : 0x90, instructionCode : 0xBB, p1Parameter : 0x00, p2Parameter : 0x00, data : Data(_: [0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]), expectedResponseLength : CommonConstants.LE_GET_ALL_RESPONSE_DATA)
|
||||
//90 AF 00 00 00
|
||||
static let BRI_LOG02 = NFCISO7816APDU(instructionClass : 0x90, instructionCode : 0xAF, p1Parameter : 0x00, p2Parameter : 0x00, data : Data(), expectedResponseLength : CommonConstants.LE_GET_ALL_RESPONSE_DATA)
|
||||
}
|
||||
174
Emoney Info/Classes/smartCard/TapCashData.swift
Executable file
174
Emoney Info/Classes/smartCard/TapCashData.swift
Executable file
@ -0,0 +1,174 @@
|
||||
//
|
||||
// TapCashData.swift
|
||||
// Emoney Info
|
||||
//
|
||||
// Created by Wira Irawan on 26/07/24.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
class TapCashData {
|
||||
var purseData: [UInt8]?
|
||||
var purseStatus: [UInt8]?
|
||||
var purseBalance: [UInt8]?
|
||||
var CAN: [UInt8]?
|
||||
var CSN: [UInt8]?
|
||||
var purseExpiry: [UInt8]?
|
||||
var lastCredirTRP: [UInt8]?
|
||||
var lastCreditHeader: [UInt8]?
|
||||
var lastTxnTRP: [UInt8]?
|
||||
var lastTxnRecord: [UInt8]?
|
||||
var BDC: [UInt8]?
|
||||
var keySet: [UInt8]?
|
||||
var maxCardBalance: [UInt8]?
|
||||
var eData: [UInt8]?
|
||||
var crcb: [UInt8]?
|
||||
var lastTransactionSignCert: [UInt8]?
|
||||
var lastCounterData: [UInt8]?
|
||||
var version: [UInt8]?
|
||||
var lastDebitOption: [UInt8]?
|
||||
var totalRecords: [UInt8]?
|
||||
|
||||
func getPurseData() -> [UInt8]? {
|
||||
return purseData
|
||||
}
|
||||
|
||||
func setPurseData(_ purseData: [UInt8]) {
|
||||
self.purseData = purseData
|
||||
unpackPurseData(data: purseData)
|
||||
}
|
||||
|
||||
func getPurseStatus() -> [UInt8]? {
|
||||
return purseStatus
|
||||
}
|
||||
|
||||
func setPurseStatus(_ purseStatus: [UInt8]) {
|
||||
self.purseStatus = purseStatus
|
||||
}
|
||||
|
||||
func getPurseBalance() -> [UInt8]? {
|
||||
return purseBalance
|
||||
}
|
||||
|
||||
func setPurseBalance(_ purseBalance: [UInt8]) {
|
||||
self.purseBalance = purseBalance
|
||||
}
|
||||
|
||||
func getCAN() -> [UInt8]? {
|
||||
return CAN
|
||||
}
|
||||
|
||||
func setCAN(_ CAN: [UInt8]) {
|
||||
self.CAN = CAN
|
||||
}
|
||||
|
||||
func getCSN() -> [UInt8]? {
|
||||
return CSN
|
||||
}
|
||||
|
||||
func setCSN(_ CSN: [UInt8]) {
|
||||
self.CSN = CSN
|
||||
}
|
||||
|
||||
func getPurseExpiry() -> [UInt8]? {
|
||||
return purseExpiry
|
||||
}
|
||||
|
||||
func setPurseExpiry(_ purseExpiry: [UInt8]) {
|
||||
self.purseExpiry = purseExpiry
|
||||
}
|
||||
|
||||
func getLastCredirTRP() -> [UInt8]? {
|
||||
return lastCredirTRP
|
||||
}
|
||||
|
||||
func setLastCredirTRP(_ lastCredirTRP: [UInt8]) {
|
||||
self.lastCredirTRP = lastCredirTRP
|
||||
}
|
||||
|
||||
func getLastCreditHeader() -> [UInt8]? {
|
||||
return lastCreditHeader
|
||||
}
|
||||
|
||||
func setLastCreditHeader(_ lastCreditHeader: [UInt8]) {
|
||||
self.lastCreditHeader = lastCreditHeader
|
||||
}
|
||||
|
||||
func getLastTxnTRP() -> [UInt8]? {
|
||||
return lastTxnTRP
|
||||
}
|
||||
|
||||
func setLastTxnTRP(_ lastTxnTRP: [UInt8]) {
|
||||
self.lastTxnTRP = lastTxnTRP
|
||||
}
|
||||
|
||||
func getLastTxnRecord() -> [UInt8]? {
|
||||
return lastTxnRecord
|
||||
}
|
||||
|
||||
func setLastTxnRecord(_ lastTxnRecord: [UInt8]) {
|
||||
self.lastTxnRecord = lastTxnRecord
|
||||
}
|
||||
|
||||
func getBDC() -> [UInt8]? {
|
||||
return BDC
|
||||
}
|
||||
|
||||
func setBDC(_ BDC: [UInt8]) {
|
||||
self.BDC = BDC
|
||||
}
|
||||
|
||||
func getKeySet() -> [UInt8]? {
|
||||
return keySet
|
||||
}
|
||||
|
||||
func setKeySet(_ keySet: [UInt8]) {
|
||||
self.keySet = keySet
|
||||
}
|
||||
|
||||
func getMaxCardBalance() -> [UInt8]? {
|
||||
return maxCardBalance
|
||||
}
|
||||
|
||||
func setMaxCardBalance(_ maxCardBalance: [UInt8]) {
|
||||
self.maxCardBalance = maxCardBalance
|
||||
}
|
||||
|
||||
func geteData() -> [UInt8]? {
|
||||
return eData
|
||||
}
|
||||
|
||||
func seteData(_ eData: [UInt8]) {
|
||||
self.eData = eData
|
||||
}
|
||||
|
||||
func getCrcb() -> [UInt8]? {
|
||||
return crcb
|
||||
}
|
||||
|
||||
func setCrcb(_ crcb: [UInt8]) {
|
||||
self.crcb = crcb
|
||||
}
|
||||
|
||||
func getTotalRecords() -> [UInt8]? {
|
||||
return totalRecords
|
||||
}
|
||||
|
||||
private func unpackPurseData(data: [UInt8]) {
|
||||
version = Array(data[0..<1])
|
||||
purseStatus = Array(data[1..<2])
|
||||
purseBalance = Array(data[2..<5])
|
||||
CAN = Array(data[8..<16])
|
||||
CSN = Array(data[16..<24])
|
||||
purseExpiry = Array(data[24..<26])
|
||||
lastCredirTRP = Array(data[28..<32])
|
||||
lastCreditHeader = Array(data[32..<40])
|
||||
totalRecords = Array(data[40..<41])
|
||||
lastTxnTRP = Array(data[42..<46])
|
||||
lastTxnRecord = Array(data[46..<62])
|
||||
BDC = Array(data[63..<64])
|
||||
keySet = Array(data[71..<72])
|
||||
maxCardBalance = Array(data[78..<81])
|
||||
lastDebitOption = Array(data[94..<95])
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user