package ru.upos;

import static ru.upos.TagSource.*;

/**
 * Tag
 */
public enum Tag {
    // EMV
    // Integrated Circuit Card
    // Specifications for Payment Systems
    // Book 3
    // Application Specification
    // Version 4.3
    // November 2011
    // Annex A Data Elements Dictionary
    //Tag9C(0x9C, "Transaction Type", Terminal, "n2", null, "1", "Indicates the type of financial transaction, represented by the first two digits of the ISO 8583:1987 Processing Code. The actual values to be used for the Transaction Type data element are defined by the relevant payment system"),
    //Tag9F02(0x9F02, "Amount, Authorised (Numeric)", Terminal, "n12", null, "6", "Authorised amount of the transaction (excluding adjustments)"),
    Tag42(0x42, "Issuer Identification Number (IIN)", Icc, "n 6", "'BF0C' or '73'", "3", "The number that identifies the major industry and the card issuer and that forms the first part of the Primary Account Number (PAN)"),
    Tag4F(0x4F, "Application Dedicated File (ADF) Name", Icc, "b", "'61'", "5-16", "Identifies the application as described in ISO/IEC 7816-5"),
    Tag50(0x50, "Application Label", Icc, "ans with the special character limited to space", "'61' or 'A5'", "1-16", "Mnemonic associated with the AID according to ISO/IEC 7816-5"),
    Tag57(0x57, "Track 2 Equivalent Data", Icc, "b", "'70' or '77'", "var. up to 19", "Contains the data elements of track 2 according to ISO/IEC 7813, excluding start sentinel, end sentinel, and Longitudinal Redundancy Check (LRC), as follows:"),
    Tag5A(0x5A, "Application Primary Account Number (PAN)", Icc, "cn var. up to 19", "'70' or '77'", "var. up to 10", "Valid cardholder account number"),
    Tag5F20(0x5F20, "Cardholder Name", Icc, "ans 2-26", "'70' or '77'", "2-26", "Indicates cardholder name according to ISO 7813"),
    Tag5F24(0x5F24, "Application Expiration Date", Icc, "n 6 YYMMDD", "'70' or '77'", "3", "Date after which application expires"),
    Tag5F25(0x5F25, "Application Effective Date", Icc, "n 6 YYMMDD", "'70' or '77'", "3", "Date from which the application may be used"),
    Tag5F28(0x5F28, "Issuer Country Code", Icc, "n 3", "'70' or '77'", "2", "Indicates the country of the issuer according to ISO 3166"),
    Tag5F2A(0x5F2A, "Transaction Currency Code", Terminal, "n 3", "", "2", "Indicates the currency code of the transaction according to ISO 4217"),
    Tag5F2D(0x5F2D, "Language Preference", Icc, "an 2", "'A5'", "2-8", "1-4 languages stored in order of preference, each represented by 2 alphabetical characters according to ISO 639 Note: EMVCo strongly recommends that cards be personalised with data element '5F2D' coded in lowercase, but that terminals accept the data element whether it is coded in upper or lower case."),
    Tag5F30(0x5F30, "Service Code", Icc, "n 3", "'70' or '77'", "2", "Service code as defined in ISO/IEC 7813 for track 1 and track 2"),
    //Tag5F34(0x5F34, "Application Primary Account Number (PAN) Sequence Number", Icc, "n 2", "'70' or '77'", "1", "Identifies and differentiates cards with the same PAN"),
    //Tag5F36(0x5F36, "Transaction Currency Exponent", Terminal, "n 1", "", "1", "Indicates the implied position of the decimal point from the right of the transaction amount represented according to ISO 4217"),
    Tag5F50(0x5F50, "Issuer URL", Icc, "ans", "'BF0C' or '73'", "var.", "The URL provides the location of the Issuers Library Server on the Internet."),
    Tag5F53(0x5F53, "International Bank Account Number (IBAN)", Icc, "var.", "'BF0C' or '73'", "Var. up to 34", "Uniquely identifies the account of a customer at a financial institution as defined in ISO 13616."),
    Tag5F54(0x5F54, "Bank Identifier Code (BIC)", Icc, "var.", "'BF0C' or '73'", "8 or 11", "Uniquely identifies a bank as defined in ISO 9362."),
    Tag5F55(0x5F55, "Issuer Country Code (alpha2 format)", Icc, "a 2", "'BF0C' or '73'", "2", "Indicates the country of the issuer as defined in ISO 3166 (using a 2 character alphabetic code)"),
    Tag5F56(0x5F56, "Issuer Country Code (alpha3 format)", Icc, "a 3", "'BF0C' or '73'", "3", "Indicates the country of the issuer as defined in ISO 3166 (using a 3 character alphabetic code)"),
    Tag5F57(0x5F57, "Account Type", Terminal, "n 2", "", "1", "Indicates the type of account selected on the terminal, coded as specified in Annex G"),
    Tag61(0x61, "Application Template", Icc, "b", "'70'", "var. up to 252", "Contains one or more data objects relevant to an application directory entry according to ISO/IEC 7816-5"),
    Tag6F(0x6F, "File Control Information (FCI) Template", Icc, "var.", "", "var. up to 252", "Identifies the FCI template according to ISO/IEC 7816-4"),
    Tag70(0x70, "READ RECORD Response Message Template", Icc, "var.", "", "var. up to 252", "Contains the contents of the record read. (Mandatory for SFIs 1-10. Response messages for SFIs 11-30 are outside the scope of EMV, but may use template '70')"),
    Tag71(0x71, "Issuer Script Template 1", Issuer, "b", "", "var.", "Contains proprietary issuer data for transmission to the ICC before the second GENERATE AC command"),
    Tag72(0x72, "Issuer Script Template 2", Issuer, "b", "", "var.", "Contains proprietary issuer data for transmission to the ICC after the second GENERATE AC command"),
    Tag73(0x73, "Directory Discretionary Template", Icc, "var.", "'61'", "var. up to 252", "Issuer discretionary part of the directory according to ISO/IEC 7816-5"),
    Tag77(0x77, "Response Message Template Format 2", Icc, "var.", "", "var.", "Contains the data objects (with tags and lengths) returned by the ICC in response to a command"),
    Tag80(0x80, "Response Message Template Format 1", Icc, "var.", "", "var.", "Contains the data objects (without tags and lengths) returned by the ICC in response to a command"),
    Tag81(0x81, "Amount, Authorised (Binary)", Terminal, "b", "", "4", "Authorised amount of the transaction (excluding adjustments)"),
    Tag82(0x82, "Application Interchange Profile", Icc, "b", "'77' or '80'", "2", "Indicates the capabilities of the card to support specific functions in the application"),
    Tag83(0x83, "Command Template", Terminal, "b", "", "var.", "Identifies the data field of a command message"),
    Tag84(0x84, "Dedicated File (DF) Name", Icc, "b", "'6F'", "5-16", "Identifies the name of the DF as described in ISO/IEC 7816-4"),
    Tag86(0x86, "Issuer Script Command", Issuer, "b", "'71' or '72'", "var. up to 261", "Contains a command for transmission to the ICC"),
    Tag87(0x87, "Application Priority Indicator", Icc, "b", "'61' or 'A5'", "1", "Indicates the priority of a given application or group of applications in a directory"),
    Tag88(0x88, "Short File Identifier (SFI)", Icc, "b", "'A5'", "1", "Identifies the AEF referenced in commands related to a given ADF or DDF. It is a binary data object having a value in the range 1 to 30 and with the three high order bits set to zero."),
    //Tag89(0x89, "Authorisation Code", Issuer, "As defined by the Payment Systems", "", "6", "Value generated by the authorisation authority for an approved transaction"),
    Tag8A(0x8A, "Authorisation Response Code", Issuer, "an 2", "", "2", "Code that defines the disposition of a message"),
    //Tag8C(0x8C, "Card Risk Management Data Object List 1 (CDOL1)", Icc, "b", "'70' or '77'", "var. up to 252", "List of data objects (tag and length) to be passed to the ICC in the first GENERATE AC command"),
    Tag8D(0x8D, "Card Risk Management Data Object List 2 (CDOL2)", Icc, "b", "'70' or '77'", "var. up to 252", "List of data objects (tag and length) to be passed to the ICC in the second GENERATE AC command"),
    Tag8E(0x8E, "Cardholder Verification Method (CVM) List", Icc, "b", "'70' or '77'", "10-252", "Identifies a method of verification of the cardholder supported by the application"),
    //Tag8F(0x8F, "Certification Authority Public Key Index", Icc, "b", "'70' or '77'", "1", "Identifies the certification authoritys public key in conjunction with the RID"),
    //Tag90(0x90, "Issuer Public Key Certificate", Icc, "b", "'70' or '77'", "NCA", "Issuer public key certified by a certification authority"),
    Tag91(0x91, "Issuer Authentication Data", Issuer, "b", "", "8-16", "Data sent to the ICC for online issuer authentication"),
    Tag92(0x92, "Issuer Public Key Remainder", Icc, "b", "'70' or '77'", "NI ? NCA + 36", "Remaining digits of the Issuer Public Key Modulus"),
    Tag93(0x93, "Signed Static Application Data", Icc, "b", "'70' or '77'", "NI", "Digital signature on critical application parameters for SDA"),
    Tag94(0x94, "Application File Locator (AFL)", Icc, "var.", "'77' or '80'", "var. up to 252", "Indicates the location (SFI, range of records) of the AEFs related to a given application"),
    Tag95(0x95, "Terminal Verification Results", Terminal, "b", "", "5", "Status of the different functions as seen from the terminal"),
    Tag97(0x97, "Transaction Certificate Data Object List (TDOL)", Icc, "b", "'70' or '77'", "var. up to 252", "List of data objects (tag and length) to be used by the terminal in generating the TC Hash Value"),
    //Tag98(0x98, "Transaction Certificate (TC) Hash Value", Terminal, "b", "", "20", "Result of a hash function specified in Book 2, Annex B3.1"),
    Tag99(0x99, "Transaction Personal Identification Number (PIN) Data", Terminal, "b", "", "var.", "Data entered by the cardholder for the purpose of the PIN verification"),
    Tag9A(0x9A, "Transaction Date", Terminal, "n 6 YYMMDD", "", "3", "Local date that the transaction was authorised"),
    Tag9B(0x9B, "Transaction Status Information", Terminal, "b", "", "2", "Indicates the functions performed in a transaction"),
    Tag9C(0x9C, "Transaction Type", Terminal, "n 2", "", "1", "Indicates the type of financial transaction, represented by the first two digits of the ISO 8583:1987 Processing Code. The actual values to be used for the Transaction Type data element are defined by the relevant payment system"),
    //Tag9D(0x9D, "Directory Definition File (DDF) Name", Icc, "b", "'61'", "5-16", "Identifies the name of a DF associated with a directory"),
    Tag9F01(0x9F01, "Acquirer Identifier", Terminal, "n 6-11", "", "6", "Uniquely identifies the acquirer within each payment system"),
    Tag9F02(0x9F02, "Amount, Authorised (Numeric)", Terminal, "n 12", "", "6", "Authorised amount of the transaction (excluding adjustments)"),
    Tag9F03(0x9F03, "Amount, Other (Numeric)", Terminal, "n 12", "", "6", "Secondary amount associated with the transaction representing a cashback amount"),
    Tag9F04(0x9F04, "Amount, Other (Binary)", Terminal, "b", "", "4", "Secondary amount associated with the transaction representing a cashback amount"),
    Tag9F05(0x9F05, "Application Discretionary Data", Icc, "b", "'70' or '77'", "1-32", "Issuer or payment system specified data relating to the application"),
    Tag9F06(0x9F06, "Application Identifier (AID)  terminal", Terminal, "b", "", "5-16", "Identifies the application as described in ISO/IEC 7816-5"),
    Tag9F07(0x9F07, "Application Usage Control", Icc, "b", "'70' or '77'", "2", "Indicates issuers specified restrictions on the geographic usage and services allowed for the application"),
    Tag9F08(0x9F08, "Application Version Number", Icc, "b", "'70' or '77'", "2", "Version number assigned by the payment system for the application"),
    Tag9F09(0x9F09, "Application Version Number", Terminal, "b", "", "2", "Version number assigned by the payment system for the application"),
    Tag9F0B(0x9F0B, "Cardholder Name Extended", Icc, "ans 27-45", "'70' or '77'", "27-45", "Indicates the whole cardholder name when greater than 26 characters using the same coding convention as in ISO 7813"),
    Tag9F0D(0x9F0D, "Issuer Action Code - Default", Icc, "b", "'70' or '77'", "5", "Specifies the issuers conditions that cause a transaction to be rejected if it might have been approved online, but the terminal is unable to process the transaction online"),
    Tag9F0E(0x9F0E, "Issuer Action Code - Denial", Icc, "b", "'70' or '77'", "5", "Specifies the issuers conditions that cause the denial of a transaction without attempt to go online"),
    Tag9F0F(0x9F0F, "Issuer Action Code - Online", Icc, "b", "'70' or '77'", "5", "Specifies the issuers conditions that cause a transaction to be transmitted online"),
    Tag9F10(0x9F10, "Issuer Application Data", Icc, "b", "'77' or '80'", "var. up to 32", "Contains proprietary application data for transmission to the issuer in an online transaction. Note: For CCD-compliant applications, Annex C, section C7 defines the specific coding of the Issuer Application Data (IAD). To avoid potential conflicts with CCD-compliant applications, it is strongly recommended that the IAD data element in an application that is not CCD-compliant should not use the coding for a CCD-compliant application"),
    Tag9F11(0x9F11, "Issuer Code Table Index", Icc, "n 2", "'A5'", "1", "Indicates the code table according to ISO/IEC 8859 for displaying the Application Preferred Name"),
    Tag9F12(0x9F12, "Application Preferred Name", Icc, "ans (see section 4.3)","'61' or 'A5'", "1-16", "Preferred mnemonic associated with the AID"),
    Tag9F13(0x9F13, "Last Online Application Transaction Counter (ATC) Register", Icc, "b", "", "2", "ATC value of the last transaction that went online"),
    Tag9F14(0x9F14, "Lower Consecutive Offline Limit", Icc, "b", "'70' or '77'", "1", "Issuer-specified preference for the maximum number of consecutive offline transactions for this ICC application allowed in a terminal with online capability"),
    Tag9F15(0x9F15, "Merchant Category Code", Terminal, "n 4", "", "2", "Classifies the type of business being done by the merchant, represented according to ISO 8583:1993 for Card Acceptor Business Code"),
    Tag9F16(0x9F16, "Merchant Identifier", Terminal, "ans 15", "", "15", "When concatenated with the Acquirer Identifier, uniquely identifies a given merchant"),
    Tag9F17(0x9F17, "Personal Identification Number (PIN) Try Counter", Icc, "b", "", "1", "Number of PIN tries remaining"),
    Tag9F18(0x9F18, "Issuer Script Identifier", Issuer, "b", "'71' or '72'", "4", "Identification of the Issuer Script"),
    Tag9F1A(0x9F1A, "Terminal Country Code", Terminal, "n 3", "", "2", "Indicates the country of the terminal, represented according to ISO 3166"),
    Tag9F1B(0x9F1B, "Terminal Floor Limit", Terminal, "b", "", "4", "Indicates the floor limit in the terminal in conjunction with the AID"),
    Tag9F1C(0x9F1C, "Terminal Identification", Terminal, "an 8", "", "8", "Designates the unique location of a terminal at a merchant"),
    Tag9F1D(0x9F1D, "Terminal Risk Management Data", Terminal, "b", "", "1-8", "Application-specific value used by the card for risk management purposes"),
    Tag9F1E(0x9F1E, "Interface Device (IFD) Serial Number", Terminal, "an 8", "", "8", "Unique and permanent serial number assigned to the IFD by the manufacturer"),
    Tag9F1F(0x9F1F, "Track 1 Discretionary Data", Icc, "ans", "'70' or '77'", "var.", "Discretionary part of track 1 according to ISO/IEC 7813"),
    Tag9F20(0x9F20, "Track 2 Discretionary Data", Icc, "cn", "'70' or '77'", "var.", "Discretionary part of track 2 according to ISO/IEC 7813"),
    Tag9F21(0x9F21, "Transaction Time", Terminal, "n 6 HHMMSS", "", "3", "Local time that the transaction was authorised"),
    Tag9F22(0x9F22, "Certification Authority Public Key Index", Terminal, "b", "", "1", "Identifies the certification authoritys public key in conjunction with the RID"),
    Tag9F23(0x9F23, "Upper Consecutive Offline Limit", Icc, "b", "'70' or '77'", "1", "Issuer-specified preference for the maximum number of consecutive offline transactions for this ICC application allowed in a terminal without online capability"),
    Tag9F26(0x9F26, "Application Cryptogram", Icc, "b", "'77' or '80'", "8", "Cryptogram returned by the ICC in response of the GENERATE AC command"),
    Tag9F27(0x9F27, "Cryptogram Information Data", Icc, "b", "'77' or '80'", "1", "Indicates the type of cryptogram and the actions to be performed by the terminal"),
    Tag9F2D(0x9F2D, "Integrated Circuit Card (ICC) PIN Encipherment Public Key Certificate", Icc, "b", "'70' or '77'", "NI", "ICC PIN Encipherment Public Key certified by the issuer"),
    Tag9F2E(0x9F2E, "Circuit Card (ICC) PIN Encipherment Public Key Exponent", Icc, "b", "'70' or '77'", "1 or 3", "ICC PIN Encipherment Public Key Exponent used for PIN encipherment"),
    Tag9F2F(0x9F2F, "Integrated Circuit Card (ICC) PIN Encipherment Public Key Remainder", Icc, "b", "'70' or '77'", "NPE ? NI + 42", "Remaining digits of the ICC PIN Encipherment Public Key Modulus"),
    Tag9F32(0x9F32, "Issuer Public Key Exponent", Icc, "b", "'70' or '77'", "1 to 3", "Issuer public key exponent used for the verification of the Signed Static Application Data and the ICC Public Key Certificate"),
    Tag9F33(0x9F33, "Terminal Capabilities", Terminal, "b", "", "3", "Indicates the card data input, CVM, and security capabilities of the terminal"),
    Tag9F34(0x9F34, "Cardholder Verification Method (CVM) Results", Terminal, "b", "", "3", "Indicates the results of the last CVM performed"),
    Tag9F35(0x9F35, "Terminal Type", Terminal, "n 2", "", "1", "Indicates the environment of the terminal, its communications capability, and its operational control"),
    Tag9F36(0x9F36, "Application Transaction Counter (ATC)", Icc, "b", "'77' or '80'", "2", "Counter maintained by the application in the ICC (incrementing the ATC is managed by the ICC)"),
    Tag9F38(0x9F38, "Processing Options Data Object List (PDOL)", Icc, "b", "'A5'", "var.", "Contains a list of terminal resident data objects (tags and lengths) needed by the ICC in processing the GET PROCESSING OPTIONS command"),
    Tag9F37(0x9F37, "Unpredictable Number", Terminal, "b", "", "4", "Value to provide variability and uniqueness to the generation of a cryptogram"),
    Tag9F39(0x9F39, "Point-of-Service (POS) Entry Mode", Terminal, "n 2", "", "1", "Indicates the method by which the PAN was entered, according to the first two digits of the ISO 8583:1987 POS Entry Mode"),
    Tag9F3A(0x9F3A, "Amount, Reference Currency", Terminal, "b", "", "4", "Authorised amount expressed in the reference currency"),
    Tag9F3B(0x9F3B, "Application Reference Currency", Icc, "n 3", "'70' or '77'", "2-8", "1-4 currency codes used between the terminal and the ICC when the Transaction Currency Code is different from the Application Currency Code (each code is 3 digits according to ISO 4217)"),
    Tag9F3C(0x9F3C, "Transaction Reference Currency Code", Terminal, "n 3", "", "2", "Code defining the common currency used by the terminal in case the Transaction Currency Code is different from the Application Currency Code"),
    Tag9F3D(0x9F3D, "Transaction Reference Currency Exponent", Terminal, "n 1", "", "1", "Indicates the implied position of the decimal point from the right of the transaction amount, with the Transaction Reference Currency Code represented according to ISO 4217"),
    Tag9F40(0x9F40, "Additional Terminal Capabilities", Terminal, "b", "", "5", "Indicates the data input and output capabilities of the terminal"),
    Tag9F41(0x9F41, "Transaction Sequence Counter", Terminal, "n 4-8", "", "2-4", "Counter maintained by the terminal that is incremented by one for each transaction"),
    Tag9F42(0x9F42, "Application Currency Code", Icc, "n 3", "'70' or '77'", "2", "Indicates the currency in which the account is managed according to ISO 4217"),
    Tag9F43(0x9F43, "Application Reference Currency Exponent", Icc, "n 1", "'70' or '77'", "1-4", "Indicates the implied position of the decimal point from the right of the amount, for each of the 1-4 reference currencies represented according to ISO 4217"),
    Tag9F44(0x9F44, "Application Currency Exponent", Icc, "n 1", "'70' or '77'", "1", "Indicates the implied position of the decimal point from the right of the amount represented according to ISO 4217"),
    Tag9F45(0x9F45, "Data Authentication Code", Icc, "b", "", "2", "An issuer assigned value that is retained by the terminal during the verification process of the Signed Static Application Data"),
    Tag9F46(0x9F46, "Integrated Circuit Card (ICC) Public Key Certificate", Icc, "b", "'70' or '77'", "NI", "ICC Public Key certified by the issuer"),
    Tag9F47(0x9F47, "Integrated Circuit Card (ICC) Public Key Exponent", Icc, "b", "'70' or '77'", "1 to 3", "ICC Public Key Exponent used for the verification of the Signed Dynamic Application Data"),
    Tag9F48(0x9F48, "Integrated Circuit Card (ICC) Public Key Remainder", Icc, "b", "'70' or '77'", "NIC ? NI + 42", "Remaining digits of the ICC Public Key Modulus"),
    Tag9F49(0x9F49, "Dynamic Data Authentication Data Object List (DDOL)", Icc, "b", "'70' or '77'", "up to 252", "List of data objects (tag and length) to be passed to the ICC in the INTERNAL AUTHENTICATE command"),
    Tag9F4A(0x9F4A, "Static Data Authentication Tag List", Icc, "", "'70' or '77'", "var.", "List of tags of primitive data objects defined in this specification whose value fields are to be included in the Signed Static or Dynamic Application Data"),
    Tag9F4B(0x9F4B, "Signed Dynamic Application Data", Icc, "b", "'77' or '80'", "NIC", "Digital signature on critical application parameters for DDA or CDA"),
    Tag9F4C(0x9F4C, "ICC Dynamic Number", Icc, "b", "", "2-8", "Time-variant number generated by the ICC, to be captured by the terminal"),
    Tag9F4D(0x9F4D, "Log Entry", Icc, "b", "'BF0C' or '73'", "2", "Provides the SFI of the Transaction Log file and its number of records"),
    Tag9F4E(0x9F4E, "Merchant Name and Location", Terminal, "ans", "", "var.", "Indicates the name and location of the merchant"),
    Tag9F4F(0x9F4F, "Log Format", Icc, "b", "", "var.", "List (in tag and length format) of data objects representing the logged data elements that are passed to the terminal when a transaction log record is read"),
    //TagA5(0xA5, "File Control Information (FCI) Proprietary Template", Icc, "var.", "'6F'", "var.", "Identifies the data object proprietary to this specification in the FCI template according to ISO/IEC 7816-4"),
    TagBF0C(0xBF0C, "File Control Information (FCI) Issuer Discretionary Data", Icc, "var.", "'A5'", "var. up to 222", "Issuer discretionary part of the FCI"),
    TagAsi(0x00, "Application Selection Indicator", Terminal, "At the discretion of the terminal. The data is not sent across the interface", "", "See format", "For an application in the ICC to be supported by an application in the terminal, the Application Selection Indicator indicates whether the associated AID in the terminal must match the AID in the card exactly, including the length of the AID, or only up to the length of the AID in the terminal There is only one Application Selection Indicator per AID supported by the terminal"),
    TagArpc(0x00, "Authorisation Response Cryptogram (ARPC)", Issuer, "b", "", "4 or 8", "Cryptogram generated by the issuer and used by the card to verify that the response came from the issuer."),
    TagCsu(0x00, "Card Status Update (CSU)", Issuer, "b", "", "4", "Contains data sent to the ICC to indicate whether the issuer approves or declines the transaction, and to initiate actions specified by the issuer. Transmitted to the card in Issuer Authentication Data."),
    TagCapkChSum(0x00, "Certification Authority Public Key Check Sum", Terminal, "b", "", "20", "A check value calculated on the concatenation of all parts of the Certification Authority Public Key (RID, Certification Authority Public Key Index, Certification Authority Public Key Modulus, Certification Authority Public Key Exponent) using SHA-1"),
    TagCapkExp(0x00, "Certification Authority Public Key Exponent", Terminal, "b", "", "1 or 3", "Value of the exponent part of the Certification Authority Public Key"),
    TagCapkMod(0x00, "Certification Authority Public Key Modulus", Terminal, "b", "", "NCA (up to 248)", "Value of the modulus part of the Certification Authority Public Key"),
    TagDdol(0x00, "Default Dynamic Data Authentication Data Object List (DDOL)", Terminal, "b", "", "var.", "DDOL to be used for constructing the INTERNAL AUTHENTICATE command if the DDOL in the card is not present"),
    TagTdol(0x00, "Default Transaction Certificate Data Object List (TDOL)", Terminal, "b", "", "var.", "TDOL to be used for generating the TC Hash Value if the TDOL in the card is not present"),
    TagPinBlock(0x00, "Enciphered Personal Identification Number (PIN) Data", Terminal, "b", "", "8", "Transaction PIN enciphered at the PIN pad for online verification or for offline verification if the PIN pad and IFD are not a single integrated device"),
    TagIssScrRes(0x00, "Issuer Script Results", Terminal, "b", "", "var.", "Indicates the result of the terminal script processing"),
    TagMaxTP(0x00, "Maximum Target Percentage to be used for Biased Random Selection", Terminal, "", "", "", "Value used in terminal risk management for random transaction selection"),
    TagMessageType(0x00, "Message Type", Terminal, "n 2", "", "1", "Indicates whether the batch data capture record is a financial record or advice"),
    TagPinKey(0x00, "Personal Identification Number (PIN) Pad Secret Key", Terminal, "", "", "", "Secret key of a symmetric algorithm used by the PIN pad to encipher the PIN and by the card reader to decipher the PIN if the PIN pad and card reader are not integrated"),
    TagPropAuthData(0x00, "Proprietary Authentication Data", Issuer, "b", "", "var. up to 8", "Contains issuer data for transmission to the card in the Issuer Authentication Data of an online transaction."),
    TagTP(0x00, "Target Percentage to be Used for Random Selection", Terminal, "", "", "", "Value used in terminal risk management for random transaction selection"),
    TagTacDefault(0x00, "Terminal Action Code - Default", Terminal, "b", "", "5", "Specifies the acquirers conditions that cause a transaction to be rejected if it might have been approved online, but the terminal is unable to process the transaction online"),
    TagTacDenial(0x00, "Terminal Action Code - Denial", Terminal, "b", "", "5", "Specifies the acquirers conditions that cause the denial of a transaction without attempt to go online"),
    TagTacOnline(0x00, "Terminal Action Code - Online", Terminal, "b", "", "5", "Specifies the acquirers conditions that cause a transaction to be transmitted online"),
    TagTV(0x00, "Threshold Value for Biased Random Selection", Terminal, "", "", "", "Value used in terminal risk management for random transaction selection"),
    TagTrAmount(0x00, "Transaction Amount", Terminal, "n 12", "", "6", "Clearing amount of the transaction, including tips and other adjustments"),
    TagCurrConv(0x00, "Transaction Reference Currency Conversion", Terminal, "n 8", "", "4", "Factor used in the conversion from the Transaction Currency Code to the Transaction Reference Currency Code"),
    // UPOS tags (EMV & UPOS tags intersection is possible, current tags intersection: 5F34, 5F36, 89, 8C, 8F, 90, 98, 9D, A5)
    Tag89(0x89, "Masked card number", Unknown, "", null, "16", ""),
    Tag8B(0x8B, "Invoice number", Unknown, "", null, "6", ""),
    Tag8C(0x8C, "Authorization Id", Unknown, "", null, "6", ""),
    Tag8F(0x8F, "Issuer or Payment system", Unknown, "", null, "10", ""),
    Tag90(0x90, "Merchant number", Unknown, "", null, "12", ""),
    Tag98(0x98, "Retrieval Reference Number (RRN)", Unknown, "", null, "", "12"),
    Tag9D(0x9D, "Terminal unique number", Unknown, "", null, "8", ""),
    TagA4(0xA4, "Sber card flag", Unknown, "", null, "1", ""),
    TagA5(0xA5, "Operation completion code", Unknown, "", null, "4", ""),
    Tag5F03(0x5F03, "Loyalty programm number", Unknown, "", null, "3", ""),
    Tag5F04(0x5F04, "Cardholder name", Unknown, "", null, "2", ""),
    Tag5F05(0x5F05, "Error response message", Unknown, "", null, "8", ""),
    Tag5F06(0x5F06, "Card exp date", Unknown, "", null, "5", ""),
    Tag5F07(0x5F07, "Internal operation type", Unknown, "", null, "3", ""),
    Tag5F0A(0x5F0A, "Request Id", Unknown, "", null, "4", ""),
    Tag5F0C(0x5F0C, "Transaction flags", Unknown, "", null, "4", ""),
    Tag5F0D(0x5F0D, "Card type", Unknown, "", null, "1", ""),
    Tag5F34(0x5F34, "Amount", Unknown, "", null, "4", ""),
    Tag5F35(0x5F35, "AmountC", Unknown, "", null, "4", ""),
    Tag5F36(0x5F36, "Card hash", Unknown, "", null, "20", ""),
    Tag5F37(0x5F37, "Operation date", Unknown, "", null, "4", ""),
    Tag5F38(0x5F38, "Operation time", Unknown, "", null, "4", ""),
    Tag5F39(0x5F39, "Enciphered data block", Unknown, "", null, "32", ""),
    // tags for MasterCall command PingInfo
    TagE2(0xE2, "ECR device information template tag", Terminal, "", null, "", ""),
    TagCE(0xCE, "", Terminal, "", null, "", ""),
    TagC4(0xC4, "", Terminal, "", null, "", ""),
    TagC5(0xC5, "", Terminal, "", null, "", ""),
    TagC8(0xC8, "", Terminal, "", null, "", ""),
    TagC9(0xC9, "", Terminal, "", null, "", ""),
    TagD3(0xD3, "", Terminal, "", null, "", ""),
    TagD4(0xD4, "", Terminal, "", null, "", ""),
    TagD5(0xD5, "", Terminal, "", null, "", ""),
    TagE1(0xE1, "", Terminal, "", null, "", ""),
    TagE4(0xE4, "", Terminal, "", null, "", "")
    ;

    private final int tag;
    private final String name;
    private final TagSource source;
    private final String format;
    private final String template;
    private final String length;
    private final String description;

    Tag(int tag, String name, TagSource source, String format, String template, String length, String description) {
        this.tag = tag;
        this.name = name;
        this.description = description;
        this.source = source;
        this.format = format;
        this.template = template;
        this.length = length;
    }

    public int getTag() {
        return tag;
    }

    public String getName() {
        return name;
    }

    public String getDescription() {
        return description;
    }

    public static Tag getTag(int tagExternal) throws Exception {
        for (Tag tag : Tag.values()) {
            if (tag.tag == tagExternal) {
                return tag;
            }
        }
        throw new Exception("Unknown tag: " + String.format("%X", tagExternal));
    }
}
