Hi Mathieu,

Here's what I got after adding a sanity check:
Modulus: 93024454
Exponent: 0

Jeff

CryptoPP::RSA::PublicKey CreatePublicKey()
{
  ...
  CryptoPP::Integer mod, exp;
  Base64ToInteger(modulus, mod);
  Base64ToInteger(exponent, exp);

  std::cout << "Modulus: " << mod << std::endl;
  std::cout << "Exponent: " << exp << std::endl;

  CryptoPP::RSA::PublicKey key;
}

On 9/11/06, Mathieu Malaterre <[EMAIL PROTECTED]> wrote:
Thanks Jeffrey,

       Actually what I am trying to do is quite simple. It's just that I
cannot find the information on internet(*). Here is what I have so far:

void Base64ToInteger(const char *base64String, Integer &xmlint)
{
  StringSource mod_s( base64String, true, new Base64Decoder);
  unsigned long mrs = mod_s.MaxRetrievable();
  char* mod_sstr = new char[mrs];
  mod_s.Get( (unsigned char*)mod_sstr, mrs );
  xmlint = Integer(mod_sstr);
  delete[] mod_sstr;
}

RSA::PublicKey CreatePublicKey()
{
  const char modulus[] =
"wehzXu32ipNZZkhWqYMVrKoWs4o5AfPKZbdTLVVt8jPfC09yKzC/ajJTeGm87moeU+yZ6Lz8PXsKOmxxNFBE3vQpbMEq++fCjhI0QdC4q/h0H6FePN7MC3WZmR0hpI3yp5sGNfBSBMPNRsnpEGI00ByxQp1N8R9hj9pc0OvwswE=";
  const char exponent[] = "AQAB";
  Integer mod, exp;
  Base64ToInteger(modulus, mod);
  Base64ToInteger(exponent, exp);

  RSA::PublicKey key;
  key.Initialize(mod, exp);
  return key;
}

int main()
{
  RSA::PublicKey pubKey = CreatePublicKey();
  const char message[] = "hello";
  RSAES_OAEP_SHA_Encryptor pub(pubKey);
  AutoSeededRandomPool randPool;
  std::string result;
  StringSource(message, true, new PK_EncryptorFilter(randPool, pub,
      new Base64Encoder(new StringSink(result))));
}

All I get is:

terminate called after throwing an instance of 'CryptoPP::InvalidArgument'
  what():  RSA/OAEP-MGF1(SHA-1): message too long for this public key


       All I am trying is do the RSA encryption by setting parameter one by
one, reading each XML elements(**).

Any suggestion ? Thanks
Mathieu

(*)
So I found this post by accident.
http://www.mail-archive.com/[email protected]/msg01619.html
Indeed if you try to find this post by using keyword like 'SetModulus'
or 'SetPublicExponent', I cannot find it either by using the internal
search engine or via google:
http://www.google.com/search?hl=en&q=SetPublicExponent+site%3Awww.mail-archive.com

(**)
http://www.w3.org/TR/xmldsig-core/#sec-RSAKeyValue

Jeffrey Walton wrote:
> Hi Mathieu,
>
> I would assume you would provide a Cryptographic Sservice Package
> (CSP). But I've never looked into in.
>
>> I am looking to replace the .NET Framework
>> crypto class by the CryptoPP one.
> You probably cannot replace the .NET cryptography package per se. You
> would provide the CSP, and then set it as the machine default CSP.
> Again, I'm shooting from the hip.
>
> Jeff
>
> On 9/11/06, Mathieu Malaterre <[EMAIL PROTECTED]> wrote:
>> Hello,
>>
>>        I am looking to replace the .NET Framework crypto class by the
>> CryptoPP
>> one. Has anyone try doing so ? Could they share there experience ? I am
>> having a hard time understanding how to setup manually all the
>> parameters (Modulus, Exponent, InverseQ...) are there any examples
>> somewhere that I can look at ?
>>        Finally the only post I was able to find mentionned a problem of
>> endianness:
>>
>> 
http://www.eggheadcafe.com/forumarchives/win32programmerdirectxvideo/dec2005/post24849638.asp
>>
>>
>>        Is this something that has been solved since ?
>>
>> Thanks for your time,
>> Mathieu
>>
>>
>
>



Reply via email to