Algorithm School
Moderator: UNKNwYSHSA
-
notuo
- Posts: 12
- Joined: Thu Jan 14, 2016 4:45 am
- Points :143
-
Contact:
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.
}
-
mabel
- Posts: 237
- Joined: Mon May 18, 2015 3:09 am
- Points :1705
-
Contact:
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:
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
Users browsing this forum: No registered users and 17 guests
JavaCard OS : Disclaimer
Board Disclaimer
The views and comments posted in these fora are personal and do not necessarily represent the those of the Management of JavaCard OS.
The Management of JavaCard OS does not, under any circumstances whatsoever, accept any responsibility for any advice, or recommentations, made by, or implied by, any member or guest vistor of JavaCard OS that results in any loss whatsoever in any manner to a member of JavaCard OS, or to any other person.
Furthermore, the Management of JavaCard OS is not, and cannot be, responsible for the content of any other Internet site(s) that have been linked to from JavaCard OS.