CreateCandidateListFromPSERecords(TLVList directoryEntries)
        {
            List <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> > candidateList = new List <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> >();

            foreach (TLV tlv in directoryEntries)
            {
                TLV            adfNameTag = tlv.Children.Get(EMVTagsEnum.APPLICATION_DEDICATED_FILE_ADF_NAME_4F_KRN.Tag);
                TLV            applicationPriorityIndicatorTag = tlv.Children.Get(EMVTagsEnum.APPLICATION_PRIORITY_INDICATOR_87_KRN.Tag);
                Optional <TLV> extendedSelectionTag            = Optional <TLV> .Create(tlv.Children.Get(EMVTagsEnum.EXTENDED_SELECTION_9F29_KRN.Tag));

                TLV preferedName = tlv.Children.Get(EMVTagsEnum.APPLICATION_PREFERRED_NAME_9F12_KRN.Tag);
                TLV appLabel     = tlv.Children.Get(EMVTagsEnum.APPLICATION_LABEL_50_KRN.Tag);

                if (adfNameTag == null)
                {
                    break;
                }

                if (adfNameTag.Value.Length < 5 || adfNameTag.Value.Length > 16)
                {
                    break;
                }

                foreach (TerminalSupportedKernelAidTransactionTypeCombination kc in TerminalSupportedKernelAidTransactionTypeCombinations.SupportedContactCombinations)
                {
                    string terminalAID = Enum.GetName(typeof(AIDEnum), ((TerminalSupportedContactKernelAidTransactionTypeCombination)kc).AIDEnum);
                    string cardAid     = Formatting.ByteArrayToHexString(adfNameTag.Value);

                    if (terminalAID != cardAid && !cardAid.StartsWith(terminalAID))
                    {
                        continue;
                    }

                    if (terminalAID == cardAid)
                    {
                        //full match
                    }

                    if (cardAid.StartsWith(terminalAID))
                    {
                        //matching aid, partial match, check if partial match allowed
                        if (!((TerminalSupportedContactKernelAidTransactionTypeCombination)kc).ApplicationSelectionIndicator)
                        {
                            continue;
                        }
                    }

                    candidateList.Add(Tuple.Create(kc, new CardKernelAidCombination()
                    {
                        AdfNameTag = adfNameTag,
                        ApplicationPriorityIndicatorTag = applicationPriorityIndicatorTag,
                        ApplicationPreferredName        = preferedName,
                        ApplicationLabel     = appLabel,
                        ExtendedSelectionTag = extendedSelectionTag,
                    }));
                }
            }

            return(candidateList);
        }
        public TLVList GetResponseTags()
        {
            try
            {
                TLVList result = new TLVList();
                if (tlvResponse.Tag.TagLable == EMVTagsEnum.RESPONSE_MESSAGE_TEMPLATE_FORMAT_1_80_KRN.Tag)
                {
                    byte[] DeviceRelayResistanceEntropy            = new byte[4];
                    byte[] MinTimeForProcessingRelayResistanceAPDU = new byte[2];
                    byte[] MaxTimeForProcessingRelayResistanceAPDU = new byte[2];
                    byte[] DeviceEstimatedTransmissionTimeForRelayResistanceRAPDU = new byte[2];

                    Array.Copy(tlvResponse.Value, 0, DeviceRelayResistanceEntropy, 0, 4);
                    Array.Copy(tlvResponse.Value, 4, MinTimeForProcessingRelayResistanceAPDU, 0, 2);
                    Array.Copy(tlvResponse.Value, 6, MaxTimeForProcessingRelayResistanceAPDU, 0, 2);
                    Array.Copy(tlvResponse.Value, 8, DeviceEstimatedTransmissionTimeForRelayResistanceRAPDU, 0, 2);

                    result.AddToList(TLV.Create(EMVTagsEnum.DEVICE_RELAY_RESISTANCE_ENTROPY_DF8302_KRN2.Tag, DeviceRelayResistanceEntropy));
                    result.AddToList(TLV.Create(EMVTagsEnum.MIN_TIME_FOR_PROCESSING_RELAY_RESISTANCE_APDU_DF8303_KRN2.Tag, MinTimeForProcessingRelayResistanceAPDU));
                    result.AddToList(TLV.Create(EMVTagsEnum.MAX_TIME_FOR_PROCESSING_RELAY_RESISTANCE_APDU_DF8304_KRN2.Tag, MaxTimeForProcessingRelayResistanceAPDU));
                    result.AddToList(TLV.Create(EMVTagsEnum.DEVICE_ESTIMATED_TRANSMISSION_TIME_FOR_RELAY_RESISTANCE_RAPDU_DF8305_KRN2.Tag, DeviceEstimatedTransmissionTimeForRelayResistanceRAPDU));
                }
                else
                {
                    throw new EMVProtocolException("Unrecognised template received from Get Processing Options");
                }

                return(result);
            }
            catch (Exception ex)
            { throw new EMVProtocolException("RESPONSE_MESSAGE_TEMPLATE_FORMAT_1_80_KRN Tag not found:" + ex.Message); }
        }
