public virtual byte[] processCommand(Apdu apdu)
 {
     CardContext context = handler.Context;
     if (apdu.P1 != 0xf3 &&
         apdu.P1 != 0xf1)
         return Error.P1OrP2NotValid;
     if (apdu.P1 == 0xf3) {
         var se = context.CurDF.GetChildSE(apdu.P2, true);
         if (se == null)
             return Error.RecordNotFound;
         if (!handler.IsVerifiedAC(se, SE_AC.AC_RESTORE))
             return Error.SecurityStatusNotSatisfied;
         handler.RestoreSE(se);
     }
     else if (apdu.P1 == 0xf1)
     {
         TLV se=new TLV(apdu.Data);
         byte[] id=se[0x83];
         if (id==null)
             id=se[0x84];
         if (id==null)
             return Error.DataFieldNotValid;
         if (id.Length!=1)
             return Error.DataFieldNotValid;
         SecurityEnvironmentComponent comp = 0;
         switch (apdu.P2) { 
             case 0xb8:
                 comp = SecurityEnvironmentComponent.CON;
                 break;
             case 0xa4:
                 comp = SecurityEnvironmentComponent.TEST;
                 break;
             case 0xb6:
                 comp = SecurityEnvironmentComponent.CDS;
                 break;
             default:
                 return Error.P1OrP2NotValid;
         }
         if (comp == 0)
             return Error.P1OrP2NotValid;
         handler.RestoreSE(comp,id[0]);
     }
     return Error.Ok;
 }
Esempio n. 2
0
        public static void CreateMSDataRecord(KernelDatabaseBase database)
        {
            //Table 4.10
            if (database.Get(EMVTagsEnum.DATA_RECORD_FF8105_KRN2) == null)
            {
                database.AddToList(TLV.Create(EMVTagsEnum.DATA_RECORD_FF8105_KRN2.Tag));
            }

            AddDREntry(EMVTagsEnum.POINTOFSERVICE_POS_ENTRY_MODE_9F39_KRN, database);
            AddDREntry(EMVTagsEnum.AMOUNT_AUTHORISED_NUMERIC_9F02_KRN, database);

            AddDREntry(EMVTagsEnum.APPLICATION_LABEL_50_KRN, database);
            AddDREntry(EMVTagsEnum.APPLICATION_PREFERRED_NAME_9F12_KRN, database);
            AddDREntry(EMVTagsEnum.DEDICATED_FILE_DF_NAME_84_KRN, database);
            AddDREntry(EMVTagsEnum.ISSUER_CODE_TABLE_INDEX_9F11_KRN, database);
            AddDREntry(EMVTagsEnum.MAGSTRIPE_APPLICATION_VERSION_NUMBER_READER_9F6D_KRN2, database);
            AddDREntry(EMVTagsEnum.TRACK_1_DATA_56_KRN2, database);
            AddDREntry(EMVTagsEnum.TRACK_2_DATA_9F6B_KRN2, database);
        }
Esempio n. 3
0
        public static void CreateEMVDiscretionaryData(KernelDatabaseBase database)
        {
            //Table 4.9
            if (database.Get(EMVTagsEnum.DISCRETIONARY_DATA_FF8106_KRN2) == null)
            {
                database.AddToList(TLV.Create(EMVTagsEnum.DISCRETIONARY_DATA_FF8106_KRN2.Tag));
            }

            AddDDEntry(EMVTagsEnum.APPLICATION_CAPABILITIES_INFORMATION_9F5D_KRN2, database);
            AddDDEntry(EMVTagsEnum.APPLICATION_CURRENCY_CODE_9F42_KRN, database);
            AddDDEntry(EMVTagsEnum.BALANCE_READ_AFTER_GEN_AC_DF8105_KRN2, database);
            AddDDEntry(EMVTagsEnum.BALANCE_READ_BEFORE_GEN_AC_DF8104_KRN2, database);
            AddDDEntry(EMVTagsEnum.DS_SUMMARY_3_DF8102_KRN2, database);
            AddDDEntry(EMVTagsEnum.DS_SUMMARY_STATUS_DF810B_KRN2, database);
            AddDDEntry(EMVTagsEnum.ERROR_INDICATION_DF8115_KRN2, database);
            AddDDEntry(EMVTagsEnum.POSTGEN_AC_PUT_DATA_STATUS_DF810E_KRN2, database);
            AddDDEntry(EMVTagsEnum.PREGEN_AC_PUT_DATA_STATUS_DF810F_KRN2, database);
            AddDDEntry(EMVTagsEnum.THIRD_PARTY_DATA_9F6E_KRN2, database);
            AddDDEntry(EMVTagsEnum.TORN_RECORD_FF8101_KRN2, database);
        }
Esempio n. 4
0
        public TimeOfDay(TLV tlv) : this()
        {
            int len = tlv.Length.Value;

            byte[] ms = tlv.Value.RawBytes.Take(4).ToArray();
            if (len == 6)
            {
                Value = baseline.AddDays(BigEndianBitConverter.Big.ToUInt16(tlv.Value.RawBytes, 4));
            }
            else if (len == 4)
            {
                Value = DateTime.Today;
            }
            else
            {
                throw new FormatException("TimeOfDay should have a length of 4 or 6 bytes");
            }
            Value      = Value.AddMilliseconds(BigEndianBitConverter.Big.ToUInt32(ms, 0));
            this.Bytes = tlv.Bytes;
        }
Esempio n. 5
0
        private static SignalsEnum DoEMVMode(Kernel3Database database, KernelQ qManager, CardQ cardQManager, CardResponse cardResponse, Stopwatch sw, PublicKeyCertificateManager publicKeyCertificateManager, CardExceptionManager cardExceptionManager)
        {
            TLV aflRaw = database.Get(EMVTagsEnum.APPLICATION_FILE_LOCATOR_AFL_94_KRN);

            if (aflRaw != null)
            {
                List <byte[]> bytes = new List <byte[]>
                {
                    new byte[] { (byte)aflRaw.Value.Length },
                    aflRaw.Value
                };
                database.ActiveAFL.Value.Deserialize(bytes.SelectMany(a => a).ToArray(), 0);
                return(K1K3.State_3_R1_CommonProcessing.DoCommonProcessing("State_3_WaitingForGPOResponse", database, qManager, cardQManager, cardResponse));
            }
            else
            {
                database.NextCommandEnum = NextCommandEnum.NONE;
                return(State_3_4_CommonProcessing.DoCommonProcessing("State_3_WaitingForGPOResponse", database, qManager, cardQManager, sw, publicKeyCertificateManager, cardExceptionManager));
            }
        }
