public byte[] BuildStaticDataToBeAuthenticated() { TLV aip = database.Get(EMVTagsEnum.APPLICATION_INTERCHANGE_PROFILE_82_KRN.Tag); if (aip != null) { TLVList newList = new TLVList(); foreach (TLV tlv in listToManage) { if (tlv.Tag.TagLable != aip.Tag.TagLable) { newList.AddToList(tlv, true); } } if (database.IsNotEmpty(EMVTagsEnum.STATIC_DATA_AUTHENTICATION_TAG_LIST_9F4A_KRN.Tag)) { StringBuilder sb = new StringBuilder(); int depth = 0; sb.Append("Final StaticDataToBeAuthenticatedList (AIP and STATIC_DATA_AUTHENTICATION_TAG_LIST_9F4A_KRN in DB): \n"); sb.AppendLine(newList.ToPrintString(ref depth)); depth = 1; sb.AppendLine(aip.ToPrintString(ref depth)); Logger.Log(sb.ToString()); return(Formatting.ConcatArrays(newList.Serialize(), aip.Value)); } else { int depth = 0; Logger.Log("Final StaticDataToBeAuthenticatedList: (AIP in DB but No STATIC_DATA_AUTHENTICATION_TAG_LIST_9F4A_KRN in DB)\n" + ToPrintString(ref depth)); return(newList.Serialize()); } } else { int depth = 0; Logger.Log("Final StaticDataToBeAuthenticatedList (No AIP in DB): \n" + ToPrintString(ref depth)); return(Serialize()); } }
internal bool ConditionsSatisfied(KernelDatabaseBase database, long amountX, long amountY) { byte tt = database.Get(EMVTagsEnum.TRANSACTION_TYPE_9C_KRN).Value[0]; TERMINAL_TYPE_9F35_KRN.TerminalType terminalType = new TERMINAL_TYPE_9F35_KRN(database).Value.TerminalType; bool isManual = false; byte posEntryMode = database.Get(EMVTagsEnum.POINTOFSERVICE_POS_ENTRY_MODE_9F39_KRN).Value[0]; if (posEntryMode == 0x01) { isManual = true; } long aa = Formatting.BcdToLong(database.Get(EMVTagsEnum.AMOUNT_AUTHORISED_NUMERIC_9F02_KRN).Value); bool tccEqualsacc = false; if (database.IsNotEmpty(EMVTagsEnum.TRANSACTION_CURRENCY_CODE_5F2A_KRN.Tag) && database.IsNotEmpty(EMVTagsEnum.APPLICATION_CURRENCY_CODE_9F42_KRN.Tag)) { string tcc = Formatting.ByteArrayToHexString(database.Get(EMVTagsEnum.TRANSACTION_CURRENCY_CODE_5F2A_KRN).Value); string acc = Formatting.ByteArrayToHexString(database.Get(EMVTagsEnum.APPLICATION_CURRENCY_CODE_9F42_KRN).Value); if (tcc == acc) { tccEqualsacc = true; } } switch (CVMConditionCode) { case CVMConditionCode.Always: return(true); case CVMConditionCode.IfUnattendedCash: if (terminalType.AttendedUnattended == TERMINAL_TYPE_9F35_KRN.AttendedUnattended.Unattended && tt == (byte)TransactionTypeEnum.CashWithdrawal) { return(true); } else { return(false); } case CVMConditionCode.IfManualCash: if (isManual && tt == (byte)TransactionTypeEnum.CashWithdrawal) { return(true); } else { return(false); } case CVMConditionCode.IfNotUnattendedCashAndNotManualCashAndNotPurchaseWithCashBack: if (!(terminalType.AttendedUnattended == TERMINAL_TYPE_9F35_KRN.AttendedUnattended.Unattended && tt == (byte)TransactionTypeEnum.CashWithdrawal) && (!(isManual && tt == (byte)TransactionTypeEnum.CashWithdrawal)) && (!(tt == (byte)TransactionTypeEnum.PurchaseWithCashback)) ) { return(true); } else { return(false); } case CVMConditionCode.IfTerminalSupportstheCVM: return(IsSupported(database)); case CVMConditionCode.IfPurchaseWithCashBack: if ((tt == (byte)TransactionTypeEnum.PurchaseWithCashback)) { return(true); } else { return(false); } case CVMConditionCode.IfTransactionIsInTheApplicationCurrencyAndIsUnderX: if (tccEqualsacc && aa <= amountX) { return(true); } else { return(false); } case CVMConditionCode.IfTransactionIsInTheApplicationCurrencyAndIsOverX: if (tccEqualsacc && aa > amountX) { return(true); } else { return(false); } case CVMConditionCode.IfTransactionIsInTheApplicationCurrencyAndIsUnderY: if (tccEqualsacc && aa <= amountY) { return(true); } else { return(false); } case CVMConditionCode.IfTransactionIsInTheApplicationCurrencyAndIsOverY: if (tccEqualsacc && aa > amountY) { return(true); } else { return(false); } default: throw new EMVProtocolException("invalid CVM ConditionCode in Rule"); } }