Пример #3
0
        protected override void DoEntryPointD(Tuple <EMVTerminalProcessingOutcome, EMVSelectApplicationResponse, TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination, EntryPointPreProcessingIndicators> indicators)
        {
            //3.4.1.1
            KernelBase kernel = EMVContactlessKernelActivation.ActivateKernel(tr, cardQProcessor, tornTransactionLogManager, publicKeyCertificateManager, indicators.Item2, indicators.Item3, indicators.Item4, indicators.Item5, cardExceptionManager, configProvider);

            kernel.ExceptionOccured += Kernel_ExceptionOccured;

            //TODO: change config to load only kernel specific tags
            terminalConfigurationData.LoadTerminalConfigurationDataObjects(((TerminalSupportedContactlessKernelAidTransactionTypeCombination)indicators.Item3).KernelEnum, configProvider);

            TLVList requestInput = new TLVList();

            requestInput.AddToList(indicators.Item2.GetFCITemplateTag());
            requestInput.AddListToList(tr.GetTxDataTLV());
            //TERMINAL_TRANSACTION_QUALIFIERS_9F66_KRN ttq = ((TerminalSupportedContactlessKernelAidTransactionTypeCombination)indicators.Item3).TTQ;
            TERMINAL_TRANSACTION_QUALIFIERS_9F66_KRN ttq = indicators.Item5.TTQ;

            if (ttq != null)
            {
                requestInput.AddToList(TLV.Create(EMVTagsEnum.TERMINAL_TRANSACTION_QUALIFIERS_TTQ_9F66_KRN.Tag, ttq.Value.Value));
            }

            KernelRequest request = new KernelRequest(KernelTerminalReaderServiceRequestEnum.ACT, requestInput);

            kernel.KernelQ.EnqueueToInput(request);
            Task.Run(() => kernel.StartNewTransaction(), cancellationTokenForTerminalApplication.Token);
            Task.Run(() => OnProcessCompleted(StartServiceQPRocess(kernel)));
        }
Пример #4
0
        private static EMVGetProcessingOptionsResponse genGPOResponse(bool includeSDAD, TLVList db)
        {
            TLVList response = new TLVList();

            //from perso
            response.AddToList(PersoAndCardStateStorage.APPLICATION_INTERCHANGE_PROFILE_82_KRN);
            response.AddToList(PersoAndCardStateStorage.TRACK_2_EQUIVALENT_DATA_57_KRN);
            response.AddToList(PersoAndCardStateStorage.CARDHOLDER_NAME_5F20_KRN);
            response.AddToList(PersoAndCardStateStorage.APPLICATION_PRIMARY_ACCOUNT_NUMBER_PAN_5A_KRN);
            response.AddToList(PersoAndCardStateStorage.APPLICATION_PRIMARY_ACCOUNT_NUMBER_PAN_SEQUENCE_NUMBER_5F34_KRN);
            response.AddToList(PersoAndCardStateStorage.FORM_FACTOR_INDICATOR_FFI_9F6E_KRN3);
            response.AddToList(PersoAndCardStateStorage.CUSTOMER_EXCLUSIVE_DATA_CED_9F7C_KRN3);

            //from storage and calculated
            response.AddToList(db.Get(EMVTagsEnum.APPLICATION_TRANSACTION_COUNTER_ATC_9F36_KRN.Tag));

            //calculated
            response.AddToList(db.Get(EMVTagsEnum.ISSUER_APPLICATION_DATA_9F10_KRN.Tag));
            response.AddToList(db.Get(EMVTagsEnum.APPLICATION_CRYPTOGRAM_9F26_KRN.Tag));
            response.AddToList(db.Get(EMVTagsEnum.CRYPTOGRAM_INFORMATION_DATA_9F27_KRN.Tag));
            response.AddToList(db.Get(EMVTagsEnum.CARD_TRANSACTION_QUALIFIERS_CTQ_9F6C_KRN3.Tag));
            if (includeSDAD)
            {
                response.AddToList(db.Get(EMVTagsEnum.SIGNED_DYNAMIC_APPLICATION_DATA_9F4B_KRN.Tag));
            }

            TLV _77 = TLV.Create(EMVTagsEnum.RESPONSE_MESSAGE_TEMPLATE_FORMAT_2_77_KRN.Tag, response.Serialize());

            EMVGetProcessingOptionsResponse resp = new EMVGetProcessingOptionsResponse();

            resp.SW1          = 0x90;
            resp.SW2          = 0x00;
            resp.ResponseData = _77.Serialize();
            return(resp);
        }