Esempio n. 6
0
        public override void Deserialize(byte[] response)
        {
            base.Deserialize(response);
            if (!Succeeded)
            {
                return;
            }

            tlvResponse = TLV.Create(EMVTagsEnum.READ_RECORD_RESPONSE_MESSAGE_TEMPLATE_70_KRN.Tag);
            try
            {
                tlvResponse.Deserialize(ResponseData, 0);
            }
            catch
            {
                tlvResponse  = TLV.Create(EMVTagsEnum.READ_RECORD_RESPONSE_MESSAGE_TEMPLATE_70_KRN.Tag);
                ResponseData = tlvResponse.Serialize();
            }
            Logger.Log(ToPrintString());
        }
Esempio n. 7
0
        public void TestAPDUin2BERTLV()
        {
            //create a big TLV
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < 65605; i++)
            {
                sb.Append("BB");
            }
            TLV expected = new TLV()
            {
                Tag    = "09",
                Length = sb.Length / 2,
                Value  = sb.ToString()
            };

            List <TLV> result = APDU.Parse("0983010045" + sb.ToString());

            Helper.compareTLV(expected, result[0]);
        }
Esempio n. 8
0
        public void TestAPDUin1BERTLV()
        {
            //create a big TLV
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < 200; i++)
            {
                sb.Append("BB");
            }
            TLV expected = new TLV()
            {
                Tag    = "09",              // 09
                Length = sb.Length / 2,     // 100
                Value  = sb.ToString()      // BB repeated 100 times
            };

            List <TLV> result = APDU.Parse("0981C8" + sb.ToString());

            Helper.compareTLV(expected, result[0]);
        }
