Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, <code>SHA256withRSA</code> is completely deterministic.</p> <p>In theory you could be affected by a bug (<a href="http://bouncy-castle.1462172.n4.nabble.com/Incorrect-Hash-header-gets-added-for-SHA256-in-signed-message-td1463380.html" rel="nofollow noreferrer">see an example</a>) in an old modified BouncyCastle library version found on one of the Android versions. Such a bug might be eliminated if you used <code>SHA512withRSA</code> instead, well, at least the referenced one would be.</p> <p>However, before you start digging into the hash algorithm, check close to home.</p> <p>Maybe you have obtained your byte array through a call to <code>String.getBytes</code>. This call depends on the default platform encoding which is <a href="https://stackoverflow.com/questions/11212173/different-charset-in-android-os-version">different</a> between Android 2.2 and Android 2.3. This implies that while your strings are the same in both cases, the byte arrays might not be.</p> <p>To get encoding under control, and make your code platform independent, specify encoding as a parameter:</p> <pre><code>plainText.getBytes("UTF-8") </code></pre> <p>Failing this, there are a few more tactics to get a platform independent implementation.</p> <ul> <li>wait until 2.2 with the presumably buggy library dies out</li> <li>distribute a known good library (jar) with your software. If that would be BouncyCastle, you will have problems making sure that your and not Android's classes are loaded. The solution is called SpongyCastle.</li> <li>play with alignment/padding. Try to make the message length in bytes to be congruent with 0,55, 56 or 63 modulo 64 by adding your own fixed padding and hope that one of these options will start giving portable signatures. These values are chosen to interact with the outermost part of the suspect algorithm which is padding to 512 bit blocks.</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload