Exemplo n.º 1
0
        public static void PackRelatedDataTag(KernelDatabaseBase database, EMVTagMeta tagToPack, TLV tagListForPack)
        {
            TLV tlvRelatedData = database.Get(tagToPack);

            if (tlvRelatedData == null)
            {
                database.AddToList(TLV.Create(tagToPack.Tag));
                tlvRelatedData = database.Get(tagToPack);
            }
            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);
            }
            tlvRelatedData.Value = tlvRelatedDataBytes.SelectMany(a => a).ToArray();
        }
Exemplo n.º 2
0
        public static TLV InitializeDiscretionaryData(KernelDatabaseBase database)
        {
            TLV disc = database.Get(EMVTagsEnum.DISCRETIONARY_DATA_FF8106_KRN2);

            if (disc == null)
            {
                disc = TLV.Create(EMVTagsEnum.DISCRETIONARY_DATA_FF8106_KRN2.Tag);
                database.AddToList(disc);
            }
            return(disc);
        }
Exemplo n.º 3
0
        public static void AddSDADDataToDatabase(KernelDatabaseBase database, ICCDynamicData iccdd)
        {
            if (iccdd.ApplicationCryptogram != null)
            {
                TLV ac = database.Get(EMVTagsEnum.APPLICATION_CRYPTOGRAM_9F26_KRN);
                if (ac == null)
                {
                    ac = TLV.Create(EMVTagsEnum.APPLICATION_CRYPTOGRAM_9F26_KRN.Tag);
                }
                ac.Value = iccdd.ApplicationCryptogram;
                database.AddToList(ac);
            }

            TLV iccdn = database.Get(EMVTagsEnum.ICC_DYNAMIC_NUMBER_9F4C_KRN);

            if (iccdn == null)
            {
                iccdn = TLV.Create(EMVTagsEnum.ICC_DYNAMIC_NUMBER_9F4C_KRN.Tag);
            }
            iccdn.Value = iccdd.ICCDynamicNumber;
            database.AddToList(iccdn);
        }
Exemplo n.º 4
0
        public static void CreateMSDiscretionaryDataRecord(KernelDatabaseBase database)
        {
            //Table 4.8
            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.DD_CARD_TRACK1_DF812A_KRN2, database);
            AddDDEntry(EMVTagsEnum.DD_CARD_TRACK2_DF812B_KRN2, database);
            AddDDEntry(EMVTagsEnum.ERROR_INDICATION_DF8115_KRN2, database);
            AddDDEntry(EMVTagsEnum.THIRD_PARTY_DATA_9F6E_KRN2, database);
        }
Exemplo n.º 5
0
        public virtual void UpdateDB()
        {
            if (database == null)
            {
                throw new EMVProtocolException("cannot call UpdateDB with database = null");
            }

            TLV tlv = database.Get(EMVTagMeta);

            if (tlv != null)
            {
                tlv.Val.Deserialize(Val.Serialize(), 0);
            }
            else
            {
                Val.Serialize();
                database.AddToList(TLV.Create(this.Tag.TagLable, Val.Value));
            }
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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();
        }