Esempio n. 9
0
        public bool IsEmpty(string tag)
        {
            TLV result = Get(tag);

            if (result == null)
            {
                return(true);
            }
            else
            {
                if (result.Value.Length == 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Esempio n. 10
0
        public SavPdu(TLV tlv)
            : this()
        {
            this.Bytes = tlv.Bytes;
            ByteArraySegment pdu = tlv.Value.Bytes;

            pdu.Length = 0;

            TLV tmp = new TLV(pdu.EncapsulatedBytes());

            pdu.Length += tmp.Bytes.Length;
            noASDU      = new NoAsdu(tmp);

            tmp = new TLV(pdu.EncapsulatedBytes());
            if (IsSecurity(tmp))
            {
                security = null;

                pdu.Length += tmp.Bytes.Length;
                tmp         = new TLV(pdu.EncapsulatedBytes());
            }

            //ASDU = new Asdu()
            if (Asdu.IsAsduSeq(tmp) && noASDU.Value > 0)
            {
                int cnt = noASDU.Value;
                tmp = new TLV(pdu.EncapsulatedBytes());
                for (int i = 0; i < cnt; i++)
                {
                    //tmp = new TLV(pdu.EncapsulatedBytes());
                    Asdu asdu = new Asdu(tmp.Value.Bytes);
                    pdu.Length += tmp.Bytes.Length;

                    ASDU.Add(asdu);
                }
            }
            else
            {
                throw new Exception("Bad SV packet");
            }
        }
 private static void Do434(Kernel2Database database, bool signedFlag, int sfi, CardResponse cardResponse, TLVList responseTags)
 {
     #region 4.34
     if (signedFlag && database.ODAStatus == 0x80)
     {
         #region 4.35
         if (sfi <= 10)
         {
             int length = cardResponse.ApduResponse.ResponseData.Length - 2; //without tag '70' and length
             if (2048 - database.StaticDataToBeAuthenticated.Serialize().Length >= length)
             {
                 database.StaticDataToBeAuthenticated.AddListToList(responseTags);
             }
             else
             {
                 TERMINAL_VERIFICATION_RESULTS_95_KRN tvr = new TERMINAL_VERIFICATION_RESULTS_95_KRN(database);
                 tvr.Value.CDAFailed = true;
                 tvr.UpdateDB();
             }
         }
         else
         {
             int length = cardResponse.ApduResponse.ResponseData.Length;
             if (cardResponse.ApduResponse.ResponseData[0] == 0x70 && 2048 - database.StaticDataToBeAuthenticated.Serialize().Length >= length)
             {
                 TLV template = TLV.Create(EMVTagsEnum.READ_RECORD_RESPONSE_MESSAGE_TEMPLATE_70_KRN.Tag);
                 template.Children.AddListToList(responseTags);
                 template.Serialize();
                 database.StaticDataToBeAuthenticated.AddToList(template);
             }
             else
             {
                 TERMINAL_VERIFICATION_RESULTS_95_KRN tvr = new TERMINAL_VERIFICATION_RESULTS_95_KRN(database);
                 tvr.Value.CDAFailed = true;
                 tvr.UpdateDB();
             }
         }
         #endregion
     }
     #endregion
 }
        private static void AddSDADDataToDatabase(Kernel2Database database, ICCDynamicData iccdd)
        {
            TLV iccdn = database.Get(EMVTagsEnum.ICC_DYNAMIC_NUMBER_9F4C_KRN);
            TLV ac    = database.Get(EMVTagsEnum.APPLICATION_CRYPTOGRAM_9F26_KRN);

            if (iccdn == null)
            {
                iccdn = TLV.Create(EMVTagsEnum.ICC_DYNAMIC_NUMBER_9F4C_KRN.Tag);
            }

            if (ac == null)
            {
                ac = TLV.Create(EMVTagsEnum.APPLICATION_CRYPTOGRAM_9F26_KRN.Tag);
            }

            iccdn.Value = iccdd.ICCDynamicNumber;
            ac.Value    = iccdd.ApplicationCryptogram;

            database.AddToList(iccdn);
            database.AddToList(ac);
        }
        public static SignalsEnum DoOfflineProcess(KernelDatabaseBase database, CardQ cardQManager)
        {
            #region 3.4.1.1 and 3.4.1.2
            TLV    ddol = database.Get(EMVTagsEnum.DYNAMIC_DATA_AUTHENTICATION_DATA_OBJECT_LIST_DDOL_9F49_KRN);
            byte[] ddolRelatedData;
            if (ddol == null)
            {
                TLV unpred = database.Get(EMVTagsEnum.UNPREDICTABLE_NUMBER_9F37_KRN);
                unpred.Val.PackValue(unpred.Val.GetLength());
                ddolRelatedData = unpred.Value;
            }
            else
            {
                ddolRelatedData = CommonRoutines.PackRelatedDataTag(database, ddol);
            }
            EMVInternalAuthenticateRequest request = new EMVInternalAuthenticateRequest(ddolRelatedData);
            cardQManager.EnqueueToInput(new CardRequest(request, CardinterfaceServiceRequestEnum.ADPU));
            return(SignalsEnum.WAITING_FOR_INTERNAL_AUTHENTICATE);

            #endregion
        }
Esempio n. 14
0
        private static SignalsEnum DoCommonProcessing(string source, KernelDatabase database, KernelQ qManager, CardQ cardQManager, CardResponse cardResponse)
        {
            TLV nextTLV = database.TagsToReadYet.GetNextGetDataTagFromList();

            if (nextTLV != null)
            {
                database.ActiveTag = nextTLV.Tag.TagLable;
            }
            else
            {
                database.ActiveTag = null;
            }

            if (database.ActiveTag != null)
            {
                EMVGetDataRequest request = new EMVGetDataRequest(Formatting.HexStringToByteArray(database.ActiveTag));
                cardQManager.EnqueueToInput(new CardRequest(request, CardinterfaceServiceRequestEnum.ADPU));
                database.NextCommandEnum = NextCommandEnum.GET_DATA;
            }
            else
            {
                if (database.ActiveAFL == null)
                {
                    return(DoInvalidReponse(database, qManager, L1Enum.NOT_SET, L2Enum.CARD_DATA_ERROR, L3Enum.NOT_SET));
                }
                else
                {
                    EMVReadRecordRequest request = new EMVReadRecordRequest(database.ActiveAFL.Value.Entries[0].SFI, database.ActiveAFL.Value.Entries[0].FirstRecordNumber);
                    cardQManager.EnqueueToInput(new CardRequest(request, CardinterfaceServiceRequestEnum.ADPU));
                    database.NextCommandEnum = NextCommandEnum.READ_RECORD;
                }
            }

            TLVList dataToSend = database.Get(EMVTagsEnum.DATA_TO_SEND_FF8104_KRN2).Children;

            APPLICATION_INTERCHANGE_PROFILE_82_KRN aip = new APPLICATION_INTERCHANGE_PROFILE_82_KRN(database);
            TERMINAL_CAPABILITIES_9F33_KRN         tc  = new TERMINAL_CAPABILITIES_9F33_KRN(database);

            return(SignalsEnum.WAITING_FOR_EMV_READ_RECORD_RESPONSE);
        }
Esempio n. 15
0
        private async void EmvTxCtl_TxCompleted(object sender, EventArgs e)
        {
            try
            {
                if ((e as TxCompletedEventArgs).EMV_Data.IsPresent())
                {
                    TLV data = (e as TxCompletedEventArgs).EMV_Data.Get();

                    string emvData = TLVasJSON.ToJSON(data);

                    string uid = Formatting.BcdToString(data.Children.Get(EMVTagsEnum.APPLICATION_PRIMARY_ACCOUNT_NUMBER_PAN_5A_KRN.Tag).Value);

                    await RegisterCard(SessionSingleton.Account.AccountNumberId, uid);

                    Device.BeginInvokeOnMainThread(() =>
                    {
                        SessionSingleton.Account.Cards.Add(new Card()
                        {
                            CardSerialNumberId = uid,
                        });
                        lblStatusCard.Text = string.Format("Card {0} linked", uid);
                        UpdateView(CardAdminViewState.CardAddStatus);
                    });
                }
                else
                {
                    lblStatusCard.Text = "Card not linked";
                    UpdateView(CardAdminViewState.CardAddStatus);
                }
            }
            catch (Exception ex)
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    UpdateView(CardAdminViewState.CardAddStatus);
                    lblStatusCard.Text = ex.Message;
                });
            }
        }
Esempio n. 16
0
        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());
            }
        }
Esempio n. 17
0
        public RegistrationC(EFSOd EFSOd, X509Certificate2 CSCA, byte[] AID, CardReader cardReader, Encoding encoding)
            : base(EFSOd, CSCA, AID, cardReader, new byte[] { 0xD0, 0x21 })
        {
            this.CharacterSetEncoding = encoding;
            this.CVOVersion           = this.DecodeBinary("1,BF8700|1,9F8701");
            this.B1 = this.DecodeString("1,BF8700|1,BF8710|1,9F8711"); // firstReg
            this.B2 = this.DecodeString("1,BF8700|1,BF8710|1,9F8712"); // firstRegEU
            this.I  = this.DecodeString("1,BF8700|1,BF8710|1,9F8713"); // tenaamstelling

            TLV           zippedXMLsTLV = this.GetTag("1,BF8700|1,BF8703|1,9F8705");
            int           i             = 1;
            List <string> cvos          = new List <string>();

            while (zippedXMLsTLV != null)
            {
                cvos.Add(Helper.GUnzip2(zippedXMLsTLV.Value));

                i++;
                zippedXMLsTLV = this.GetTag(string.Format("1,BF8700|{0},BF8703|1,9F8705", i));
            }
            this.CVOs = cvos.ToArray();
        }