Пример #5
0
        private static TLVList DeserList(tlvXMLType[] serXML)
        {
            TLVList result = new TLVList();

            serXML.ToList().ForEach((x) =>
            {
                TLV tlvToAdd = TLV.Create(x.tag.Name);
                //x.tag.Description = TLVMetaDataSourceSingleton.Instance.DataSource.GetName(tlvToAdd.Tag.TagLable);
                result.AddToList(tlvToAdd);
                if (x.children != null)
                {
                    tlvToAdd.Children.AddListToList(DeserList(x.children));
                }
                else
                {
                    if (x.value != null)
                    {
                        if (x.value.Formatting == FormattingEnum.ASCII)
                        {
                            tlvToAdd.Value = Formatting.ASCIIStringToByteArray(x.value.Value);
                        }
                        else
                        {
                            tlvToAdd.Value = Formatting.HexStringToByteArray(x.value.Value);
                        }
                    }
                    if (x.valueC9 != null)
                    {
                    }
                }
            });
            return(result);
        }
        public TLVList GetResponseTags()
        {
            try
            {
                TLVList result = new TLVList();
                if (tlvResponse.Tag.TagLable == EMVTagsEnum.RESPONSE_MESSAGE_TEMPLATE_FORMAT_1_80_KRN.Tag)
                {
                    byte[] aip = EMVTagsEnum.APPLICATION_INTERCHANGE_PROFILE_82_KRN.InitValue();
                    byte[] afl = new byte[tlvResponse.Value.Length - aip.Length];
                    Array.Copy(tlvResponse.Value, 0, aip, 0, aip.Length);
                    Array.Copy(tlvResponse.Value, aip.Length, afl, 0, afl.Length);
                    result.AddToList(TLV.Create(EMVTagsEnum.APPLICATION_INTERCHANGE_PROFILE_82_KRN.Tag, aip));
                    result.AddToList(TLV.Create(EMVTagsEnum.APPLICATION_FILE_LOCATOR_AFL_94_KRN.Tag, afl));
                }
                else if (tlvResponse.Tag.TagLable == EMVTagsEnum.RESPONSE_MESSAGE_TEMPLATE_FORMAT_2_77_KRN.Tag)
                {
                    return(tlvResponse.Children);
                }
                else
                {
                    throw new EMVProtocolException("Unrecognised template received from Get Processing Options");
                }

                return(result);
            }
            catch (Exception ex)
            { throw new EMVProtocolException("APPLICATION_IDENTIFIER_CARD_4F Tag not found:" + ex.Message); }
        }
