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.

How to get hash of message

Algorithm School

Moderator: UNKNwYSHSA

notuo
Posts: 12
Joined: Thu Jan 14, 2016 4:45 am
Points :143
Contact:

How to get hash of message

Post by notuo » Mon Oct 17, 2016 11:14 pm

I tried to use MessageDigest to get hash. it always returned 6F 00. I guess MessageDigest.getInstance caused the problem, but I'm not sure. ANY HELP? tHANKS!

My sectional code:

Code: Select all

private void getDigest(byte[] buffer)
     {
          if (hashArray == null)
               hashArray = JCSystem.makeTransientByteArray((short)20, JCSystem.CLEAR_ON_DESELECT);
                   
          MessageDigest alg = MessageDigest.getInstance(MessageDigest.ALG_SHA,true);// If I comment this line, the applet can run w/o any problem.
                   
     }

User avatar
mabel
Posts: 237
Joined: Mon May 18, 2015 3:09 am
Points :1705
Contact:

Re: How to get hash of message

Post by mabel » Tue Oct 18, 2016 3:39 am

Use try/catch to find the reason.

Just like:

Code: Select all

try{
   MessageDigest alg = MessageDigest.getInstance(MessageDigest.ALG_SHA,true);
    }
catch(CryptoException e)
   {
     if ( e.GetReason() == CryptoException.NO_SUCH_ALGORITHM )
                           ISOException.throwIt( something );
   }

Tarantino
Posts: 101
Joined: Wed Aug 19, 2015 1:56 am
Points :478
Contact:

Re: How to get hash of message

Post by Tarantino » Tue Oct 18, 2016 4:46 am

MessageDigest.getInstance exception:
Throws:
CryptoException - with the following reason codes:
CryptoException.NO_SUCH_ALGORITHM if the requested algorithm or shared access mode is not supported.

So, you should make sure that that your card supports SHA.
The greatest glory in living lies not in never falling, but in rising every time we fall.--Nelson Mandela

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 30 guests

JavaCard OS : Disclaimer