SelectAppChosen(CardQProcessor cardInterfaceManager, TerminalSupportedKernelAidTransactionTypeCombination supportedKernelAidCombination, CardKernelAidCombination candidate) { string finalAdfName = Formatting.ByteArrayToHexString(candidate.AdfNameTag.Value); ApduResponse cardResponse = cardInterfaceManager.SendCommand(new EMVSelectApplicationRequest(finalAdfName)) as EMVSelectApplicationResponse; EMVSelectApplicationResponse response; if (cardResponse is EMVSelectApplicationResponse) { response = (EMVSelectApplicationResponse)cardResponse; } else { throw new EMVProtocolException("Pre-processing transmit error: try again"); } if (!response.Succeeded) { return(Tuple.Create( new EMVTerminalProcessingOutcome() { NextProcessState = EMVTerminalPreProcessingStateEnum.CombinationSelection_StartC }, response, supportedKernelAidCombination)); } //TLV ttqInPDOL = response.GetPDOLTags().Get(EMVTagsEnum.TERMINAL_TRANSACTION_QUALIFIERS_TTQ_9F66_KRN.Tag); return(Tuple.Create( new EMVTerminalProcessingOutcome() { NextProcessState = EMVTerminalPreProcessingStateEnum.KernelActivation_StartD }, response, supportedKernelAidCombination)); }
CombinationSelection_C(EMVTerminalPreProcessingStateEnum parent) { Tuple <EMVTerminalProcessingOutcome, EMVSelectApplicationResponse, TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination, List <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> > > result; switch (parent) { case EMVTerminalPreProcessingStateEnum.Preprocessing_StartA: result = EMVContactCombinationSelection.CombinationSelection_FromA(cardQProcessor, uiProvider); lastCandidateSelected = Tuple.Create(result.Item1, result.Item2, result.Item3, result.Item4); break; case EMVTerminalPreProcessingStateEnum.ProtocolActivation_StartB: result = EMVContactCombinationSelection.CombinationSelection_FromB(cardQProcessor, lastCandidateSelected, candidates, uiProvider); break; case EMVTerminalPreProcessingStateEnum.CombinationSelection_StartC: preProcessingValues.RemoveAll(x => ((TerminalSupportedContactKernelAidTransactionTypeCombination)x.Item1).AIDEnum == ((TerminalSupportedContactKernelAidTransactionTypeCombination)lastCandidateSelected.Item3).AIDEnum); candidates.RemoveAll(x => ((TerminalSupportedContactKernelAidTransactionTypeCombination)x.Item1).AIDEnum == ((TerminalSupportedContactKernelAidTransactionTypeCombination)lastCandidateSelected.Item3).AIDEnum); result = EMVContactCombinationSelection.CombinationSelection_FromC(cardQProcessor, candidates, uiProvider); lastCandidateSelected = Tuple.Create(result.Item1, result.Item2, result.Item3, result.Item4); break; default: throw new EMVProtocolException("unimplemeted TerminalPreProcessingStateEnum in CombinationSelection"); } if (result.Item1.NextProcessState == EMVTerminalPreProcessingStateEnum.EndProcess) { return(Tuple.Create(result.Item1, (EMVSelectApplicationResponse)null, (TerminalSupportedKernelAidTransactionTypeCombination)null, (CardKernelAidCombination)null, (EntryPointPreProcessingIndicators)null)); } candidates = result.Item5; TerminalSupportedKernelAidTransactionTypeCombination terminalCombinationForSelected = result.Item3; List <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, EntryPointPreProcessingIndicators> > filteredIndicators = preProcessingValues.Where(x => (((TerminalSupportedContactKernelAidTransactionTypeCombination)x.Item1).AIDEnum == ((TerminalSupportedContactKernelAidTransactionTypeCombination)terminalCombinationForSelected).AIDEnum)).ToList(); if (filteredIndicators.Count == 0) { result.Item1.NextProcessState = EMVTerminalPreProcessingStateEnum.EndProcess; return(Tuple.Create(result.Item1, result.Item2, result.Item3, result.Item4, (EntryPointPreProcessingIndicators)null)); } EntryPointPreProcessingIndicators processingIndicatorsForSelected = filteredIndicators.Select(x => x.Item2).ToList().First(); return(Tuple.Create(result.Item1, result.Item2, result.Item3, result.Item4, processingIndicatorsForSelected)); }
public static KernelBase ActivateKernel( TransactionRequest tt, CardQProcessor cardInterface, PublicKeyCertificateManager publicKeyCertificateManager, EMVSelectApplicationResponse response, TerminalSupportedKernelAidTransactionTypeCombination terminalCombinationForSelected, CardKernelAidCombination cardCombinationForSelected, EntryPointPreProcessingIndicators processingIndicatorsForSelected, CardExceptionManager cardExceptionManager, IConfigurationProvider configProvider ) //the response from the selected aid command { return(new Kernel(tt.GetTransactionType_9C(), cardInterface, publicKeyCertificateManager, processingIndicatorsForSelected, cardExceptionManager, configProvider, response)); }
public static KernelBase ActivateKernel( TransactionRequest tt, CardQProcessor cardInterface, TornTransactionLogManager tornTransactionLogManager, PublicKeyCertificateManager publicKeyCertificateManager, EMVSelectApplicationResponse response, TerminalSupportedKernelAidTransactionTypeCombination terminalCombinationForSelected, CardKernelAidCombination cardCombinationForSelected, EntryPointPreProcessingIndicators processingIndicatorsForSelected, CardExceptionManager cardExceptionManager, IConfigurationProvider configProvider ) //the response from the selected aid command { switch (((TerminalSupportedContactlessKernelAidTransactionTypeCombination)terminalCombinationForSelected).KernelEnum) { case KernelEnum.Kernel1: EMVTagsEnum.DataKernelID = DataKernelID.K1; return(new Kernel1(tt.GetTransactionType_9C(), cardInterface, publicKeyCertificateManager, processingIndicatorsForSelected, cardExceptionManager, configProvider)); case KernelEnum.Kernel2: EMVTagsEnum.DataKernelID = DataKernelID.K2; return(new Kernel2(tt.GetTransactionType_9C(), tornTransactionLogManager, cardInterface, publicKeyCertificateManager, processingIndicatorsForSelected, cardExceptionManager, configProvider)); case KernelEnum.Kernel3: EMVTagsEnum.DataKernelID = DataKernelID.K3; return(new Kernel3(tt.GetTransactionType_9C(), cardInterface, publicKeyCertificateManager, processingIndicatorsForSelected, cardExceptionManager, configProvider)); case KernelEnum.Kernel4: break; case KernelEnum.Kernel5: break; case KernelEnum.Kernel6: break; case KernelEnum.Kernel7: break; default: throw new EMVProtocolException("Unsupported kernel: " + ((TerminalSupportedContactlessKernelAidTransactionTypeCombination)terminalCombinationForSelected).KernelEnum); } throw new EMVProtocolException("Unsupported kernel: " + ((TerminalSupportedContactlessKernelAidTransactionTypeCombination)terminalCombinationForSelected).KernelEnum); }
FinalCombinationSelection_Step3_From_3_3_3_3(CardQProcessor cardInterfaceManager, TerminalSupportedKernelAidTransactionTypeCombination supportedKernelAidCombination, CardKernelAidCombination candidate, TLV iad, TLV scriptData) { string finalAdfName = Formatting.ByteArrayToHexString(candidate.AdfNameTag.Value); #region 3.3.3.3 if (candidate.ExtendedSelectionTag.IsPresent() && ((TerminalSupportedContactlessKernelAidTransactionTypeCombination)supportedKernelAidCombination).ExtendedSelectionSupportFlag != null && (bool)((TerminalSupportedContactlessKernelAidTransactionTypeCombination)supportedKernelAidCombination).ExtendedSelectionSupportFlag) { finalAdfName = finalAdfName + Formatting.ByteArrayToHexString(candidate.ExtendedSelectionTag.Get().Value); } #endregion #region 3.3.3.4 ApduResponse cardResponse = cardInterfaceManager.SendCommand(new EMVSelectApplicationRequest(finalAdfName)) as EMVSelectApplicationResponse; EMVSelectApplicationResponse response; if (cardResponse is EMVSelectApplicationResponse) { response = (EMVSelectApplicationResponse)cardResponse; } else { throw new EMVProtocolException("Pre-processing transmit error: try again"); } #endregion #region 3.3.3.5 if (!response.Succeeded) #endregion { if (iad != null || scriptData != null) { return(Tuple.Create( new EMVTerminalProcessingOutcome() { NextProcessState = EMVTerminalPreProcessingStateEnum.EndProcess, UIRequestOnOutcomePresent = true, UserInterfaceRequest = new UserInterfaceRequest() { MessageIdentifier = MessageIdentifiersEnum.InsertSwipeOrTryAnotherCard, Status = StatusEnum.ReadyToRead }, UIRequestOnRestartPresent = false }, response, supportedKernelAidCombination)); } else { return(Tuple.Create( new EMVTerminalProcessingOutcome() { NextProcessState = EMVTerminalPreProcessingStateEnum.CombinationSelection_StartC }, response, supportedKernelAidCombination)); } } TLV ttqInPDOL = response.GetPDOLTags().Get(EMVTagsEnum.TERMINAL_TRANSACTION_QUALIFIERS_TTQ_9F66_KRN.Tag); #region 3.3.3.6 if (finalAdfName.StartsWith(Enum.GetName(typeof(RIDEnum), RIDEnum.A000000003))) #endregion { if (((TerminalSupportedContactlessKernelAidTransactionTypeCombination)supportedKernelAidCombination).KernelEnum == KernelEnum.Kernel3) { if (response.GetPDOLTags().Count == 0 || ttqInPDOL == null) { if (TerminalSupportedKernelAidTransactionTypeCombinations.SupportedContactlessCombinations.Where(x => x.KernelEnum == KernelEnum.Kernel1).ToList().Count > 0) { //switch kernel to enable to kernel 1 TerminalSupportedKernelAidTransactionTypeCombination val = TerminalSupportedKernelAidTransactionTypeCombinations.SupportedContactlessCombinations.Where(x => x.KernelEnum == KernelEnum.Kernel1).ElementAt(0); return(Tuple.Create( new EMVTerminalProcessingOutcome() { NextProcessState = EMVTerminalPreProcessingStateEnum.KernelActivation_StartD }, response, val)); } else { return(Tuple.Create( new EMVTerminalProcessingOutcome() { NextProcessState = EMVTerminalPreProcessingStateEnum.CombinationSelection_StartC }, response, supportedKernelAidCombination)); } } } } //we will not support Application Selection Registered Proprietary Data (ASRPD) and continue as if the data was not present return(Tuple.Create( new EMVTerminalProcessingOutcome() { NextProcessState = EMVTerminalPreProcessingStateEnum.KernelActivation_StartD }, response, supportedKernelAidCombination)); }