Page 1 of 1

Problem in coding output data

Posted: Sat Apr 08, 2017 5:54 am
by aahmadzadeh
What do you think about this codes?
Why we get plain data as output ?

Code: Select all

if(secureChannel.getSecurityLevel() != (byte)0x83)
   ISOException.throwIt(ISO7816.SW_SECURITY_STATUS_NOT_SATISFIED);
            
byte[] data= new byte[] {(byte)0x11, (byte)0x22, (byte)0x33, (byte)0x44, (byte)0x55, (byte)0x66, (byte)0x77, (byte)0x88};
Util.arrayCopyNonAtomic(data, (short)0, apdu.getBuffer(), (short)0, (short)data.length);
short length = secureChannel.wrap(apdu.getBuffer(), (short)0, (short)data.length);
apdu.setOutgoingAndSend((short)0, length);

output: 11 22 33 44 55 66 77 88

:?:

Re: Problem in coding output data

Posted: Sun Apr 09, 2017 10:25 pm
by UNKNwYSHSA
Did you want to encrypt the response data and/or generate MAC for response data?

Code: Select all

/**
    * The <code>wrap</code> method will encrypt the outgoing response data (0x20).
    * <p>Note:<ul>
    * <li><em>Response data encryption could be indicated along with entity authentication and one
    * or more levels of security.</em>
    */
   public static final byte R_ENCRYPTION = (byte) 0x20;

   /**
    * The <code>wrap</code> method will generate a MAC for the outgoing response data (0x10).
    * <p>Note:<ul>
    * <li><em>MAC generation could be indicated along with entity authentication and one or more
    * levels of security, e.g. a value of '91' indicates that entity authentication has occurred,
    * that the <code>unwrap</code> method will verify the MAC on incoming commands and that the
    * <code>wrap</code> method will generate a MAC on outgoing response data.</em>
    */
   public static final byte R_MAC = (byte) 0x10;

The security level shall mask these bit(s).