Adding Issuer script in response - Tag 72

2,521 views
Skip to first unread message

Hari Gade

unread,
Dec 8, 2016, 10:31:21 PM12/8/16
to jPOS Users
Hi All,

I am facing problems in adding Tag 72  issuer script in response in DE55. Below is the problem and please advice.

Description : When transaction is received with icc data, we expand the DE 55 and  create the issuer script if below scenario are true.
1)  whether issuer script update in last transaction is failed. 
2) There is a pin change requested.


Now if either of case is true . We format a command 351(with MKDMethod, SKDMethod etc..basically we are using atalla box) and send to atalla to generate the pin and mac. Now Atalla will respond with PINBLOCK and MAC.

Before I move forward , Just want to let you how the TAG 72 is :

Tag  length   value
72    1F      861D8424000218XXXXXXXXXXXXXXXXYYYYYYYY (Where XXXXXXXXXXXXXXXX is pinblock and YYYYYYYY is Mac)

From the above value is in-turn a tag value as below

Tag     length         value
86       1D            8424000218XXXXXXXXXXXXXXXXYYYYYYYY

So TAG 72 value type is a EMV TAGVALUE (86 tag)

Now firstly I have created the 86 TAGVALUE where the object is of EMVTag[]. So the type of value of 72 tag is EMVTag[].

Reason why we need to create the type of value of 72 tag as EMVTag[]. is below 

public enum EMVStandardTagType implements EMVTagType {

ISSUER_SCRIPT_TEMPLATE_2_0x72(

            0x72,

            "Issuer Script Template 2",

            "Contains proprietary issuer data for transmission to the ICC after the second GENERATE AC command",

            DataSource.ISSUER, TLVDataFormat.CONSTRUCTED, new VariableDataLength(

            DataLength.DATA_LENGTH_VAR, DataLength.DATA_LENGTH_VAR), 0x00, new VariableByteLength(

            ByteLength.BYTE_LENGTH_VAR, ByteLength.BYTE_LENGTH_VAR)),

}


from above TLVDataFormat.CONSTRUCTED. if TLVDataFormat.CONSTRUCTED then 


 public Class<?> getDataType() throws ProprietaryFormatException {

        switch (format) {

            case PROPRIETARY:

                throw new ProprietaryFormatException(tagShortDescription);

            case BINARY:

                return byte[].class;

            case CONSTRUCTED:

                return EMVTag[].class;

            default:

                return String.class;

        }

    }


From the above  value of 72 tag (86 tag and value)  type should be EMVTag[]. 


So I have created the 72 tag value which is combination of 86 tag and value as a EMVTag[] object.


But now the problem here is in JPOS there is no where supported EMVTag[] ex:


In TagsequenceBase.class in JPOS has  below which doesn't have value instanceof EMVTag[].


public synchronized void writeTo(ISOMsg isoMsg) throws ISOException {

        int maxField = isoMsg.getMaxField();

        List<TagValue> tagValueList = getOrderedList();

        int fieldNumber = 0;

        for (TagValue tagValue : tagValueList) {

            Object value = tagValue.getValue();

            if (value != null) {

                ISOComponent subField;

                if (value instanceof byte[]) {

                    subField = new ISOBinaryField(fieldNumber + maxField + 1, (byte[]) value);

                } else if (value instanceof String) {

                    subField = new ISOField(fieldNumber + maxField + 1, (String) value);

                } else if (value instanceof TagSequence) {

                    TagSequence subSequence = (TagSequence) tagValue;

                    subField = new ISOMsg(fieldNumber + maxField + 1);

                    subSequence.writeTo((ISOMsg) subField);

                } else if (value instanceof ISOMsg) {

                    ISOMsgTagValue subSequence = (ISOMsgTagValue) tagValue;

                    subField = subSequence.getValue();

                    subField.setFieldNumber(fieldNumber + maxField + 1);

                } else {

                    throw new ISOException("Unknown TagValue subclass: " + tagValue.getClass());

                }

                isoMsg.set(new ISOTaggedField(tagValue.getTag(), subField));

            }

            fieldNumber++;

        }

    }


I can override and include the if condition that checks whether instanceof EMVTag[] , but I need to change like this in every .class of JPOS that is not possible.


So please can anyone suggest how can Tag 72 is added in the DE55 response.


Thanks,

