As Ludwig said, you probably need to inverse the public and the private key, as Crypto++ doesn't provide an Encrypt method with the private key nor  Decrypt with the public key.
 
To encrypt with the private key is easier, as you can export the modulus and the private exponent into a public key structure and use it to encrypt.
 
It is more difficult to decrypt with the public key, as you cannot initialize a private key with the modulus and the public exponent (as far as I know) to use its Decrypt method, in Crypto++ the private key must also contain other parameters, including the public key.
 
The solution I found for this problem (and it seems to work) was to add a Decrypt method to do the work and decrypt with the public key.
 
And another problem you should pay attention to is generating key pairs with Crypto++, as the public exponent is by default 17 and so you would be able to derive the public key knowing the private key (the modulus in fact). The solution I found here was generating the public exponent randomly.
 
Adrian.

Reply via email to