Пример #7
0
        public static byte[] PackRelatedDataTag(KernelDatabaseBase database, TLV tagListForPack)
        {
            List <byte[]> tlvRelatedDataBytes = new List <byte[]>();
            TLVList       tags = TLV.DeserializeChildrenWithNoV(tagListForPack.Value, 0);

            Logger.Log("Packing tag: " + tagListForPack.ToString());
            foreach (TLV tlv in tags)
            {
                TLV valForPackDb = database.Get(tlv.Tag.TagLable);
                TLV valForPack;
                if (valForPackDb == null)
                {
                    valForPack = TLV.Create(tlv.Tag.TagLable);
                }
                else
                {
                    byte[] copyVal = new byte[valForPackDb.Value.Length];
                    Array.Copy(valForPackDb.Value, copyVal, valForPackDb.Value.Length);
                    valForPack = TLV.Create(tlv.Tag.TagLable, copyVal);
                }
                valForPack.Val.PackValue(tlv.Val.GetLength());
                Logger.Log("Adding tag: " + valForPack.ToString());
                tlvRelatedDataBytes.Add(valForPack.Value);
            }
            return(tlvRelatedDataBytes.SelectMany(a => a).ToArray());
        }
Пример #8
0
        public TLVList GetResponseTags()
        {
            TLVList ret = new TLVList();

            ret.AddToList(GetTLVResponse());
            return(ret);
        }
Пример #9
0
        public override TLVList getArguments()
        {
            TLVList list = new TLVList();

            if (_handle == null)
            {
                throw new MalformedMessageException("Detach header's handle can't be null");
            }

            list.addElement(0, AMQPWrapper <AMQPSymbol> .wrap(_handle));

            if (_closed != null)
            {
                list.addElement(1, AMQPWrapper <AMQPSymbol> .wrap(_closed));
            }

            if (_error != null)
            {
                list.addElement(2, _error.getList());
            }

            DescribedConstructor constructor = new DescribedConstructor(list.Code, new TLVFixed(AMQPType.SMALL_ULONG, new byte[] { (byte)_code }));

            list.Constructor = constructor;

            return(list);
        }
        public override TLVList getArguments()
        {
            TLVList list = new TLVList();

            if (_mechanism == null)
            {
                throw new MalformedMessageException("SASL-Init header's mechanism can't be null");
            }

            list.addElement(0, AMQPWrapper <AMQPSymbol> .wrap(_mechanism));

            if (_initialResponse != null)
            {
                list.addElement(1, AMQPWrapper <AMQPSymbol> .wrap(_initialResponse));
            }

            if (_hostName != null)
            {
                list.addElement(2, AMQPWrapper <AMQPSymbol> .wrap(_hostName));
            }

            DescribedConstructor constructor = new DescribedConstructor(list.Code, new TLVFixed(AMQPType.SMALL_ULONG, new byte[] { 0x41 }));

            list.Constructor = constructor;

            return(list);
        }
        private static TLVList ReadAllPSERecords(TLV sfi, CardQProcessor cardInterfaceManager)
        {
            byte    record = 1;
            TLVList _61    = new TLVList();

            while (record != 0)
            {
                EMVReadRecordRequest request = new EMVReadRecordRequest(sfi.Value[0], record);

                //do read record commands starting with record 1 untill the card returns 6A83
                ApduResponse cardResponse = cardInterfaceManager.SendCommand(request);
                if (cardResponse is EMVReadRecordResponse)
                {
                    if (cardResponse.Succeeded)
                    {
                        TLVList tags = (cardResponse as EMVReadRecordResponse).GetResponseTags();
                        foreach (TLV tlv in tags)
                        {
                            _61.AddToList(tlv, true);
                        }
                        record++;
                    }
                    else
                    {
                        record = 0;
                    }
                }
                else
                {
                    throw new EMVProtocolException("ReadAllRecords transmit error");
                }
            }
            return(_61);
        }