Esempio n. 18
0
        public void TLV_Normal_2GrandChild()
        {
            var testData    = "GG0C810A98088402889985020032";
            TLV grandParent = new TLV()
            {
                Tag = "GG", Length = 12, Value = "810A98088402889985020032"
            };

            TLV parent = new TLV()
            {
                Tag = "81", Length = 10, Value = "98088402889985020032"
            };

            grandParent.addChild(parent);

            TLV child = new TLV()
            {
                Tag = "98", Length = 8, Value = "8402889985020032"
            };

            parent.addChild(child);

            TLV grandChild1 = new TLV()
            {
                Tag = "84", Length = 2, Value = "8899"
            };

            TLV grandChild2 = new TLV()
            {
                Tag = "85", Length = 2, Value = "0032"
            };

            child.addChild(grandChild1);
            child.addChild(grandChild2);

            TLV result = TLV.parse(testData);

            Helper.compareTLV(grandParent, result);
        }
Esempio n. 19
0
 CombinationSelection_FromB(CardQProcessor cardInterfaceManager,
                            Tuple <EMVTerminalProcessingOutcome, EMVSelectApplicationResponse, TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> lastCandidateSelected,
                            List <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> > candidates,
                            TLV iad, TLV scriptData)
 {
     /*
      * If Issuer Authentication Data and/or Issuer Script is present,
      * then processing shall continue at requirement 3.3.3.3 of Final
      * Combination Selection with the Combination that was
      * selected during the previous Final Combination Selection.
      */
     if (iad != null || scriptData != null)
     {
         Tuple <EMVTerminalProcessingOutcome, EMVSelectApplicationResponse, TerminalSupportedKernelAidTransactionTypeCombination>
         result = FinalCombinationSelection_Step3_From_3_3_3_3(cardInterfaceManager, lastCandidateSelected.Item3, lastCandidateSelected.Item4, iad, scriptData);
         return(Tuple.Create(result.Item1, result.Item2, result.Item3, lastCandidateSelected.Item4, candidates));
     }
     else
     {
         return(CombinationSelection_FromA(cardInterfaceManager, iad, scriptData));
     }
 }
Esempio n. 20
0
        /// <summary>
        /// Parse byte[] into TLVs
        /// </summary>
        public void ParseByteArrayIntoTlvs(byte[] bytes, int offset)
        {
            log.DebugFormat("bytes.Length {0}, offset {1}", bytes.Length, offset);

            int position = 0;

            TlvCollection.Clear();

            while (position < bytes.Length)
            {
                // The payload type
                var byteArraySegment = new ByteArraySegment(bytes, offset + position, TLVTypeLength.TypeLengthLength);
                var typeLength       = new TLVTypeLength(byteArraySegment);

                // create a TLV based on the type and
                // add it to the collection
                TLV currentTlv = TLVFactory(bytes, offset + position, typeLength.Type);
                if (currentTlv == null)
                {
                    log.Debug("currentTlv == null");
                    break;
                }

                log.DebugFormat("Adding tlv {0}, Type {1}",
                                currentTlv.GetType(), currentTlv.Type);
                TlvCollection.Add(currentTlv);

                // stop at the first end tlv we run into
                if (currentTlv is EndOfLLDPDU)
                {
                    break;
                }

                // Increment the position to seek the next TLV
                position += (currentTlv.TotalLength);
            }

            log.DebugFormat("Done, position {0}", position);
        }
Esempio n. 21
0
        public void ParseByteArrayIntoTlvs(byte[] bytes, int offset)
        {
            int num = 0;

            this.TlvCollection.Clear();
            while (num < bytes.Length)
            {
                ByteArraySegment byteArraySegment = new ByteArraySegment(bytes, offset + num, 2);
                TLVTypeLength    length           = new TLVTypeLength(byteArraySegment);
                TLV item = TLVFactory(bytes, offset + num, length.Type);
                if (item == null)
                {
                    break;
                }
                this.TlvCollection.Add(item);
                if (item is EndOfLLDPDU)
                {
                    break;
                }
                num += item.TotalLength;
            }
        }
        private static EMVGenerateACRequest DoPart4(KernelDatabaseBase database)
        {
            REFERENCE_CONTROL_PARAMETER_DF8114_KRN2 rcpST = new REFERENCE_CONTROL_PARAMETER_DF8114_KRN2(database);

            rcpST.Value.ACTypeEnum            = GetDSACType(database);
            rcpST.Value.CDASignatureRequested = GetODAStatus(database) == 0x80 ? true : false;
            rcpST.UpdateDB();

            TLV cdol1 = database.Get(EMVTagsEnum.CARD_RISK_MANAGEMENT_DATA_OBJECT_LIST_1_CDOL1_8C_KRN);

            CommonRoutines.PackRelatedDataTag(database, EMVTagsEnum.CDOL1_RELATED_DATA_DF8107_KRN2, cdol1);
            CommonRoutines.PackDSDOLRelatedDataTag(database);

            EMVGenerateACRequest request = new EMVGenerateACRequest(database.Get(EMVTagsEnum.CDOL1_RELATED_DATA_DF8107_KRN2), database.Get(EMVTagsEnum.DRDOL_RELATED_DATA_DF8113_KRN2), rcpST);

            IDS_STATUS_DF8128_KRN2 ids = new IDS_STATUS_DF8128_KRN2(database);

            ids.Value.IsWrite = true;
            ids.UpdateDB();

            return(request);
        }
Esempio n. 23
0
        CombinationSelection_FromA(CardQProcessor cardInterfaceManager, TLV iad, TLV scriptData)
        {
            List <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> > candidates = new List <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> >();

            EMVSelectPPSEResponse responsePPSE = FinalCombinationSelection_Step1(cardInterfaceManager);

            #region 3.3.2.4
            if (responsePPSE.Succeeded && responsePPSE.GetDirectoryEntries_61() != null)
            #endregion
            {
                #region 3.3.2.3
                if (responsePPSE.Succeeded)
                {
                    candidates = FinalCombinationSelection_Step2(responsePPSE.GetDirectoryEntries_61());
                }
                #endregion

                #region 3.3.2.7
                if (candidates.Count == 0)
                #endregion
                {
                    return(Tuple.Create(
                               new EMVTerminalProcessingOutcome()
                    {
                        NextProcessState = EMVTerminalPreProcessingStateEnum.EndProcess,
                        UIRequestOnOutcomePresent = true,
                        UserInterfaceRequest = new UserInterfaceRequest()
                        {
                            MessageIdentifier = MessageIdentifiersEnum.InsertSwipeOrTryAnotherCard, Status = StatusEnum.ReadyToRead
                        },
                        UIRequestOnRestartPresent = false,
                    }, (EMVSelectApplicationResponse)null, (TerminalSupportedKernelAidTransactionTypeCombination)null, (CardKernelAidCombination)null,
                               (List <Tuple <TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination> >)null));
                }
            }

            return(ProcessCandidates(cardInterfaceManager, candidates, iad, scriptData));
        }
