Our Online Store have the new products: RFID antenna board. Currently it can work with JC10M24R and JCOP4 card chips.
Compared with normal cards, the antenna board module has a smaller size and fixed holes, which is easy to integrate in the IOT(Internet Of Things) project.

Got 6E00 when implementing RSA encryption

Algorithm School

Moderator: UNKNwYSHSA

User avatar
lostsiwonlw
Posts: 55
Joined: Fri Jul 31, 2015 9:09 pm
Points :358
Contact:

Got 6E00 when implementing RSA encryption

Post by lostsiwonlw » Tue Dec 01, 2015 2:43 am

I am writing a javacard applet. RSA public and private keys are generated in constructor.

Code: Select all

public RSAApplet() {
    keyPair = new KeyPair(KeyPair.ALG_RSA_CRT, KeyBuilder.LENGTH_RSA_2048);
    keyPair.genKeyPair();
    rsaPrivateKey = (RSAPrivateKey) keyPair.getPrivate();
    rsaPublicKey = (RSAPublicKey) keyPair.getPublic();

    cipher = Cipher.getInstance(Cipher.ALG_RSA_PKCS1, false);

    register();
}


Main method code:

Code: Select all

private void encryptData(APDU apdu) {
    if (!rsaPublicKey.isInitialized()) {
        ISOException.throwIt(ISO7816.SW_CONDITIONS_NOT_SATISFIED);
    }
    byte[] apduBuffer = apdu.getBuffer();
    apdu.setIncomingAndReceive();

    cipher.init(rsaPrivateKey, Cipher.MODE_ENCRYPT);
    byte[] encryptedBuffer = new byte[apduBuffer.length];
    Util.arrayFillNonAtomic(encryptedBuffer, (short) 0,
            (short) encryptedBuffer.length, (byte) 0xAA);
    cipher.doFinal(encryptedBuffer, (short) 0, (short) encryptedBuffer.length, apduBuffer, (short) 0);
    // Just for testing send 120 bytes
    apdu.setOutgoingAndSend((short) 0, (short) 120);
}


When I install applet into my javacard, it returns sw=6E00.

I guess the problem may occur when cipher.doFinal() is executing. But I don't know the details about what is going on.

Could anybody help me determin the problem? Any help is greatly appreciated.
Searching for meaning...

predators
Posts: 21
Joined: Wed Aug 19, 2015 7:18 am
Points :12
Contact:

Re: Got 6E00 when implementing RSA encryption

Post by predators » Wed Dec 02, 2015 8:51 am

You can using try{...} catch(){...} to get the reason of this error.
such as

Code: Select all

try
      {
         length = cipher.doFinal(, , , );
      }
      catch(CryptoException e)
      {
         short i = e.getReason();
      }

User avatar
UNKNwYSHSA
Posts: 630
Joined: Thu May 21, 2015 4:05 am
Points :3053
Contact:

Re: Got 6E00 when implementing RSA encryption

Post by UNKNwYSHSA » Thu Dec 03, 2015 1:14 am

6E00 means the CLA not supported.
What is the APDU command you sent?
sense and simplicity

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 14 guests

JavaCard OS : Disclaimer