Пример #12
0
        public override void fillArguments(TLVList list)
        {
            int size = list.getList().Count;

            if (size == 0)
            {
                throw new MalformedMessageException("Received malformed SASL-Challenge header: challenge can't be null");
            }

            if (size > 1)
            {
                throw new MalformedMessageException("Received malformed SASL-Challenge header. Invalid number of arguments: " + size);
            }

            if (size > 0)
            {
                TLVAmqp element = list.getList()[0];
                if (element.isNull())
                {
                    throw new MalformedMessageException("Received malformed SASL-Challenge header: challenge can't be null");
                }

                _challenge = AMQPUnwrapper <AMQPSymbol> .unwrapBinary(element);
            }
        }
        public TLVList getList()
        {
            TLVList list = new TLVList();

            if (_condition != null)
            {
                list.addElement(0, AMQPWrapper <AMQPSymbol> .wrap(new AMQPSymbol(StringEnum.GetStringValue(_condition))));
            }

            if (_description != null)
            {
                list.addElement(1, AMQPWrapper <AMQPSymbol> .wrap(_description));
            }

            if (_info != null)
            {
                list.addElement(2, AMQPWrapper <AMQPSymbol> .wrapMap(_info));
            }

            DescribedConstructor constructor = new DescribedConstructor(list.Code, new TLVFixed(AMQPType.SMALL_ULONG, new byte[] { 0x1D }));

            list.Constructor = constructor;

            return(list);
        }
        public void fill(TLVList list)
        {
            if (list.getList().Count > 0)
            {
                TLVAmqp element = list.getList()[0];
                if (!element.isNull())
                {
                    _condition = (ErrorCodes)StringEnum.Parse(typeof(ErrorCodes), AMQPUnwrapper <AMQPSymbol> .unwrapSymbol(element).Value);
                }
            }

            if (list.getList().Count > 1)
            {
                TLVAmqp element = list.getList()[1];
                if (!element.isNull())
                {
                    _description = AMQPUnwrapper <AMQPSymbol> .unwrapString(element);
                }
            }

            if (list.getList().Count > 2)
            {
                TLVAmqp element = list.getList()[2];
                if (!element.isNull())
                {
                    _info = AMQPUnwrapper <AMQPSymbol> .unwrapMap(element);
                }
            }
        }
Пример #15
0
        public virtual void Deserialize(byte[] input)
        {
            int pos = 0;

            DGI = new byte[2];
            Array.Copy(input, pos, DGI, 0, 2);
            pos = pos + 2;

            DGILength = input[pos];
            pos++;

            DataBytes = new byte[DGILength];
            Array.Copy(input, pos, DataBytes, 0, DGILength);
            pos = pos + DGILength;

            DGIMeta = DGITagsList.GetMeta(Formatting.ByteArrayToHexString(DGI), DataBytes[0]);
            if (DGIMeta.IsTLVFormatted)
            {
                Data = new TLVList();
                Data.Deserialize(DataBytes);
            }

            if (pos != input.Length)
            {
                MAC = new byte[8];
                Array.Copy(input, pos, MAC, 0, 8);
                pos = pos + 8;
            }
        }
Пример #16
0
        public List <string> GetADFNames()
        {
            try
            {
                if (GetTLVResponse().Tag.TagLable != EMVTagsEnum.FILE_CONTROL_INFORMATION_FCI_TEMPLATE_6F_KRN.Tag)
                {
                    throw new EMVProtocolException("No FILE_CONTROL_INFO_TEMPLATE_6F tag found");
                }

                TLV y = GetTLVResponse().Children.Get(EMVTagsEnum.FILE_CONTROL_INFORMATION_FCI_ISSUER_DISCRETIONARY_DATA_BF0C_KRN.Tag);

                TLV z = y.Children.Get(EMVTagsEnum.FILE_CONTROL_INFORMATION_FCI_ISSUER_DISCRETIONARY_DATA_BF0C_KRN.Tag);

                TLVList a = z.Children.FindAll(EMVTagsEnum.APPLICATION_TEMPLATE_61_KRN.Tag);

                List <string> result = new List <string>();
                foreach (TLV tlv in a)
                {
                    result.Add(Formatting.ByteArrayToHexString(tlv.Children.Get(EMVTagsEnum.APPLICATION_DEDICATED_FILE_ADF_NAME_4F_KRN.Tag).Value));
                }

                return(result);
            }
            catch (Exception ex)
            { throw new EMVProtocolException("APPLICATION_IDENTIFIER_CARD_4F Tag not found:" + ex.Message); }
        }
