Install(byte[] buffer,short offset, byte length)

Anyone could tell me where i can find the defination of data format of 'buffer' in 'install(byte[] buffer,short offset, byte length)', it is standard, right?!

Look in appendix A.2 of the GlobalPlatform Card Specifications 2.1.1 (pages 160,161). The same information is specified for the install() method in the Java Card 2.2 API spec. The format is the same for Java Card 2.1.1 and GlobalPlatform 2.0.1'.
G

Similar Messages

  • Memory leak in String(byte[] bytes, int offset, int length)

    Has anyone run into memory leak problem using this String(byte[] bytes, int offset, int length) class? I am using it to convert byte array to string, and I am showing memory leak using this class. Any idea what is going on?

    Hi,
    If you post in Native methods forum I assume you are using this constructor in the native side.
    Be aware that getting char * from jstring eats memory that you must free before returning from native with env->ReleaseStringUTFChars().
    --Marc (http://jnative.sf.net)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Problem with byte[].length

    dear sir
    I am working with javacard 2.2.2, windows, jdk 1.5 and JCWDE
    I would like to know the byte length of an array ("aCrypter" in this fallowing code)
    1     public byte[] cryter(byte[] Crypter){
    2
    3          ecipher.init(key, Cipher.MODE_ENCRYPT);
    4          ecipher.doFinal(Crypter, (short)0, (short)aCrypter.length, donneeCrypter , (short)0);
    5          
    6          return donneeCrypter;
    7     }
    JCVM return an error on line 4 (it works with "(short)1"
    there is a solution to know the array length?
    regards
    Alexis
    Edited by: Alexis "le francais" on 21 mars 2011 07:33

    thanks for your help.
    In fact I would like to crypt and after decrypt with this fallowing code:
           private byte[] Crypto = {(byte)0xA0, (byte)0x00,
                 (byte)0x00, (byte)0x00, (byte)0x62, (byte)0x03, (byte)0x01, (byte)0x0C,
                 (byte)0x0f, (byte)0x01, (byte)0x01};
    public void process(APDU apdu) throws ISOException {
              // TODO Auto-generated method stub
              byte[] buffer = apdu.getBuffer();
              if (this.selectingApplet()) return;
              if (buffer[ISO7816.OFFSET_CLA] != CLA_MONAPPLET) {
                   ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
              switch (buffer[ISO7816.OFFSET_INS]) {
                   case INS_INTERROGER_COMPTEUR:
                        tab = new byte[1000];
                        tab[0]= compteur;               
                        tableau = cryter(tab);
                        tableau2= decrypter(tableau);                    
                        apdu.setOutgoing();
                        apdu.setOutgoingLength((short) 7);
                        apdu.sendBytesLong(tableau2,(short) 0, tableau2.lenght);
                        break;          
         public void initialisation(){
            key = (DESKey)KeyBuilder.buildKey(KeyBuilder.TYPE_DES_TRANSIENT_DESELECT,KeyBuilder.LENGTH_DES, false);
            key.setKey(Crypto, (short)0);
            ecipher = Cipher.getInstance(Cipher.ALG_DES_CBC_ISO9797_M2,false);
         public byte[] decrypter(byte[] aDecrypter){
              ecipher.init(key, Cipher.MODE_DECRYPT);
              donneeDecrypte = new byte[10000];
              ecipher.doFinal(aDecrypter, (short)0, (short)aDecrypter.length, donneeDecrypte, (short)0);
              return donneeDecrypte;
         public byte[] cryter(byte[] Crypter){
              ecipher.init(key, Cipher.MODE_ENCRYPT);
              donneeCrypter = new byte[10000];
              ecipher.doFinal(Crypter, (short)0, (short)Crypter.length, donneeCrypter, (short)0);
              return donneeCrypter;
         }Now "crypter" method is executed, but when the debugger is at this fallowing line there is a problem :
    tableau2= decrypter(tableau);maybe the size of the array?
    >
    return ecipher.doFinal(aCrypter);
    >
    I work with Javacard 2.2.2, this method does not exist in the API only :
    abstract short doFinal270(byte[] inBuff, short inOffset, short inLength,byte[] outBuff, short outOffset)Edited by: le francais on 22 mars 2011 03:07

  • NVARCHAR UTF-8 byte length

    The following call returns the wrong byte length when the databasee character set is UTF8 for NVARCHAR2 columns. It returns double the character length rather than triple. Oracle version 10.1.0.3.
    OCIAttrGet((dvoid *)param,
    OCI_DTYPE_PARAM,
    (dvoid *)&outcol->data_size,
    (dvoid *)0,
    OCI_ATTR_DATA_SIZE,
    statement->pError)
    This seems like a bug.

    Yes there is a maximum length. A short look at the docs for DataOutputStream.writeUTF tells you:
    >>>
    Writes a string to the underlying output stream using UTF-8 encoding in a machine-independent manner.
    First, two bytes are written to the output stream as if by the writeShort method giving the number of bytes to follow. This value is the number of bytes actually written out, not the length of the string.
    <<<
    So writeUTF bails whenever the number of bytes written would be more than what fits into a short, which is 32767. That's your max length (note, that this is the number of bytes, not chars, since in UTF-8 encoding, all non-ASCII chars are saved as 2 or 3 bytes!)

  • DDIC-Structure - Need Byte Length of a DDIC-STRUCTURE!!!

    Hello,
    how can I write a Report/ Function that becomes in Input each DDIC-Structurename and gives the user an Output back, that contains the whole Byte Length of the STRUCTURE.
    For Example, we have an DDIC-Structure with name structure_example:
    Name          TYPE     c     LENGTH     15,
    Firstname   TYPE     c     LENGTH      10,
    Street         TYPE     c     LENGTH      30,
    ZIP-Code    TYPE     int2 LENGTH      5.
    Their must existing a Functionality which can used the structurename and gives the user the Byte Length of the Structure back.
    In our example the user gets for "structure_Example" the Output "60" Bytes back.
    Input:          structure_example
    Output:       60
    I hope someone can give me a solution to solve this problem.
    Thanks for all help in this forum.
    With kind regards
    ETN

    Hi,
    check out the below code...
    my be this might help you.
    TYPES:
      BEGIN OF my_struct,
        comp_a type i,
        comp_b type f,
      END OF my_struct.
    DATA:
      my_data   TYPE my_struct,
      descr_ref TYPE ref to cl_abap_structdescr.
    FIELD-SYMBOLS:
      <comp_wa> TYPE abap_compdescr.
    START-OF-SELECTION.
      descr_ref ?= cl_abap_typedescr=>describe_by_data( my_data ).
      WRITE: / 'Typename     :', descr_ref->absolute_name.
      WRITE: / 'Kind         :', descr_ref->type_kind.
      *WRITE: / 'Length       :', descr_ref->length.*
    WRITE: / 'Decimals     :', descr_ref->decimals.
      WRITE: / 'Struct Kind  :', descr_ref->struct_kind.
      WRITE: / 'Components'.
      WRITE: / 'Name              Kind   Length   Decimals'.
      LOOP AT descr_ref->components ASSIGNING <comp_wa>.
        WRITE: / <comp_wa>-name, <comp_wa>-type_kind,
                 <comp_wa>-length, <comp_wa>-decimals.
      ENDLOOP.
    regards,
    Santosh Thorat

  • How to get the string's byte length?

    I have some string,I want to get the string's byte length,how
    can do it?
    for example:
    <cfoutput>#len('hihi,这是测试')#</cfoutput>
    output is 9
    I want to get the byte length is 14, how can i get it?
    Thanks.

    >> Fair cop. I didn't realise that asc() returned the
    codepoint rather than the
    > actual character code.
    >
    > and what would be the difference?
    Oh, sorry, whatever the term is (I'm crap with jargon). The
    value returned
    by asc() for those chars was only two bytes (ie: four hex
    digits). I
    didn't realise there was more to it than that, and that
    2-byte value maps
    to some other THREE byte value. I need to do some reading...
    > that's what both cf & java counted as the length.
    CHARACTER length, sure. No-one's disputing that. On the other
    hand,
    no-one's asking about it, either.
    > by adding a BOM you've already effected the encoding,
    which may or may not
    > match the original. so you still don't know how many
    bytes were in the original
    > string.
    [groan]
    Yes, that's a reasonable strawman there. I was only putting
    it in a file
    so I could save it and check the number of bytes occupied by
    the data.
    Clearly... CLEARLY... the OP is not asking for a character
    length of that
    string. They've said as much.
    I copy and pasted the string from their post, and used it as
    a
    demonstration of how "nine" is not the right answer for the
    BYTE LENGTH of
    that string. Whether or not the original string was UTF-8,
    UTF-16 or
    special-marmoset-encoding, it almost certainly was NOT in a
    fictitious kind
    encoding in which each of those particular characters only
    occupied one
    byte each, which would mean that "nine" is the correct answer
    to the
    question.
    When I copied those characters from either the web browser
    for from my
    text-based news agent, notepad identified them (and rendered
    them
    correctly) as UTF-8, so I'm fairly confident they ARE UTF-8.
    Of course
    this could be down to some intermediary encoding (pasting
    them in to the
    original posting, for example, via some encoding-transforming
    mechanism),
    but Occam's Razor suggests the original question was from a
    UTF-8 POV.
    But maybe we should quit speculating and ask the OP. Unless
    they've
    buggered off in despair of how drawn out all this is getting.
    For which I
    would not blame them.
    Adam

  • ABEND RS_EXCEPTION (000): Part-field access (offset = 45, length = 45) ...

    Hi BI Experts,
    We are getting error below when run the query in BEx Broadcaster whereas the same query can be run without error in RSRT. One of the object used in the query is 0TCTBISBOBJ (BI Application Obj). When i remove this object from the query, i am able to execute the query in BEx Broadcaster. Please advice.
    Error: com.sap.ip.bi.base.application.exceptions.AbortMessageRuntimeException
    com.sap.ip.bi.base.exception.BIBaseRuntimeException ERROR
    com.sap.ip.bi.base.application.exceptions.AbortMessageRuntimeException
    Log ID: 00144F25CCDC303C0000010600005CBD00046ADC8504A84D
    Initial cause
    ABEND RS_EXCEPTION (000): Part-field access (offset = 45, length = 45) to a data object of the size 60 exceeds valid boundaries.
      MSGV1: Part-field access (offset = 45, length = 45) to a
      MSGV2: data object of the size 60 exceeds valid
      MSGV3: boundaries.
    Stack trace: com.sap.ip.bi.base.application.exceptions.AbortMessageRuntimeException: Termination message sent
    We have recently upgraded to SAP BI7.0 SP19.
    Thanks in advance.
    Best Regards,
    Pei Fung

    Can someone throw some light on this? Thanks.

  • Replacing 20 fixstatements by Global Variable - Problem 255 bytes length

    Hello,
    we have an issue in businessrules with setting the fix statement on 1 dimension:
    we currently use Fix (@RELATIVE("CBU_ALL",0) ) - on level 0 are approx. 3000 members - on medium level are 20 CBUs Seat and 20 CBUs Door
    we have approx. 20-30 similar businessrules - which either calculate on seat or door CBUs
    the requirement is to either calculate with a rule the 20 CBUs for Seats or the 20 CBUs for Doors
    as we currently do not fix properly on either Seat or Door CBUs, we calculate approx. 1500 empty members (empty, if fix in another dimension done correctly) - tests showed, that this doubles the time which would be needed.
    I know we could easily set 20 fixes in each business rule:
    @RELATIVE("CBU_BMW_Seat",0)
    ....20 more....
    @RELATIVE("CBU_Ford_Seat",0)
    (the fix above would then exclude the 1500 members, which are below:
    @RELATIVE("CBU_BMW_Doors",0)
    ....20 more....
    @RELATIVE("CBU_Ford_Doors",0)
    unfortunately, the number of CBUs/Customers is frequently renamed or some are added, so I can not afford to built these 20 fixstatements into 20 different businessrules and maintain them all the time.
    I thought of using UDAs or Attribute Values -
    but it seems not to be possible in a fixstatment to combine a relative or Children fixstatement with UDAs, which are set on the upper member ?
    I assume it works, if I classify all 3000 level 0 members with UDA or attribute SEATS or DOORS - but that's inefficient
    @RELATIVE("CBU_BMW_Seat",0) AND @UDA(CBU,"SEATS")
    @CHILDREN("CBU_BMW_Seat") AND @UDA(CBU,"SEATS")
    @Descendants("CBU_BMW_Seat") AND @UDA(CBU,"SEATS")
    @UDA(CBU,"SEATS")
    generally, it seems not to be allowed to combine Children or descendant fixes with any other relations or conditions ?
    @CHILDREN(@Match(CBU," Seat") ) (attempt to search for all children of all CBUs with Seat in its name)
    So the idea is to define 2 global variables:
    1 for Seats and 1 for Doors:
    [SEAT] includes then then: @children("CBU_BMW_Seat") ... 20 more @children("CBU_Ford_Seat")
    advantage would be, we can maintain the list of CBUs in 1 place
    my problem is: length of global variable is limited to 255 bytes - I need 800 to 900 digits to define the 20 CBUs
    having 8 global variables instead of 40 CBUs referenced in Fixstatements is not really an advantage
    even if I would rename the CBUs to just S1,S2,S3,S4 D1,D2,D3 (S for Seat, D for Door) (and use aliases in Planning and Reporting with full name to have the right meaning for the users), it does not fit into 1 variable: @children("S1"), @Children("S2"), ..... is simply too long (still 400 digits)
    also other attempts to make the statement shorter, failed:
    @children(@list("CBU_BMW_Seat","CBU_Ford_Seat",.....)) is not allowed
    is there any other idea of using global variables, makros, sequences ?
    is there a workaround to extend global variable limit ? we have release 9.3.1 - is this solved in future releases ?
    are there any other commands, which I can combine in clever way in fixstatements with
    @relative
    @children
    @descendants
    with things like @match @list ?
    (Generation and Level are no approrate criteria for Separating Seat and Doors, as the hierarchy is the same)
    please understand, that as we use this application for 5 years with a lot of historic data and it's a planning application with a lot of webforms and financial reports, and all the CBU members are stored members with calculated totals and access rights and setup data on upper members,
    I can not simply re-group the whole cbu structure and separate Seats and Doors just for calculation performance
    CBU dimension details is like this:
    Generation:
    1 CBU_ALL
    2 CBU_BMW
    3 CBU_BMW_Seat
    4 Product A
    4 Product B
    ..... hundreds more
    3 CBU_BMW_Door
    4 Product C
    4 Product D
    .... hundreds more
    2 CBU_Ford
    3 CBU_Ford_Seat
    4 Product E
    4 Product F
    .... hundreds more
    3 CBU_Ford_Doors
    4 Product G
    4 Product H
    .... hundreds more
    20 more CBUs with below 20 CBUs Seat and 20 CBUs Door

    How hard would it be to insert 2 children under CBU_All? Name them CBU_Seats and CBU_Doors, then group all the Seats and Doors under them.
    Then your calc could be @Relative(CBU_Doors, 0).
    I know it's not always easy or feasible to effect change to a hierarchy, but I just had the thought.
    Robert

  • Byte length problem

    I don't understand this, but I suppose the solution is simple.
    I wanna use the getByAddress(byte[] address) method of the class InetAddress in java.net .
    address is a byte array of length 4, that should contain the 4 parts of an IP address.
    BUT, each part of an IP address can be 32 bits long, wich is bigger then the possible length of a byte.
    Someone knows what I do wrong?

    I don't understand this, but I suppose the solution
    is simple.
    I wanna use the getByAddress(byte[] address) method
    of the class InetAddress in java.net .
    address is a byte array of length 4, that should
    contain the 4 parts of an IP address.
    BUT, each part of an IP address can be 32 bits long,
    wich is bigger then the possible length of a byte.
    Someone knows what I do wrong?Hi, it depends on which type of ip-address. The one which is most common is only 32 bits long. E.g. 255.123.123.01 <- 4 bytes.
    Kaj

  • Method to Get the INPUT parameter CONTENT byte length

    method to get the INPUT parameter CONTENT byte length

    Dear "clown of forums",
    Please read the forum rules and ask understandable questions -> one thread per properly formulated question after having searched.
    Thread locked.

  • InputStreamRead read(char[] cbuf, int offset, int length) method hangs

    This method hangs for the following values
    read(xchar, 0, 1)
    Does not throw any exception.
    The inputstream does have data in it.
    the characterset is cp037.

    So the problem is probably in your implementation of InputStream. Do you implement the available() method? What will your class do if you attempt to read more bytes than there are? (say, call read(chars, 0, 1000000))
    The InputStreamReader keeps an internal buffer (of 1024 bytes?) which it uses for decoding the bytesto characters..if your stream blocks when InputStreamReader is filling its buffer you'd get this sort of behaviour.

  • InputStreamReader read(char[] cbuf, int offset, int length) method hangs

    Hi all,
    I am posting this message again.
    I would appreciate any help, as I am stuck with a customer issue.
    This method hangs for the following values
    read(xchar, 0, 1)
    Does not throw any exception.
    The inputstream does have data in it.
    the characterset is cp037.
    I know for sure that the InputStream has data in it. In fact the read method reads couple of fields with length greater than 1 and hangs when it tries to read data with length 1.
    Bug # 4401798 talks about some error similar to this being fixed. Any one has any idea, which jdk had this problem and which one has a fix for this?
    Thanks.

    You should have continued in your original thread, rather than starting a new one. What you have posted in this new thread could have gone in the old one:
    http://forum.java.sun.com/thread.jspa?threadID=665303

  • Blob.getBytes(long offset, int length)      buggy?

    i have problems with this method. i tried different parameters from
    (0,1) to (1,blobname.length()) and (0,blobname.length()). i always got an ArrayIndexOutOfBoundsException, though by blob was a valid blob and
    != "null"
    where is my mistake? or is this method buggy?
    henrik

    And what does length() return?

  • Code explaination: [buffer,offset, length]

    I am trying to understand the following Example in APPENDIX A.
    http://international.visa.com/fb/vendors/openplatform/pdfs/Guidelines_for_Developing_Apps_on_OP_Cards_11a.pdf
    public static void install(byte[] buffer, short offset, byte length) {
    // Determine the offset and length of the
    // instance AID for the constructor.
    byte instanceLength = (byte) buffer[offset];
    short instanceOffset = (short)(offset + 1);
    // Locate the install privileges and insure that the
    // applet has PIN change permission
    byte appletPrivileges = (byte) buffer[(short) (offset+1+instanceLength+1)];
    if( appletPrivileges != 0x02 )
    ISOException.throwIt(ISO7816.SW_DATA_INVALID);
    appletKey = (DESKey) KeyBuilder.buildKey( KeyBuilder.TYPE_DES,
    KeyBuilder.LENGTH_DES, false);
    DESInstance = Cipher.getInstance(Cipher.ALG_DES_ECB_NOPAD,false);
    // Applet constructor
    new Compliance(buffer, instanceOffset, instanceLength);
    I saw not only this example but also others, the following:
    byte instanceLength = (byte) buffer[offset];
    short instanceOffset = (short)(offset + 1);
    They set the new parameters for the constructor from the install method's parameters. I don't understand coz there are not much explaination on this and i am not quite understand what the parameters in the install method [buffer,offset,length] used for. And why they set the different offset and length when call the constructor. Can someone explain the detail for me pls! Thank you very much!

    Dear Durangova,
    First, i will tell u what i have. I have a Aspects Developer IDE for develop Javacard applet and a Aspects OS755 card. In the spec, they gave me following card personalisation information but i don't know most of the key use for:
    Card Lifecycle State > SECURED
    ISD AID > 0xA0 0x00 0x00 0x01 0x51 0x00 0x00
    ISD SCP implementation > SCP 01, option 05
    ISD SCP key set - SENC location > key index 01, key version 01
    ISD SCP key set - SENC value > 0x40 0x41 0x42 0x43 0x44 0x45 0x46 0x47
    0x48 0x49 0x4A 0x4B 0x4C 0x4D 0x4E 0x4F
    ISD SCP key set - SMAC location > Key index 02, key version 01
    ISD SCP key set - SMAC value > 0x40 0x41 0x42 0x43 0x44 0x45 0x46 0x47
    0x48 0x49 0x4A 0x4B 0x4C 0x4D 0x4E 0x4F
    ISD SCP key set - DEK location > Key index 03, key version 01
    ISD SCP key set - DEK value > 0x40 0x41 0x42 0x43 0x44 0x45 0x46 0x47
    0x48 0x49 0x4A 0x4B 0x4C 0x4D 0x4E 0x4F
    Ok.. now after i write an applet, say an applet to store identity and have a function like change PIN, change identity information, i just need to install the application to the simulator or OS755 card using the intsall function in the IDE . Then i can test the card function by sending the apdu command using the IDE apdu command window. These all worked fine and i now i wanted to consider the security issue as describe in the GP. I want to create a mutual authentication between the card and the off card entity before the all the above functions can be procceed. So do i still need to select the card manager? or just select this applet? So in order to make the communication secure, i need to create a security domain in my applet (is create security domain mean that including all those external authen, inital update etc method in ur applet?)? Can you show me the step by step practical programming method to create the secure channel when we want a Authentication between the card and off card? If u have not much time to show me, a little important guidance to make up my mind clearer would help and i'd appreciate that. Thank you!

  • Socket read not returns all bytes

    Hi all,
    we developed an java application which creates customer orders over the internet. The java application sends commands to our erp system, which creates the order. The communication between these system is realised with sockets. On my local pc everything works fine. But on our live system (sun - solaris) we become some problems. For the first entry send over the socket it works. But if another entry is added we got a problem. After sending ovber the socket the erp system creates the order and returns the checked data. The data returned are read as followed:
    protected void readFromSocket(byte[] buffer, int offset, int length)
    throws IOException {
    Arrays.fill(buffer, (byte) 0xee);
    int bytesRead = 0;
    while (bytesRead != length) {
    bytesRead = getIn().read(buffer, offset + bytesRead, length - bytesRead);
    While reading the second entry from the stream, it hangs. The socket does not return the full number of bytes we recommended.
    I will be thankfull for any idea.
    Thanks

    I would suspect that you have an infinite loop because you're not performing the correct logic, not that the socket hangs. Try putting a System.out.println("I read another " + bytesRead + " bytes from the socket...") statement after the read and see if it keeps printing something over and over.

Maybe you are looking for