Hi,

    I have followed Android's keystore mechanism defined 
by http://developer.android.com/training/articles/keystore.html to generate 
private key and then used the private key to sign the data. When I am using 
same private key and same data, I am getting similar signature most of the 
time. But this behaviour is not consistent. During a stress test, 1 out of 
10 times, my application fails as *Android Signature API is giving 
different result with same private key and same data. *Below is my code 
look like.

Signature signatureObject = Signature.getInstance("SHA256withRSA");
if(null != signatureObject) {
    signatureObject.initSign(existingKey);
    signatureObject.update(dataByterray);
    byte[] signatureByteArray = signatureObject.sign();
    if(null != signatureByteArray && 0 < signatureByteArray.length) {
        String signatureString = Base64.encodeToString(signatureByteArray, 
Base64.DEFAULT);
        //s_log.debug("db signature string = " + signatureString, s_CLASS);
        result = signatureString.substring(0,31).toCharArray();
    } 

}


    Please help me to find out the problem. I am using the result data to 
encrypt my database, but as I am getting different result sometimes, I am 
getting error in opening the database, thus lots of complains from users. This 
is happening in most of Android devices >= 18. Please suggest what can be done.



Thanks.



-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/66fbe817-04be-40da-9b65-984342043761%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to