Пример #17
0
        private String unpackKeyData(byte[] data)
        {
            StringBuilder sb = new StringBuilder();

            TLVList tlvList = new TLVList();

            tlvList.Deserialize(data);
            sb.AppendLine("Card Data");
            try
            {
                String oidVersion = Formatting.ByteArrayToASCIIString(tlvList.Get("66").Children.Get("73").Children.Get("06").Value);
                String version    = Formatting.ByteArrayToASCIIString(tlvList.Get("66").Children.Get("73").Children.Get("60").Children.Get("06").Value);
                String tag3       = Formatting.ByteArrayToASCIIString(tlvList.Get("66").Children.Get("73").Children.Get("63").Children.Get("06").Value);
                String scpVersion = Formatting.ByteArrayToASCIIString(tlvList.Get("66").Children.Get("73").Children.Get("64").Children.Get("06").Value);
                String tag5       = Formatting.ByteArrayToASCIIString(tlvList.Get("66").Children.Get("73").Children.Get("65").Children.Get("06").Value);
                String tag6       = Formatting.ByteArrayToASCIIString(tlvList.Get("66").Children.Get("73").Children.Get("66").Children.Get("06").Value);

                sb.AppendLine("OID Version:" + oidVersion);
                sb.AppendLine("Version:" + version);
                sb.AppendLine("Tag3:" + tag3);
                sb.AppendLine("SCP Version:" + scpVersion);
                sb.AppendLine("Tag5:" + tag5);
                sb.AppendLine("Tag6:" + tag6);
            }
            catch (Exception ex)
            {
                sb.AppendLine("Error Parsing Data:" + ex.Message);
            }

            return(sb.ToString());
        }
Пример #18
0
        public override void fillArguments(TLVList list)
        {
            int size = list.getList().Count;

            if (size == 0)
            {
                throw new MalformedMessageException("Received malformed SASL-Outcome header: code can't be null");
            }

            if (size > 2)
            {
                throw new MalformedMessageException("Received malformed SASL-Outcome header. Invalid number of arguments: " + size);
            }

            if (size > 0)
            {
                TLVAmqp element = list.getList()[0];
                if (element.isNull())
                {
                    throw new MalformedMessageException("Received malformed SASL-Outcome header: code can't be null");
                }

                _outcomeCode = (OutcomeCodes)AMQPUnwrapper <AMQPSymbol> .unwrapUByte(element);
            }

            if (list.getList().Count > 1)
            {
                TLVAmqp element = list.getList()[1];
                if (!element.isNull())
                {
                    _additionalData = AMQPUnwrapper <AMQPSymbol> .unwrapBinary(element);
                }
            }
        }
Пример #19
0
 public KernelDatabaseBase(PublicKeyCertificateManager publicKeyCertificateManager)
 {
     PublicKeyCertificateManager = publicKeyCertificateManager;
     KernelConfigurationData     = new KernelConfigurationData();
     TagsToReadYet = new TLVList();
     StaticDataToBeAuthenticated = new StaticDataToBeAuthenticatedList(this);
 }
Пример #20
0
        public void fill(TLVList list)
        {
            if (list.getList().Count > 0)
            {
                TLVAmqp element = list.getList()[0];
                if (!element.isNull())
                {
                    _deliveryFailed = AMQPUnwrapper <AMQPSymbol> .unwrapBool(element);
                }
            }

            if (list.getList().Count > 1)
            {
                TLVAmqp element = list.getList()[1];
                if (!element.isNull())
                {
                    _undeliverableHere = AMQPUnwrapper <AMQPSymbol> .unwrapBool(element);
                }
            }

            if (list.getList().Count > 2)
            {
                TLVAmqp element = list.getList()[2];
                if (!element.isNull())
                {
                    _messageAnnotations = AMQPUnwrapper <AMQPSymbol> .unwrapMap(element);
                }
            }
        }
        private static bool DoDEKIfNeeded(KernelDatabaseBase database, KernelQ qManager)
        {
            TLVList toRemove = new TLVList();

            foreach (TLV tlv in database.TagsToReadYet)
            {
                if (database.IsNotEmpty(tlv.Tag.TagLable))
                {
                    database.Get(EMVTagsEnum.DATA_TO_SEND_FF8104_KRN2).Children.AddToList(tlv);
                    toRemove.AddToList(tlv);
                }
            }
            foreach (TLV tlv in toRemove)
            {
                database.TagsToReadYet.RemoveFromList(tlv);
            }

            if (database.IsNotEmptyList(EMVTagsEnum.DATA_TO_SEND_FF8104_KRN2.Tag) && database.TagsToReadYet.Count == 0)
            {
                CommonRoutines.PostDEK(database, qManager);
                database.Get(EMVTagsEnum.DATA_TO_SEND_FF8104_KRN2).Initialize();
                database.Get(EMVTagsEnum.DATA_NEEDED_DF8106_KRN2).Initialize();
                return(true);
            }
            return(false);
        }