Exemplo n.º 9
0
        public static void CreateEMVDataRecord(KernelDatabaseBase database)
        {
            //Table 4.7
            if (database.Get(EMVTagsEnum.DATA_RECORD_FF8105_KRN2) == null)
            {
                database.AddToList(TLV.Create(EMVTagsEnum.DATA_RECORD_FF8105_KRN2.Tag));
            }

            CARDHOLDER_VERIFICATION_METHOD_CVM_RESULTS_9F34_KRN cvr = new CARDHOLDER_VERIFICATION_METHOD_CVM_RESULTS_9F34_KRN(database);

            if (cvr.Value.GetCVMPerformed() == CVMCode.EncipheredPINVerifiedOnline && cvr.Value.GetCVMResult() != CVMResult.Failed)
            {
                AddDREntry(EMVTagsEnum.TRANSACTION_PERSONAL_IDENTIFICATION_NUMBER_PIN_DATA_99_KRN, database);
            }

            AddDREntry(EMVTagsEnum.POINTOFSERVICE_POS_ENTRY_MODE_9F39_KRN, database);
            AddDREntry(EMVTagsEnum.AMOUNT_AUTHORISED_NUMERIC_9F02_KRN, database);
            AddDREntry(EMVTagsEnum.AMOUNT_OTHER_NUMERIC_9F03_KRN, database);
            AddDREntry(EMVTagsEnum.APPLICATION_CRYPTOGRAM_9F26_KRN, database);
            AddDREntry(EMVTagsEnum.APPLICATION_EXPIRATION_DATE_5F24_KRN, database);
            AddDREntry(EMVTagsEnum.APPLICATION_INTERCHANGE_PROFILE_82_KRN, database);
            AddDREntry(EMVTagsEnum.APPLICATION_LABEL_50_KRN, database);
            AddDREntry(EMVTagsEnum.APPLICATION_PRIMARY_ACCOUNT_NUMBER_PAN_5A_KRN, database);
            AddDREntry(EMVTagsEnum.APPLICATION_PRIMARY_ACCOUNT_NUMBER_PAN_SEQUENCE_NUMBER_5F34_KRN, database);
            AddDREntry(EMVTagsEnum.APPLICATION_PREFERRED_NAME_9F12_KRN, database);
            AddDREntry(EMVTagsEnum.APPLICATION_TRANSACTION_COUNTER_ATC_9F36_KRN, database);
            AddDREntry(EMVTagsEnum.APPLICATION_USAGE_CONTROL_9F07_KRN, database);
            AddDREntry(EMVTagsEnum.APPLICATION_VERSION_NUMBER_TERMINAL_9F09_KRN, database);
            AddDREntry(EMVTagsEnum.CRYPTOGRAM_INFORMATION_DATA_9F27_KRN, database);
            AddDREntry(EMVTagsEnum.CARDHOLDER_VERIFICATION_METHOD_CVM_RESULTS_9F34_KRN, database);
            AddDREntry(EMVTagsEnum.DEDICATED_FILE_DF_NAME_84_KRN, database);
            AddDREntry(EMVTagsEnum.INTERFACE_DEVICE_IFD_SERIAL_NUMBER_9F1E_KRN, database);
            AddDREntry(EMVTagsEnum.ISSUER_APPLICATION_DATA_9F10_KRN, database);
            AddDREntry(EMVTagsEnum.ISSUER_CODE_TABLE_INDEX_9F11_KRN, database);
            AddDREntry(EMVTagsEnum.TERMINAL_CAPABILITIES_9F33_KRN, database);
            AddDREntry(EMVTagsEnum.TERMINAL_COUNTRY_CODE_9F1A_KRN, database);
            AddDREntry(EMVTagsEnum.TERMINAL_TYPE_9F35_KRN, database);
            AddDREntry(EMVTagsEnum.TERMINAL_VERIFICATION_RESULTS_95_KRN, database);
            AddDREntry(EMVTagsEnum.TRACK_2_EQUIVALENT_DATA_57_KRN, database);
            AddDREntry(EMVTagsEnum.TRANSACTION_CURRENCY_CODE_5F2A_KRN, database);
            AddDREntry(EMVTagsEnum.TRANSACTION_DATE_9A_KRN, database);
            AddDREntry(EMVTagsEnum.TRANSACTION_TYPE_9C_KRN, database);
            AddDREntry(EMVTagsEnum.UNPREDICTABLE_NUMBER_9F37_KRN, database);
            AddDREntry(EMVTagsEnum.TRANSACTION_STATUS_INFORMATION_9B_KRN, database);

            #region c-3 kernel 3 req 3.2.1.3
            AddDREntry(EMVTagsEnum.PAYMENT_ACCOUNT_REFERENCE_9F24_KRN, database);
            #endregion

            //Kernel 2
            AddDREntry(EMVTagsEnum.TRANSACTION_CATEGORY_CODE_9F53_KRN2, database);

            //Kernel 3
            #region c-3 kernel 3 req 3.2.1.2
            AddDREntry(EMVTagsEnum.FORM_FACTOR_INDICATOR_FFI_9F6E_KRN3, database);
            AddDREntry(EMVTagsEnum.CUSTOMER_EXCLUSIVE_DATA_CED_9F7C_KRN3, database);
            #endregion

            #region c-3 kernel 3 req 4.1.1.1
            TLV ffi = database.Get(EMVTagsEnum.FORM_FACTOR_INDICATOR_FFI_9F6E_KRN3);
            if (ffi != null)
            {
                ffi.Value[3] = (byte)(ffi.Value[3] & 0xF0);//indicating that the transaction was conducted using [ISO 14443]
            }
            #endregion
        }