Esempio n. 24
0
        public void TLV_Normal_2Parent()
        {
            var testData    = "GG1082048502332283088606004455668877";
            TLV grandParent = new TLV()
            {
                Tag = "GG", Length = 16, Value = "82048502332283088606004455668877"
            };

            TLV parent1 = new TLV()
            {
                Tag = "82", Length = 4, Value = "85023322"
            };
            TLV child1 = new TLV()
            {
                Tag = "85", Length = 2, Value = "3322"
            };

            parent1.addChild(child1);


            TLV parent2 = new TLV {
                Tag = "83", Length = 8, Value = "8606004455668877"
            };
            TLV child2 = new TLV()
            {
                Tag = "86", Length = 6, Value = "004455668877"
            };

            parent2.addChild(child2);


            grandParent.addChild(parent1);
            grandParent.addChild(parent2);

            TLV result = TLV.parse(testData);

            Helper.compareTLV(grandParent, result);
        }
Esempio n. 25
0
        public void DoOnlineReponse(KernelOnlineResponseType responseType, TLV authCode_8A, TLV issuerAuthData_91, TLV scriptList_71, TLV scriptList_72)
        {
            if (kernel == null)
            {
                throw new EMVProtocolException("DoOnlineReponse called without kernel being activated");
            }

            TLVList returnVal = new TLVList();

            returnVal.AddToList(authCode_8A);
            returnVal.AddToList(issuerAuthData_91);
            if (scriptList_71 != null)
            {
                returnVal.AddToList(scriptList_71);
            }
            if (scriptList_72 != null)
            {
                returnVal.AddToList(scriptList_72);
            }
            KernelOnlineRequest request = new KernelOnlineRequest(returnVal, responseType);

            kernel.KernelQ.EnqueueToInput(request);
        }