Пример #22
0
        public TLVAmqp getValue()
        {
            TLVList list = new TLVList();

            if (_durable != null)
            {
                list.addElement(0, AMQPWrapper <AMQPSymbol> .wrap(_durable));
            }
            if (_priority != null)
            {
                list.addElement(1, AMQPWrapper <AMQPSymbol> .wrap(_priority));
            }
            if (_milliseconds != null)
            {
                list.addElement(2, AMQPWrapper <AMQPSymbol> .wrap(_milliseconds));
            }
            if (_firstAquirer != null)
            {
                list.addElement(3, AMQPWrapper <AMQPSymbol> .wrap(_firstAquirer));
            }
            if (_deliveryCount != null)
            {
                list.addElement(4, AMQPWrapper <AMQPSymbol> .wrap(_deliveryCount));
            }

            DescribedConstructor constructor = new DescribedConstructor(list.Code, new TLVFixed(AMQPType.SMALL_ULONG, new byte[] { 0x70 }));

            list.Constructor = constructor;

            return(list);
        }
        public static AMQPOutcome getOutcome(TLVList list)
        {
            AMQPOutcome outcome = null;

            Byte       byteCode = list.Constructor.getDescriptorCode().Value;
            StateCodes code     = (StateCodes)byteCode;

            switch (code)
            {
            case StateCodes.ACCEPTED:
                outcome = new AMQPAccepted();
                break;

            case StateCodes.MODIFIED:
                outcome = new AMQPModified();
                break;

            case StateCodes.REJECTED:
                outcome = new AMQPRejected();
                break;

            case StateCodes.RELEASED:
                outcome = new AMQPReleased();
                break;

            default:
                throw new MalformedMessageException("Received header with unrecognized outcome code");
            }
            return(outcome);
        }
Пример #24
0
        private static SignalsEnum EntryPointDET(KernelDatabaseBase database, KernelRequest kernel1Request, CardQ cardQManager, Stopwatch sw)
        {
            database.UpdateWithDETData(kernel1Request.InputData);

            bool    missingPDOLData            = false;
            TLV     _9f38                      = database.Get(EMVTagsEnum.PROCESSING_OPTIONS_DATA_OBJECT_LIST_PDOL_9F38_KRN);
            TLVList pdolList                   = TLV.DeserializeChildrenWithNoV(_9f38.Value, 0);
            DATA_NEEDED_DF8106_KRN2 dataNeeded = new DATA_NEEDED_DF8106_KRN2(database);

            foreach (TLV tlv in pdolList)
            {
                if (database.IsEmpty(tlv.Tag.TagLable))
                {
                    missingPDOLData = true;
                    dataNeeded.Value.Tags.Add(tlv.Tag.TagLable);
                }
            }
            dataNeeded.UpdateDB();

            if (missingPDOLData)
            {
                return(SignalsEnum.WAITING_FOR_PDOL_DATA);
            }

            database.Initialize(EMVTagsEnum.PDOL_RELATED_DATA_DF8111_KRN2.Tag);
            CommonRoutines.PackRelatedDataTag(database, EMVTagsEnum.PDOL_RELATED_DATA_DF8111_KRN2, pdolList);
            EMVGetProcessingOptionsRequest request = new EMVGetProcessingOptionsRequest(database.Get(EMVTagsEnum.PDOL_RELATED_DATA_DF8111_KRN2));

            sw.Stop();
            cardQManager.EnqueueToInput(new CardRequest(request, CardinterfaceServiceRequestEnum.ADPU));

            return(SignalsEnum.WAITING_FOR_GPO_REPONSE);
        }
