Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>@CodesInChaos was right, it was an endianness problem.</p> <p>I have used a function "OS2IP" taken from <a href="http://www.codeproject.com/Articles/421656/RSA-Library-with-Private-Key-Encryption-in-Csharp" rel="nofollow">here</a>. Just used it to generate the BigInteger from the byte array.</p> <pre><code>Dim P As Numerics.BigInteger = cripto.OS2IP(Convert.FromBase64String("gbb1FjTyN ... hs="), false) </code></pre> <p>Then I had to reverse the generated byte array:</p> <pre><code>Dim ResultBytes As Byte() = cripto.RSA_Decrypt(P, Q, D, Data).Reverse.ToArray </code></pre> <p>And the function that corrects the endianness:</p> <pre><code>''' &lt;summary&gt; ''' Converts a byte array to a non-negative integer. ''' &lt;/summary&gt; ''' &lt;param name="data"&gt;The number in the form of a byte array.&lt;/param&gt; ''' &lt;param name="isLittleEndian"&gt;Endianness of the byte array.&lt;/param&gt; ''' &lt;returns&gt;An non-negative integer from the byte array of the specified endianness.&lt;/returns&gt; Public Shared Function OS2IP(data As Byte(), isLittleEndian As Boolean) As Numerics.BigInteger Dim bi As Numerics.BigInteger = 0 If isLittleEndian Then For i As Integer = 0 To data.Length - 1 bi += Numerics.BigInteger.Pow(256, i) * data(i) Next Else For i As Integer = 1 To data.Length bi += Numerics.BigInteger.Pow(256, i - 1) * data(data.Length - i) Next End If Return bi End Function </code></pre> <p>With that change, the result is now correct. Now I will look at the timing-attack issue :)</p>
 

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