Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I can't answer as to why this works in C#, but as for Crypto++, there are a couple of issues.</p> <p><br> Firstly, you're probably invoking the wrong constructor of <a href="http://www.cryptopp.com/docs/ref/class_integer.html#a7fcab0564d7270017ebcca55bae1a17a" rel="nofollow"><code>Integer</code></a>. I guess you want this one which converts from big-endian byte array:</p> <pre><code>Integer (const byte *encodedInteger, size_t byteCount, Signedness s=UNSIGNED) </code></pre> <p>but are using <a href="http://www.cryptopp.com/docs/ref/class_integer.html#a9e8bf8c72458dff4ceb5d6cdf9e5c97a" rel="nofollow">this one</a> which convert from a string in base 2, 8, 10, or 16 (in your case base 10).</p> <p>So, using <code>ExponentCON</code> as an example, you should do:</p> <pre><code>const int ExponentSize(0x4); const byte ExponentCON[ExponentSize] = { 0x00, 0x01, 0x00, 0x01 }; Integer integ1(ExponentCON, ExponentSize); </code></pre> <p>or possibly better still:</p> <pre><code>std::string ExponentCON("101h"); // &lt;-- Note trailing 'h' indicating hex encoding Integer integ1(ExponentCON.c_str()); </code></pre> <p><br></p> <p>Next, the members of <code>InvertibleRSAFunction</code> must satisfy certain conditions in order to qualify as a valid key. These can be seen by stepping through the <a href="http://www.cryptopp.com/docs/ref/class_invertible_r_s_a_function.html#a35247205517f839220a16287917ce0ce" rel="nofollow"><code>InvertibleRSAFunction::Validate</code></a> function and I assume check for the conditions <a href="http://en.wikipedia.org/wiki/RSA_%28algorithm%29#Key_generation" rel="nofollow">described here</a>.</p> <pre><code>params.Validate(rng, 3); // Returns false for your input data </code></pre> <p><br> There are some helper functions which are designed to avoid having to set everything explicitly as you're doing. I don't know if these are suitable for you, but I'm referring to <a href="http://www.cryptopp.com/docs/ref/class_generatable_crypto_material.html#a38d492343c32e530a5c2781b5797f755" rel="nofollow"><code>InvertibleRSAFunction::GenerateRandomWithKeySize</code></a> and the overloaded <a href="http://www.cryptopp.com/docs/ref/class_invertible_r_s_a_function-members.html" rel="nofollow"><code>InvertibleRSAFunction::Initialize</code></a>.</p> <p>The <a href="http://www.cryptopp.com/wiki/RSA#Keys" rel="nofollow">Crypto++ Wiki</a> describes the use of these functions with example code.</p>
    singulars
    1. This table or related slice is empty.
    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. 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