protected override void LoadKernelDefaultConfigurationDataObjects(TransactionTypeEnum transactionTypeEnum, IConfigurationProvider configProvider) { Logger.Log("Using Kernel 2 Defaults:"); KernelConfigurationDataForTransactionType kcdott = new KernelConfigurationDataForTransactionType() { TransactionTypeEnum = transactionTypeEnum, KernelConfigurationDataObjects = TLVListXML.XmlDeserialize(configProvider.GetKernel2ConfigurationDataXML(Formatting.ByteArrayToHexString(new byte[] { (byte)transactionTypeEnum }))) }; int depth = 0; Logger.Log("Transaction Type: " + transactionTypeEnum + " Using Kernel2 Defaults: \n" + kcdott.KernelConfigurationDataObjects.ToPrintString(ref depth)); TLV _9f1d = kcdott.KernelConfigurationDataObjects.Get(EMVTagsEnum.TERMINAL_RISK_MANAGEMENT_DATA_9F1D_KRN.Tag); TERMINAL_CAPABILITIES_9F33_KRN tc = new TERMINAL_CAPABILITIES_9F33_KRN(kcdott.KernelConfigurationDataObjects.Get(EMVTagsEnum.TERMINAL_CAPABILITIES_9F33_KRN.Tag)); if (tc.Value.EncipheredPINForOnlineVerificationCapable) { Formatting.SetBitPosition(ref _9f1d.Value[0], true, 7); } KERNEL_CONFIGURATION_DF811B_KRN2 kc = new KERNEL_CONFIGURATION_DF811B_KRN2(kcdott.KernelConfigurationDataObjects.Get(EMVTagsEnum.KERNEL_CONFIGURATION_DF811B_KRN2.Tag)); if (kc.Value.OnDeviceCardholderVerificationSupported) { Formatting.SetBitPosition(ref _9f1d.Value[0], true, 3); } KernelConfigurationData.Add(kcdott); }
private static EMVGenerateACRequest DoGAC22_26(KernelDatabaseBase database) { #region GAC.22 APPLICATION_INTERCHANGE_PROFILE_82_KRN aip = new APPLICATION_INTERCHANGE_PROFILE_82_KRN(database); KERNEL_CONFIGURATION_DF811B_KRN2 kc = new KERNEL_CONFIGURATION_DF811B_KRN2(database); if (aip.Value.OnDeviceCardholderVerificationIsSupported && kc.Value.OnDeviceCardholderVerificationSupported) #endregion { #region GAC.23 SetDSACType(database, ACTypeEnum.AAC); #endregion } return(DoGAC26(database)); }
private static SignalsEnum DoMagMode(Kernel2Database database, KernelQ qManager, CardQ cardQManager) { KERNEL_CONFIGURATION_DF811B_KRN2 kc = new KERNEL_CONFIGURATION_DF811B_KRN2(database); TLV aflRaw = database.Get(EMVTagsEnum.APPLICATION_FILE_LOCATOR_AFL_94_KRN); byte[] kcValCheck = new byte[4]; Array.Copy(aflRaw.Value, 0, kcValCheck, 0, kcValCheck.Length); #region 3.70 if (aflRaw.Value.Length >= 4 && Formatting.ByteArrayToHexString(kcValCheck) == "08010100") #endregion { #region 3.72 byte[] activeAFLBytes = new byte[4]; Array.Copy(aflRaw.Value, 0, activeAFLBytes, 0, activeAFLBytes.Length); List <byte[]> bytes = new List <byte[]> { new byte[] { (byte)activeAFLBytes.Length }, activeAFLBytes }; database.ActiveAFL.Value.Deserialize(bytes.SelectMany(a => a).ToArray(), 0); //database.ActiveAFL.Value.Entries.Add(new FILE_LOCATOR_ENTRY(activeAFLBytes)); #endregion } else { #region 3.71 List <byte[]> bytes = new List <byte[]> { new byte[] { (byte)aflRaw.Value.Length }, aflRaw.Value }; database.ActiveAFL.Value.Deserialize(bytes.SelectMany(a => a).ToArray(), 0); //database.ActiveAFL.Value.Entries.Add(new FILE_LOCATOR_ENTRY(aflRaw.Value)); #endregion } #region 3.73 APPLICATION_INTERCHANGE_PROFILE_82_KRN aip = new APPLICATION_INTERCHANGE_PROFILE_82_KRN(database); if (aip.Value.OnDeviceCardholderVerificationIsSupported && kc.Value.OnDeviceCardholderVerificationSupported) { #region 3.75 database.ReaderContactlessTransactionLismit = Formatting.BcdToLong(database.Get(EMVTagsEnum.READER_CONTACTLESS_TRANSACTION_LIMIT_ONDEVICE_CVM_DF8125_KRN2).Value); #endregion } else { #region 3.74 database.ReaderContactlessTransactionLismit = Formatting.BcdToLong(database.Get(EMVTagsEnum.READER_CONTACTLESS_TRANSACTION_LIMIT_NO_ONDEVICE_CVM_DF8124_KRN2).Value); #endregion } #endregion #region 3.76 TLVList dataToSend = database.Get(EMVTagsEnum.DATA_TO_SEND_FF8104_KRN2).Children; TLVList tagsToRemove = new TLVList(); foreach (TLV ttry in database.TagsToReadYet) { if (database.IsNotEmpty(ttry.Tag.TagLable)) { dataToSend.AddToList(ttry); tagsToRemove.AddToList(ttry); } } foreach (TLV ttr in tagsToRemove) { database.TagsToReadYet.RemoveFromList(ttr); } #endregion #region 3.77 if (database.IsNotEmptyList(EMVTagsEnum.DATA_NEEDED_DF8106_KRN2.Tag) || (database.IsNotEmptyList(EMVTagsEnum.DATA_TO_SEND_FF8104_KRN2.Tag) && database.TagsToReadYet.Count == 0)) { #region 3.78 CommonRoutines.PostDEK(database, qManager); database.Get(EMVTagsEnum.DATA_TO_SEND_FF8104_KRN2).Initialize(); database.Get(EMVTagsEnum.DATA_NEEDED_DF8106_KRN2).Initialize(); #endregion } #region 3.80 EMVReadRecordRequest request = new EMVReadRecordRequest(database.ActiveAFL.Value.Entries[0].SFI, database.ActiveAFL.Value.Entries[0].FirstRecordNumber); #endregion #region 3.81 cardQManager.EnqueueToInput(new CardRequest(request, CardinterfaceServiceRequestEnum.ADPU)); #endregion return(SignalsEnum.WAITING_FOR_MAG_STRIPE_READ_RECORD_RESPONSE); #endregion }
/* * S3.1 */ private static SignalsEnum EntryPointRA(Kernel2Database database, CardResponse cardResponse, KernelQ qManager, CardQ cardQManager, Stopwatch sw) { #region S3.8 if (!cardResponse.ApduResponse.Succeeded) #endregion { #region 3.9.1 and 3.9.2 return(CommonRoutines.PostOutcome(database, qManager, KernelMessageidentifierEnum.ERROR_OTHER_CARD, KernelStatusEnum.NOT_READY, null, Kernel2OutcomeStatusEnum.SELECT_NEXT, Kernel2StartEnum.C, null, KernelMessageidentifierEnum.ERROR_OTHER_CARD, L1Enum.NOT_SET, cardResponse.ApduResponse.SW12, L2Enum.STATUS_BYTES, L3Enum.NOT_SET)); #endregion } #region S3.10 bool parsingResult = false; if (cardResponse.ApduResponse.ResponseData.Length > 0 && cardResponse.ApduResponse.ResponseData[0] == 0x77) { EMVGetProcessingOptionsResponse response = cardResponse.ApduResponse as EMVGetProcessingOptionsResponse; parsingResult = database.ParseAndStoreCardResponse(response.ResponseData); } else { if (cardResponse.ApduResponse.ResponseData.Length > 0 && cardResponse.ApduResponse.ResponseData[0] == 0x80) { EMVGetProcessingOptionsResponse response = cardResponse.ApduResponse as EMVGetProcessingOptionsResponse; if (cardResponse.ApduResponse.ResponseData.Length < 6 || ((cardResponse.ApduResponse.ResponseData.Length - 2) % 4 != 0) || database.IsNotEmpty(EMVTagsEnum.APPLICATION_INTERCHANGE_PROFILE_82_KRN.Tag) || database.IsNotEmpty(EMVTagsEnum.APPLICATION_FILE_LOCATOR_AFL_94_KRN.Tag)) { parsingResult = false; } else { //database.Get(EMVTagsEnum.APPLICATION_INTERCHANGE_PROFILE_82_KRN).Value = new byte[] { cardResponse.ApduResponse.ResponseData[0], cardResponse.ApduResponse.ResponseData[1]}; //byte[] afl = new byte[cardResponse.ApduResponse.ResponseData.Length - 2]; //Array.Copy(cardResponse.ApduResponse.ResponseData, 2, afl, 0, afl.Length); //database.Get(EMVTagsEnum.APPLICATION_FILE_LOCATOR_AFL_94_KRN).Value = afl; //EMVGetProcessingOptionsResponse does the unpacking of the tags foreach (TLV tlv in response.GetResponseTags()) { parsingResult = database.ParseAndStoreCardResponse(tlv); if (!parsingResult) { break; } } } } } #endregion #region S3.11 if (!parsingResult) { #region S3.12 return(State_3_R1_CommonProcessing.DoInvalidReponse(database, qManager, L1Enum.NOT_SET, L2Enum.PARSING_ERROR, L3Enum.NOT_SET)); #endregion } else { #region S3.13 if (!(database.IsNotEmpty(EMVTagsEnum.APPLICATION_INTERCHANGE_PROFILE_82_KRN.Tag)) && database.IsNotEmpty(EMVTagsEnum.APPLICATION_FILE_LOCATOR_AFL_94_KRN.Tag)) { #region S3.14 return(State_3_R1_CommonProcessing.DoInvalidReponse(database, qManager, L1Enum.NOT_SET, L2Enum.CARD_DATA_MISSING, L3Enum.NOT_SET)); #endregion } else { #region S3.15 KERNEL_CONFIGURATION_DF811B_KRN2 kc = new KERNEL_CONFIGURATION_DF811B_KRN2(database); if (!kc.Value.EMVModeContactlessTransactionsNotSupported) { #region S3.16 APPLICATION_INTERCHANGE_PROFILE_82_KRN aip = new APPLICATION_INTERCHANGE_PROFILE_82_KRN(database); if (aip.Value.EMVModeIsSupported) { //goto 3.30 return(DoEMVMode(database, qManager, cardQManager, cardResponse, sw)); } #endregion } #region S3.17 if (kc.Value.MagStripeModeContactlessTransactionsNotSupported) { #region S3.18 return(State_3_R1_CommonProcessing.DoInvalidReponse(database, qManager, L1Enum.NOT_SET, L2Enum.MAGSTRIPE_NOT_SUPPORTED, L3Enum.NOT_SET)); #endregion } else { //goto 3.70 return(DoMagMode(database, qManager, cardQManager)); } #endregion #endregion } #endregion } #endregion }
private static SignalsEnum DoEMVMode(Kernel2Database database, KernelQ qManager, CardQ cardQManager, CardResponse cardResponse, Stopwatch sw) { #region 3.30 KERNEL_CONFIGURATION_DF811B_KRN2 kc = new KERNEL_CONFIGURATION_DF811B_KRN2(database); TLV aflRaw = database.Get(EMVTagsEnum.APPLICATION_FILE_LOCATOR_AFL_94_KRN); byte[] kcValCheck = new byte[4]; Array.Copy(aflRaw.Value, 0, kcValCheck, 0, kcValCheck.Length); if (aflRaw.Value.Length >= 4 && Formatting.ByteArrayToHexString(kcValCheck) == "08010100" && !kc.Value.MagStripeModeContactlessTransactionsNotSupported) { #region 3.32 byte[] activeAFLBytes = new byte[aflRaw.Value.Length - 4]; Array.Copy(aflRaw.Value, 4, activeAFLBytes, 0, activeAFLBytes.Length); List <byte[]> bytes = new List <byte[]> { new byte[] { (byte)activeAFLBytes.Length }, activeAFLBytes }; database.ActiveAFL.Value.Deserialize(bytes.SelectMany(a => a).ToArray(), 0); //database.ActiveAFL.Value.Entries.Add(new FILE_LOCATOR_ENTRY(activeAFLBytes)); #endregion } else { #region 3.31 List <byte[]> bytes = new List <byte[]> { new byte[] { (byte)aflRaw.Value.Length }, aflRaw.Value }; database.ActiveAFL.Value.Deserialize(bytes.SelectMany(a => a).ToArray(), 0); //database.ActiveAFL.Value.Entries.Add(new FILE_LOCATOR_ENTRY(aflRaw.Value)); #endregion } #endregion #region 3.33 APPLICATION_INTERCHANGE_PROFILE_82_KRN aip = new APPLICATION_INTERCHANGE_PROFILE_82_KRN(database); if (aip.Value.OnDeviceCardholderVerificationIsSupported && kc.Value.OnDeviceCardholderVerificationSupported) { #region 3.35 database.ReaderContactlessTransactionLismit = Formatting.BcdToLong(database.Get(EMVTagsEnum.READER_CONTACTLESS_TRANSACTION_LIMIT_ONDEVICE_CVM_DF8125_KRN2).Value); #endregion } else { #region 3.34 database.ReaderContactlessTransactionLismit = Formatting.BcdToLong(database.Get(EMVTagsEnum.READER_CONTACTLESS_TRANSACTION_LIMIT_NO_ONDEVICE_CVM_DF8124_KRN2).Value); #endregion } #endregion #region 3.60 if (kc.Value.RelayResistanceProtocolSupported && aip.Value.RelayResistanceProtocolIsSupported) #endregion { #region 3.61 database.Get(EMVTagsEnum.UNPREDICTABLE_NUMBER_9F37_KRN).Value = Formatting.GetRandomNumber(); database.Get(EMVTagsEnum.TERMINAL_RELAY_RESISTANCE_ENTROPY_DF8301_KRN2).Value = database.Get(EMVTagsEnum.UNPREDICTABLE_NUMBER_9F37_KRN).Value; #endregion #region 3.62 EMVExchangeRelayResistanceDataRequest request = new EMVExchangeRelayResistanceDataRequest(database.Get(EMVTagsEnum.TERMINAL_RELAY_RESISTANCE_ENTROPY_DF8301_KRN2).Value); #endregion #region 3.63 sw.Start(); #endregion #region 3.64 cardQManager.EnqueueToInput(new CardRequest(request, CardinterfaceServiceRequestEnum.ADPU)); #endregion return(SignalsEnum.WAITING_FOR_EXCHANGE_RELAY_RESISTANCE_DATA_RESPONSE); } else { #region 3.65 TERMINAL_VERIFICATION_RESULTS_95_KRN tvr = new TERMINAL_VERIFICATION_RESULTS_95_KRN(database); tvr.Value.RelayResistancePerformedEnum = RelayResistancePerformedEnum.RRP_NOT_PERFORMED; tvr.UpdateDB(); #endregion return(State_3_R1_CommonProcessing.DoCommonProcessing("State_3_WaitingForGPOResponse", database, qManager, cardQManager, cardResponse)); } }