Esempio n. 26
0
        protected override void DoEntryPointD(Tuple <EMVTerminalProcessingOutcome, EMVSelectApplicationResponse, TerminalSupportedKernelAidTransactionTypeCombination, CardKernelAidCombination, EntryPointPreProcessingIndicators> indicators)
        {
            kernel = EMVContactKernelActivation.ActivateKernel(tr, cardQProcessor, 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(KernelEnum.Kernel, configProvider);

            TLVList requestInput = new TLVList();

            requestInput.AddToList(indicators.Item2.GetFCITemplateTag());
            requestInput.AddListToList(tr.GetTxDataTLV());
            if (indicators.Item5.TTQ != null)
            {
                requestInput.AddToList(TLV.Create(EMVTagsEnum.TERMINAL_TRANSACTION_QUALIFIERS_TTQ_9F66_KRN.Tag, indicators.Item5.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)));
        }
Esempio n. 27
0
        public override void UpdateWithDETData(TLVList terminalSentData)
        {
            base.UpdateWithDETData(terminalSentData);

            TLV tagsToRead = terminalSentData.Get(EMVTagsEnum.TAGS_TO_READ_DF8112_KRN2.Tag);

            if (tagsToRead != null)
            {
                TagsToReadYet.AddListToList(TLV.DeserializeChildrenWithNoLV(tagsToRead.Value, 0));
            }
            TLV tagsToWriteBeforeGenAC = terminalSentData.Get(EMVTagsEnum.TAGS_TO_WRITE_BEFORE_GEN_AC_FF8102_KRN2.Tag);

            if (tagsToWriteBeforeGenAC != null)
            {
                TagsToWriteBeforeGenACYet.AddListToList(tagsToWriteBeforeGenAC.Children);
            }
            TLV tagsToWriteAfterGenAC = terminalSentData.Get(EMVTagsEnum.TAGS_TO_WRITE_AFTER_GEN_AC_FF8103_KRN2.Tag);

            if (tagsToWriteAfterGenAC != null)
            {
                TagsToWriteAfterGenACYet.AddListToList(tagsToWriteAfterGenAC.Children);
            }
        }
Esempio n. 28
0
        public override void Update(int recNum, byte[] data)
        {
            if (recNum < 0 || recNum >= this.data.Count)
            {
                throw new ISO7816Exception(Error.RecordNotFound);
            }

            try
            {
                TLV tlv = new TLV(data);
            }
            catch
            {
                throw new ISO7816Exception(Error.RecordInconsistentWithTLVDataStructure);
            }

            if (totSize - this.data[recNum].Length + data.Length > size)
            {
                throw new ISO7816Exception(Error.NotEnoughSpace);
            }

            this.data[recNum] = data;
        }
Esempio n. 29
0
        public override CommandApdu AsApdu()
        {
            var apdu = CommandApdu.Case2S(ApduClass.GlobalPlatform, ApduInstruction.Delete, this.P1, this.P2, 0x00);

            var data = new List <byte>();

            switch (this.scope)
            {
            case DeleteCommandScope.CardContent:
                data.AddTLV(TLV.Build((byte)Tag.ExecutableLoadFileOrApplicationAID, this.application));

                if (this.token.Any())
                {
                    data.AddTLV(TLV.Build((byte)Tag.DeleteToken, this.token));
                }
                break;

            case DeleteCommandScope.Key:
                if (this.keyIdentifier == 0 && this.keyVersionNumber == 0)
                {
                    throw new InvalidOperationException("A key identifier or key version number must be specified.");
                }
                if (this.keyIdentifier > 0)
                {
                    data.AddTLV(TLV.Build((byte)Tag.KeyIdentifier, this.keyIdentifier));
                }
                if (this.keyVersionNumber > 0)
                {
                    data.AddTLV(TLV.Build((byte)Tag.KeyVersionNumber, this.keyVersionNumber));
                }
                break;
            }

            apdu.CommandData = data.ToArray();

            return(apdu);
        }
Esempio n. 30
0
        public static void PackDSDOLRelatedDataTag(KernelDatabaseBase database)
        {
            TLV tlvRelatedData = database.Get(EMVTagsEnum.DRDOL_RELATED_DATA_DF8113_KRN2);

            if (tlvRelatedData == null)
            {
                database.AddToList(TLV.Create(EMVTagsEnum.DRDOL_RELATED_DATA_DF8113_KRN2.Tag));
                tlvRelatedData = database.Get(EMVTagsEnum.DRDOL_RELATED_DATA_DF8113_KRN2);
            }
            List <byte[]> tlvRelatedDataBytes = new List <byte[]>();
            TLVList       tags = TLV.DeserializeChildrenWithNoV(database.Get(EMVTagsEnum.DSDOL_9F5B_KRN2).Value, 0);

            int count = 1;

            foreach (TLV tlv in tags)
            {
                TLV valForPack = database.Get(tlv.Tag.TagLable);
                if (valForPack == null)
                {
                    valForPack = TLV.Create(tlv.Tag.TagLable);
                }

                if (count == tags.Count && tlv.Val.GetLength() > valForPack.Value.Length)
                {
                    tlvRelatedDataBytes.Add(valForPack.Value);
                }
                else
                {
                    valForPack.Val.PackValue(tlv.Val.GetLength());
                    tlvRelatedDataBytes.Add(valForPack.Value);
                    count++;
                }
                Logger.Log("Packing DSDOL, Adding tag: " + valForPack.ToString());
            }

            tlvRelatedData.Value = tlvRelatedDataBytes.SelectMany(a => a).ToArray();
        }
        private static bool VerifySDAD_Summaries_9_10__3(Kernel2Database database, CAPublicKeyCertificate capk, CardResponse cardResponse)
        {
            ICCDynamicData iccdd = VerifySAD.VerifySDAD(ICCDynamicDataType.IDS, true, database, database.StaticDataToBeAuthenticated, capk, cardResponse);

            if (iccdd == null)
            {
                return(false);
            }

            VerifySAD.AddSDADDataToDatabase(database, iccdd);

            TLV ds2 = database.Get(EMVTagsEnum.DS_SUMMARY_2_DF8101_KRN2);
            TLV ds3 = database.Get(EMVTagsEnum.DS_SUMMARY_3_DF8102_KRN2);

            if (ds2 == null && iccdd.DSSummary2 != null)
            {
                ds2 = TLV.Create(EMVTagsEnum.DS_SUMMARY_2_DF8101_KRN2.Tag, iccdd.DSSummary2);
                database.AddToList(ds2);
            }

            if (ds3 == null && iccdd.DSSummary3 != null)
            {
                ds3 = TLV.Create(EMVTagsEnum.DS_SUMMARY_3_DF8102_KRN2.Tag, iccdd.DSSummary3);
                database.AddToList(ds3);
            }

            if (iccdd.DSSummary2 != null)
            {
                ds2.Value = iccdd.DSSummary2;
            }
            if (iccdd.DSSummary3 != null)
            {
                ds3.Value = iccdd.DSSummary3;
            }

            return(true);
        }
Esempio n. 32
0
        byte[] CreateSE(TLV seci)
        {
            var Id = seci[0x83];
            var Data = seci[0x8F];
            var AC = seci[0x86];

            if (Id == null) return Error.DataFieldNotValid;
            if (Data == null) return Error.DataFieldNotValid;
            if (AC == null) return Error.DataFieldNotValid;

            if (Id.Length != 1) return Error.DataFieldNotValid;
            if (Data.Length != 6) return Error.DataFieldNotValid;

            if (context.CurDF == null)
                return Error.ClaNotValid;

            if (!handler.IsVerifiedAC(context.CurDF, DF_AC.AC_APPEND))
                return Error.SecurityStatusNotSatisfied;

            var se = card.CreateSE(Id[0], context.CurDF);
            se.AC.Set(AC);
            se.Data = Data;

            return Error.Ok;
        }
Esempio n. 33
0
        public virtual byte[] PutDataFCI(Apdu apdu)
        {
            TLV fci = new TLV(apdu.Data);
            var Aid = fci[0x84];
            var AC = fci[0x86];
            var SM = card.GetSMTLV(fci);

            if (Aid!=null && Aid.Length > 16) 
                return Error.DataFieldNotValid;

            if (context.CurFile is EF)
            {
                if (!handler.IsVerifiedAC(context.CurFile, EF_AC.AC_ADMIN))
                    return Error.SecurityStatusNotSatisfied;
            }
            else if (context.CurFile is DF)
            {
                if (!handler.IsVerifiedAC(context.CurFile, DF_AC.AC_ADMIN))
                    return Error.SecurityStatusNotSatisfied;
            }

            if (context.CurEF != null && Aid != null) 
                return Error.CommandIncompatibleWithFileStructure;
            if (AC != null) context.CurFile.AC.Set(AC);
            if (SM != null) context.CurFile.SM.Set(SM);
            
            if (context.CurDF != null)
                if (Aid != null) context.CurDF.AID = Aid;

            return Error.Ok;
        }
Esempio n. 34
0
        byte[] CreateBSO(TLV oci)
        {
            var Id = oci[0x83];
            var Options = oci[0x85];
            var AC = oci[0x86];
            var SM = card.GetSMTLV(oci);
            var Data = oci[0x8F];

            if (Id == null) return Error.DataFieldNotValid;
            if (Options == null) return Error.DataFieldNotValid;
            if (Data == null) return Error.DataFieldNotValid;
            if (AC == null) return Error.DataFieldNotValid;

            if (Options.Length != 8) return Error.DataFieldNotValid;
            if (Id.Length != 2) return Error.DataFieldNotValid;

            if (!card.CheckBSOId(Id[1]))
                return Error.DataFieldNotValid;

            var curDF = context.CurDF;
            if (curDF == null)
                return Error.InsNotValid;

            if (!handler.IsVerifiedAC(context.CurDF, DF_AC.AC_APPEND))
                return Error.SecurityStatusNotSatisfied;

            //if (!curDF->ACGranted(AC_DF_APPEND))
            //    SCReturnWithError(0x6982);

            BSO bso = new BSO(Util.ToUShort(Id), card, curDF);
            bso.Options = Options;
            bso.AC.Set(AC);
            if (SM != null)
                bso.SM.Set(SM);
            bso.Data = Data;

            return Error.Ok;
        }
Esempio n. 35
0
        public override int Append(byte[] data) {
            try {
                TLV tlv = new TLV(data);
            }
            catch {
                throw new ISO7816Exception(Error.RecordInconsistentWithTLVDataStructure);
            }

            if (totSize + data.Length > size)
                throw new ISO7816Exception(Error.NotEnoughSpace);

            this.data.Add(data);
            totSize += data.Length;
            owner.ObjectChanged(this, ChangeType.Modified);
            return this.data.Count - 1;
        }
Esempio n. 36
0
 public virtual byte[] PutDataSE(Apdu apdu) {
     TLV seci = new TLV(apdu.Data);
     var Id = seci[0x83];
     if (context.CurDF.GetChildSE(Id[0]) != null)
         return UpdateSE(seci);
     else
         return CreateSE(seci);
 }
Esempio n. 37
0
        byte[] UpdateBSO(BSO bso, TLV oci)
        {
            var AC = oci[0x86];
            var SM = card.GetSMTLV(oci);
            var Data = oci[0x8F];

            var curDF = context.CurDF;
            if (curDF == null)
                return Error.InsNotValid;

            if (!handler.IsVerifiedAC(context.CurDF, DF_AC.AC_UPDATE))
                return Error.SecurityStatusNotSatisfied;

            if (AC != null) bso.AC.Set(AC);
            if (SM != null) bso.SM.Set(SM);
            if (Data != null) bso.Data = Data;

            return Error.Ok;
        }
Esempio n. 38
0
        public virtual byte[] processCommand(Apdu apdu)
        {
            CardContext context = handler.Context;
            if (apdu.P2 != 0)
                return Error.P1OrP2NotValid;
            CardSelectable obj = null;
            switch (apdu.P1)
            {
                case 0:
                    if (apdu.Data == null || apdu.Data.Length == 0)
                        obj = card.MasterFile;
                    else
                    {
                        if (apdu.Data.Length != 2)
                            return Error.DataFieldNotValid;
                        ushort id = Util.ToUShort(apdu.Data);
                        if (id == 0x3f00)
                            obj = card.MasterFile;
                        else
                        {
                            obj = context.CurDF.GetChildEForDF(id);
                            if (obj == null && context.CurDF.Parent != null)
                                obj = context.CurDF.Parent.GetChildEForDF(id);
                            if (obj == null && context.CurDF.Parent != null && id == context.CurDF.ID)
                                obj = context.CurDF.Parent;
                        }
                    }
                    if (obj == null)
                        return Error.FileNotFound;

                    context.CurFile = obj;
                    break;
                case 1:
                    if (apdu.Data == null || apdu.Data.Length != 2)
                        return Error.DataFieldNotValid;
                    ushort id2 = Util.ToUShort(apdu.Data);
                    obj = context.CurDF.GetChildDF(id2);
                    if (obj == null)
                        return Error.FileNotFound;
                    context.CurFile = obj;
                    break;
                case 2:
                    if (apdu.Data == null || apdu.Data.Length != 2)
                        return Error.DataFieldNotValid;
                    ushort id3 = Util.ToUShort(apdu.Data);
                    obj = context.CurDF.GetChildDF(id3);
                    if (obj == null)
                        return Error.FileNotFound;
                    context.CurFile = obj;
                    break;
                case 3:
                    if (apdu.Data != null && apdu.Data.Length != 0)
                        return Error.DataFieldNotValid;

                    if (context.CurDF.Parent == null)
                        return Error.FileNotFound;

                    context.CurFile = context.CurDF.Parent;
                    break;
                case 4:
                    if (apdu.Data == null || apdu.Data.Length == 0)
                        return Error.DataFieldNotValid;

                    DF namedDF = handler.GetNamedDF(card.MasterFile, apdu.Data);
                    if (namedDF == null)
                        return Error.FileNotFound;

                    context.CurFile = namedDF;
                    break;
                case 8:
                    if (apdu.Data == null || apdu.Data.Length == 0)
                        obj = card.MasterFile;
                    else
                        if (apdu.Data != null && apdu.Data.Length == 2 && Util.ToUShort(apdu.Data) == 0x3f00)
                            obj = card.MasterFile;
                        else
                        {
                            if ((apdu.Data.Length % 2) != 0)
                                return Error.DataFieldNotValid;
                            obj = handler.GetSelectablePath(card.MasterFile, apdu.Data, 0);
                            if (obj == null)
                                return Error.FileNotFound;
                        }
                    context.CurFile = obj;
                    break;
                case 9:
                    if (apdu.Data == null || apdu.Data.Length == 0)
                        return Error.DataFieldNotValid;
                    else
                    {
                        if ((apdu.Data.Length % 2) != 0)
                            return Error.DataFieldNotValid;
                        if (context.CurDF == null)
                            return Error.ClaNotValid;
                        obj = handler.GetSelectablePath(context.CurDF, apdu.Data, 0);
                        if (obj == null)
                            return Error.FileNotFound;
                    }
                    context.CurFile = obj;
                    break;
                default:
                    return Error.P1OrP2NotValid;
            }
            if (context.CurFile == null)
                return Error.FileNotFound;
            var outData = (context.CurFile as IObjectWithFCI).FCI;
            TLV tlv = new TLV();
            TLV tlv2 = new TLV();
            tlv2.elems.AddRange(outData);
            tlv.addTag(0x6f, tlv2.GetBytes());
            return Util.Response(tlv.GetBytes(), Error.Ok);
        }
Esempio n. 39
0
        public virtual byte[] processCommand(Apdu apdu)
        {
            CardContext context = handler.Context;
            
            if (context.CurDF == null)
                return Error.ClaNotValid;

            TLV fciExt = new TLV(apdu.Data);
            if (fciExt[0x62] == null) return Error.DataFieldNotValid;
            TLV fci = new TLV(fciExt[0x62]);
            var Size1 = fci[0x80];
            var Size2 = fci[0x81];
            var Options = fci[0x82];
            var Id = fci[0x83];
            var Fixed = fci[0x85];
            var AC = fci[0x86];
            var SM = card.GetSMTLV(fci);
            if (Size1 != null && Size2 != null) return Error.DataFieldNotValid;
            if (Options==null) return Error.DataFieldNotValid;
            if (Id == null) return Error.DataFieldNotValid;
            if (Fixed == null) return Error.DataFieldNotValid;
            if (AC == null) return Error.DataFieldNotValid;

            if (Options.Length != 3) return Error.DataFieldNotValid;
            if (Id.Length != 2) return Error.DataFieldNotValid;
            if (Fixed.Length != 1) return Error.DataFieldNotValid;

            if (Fixed[0] != 1) return Error.DataFieldNotValid;
            if (Options[0] == 0x38 && Size2 == null) return Error.DataFieldNotValid;

            if (!handler.IsVerifiedAC(context.CurDF, DF_AC.AC_CREATE))
                return Error.SecurityStatusNotSatisfied;
            ushort newId=Util.ToUShort(Id);

            if (newId == 0x3F00 || newId == 0x3FFF || newId == 0xFFFF)
                return Error.DataFieldNotValid;

            if (context.CurDF.GetChildEForDF(newId) != null)
                return Error.FileAlreadyExists;

            CardSelectable obj = null;
            if (Options[0] == 0x38)
                obj = card.CreateDF(newId, context.CurDF);
            else if (Options[0] == 0x01)
                obj = card.CreateEF(newId, context.CurDF,Util.ToUInt(Size1));
            else if (Options[0] == 0x02)
                obj = new EFLinearFixed(newId, card, context.CurDF, Util.ToUInt(Size1), Options[2]);
            else if (Options[0] == 0x05)
                obj = card.CreateEFLinearTLV(newId, context.CurDF, Util.ToUInt(Size1));
            else if (Options[0] == 0x06)
                obj = new EFCyclic(newId, card, context.CurDF, Util.ToUInt(Size1), Options[2]);
            else
                return Error.DataFieldNotValid;

            if (AC != null)
                obj.AC.Set(AC);
            if (SM != null)
                obj.SM.Set(SM);

            if (obj != null)
                context.CurFile = obj;

            return Error.Ok;
        }
Esempio n. 40
0
        byte[] UpdateSE(TLV seci)
        {
            var Id = seci[0x83];
            var AC = seci[0x86];

            if (Id == null) return Error.DataFieldNotValid;
            if (AC == null) return Error.DataFieldNotValid;

            if (Id.Length != 1) return Error.DataFieldNotValid;

            if (context.CurDF == null)
                return Error.ClaNotValid;

            if (!handler.IsVerifiedAC(context.CurDF, DF_AC.AC_UPDATE))
                return Error.SecurityStatusNotSatisfied;

            var se = context.CurDF.GetChildSE(Id[0]);
            se.AC.Set(AC);

            return Error.Ok;
        }
Esempio n. 41
0
 public virtual byte[] PutDataOCI(Apdu apdu)
 {
     TLV oci = new TLV(apdu.Data);
     ushort id = Util.ToUShort(oci[0x83]);
     if (context.CurDF == null)
         return Error.ClaNotValid;
     var obj = context.CurDF.GetChildBSO(id);
     if (obj == null)
         return CreateBSO(oci);
     else
     {
         if (!(obj is BSO))
             return Error.DataFieldNotValid;
         return UpdateBSO(obj as BSO, oci);
     }
 }
Esempio n. 42
0
        public override void Update(int recNum, byte[] data) {
            if (recNum < 0 || recNum >= this.data.Count)
                throw new ISO7816Exception(Error.RecordNotFound);

            try
            {
                TLV tlv = new TLV(data);
            }
            catch
            {
                throw new ISO7816Exception(Error.RecordInconsistentWithTLVDataStructure);
            }

            if (totSize - this.data[recNum].Length + data.Length > size)
                throw new ISO7816Exception(Error.NotEnoughSpace);

            this.data[recNum] = data;
        }
Esempio n. 43
0
        public void GenerateKey(BSO privExpBso,BSO moduleBso, EFLinearTLV pubKeyEF, ushort pubExpLen)
        {
            BigInteger publicExponent;
            BigInteger privateExponent;
            BigInteger module;
            BigInteger.GenerateRSAKey(1024, pubExpLen, out publicExponent, out module, out privateExponent);

            ByteArray baPrivateExponent = new ByteArray(new byte[] { 0, 0 });
            baPrivateExponent=baPrivateExponent.Append(privateExponent.getBytes());
            baPrivateExponent[0]=(byte)(baPrivateExponent.Size-1);
            privExpBso.Data = baPrivateExponent;

            ByteArray baModule = new ByteArray(new byte[] { 0, 0 });
            baModule = baModule.Append(module.getBytes());
            baModule[0] = (byte)(baModule.Size - 1);
            moduleBso.Data = baModule;

            TLV modTlv = new TLV();
            modTlv.addTag(0x10, baModule);
            pubKeyEF.Append(modTlv.GetBytes());

            ByteArray baPublicExponent = new ByteArray(new byte[] { 0, 0 });
            baPublicExponent = baPublicExponent.Append(publicExponent.getBytes());
            baPublicExponent[0] = (byte)(baPublicExponent.Size - 1);

            TLV pubExpTlv = new TLV();
            pubExpTlv.addTag(0x11, baPublicExponent);
            pubKeyEF.Append(pubExpTlv.GetBytes());
        }
Esempio n. 44
-1
 public TPDU(TLV val)
 {
     this.Tag = val.Tag;
     this.Length = val.Length;
     this.Value = val.Value;
     data_0340 = new Data_0340(val.Value);
 }