Пример #25
0
        public TLVList getList()
        {
            TLVList list = new TLVList();

            if (_address != null)
            {
                list.addElement(0, AMQPWrapper <AMQPSymbol> .wrap(_address));
            }

            if (_durable != null)
            {
                list.addElement(1, AMQPWrapper <AMQPSymbol> .wrap((Int64)_durable.Value));
            }

            if (_expiryPeriod != null)
            {
                list.addElement(2, AMQPWrapper <AMQPSymbol> .wrap(new AMQPSymbol(StringEnum.GetStringValue(_expiryPeriod.Value))));
            }

            if (_timeout != null)
            {
                list.addElement(3, AMQPWrapper <AMQPSymbol> .wrap(_timeout));
            }

            if (_dynamic != null)
            {
                list.addElement(4, AMQPWrapper <AMQPSymbol> .wrap(_dynamic));
            }

            if (_dynamicNodeProperties != null)
            {
                if (_dynamic != null)
                {
                    if (_dynamic.Value)
                    {
                        list.addElement(5, AMQPWrapper <AMQPSymbol> .wrapMap(_dynamicNodeProperties));
                    }
                    else
                    {
                        throw new MalformedMessageException("Target's dynamic-node-properties can't be specified when dynamic flag is false");
                    }
                }
                else
                {
                    throw new MalformedMessageException("Target's dynamic-node-properties can't be specified when dynamic flag is not set");
                }
            }

            if (_capabilities != null)
            {
                list.addElement(6, AMQPWrapper <AMQPSymbol> .wrapArray(_capabilities));
            }

            DescribedConstructor constructor = new DescribedConstructor(list.Code, new TLVFixed(AMQPType.SMALL_ULONG, new byte[] { 0x29 }));

            list.Constructor = constructor;

            return(list);
        }
        public TLVList getList()
        {
            TLVList list = new TLVList();
            DescribedConstructor constructor = new DescribedConstructor(list.Code, new TLVFixed(AMQPType.SMALL_ULONG, new byte[] { (byte)_code }));

            list.Constructor = constructor;
            return(list);
        }
 public void fill(TLVList list)
 {
     if (!list.isNull())
     {
         DescribedConstructor constructor = (DescribedConstructor)list.Constructor;
         _code = (LifetimePolicy)(constructor.getDescriptorCode() & 0x0ff);
     }
 }
Пример #28
0
        public override void AddListToList(TLVList list, bool withDup = false, Func <TLV, bool> function = null)
        {
            base.AddListToList(list, true);//, (x) => { return TLVMetaDataSourceSingleton.Instance.DataSource.GetName(x.Tag.TagLable) == "Invalid tag"; });

            int depth = 0;

            Logger.Log("Added to StaticDataToBeAuthenticatedList: \n" + ToPrintString(ref depth));
        }
        public void LoadTerminalConfigurationDataObjects(KernelEnum kernel, IConfigurationProvider configProvider)
        {
            TerminalConfigurationDataObjects = TLVListXML.XmlDeserialize(configProvider.GetTerminalConfigurationDataXML(Formatting.ByteArrayToHexString(new byte[] { (byte)kernel })));

            int depth = 0;

            Logger.Log("Using Terminal Defaults: \n" + TerminalConfigurationDataObjects.ToPrintString(ref depth));
        }
Пример #30
0
        private void ContactlessApp_PinRequest(TLVList data)
        {
            CapturePin();
            //TODO: encrypt the pin
            TLV pin = TLV.Create(EMVTagsEnum.TRANSACTION_PERSONAL_IDENTIFICATION_NUMBER_PIN_DATA_99_KRN.Tag, Formatting.HexStringToByteArray(pinEntryTCS.Task.Result));

            data.AddToList(pin);
        }
Пример #31
0
        public static TLVList Parse(Stream s)
        {
            TLVList l = new TLVList();

            while (s.Position < s.Length)
            {
                TLV t = new TLV(s);
                t.Childs = TLV.ParseTagList(t.Value);
                l.Add(t);
            }

            return l;
        }
Пример #32
0
        private static TLVList ParseTagList(byte[] data)
        {
            TLVList tagList = new TLVList();
            MemoryStream ms = new MemoryStream(data);

            while (ms.Position < ms.Length)
            {
                TLV tlv = new TLV(ms);

                if (tlv.Value != null && tlv.Value.Length > 0)
                {
                    if (tlv.isConstructed)
                    {
                        tlv.Childs = TLV.ParseTagList(tlv.Value);
                    }
                    tagList.Add(tlv);
                }
            }
            return tagList;
        }