OpenPGP card on Javacard

Werner Koch wk at gnupg.org
Wed Aug 1 20:22:38 CEST 2007


On Wed,  1 Aug 2007 16:06, ged at solace.miun.se said:

> the OpenPGP card specification on Java card. It is avaible from
> sourceforge at http://sourceforge.net/projects/jopenpgpcard/. Feel free to

Cool.

> and gnupg. I does not support key sizes above 1536 bits. You may have to
> apply a patch to gnupg apdu.c implementing support for "SW_EXACT_LENGTH"

BTW, we already have such a thing at a higher level.  Anyway, I just
added a similar patch to apdu.c (SVN trunk):

--- apdu.c      (revision 4543)
+++ apdu.c      (working copy)
@@ -2648,6 +2649,7 @@
   assert (sizeof (apdu) >= apdulen);
   /* As safeguard don't pass any garbage from the stack to the driver. */
   memset (apdu+apdulen, 0, sizeof (apdu) - apdulen);
+ exact_length_hack:
   resultlen = RESULTLEN;
   rc = send_apdu (slot, apdu, apdulen, result, &resultlen, pininfo);
   if (rc || resultlen < 2)
@@ -2658,7 +2660,14 @@
       return rc? rc : SW_HOST_INCOMPLETE_CARD_RESPONSE;
     }
   sw = (result[resultlen-2] << 8) | result[resultlen-1];
-  /* store away the returned data but strip the statusword. */
+  if (!did_exact_length_hack && SW_EXACT_LENGTH_P (sw))
+    {
+      apdu[apdulen-1] = (sw & 0x00ff);
+      did_exact_length_hack = 1;
+      goto exact_length_hack;
+    }
+
+  /* Store away the returned data but strip the statusword. */
   resultlen -= 2;
   if (DBG_CARD_IO)
     {



Shalom-Salam,

   Werner




More information about the Gnupg-users mailing list