Sergio:

        I presume your main question is -to process APDUs as your read 
        or not, when the incoming APDUs can be larger than 37 bytes(5+32).
        Ideally, you would prefer to process APDU as you read. The Java Card
        API documentation denotes this;
        
        // process bytes in buffer[5] to buffer[readCount+4]
        
        In other words you would;
        
        Util.arrayCopyNonAtomic(apduBuffer, ISO7816.OFFSET_CDATA, apduBuffer, 
(byte)0, bytesRead);


        If you have not already read the chapter 8 of the book "JavaCard 
        Technology for Smart Cards" by Zhiqun Chen, please do so. Also 
        check the HelloWorld.java example in Sun's Java Card Development 
        Kit.
        
        Hope this helps.
        
                -Mayank 
        
> Delivered-To: [EMAIL PROTECTED]
> Old-Return-Path: <[EMAIL PROTECTED]>
> Delivered-To: [EMAIL PROTECTED]
> Date: Fri, 30 Mar 2001 10:18:07 -0500 (EST)
> From: Sergio Lopez <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Mime-Version: 1.0
> Content-Transfer-Encoding: 7bit
> X-Originating-IP: 212.120.155.66
> Resent-Message-ID: <[EMAIL PROTECTED]>
> Resent-From: [EMAIL PROTECTED]
> X-Mailing-List: <[EMAIL PROTECTED]> archive/latest/2238
> X-Loop: [EMAIL PROTECTED]
> Resent-Sender: [EMAIL PROTECTED]
> Subject: [OCF]  how to use it correctly?
> Resent-Date: Fri, 30 Mar 2001 17:18:27 +0200 (CEST)
> 
> Dear Gurus,
> 
> I am a newcomer in the Java Card World.
> 
> I have written only a few test applets to run on the card, similar to the
> examples provided by the Sun Microsystems.
> 
> Moving forward, I have found, that in the Java Card 2.1.1 Application
> Programming Interface they recommend to use slightly different technique to
> send and receive APDU, than in the examples.
> 
> How would you explain the following part of the javacard.framework.APDU
> class documentation:
> 
> "The incoming APDU data size may be bigger than the APDU buffer size and may
> therefore need to be read in portions by the applet."
> 
> What is the correct way of APDU buffer usage:
> 
> First variant:
> 
> /***** Step1: receive all incoming APDU data *****/
> 
> short readCount = apdu.setIncomingAndReceive();
> 
> short bytesLeft = (short) (buffer[ISO7816.OFFSET_LC] & 0x00FF);
> 
> while ( bytesLeft > 0){
> 
> bytesLeft -= readCount;
> 
> readCount = apdu.receiveBytes ( ISO7816.OFFSET_CDATA );
> 
> /***** Step2: acces any part of the TOTAL resulting APDU buffer to process
> data ***** /
> 
> processAllBuffer();
> 
> }
> 
> 
> Second variant:
> 
> /***** Step1: receive the portion of the incoming APDU data (of the
> readCount length) *****/
> 
> short readCount = apdu.setIncomingAndReceive();
> 
> short bytesLeft = (short) (buffer[ISO7816.OFFSET_LC] & 0x00FF);
> 
> while ( bytesLeft > 0){
> 
> /***** Step2: access only this particular portion of the APDU data to
> process *****/
> 
> processPortionOfBuffer();
> 
> bytesLeft -= readCount;
> 
> readCount = apdu.receiveBytes ( ISO7816.OFFSET_CDATA );
> 
> }
> 
> Thanks!
> 
> With every good wish to all of you,
> Sergio.
> 
> 
> ______________________________________________
> FREE Personalized Email at Mail.com
> Sign up at http://www.mail.com/?sr=signup
> 
> 
> ---
> > Visit the OpenCard web site at http://www.opencard.org/ for more
> > information on OpenCard---binaries, source code, documents.
> > This list is being archived at http://www.opencard.org/archive/opencard/
> 
> ! To unsubscribe from the [EMAIL PROTECTED] mailing list send an email
> ! to
> !                           [EMAIL PROTECTED]
> ! containing the word
> !                           unsubscribe 
> ! in the body.
> 



---
> Visit the OpenCard web site at http://www.opencard.org/ for more
> information on OpenCard---binaries, source code, documents.
> This list is being archived at http://www.opencard.org/archive/opencard/

! To unsubscribe from the [EMAIL PROTECTED] mailing list send an email
! to
!                           [EMAIL PROTECTED]
! containing the word
!                           unsubscribe 
! in the body.

Reply via email to