Hari.




Mark Salter

unread,
Dec 9, 2016, 1:51:59 AM12/9/16
to jpos-...@googlegroups.com
On 09/12/16 03:31, Hari Gade wrote:
> I am facing problems in adding Tag 72 issuer script in response in
> DE55. Below is the problem and please advice.
Please confirm the version of jPOS you are actually using.

I don't recognise the classes you reference and fear you are on the
wrong mailing list or perhaps referencing code that forms part of your
'closed' project and not our open one.

If you are really using jPOS, then you are doing way too much lifting,
since what you want can be achieved in a handful of lines of code using
jPOS.

Please confirm or rebuked my guess work above and I will try to provide
some code examples later today (I am on my way out of the door now).

--
Mark

Victor Salaman

unread,
Dec 9, 2016, 2:04:47 AM12/9/16
to jpos-...@googlegroups.com

On Thu, Dec 8, 2016 at 10:31 PM, Hari Gade <hari.g...@gmail.com> wrote:
861D8424000218XXXXXXXXXXXXXXXXYYYYYYYY (Where XXXXXXXXXXXXXXXX is pinblock and YYYYYYYY


Hi:

You can construct first the Tag 86 independently, convert to a byte array. The result of that operation you will use to create Tag 72. Doesn't this do what you need?

/V


chhil

unread,
Dec 9, 2016, 7:17:13 AM12/9/16
to jpos-...@googlegroups.com

Mark,
It's from a contributed code to jpos

E. G.

https://github.com/jpos/jPOS/blob/master/jpos/src/main/java/org/jpos/emv/EMVStandardTagType.java

-chhil


--
--
jPOS is licensed under AGPL - free for community usage for your open-source project. Licenses are also available for commercial usage. Please support jPOS, contact: sa...@jpos.org
---
You received this message because you are subscribed to the Google Groups "jPOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+...@googlegroups.com.
To post to this group, send email to jpos-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/CALK1SyzvQBVE9GR2fCnthZg8QMFAWTGh1LS37Q8_%2BaGKPZ%2BpiQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Hari Gade

unread,
Dec 9, 2016, 1:57:57 PM12/9/16
to jPOS Users, Tushar
Hi Victor,

Thanks for your quick response. I want to add Tag 72 which is an constructed tag (ex: 72LLTLVTLV). DO you have any code / any way of implementation, how to add this tag 72 as a sub element of DE-55 with tag 91 (issuer resposne data). I am facing problem adding it.
Tag 91 and tag 72 both should go in transaction response to the card.
 
Below is the implementaion/code i am trying to implement.

I have created TAG 86 independently and result of that operation is used to create Tag 72. Now the problem here is I have to add the result operation of Tag 72 to the response of ISO MSG in DE 55(I want to add Tag 72 as one of the sub element in DE 55 like Tag 91)  . For this to add in ISO MSG i have to use TagSequenceBase class in JPOS  as shown in below.

public synchronized void writeTo(ISOMsg isoMsg) throws ISOException {

        int maxField = isoMsg.getMaxField();

        List<TagValue> tagValueList = getOrderedList();

        int fieldNumber = 0;

        for (TagValue tagValue : tagValueList) {

            Object value = tagValue.getValue();

            if (value != null) {

                ISOComponent subField;

                if (value instanceof byte[]) {

                    subField = new ISOBinaryField(fieldNumber + maxField + 1, (byte[]) value);

                } else if (value instanceof String) {

                    subField = new ISOField(fieldNumber + maxField + 1, (String) value);

                } else if (value instanceof TagSequence) {

                    TagSequence subSequence = (TagSequence) tagValue;

                    subField = new ISOMsg(fieldNumber + maxField + 1);

                    subSequence.writeTo((ISOMsg) subField);

                } else if (value instanceof ISOMsg) {

                    ISOMsgTagValue subSequence = (ISOMsgTagValue) tagValue;

                    subField = subSequence.getValue();

                    subField.setFieldNumber(fieldNumber + maxField + 1);

                } else {

                    throw new ISOException("Unknown TagValue subclass: " + tagValue.getClass());

                }

                isoMsg.set(new ISOTaggedField(tagValue.getTag(), subField));

            }

            fieldNumber++;

        }

    }


From the above we don't have instance of EMVTag[] since result operation of Tag 72 value is an instance of EMVTag[] . Now i did override to customize my requirement as below

public synchronized void writeTo(ISOMsg isoMsgthrows ISOException {

        int maxField = isoMsg.getMaxField();

        List<TagValue> tagValueList = getOrderedList();

        int fieldNumber = 0;

        for (TagValue tagValue : tagValueList) {

            Object value = tagValue.getValue();

            if (value != null) {

                ISOComponent subField;

                if (value instanceof byte[]) {

                    subField = new ISOBinaryField(fieldNumber + maxField + 1, (byte[]) value);

                } else if (value instanceof String) {

                    subField = new ISOField(fieldNumber + maxField + 1, (String) value);

                } else if (value instanceof TagSequence) {

                    TagSequence subSequence = (TagSequence) tagValue;

                    subField = new ISOMsg(fieldNumber + maxField + 1);

                    subSequence.writeTo((ISOMsg) subField);

                } else if (value instanceof ISOMsg) {

                    ISOMsgTagValue subSequence = (ISOMsgTagValue) tagValue;

                    subField = subSequence.getValue();

                    subField.setFieldNumber(fieldNumber + maxField + 1);

                } else if (value instanceof EMVTag[]) {

                    subField = new ISOMsg(fieldNumber + maxField + 1);

                    subSequence.writeTo((ISOMsg) subField);

                 else {

                    throw new ISOException("Unknown TagValue subclass: " + tagValue.getClass());

                }

                isoMsg.set(new ISOTaggedField(tagValue.getTag(), subField));

            }

            fieldNumber++;

        }

    }



If I customise as above then I can pass the exception that I have faced(throw new ISOException("Unknown TagValue subclass: " + tagValue.getClass());)  but again going forward i have below in TagsequenceBase as 


   protected abstract TagSequence createTagValueSequence(String tag);


    protected abstract TagValue createLiteralTagValuePair(String tag, String value) throws ISOException;


    protected abstract TagValue createBinaryTagValuePair(String tag, byte[] value) throws ISOException;


Now from above value is type of string or byte but we dont have EMVTag[]. I cannot override again,  so like these we have many issues where I cannot fit tag 72 value since it is EMVTag[].







 

Mark Salter

unread,
Dec 9, 2016, 5:51:03 PM12/9/16
to jpos-...@googlegroups.com
On 09/12/16 12:16, chhil wrote:
> Mark,
> It's from a contributed code to jpos
>
> E. G.
>
> https://github.com/jpos/jPOS/blob/master/jpos/src/main/java/org/jpos/emv/EMVStandardTagType.java
>
Thanks Chhil, I had missed that, and I failed to get any 'jPOS' results
from my google search.

Thanks for sharing.

--
Mark

Mark Salter

unread,
Dec 9, 2016, 5:57:59 PM12/9/16
to jpos-...@googlegroups.com
Perfect advise Victor.

I see the OP is repeating himself, but I hope he will reread your
response and follow it - he seems lost in the detail and seems to be
missing the simply obvious.

--
Mark

Victor Salaman

unread,
Dec 10, 2016, 1:45:36 AM12/10/16
to jpos-...@googlegroups.com

Hi

Take a look at:

    public static void main(String[] args) throws ISOException
    {
        // Creates Tag 86 independently (Command/APDU for EMV PIN Change)
        //  CLA=84
        //  INS=24
        //   P1=00
        //   P1=02
        //  LEN=0C
        // DATA=0102030405060708 (PINBLOCK) + 01020304 (MAC)
        TLVMsg script=new TLVMsg(0x86,
                                 ISOUtil.hex2byte("842400020C010203040506070801020304"));

        // Creates a tag list
        TLVList l = new TLVList();

        // Add tag 72 using the TLV contents as opaque bytes from the "script"
        l.append(0x72,script.getTLV());

        // Create a byte array representation of the TLV
        byte[] packed=l.pack();

        // Let's print it.
        String hex=ISOUtil.hexString(packed);
        System.out.println("hex = " + hex);
    }

--
--
jPOS is licensed under AGPL - free for community usage for your open-source project. Licenses are also available for commercial usage.  Please support jPOS, contact: sa...@jpos.org
---
You received this message because you are subscribed to the Google Groups "jPOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+unsubscribe@googlegroups.com.

To post to this group, send email to jpos-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages