Page 1 of 1

Do hash on PC and send digest to my card for signing

Posted: Tue Mar 14, 2017 3:33 am
by Christy16
My card supports ALG_ECDSA_SHA. As we all know,for java card, hash calculation is time-consuming,let along data transferring time. Thus I want to do hash on pc and then send digest to my card for signing.
But I don't know how to do this. Any help?

Re: Do hash on PC and send digest to my card for signing

Posted: Tue Mar 14, 2017 5:14 am
by popmun09
Try to use cipher instead of hash.

Re: Do hash on PC and send digest to my card for signing

Posted: Tue Mar 14, 2017 6:18 am
by mabel
Use signPreComputedHash, which can help you generate the signature of the precomputed hash data. But you java card version should support
since 3.

Detailed info:
signPreComputedHash

public abstract short signPreComputedHash(byte[] hashBuff,
short hashOff,
short hashLength,
byte[] sigBuff,
short sigOffset)
throws CryptoException

Generates the signature of the precomputed hash data.

A call to this method also resets this Signature object to the state it was in when previously initialized via a call to init(). That is, the object is reset and available to sign another precomputed hash.

Note:
This method throws an exception if the underlying signature algorithm does not compute a distinct message digest value prior to applying cryptographic primitives. These algorithms throw exception - DES, triple DES, AES, and KOREAN SEED.
Any data previously accumulated from previous calls to the update method are discarded.
The hash and output buffer data may overlap.

Parameters:
hashBuff - the input buffer of precomputed hash to be signed
hashOffset - the offset into the buffer where the hash begins
hashLength - the byte length of the hash
sigBuff - the output buffer to store signature data
sigOffset - the offset into sigBuff at which to begin signature data

Returns:
number of bytes of signature output in sigBuff

Throws:
CryptoException - with the following reason codes:
CryptoException.UNINITIALIZED_KEY if key not initialized.
CryptoException.INVALID_INIT if this Signature object is not initialized or initialized for signature verify mode.
CryptoException.ILLEGAL_USE if one of the following conditions is met:
if the hashLength value is not equal to the length of the algorithm's message digest length.
if this Signature algorithm includes message recovery functionality.
if the Signature algorithm does not compute a distinct message digest value prior to applying cryptographic primitives



Re: Do hash on PC and send digest to my card for signing

Posted: Tue Jul 11, 2017 2:26 am
by Sheley
popmun09 wrote:Try to use cipher instead of hash.


Why's that?

Re: Do hash on PC and send digest to my card for signing

Posted: Wed Apr 04, 2018 7:40 am
by Arynews
Use signPreComputedHash, which can help you generate the signature of the precomputed hash data. elections results But you java card version should support since 3.

Re: Do hash on PC and send digest to my card for signing

Posted: Mon Jun 04, 2018 9:11 am
by timros
Why's that?[/quote]

It is clear why

Re: Do hash on PC and send digest to my card for signing

Posted: Mon Jun 04, 2018 9:12 am
by timros
good info

Re: Do hash on PC and send digest to my card for signing

Posted: Fri Jun 22, 2018 3:27 am
by scotmaria
A call to this method also resets this Signature object to the state it was in when previously initialized via a call to init(). That is, the object is reset and available to sign another precomputed hash.

Re: Do hash on PC and send digest to my card for signing

Posted: Thu Jul 19, 2018 3:54 am
by Arydigital
popmun09 wrote:Try to use cipher https://www.arydigital.tv/videos/catego ... hand-rakh/ instead of hash.
Why's that?