Hello Sylvain,
private void ComputeCrypt(APDU apdu, byte[] apduBuffer) {
byte[] buffer = apduBuffer;
+#ifdef WITH_EXT_APDU
short dataOffset = apdu.getOffsetCdata();
-#ifdef WITH_EXT_APDU
short LC = apdu.getIncomingLength();
short bytesLeft = apdu.setIncomingAndReceive();
this is INVALID. according SUN specification, getIncomingLength
& getOffsetCdata can be used only AFTER a call to setIncomingAndReceive.
Ouch, my bad. I've just re-read the JC API and, indeed, the JVM should
throw an APDUException.ILLEGAL_USE exception - the weird part is that
I've been using the Muscle applet with the extended APDU patch for a
couple of months now, with absolutely no issues. I use it to login on
OS X, sign emails, use ssh, etc., on a daily basis...
Nevertheless, I've attached a small patch that should fix this. I've
re-compiled the applet with and without extended APDU support and used
pkcs11-tool from the OpenSC project to test both versions. According
to my tests both versions are working OK (see debug.ext_apdu.txt and
debug.txt).
If there's still any issue, please let me know!
Thank you.
Best regards,
Joao
C_SeedRandom() and C_GenerateRandom():
seeding (C_SeedRandom) not supported
seems to be OK
Digests:
all 4 digest functions seem to work
MD5: OK
SHA-1: OK
RIPEMD160: OK
Signatures (currently only RSA signatures)
testing key 0 (Private Key)
all 4 signature functions seem to work
testing signature mechanisms:
RSA-X-509: OK
RSA-PKCS: OK
SHA1-RSA-PKCS: OK
MD5-RSA-PKCS: OK
RIPEMD160-RSA-PKCS: OK
Verify (currently only for RSA):
testing key 0 (Private Key)
RSA-X-509: OK
RSA-PKCS: OK
SHA1-RSA-PKCS: OK
MD5-RSA-PKCS: OK
RIPEMD160-RSA-PKCS: OK
Key unwrap (RSA)
testing key 0 (Private Key)
DES-CBC: OK
DES-EDE3-CBC: OK
BF-CBC: OK
CAST5-CFB: OK
Decryption (RSA)
testing key 0 (Private Key)
RSA-X-509: OK
RSA-PKCS: OK
Testing card detection
Please press return to continue, x to exit: Testing card detection using
C_WaitForSlotEvent
Please press return to continue, x to exit: No errors
C_SeedRandom() and C_GenerateRandom():
seeding (C_SeedRandom) not supported
seems to be OK
Digests:
all 4 digest functions seem to work
MD5: OK
SHA-1: OK
RIPEMD160: OK
Signatures (currently only RSA signatures)
testing key 0 (Private Key)
all 4 signature functions seem to work
testing signature mechanisms:
RSA-X-509: OK
RSA-PKCS: OK
SHA1-RSA-PKCS: OK
MD5-RSA-PKCS: OK
RIPEMD160-RSA-PKCS: OK
Verify (currently only for RSA):
testing key 0 (Private Key)
RSA-X-509: OK
RSA-PKCS: OK
SHA1-RSA-PKCS: OK
MD5-RSA-PKCS: OK
RIPEMD160-RSA-PKCS: OK
Key unwrap (RSA)
testing key 0 (Private Key)
DES-CBC: OK
DES-EDE3-CBC: OK
BF-CBC: OK
CAST5-CFB: OK
Decryption (RSA)
testing key 0 (Private Key)
RSA-X-509: OK
RSA-PKCS: OK
Testing card detection
Please press return to continue, x to exit: Testing card detection using
C_WaitForSlotEvent
Please press return to continue, x to exit: No errors
--- CardEdge.src 2009-05-27 20:42:14.000000000 +0100
+++ CardEdge.src.patched 2009-05-27 20:40:32.000000000 +0100
@@ -910,11 +910,12 @@
private void ComputeCrypt(APDU apdu, byte[] apduBuffer) {
/* Buffer pointer */
byte[] buffer = apduBuffer;
- short dataOffset = apdu.getOffsetCdata();
+
#ifdef WITH_EXT_APDU
- short LC = apdu.getIncomingLength();
short bytesLeft = apdu.setIncomingAndReceive();
-
+ short LC = apdu.getIncomingLength();
+ short dataOffset = apdu.getOffsetCdata();
+
if((short) (LC + dataOffset) > EXT_APDU_BUFFER_SIZE)
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
@@ -927,6 +928,8 @@
#else
short bytesLeft = Util.makeShort((byte) 0x00,
buffer[ISO7816.OFFSET_LC]);
+ short dataOffset = ISO7816.OFFSET_CDATA;
+
if (bytesLeft != apdu.setIncomingAndReceive())
ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
#endif
_______________________________________________
Muscle mailing list
[email protected]
http://lists.drizzle.com/mailman/listinfo/muscle