Re: Encrypting using RSA private Key



Hi Jeronimo Bertran,

not with .NET! the answer is YES but only if you rewrite the rsa algo :-D
....you need a BigInteger library ;-)

P = 1st large prime number
Q = 2nd large prime number
E = Public Exponent: 3 (fast operation), 65537 (secure) (or random number
which must: GCD(E, (P-1)*(Q-1))==1)
N = Public Modulus, N=P*Q
D = Private Exponent: D=E^(-1) mod ((P-1)*(Q-1))

{N,E}=publickey
{D}=privatekey

standard use:
-------------
encryption: C=M^E mod N with M<N
decryption: M=C^D mod N

the inverse use of rsa :-o is:

encryption: C=M^D mod N with M<N
decryption: M=C^E mod N

^ = PowerOf

HTH
--
Marcello Cantelmo
www.cantelmosoftware.com

Hi,

Is it possible to encrypt using the RSA private key and decrypt using the
public key? I am able to do the opposite but when I try to decrypt using
the private key I get a "Bad Key" Exception. Here is an example:

rsa = new RSACryptoServiceProvider();
RSAParameters publicKey = rsa.ExportParameters(false);
RSAParameters privateKey = rsa.ExportParameters(true);
byte[] testPlainData = new byte[] { 0x01, 0x02, 0x03 };
rsa.ImportParameters(publicKey);
byte[] enc = rsa.Encrypt(testPlainData, false);
rsa.ImportParameters(privateKey);
byte[] plain = rsa.Decrypt(enc, false);

enc = rsa.Encrypt(testPlainData, false);
rsa.ImportParameters(publicKey);
rsa.Decrypt(enc, false);

The first encryption and decryption work fine. The second encryption
(using the private key) seems to work but the decryption using the public
key throws the exception.

Thanks,

Jeronimo


.



Relevant Pages

  • Re: RSA breaking vs. factoring
    ... affects the two possible usages of RSA both for encryption (first public, ... then private key) and for signing ... are identical to encryption, in reverse order. ... Digital signature generation takes an input message (which may be quite ...
    (sci.crypt)
  • Re: Symmetric encryption algorithm with group like properties
    ... >> Solutions that exist today are not as secure as they can be. ... I wouldn't expect more than PGP / GPG type encryption, ... > versions - with the key, protected by RSA encryption under a RSA public key ... > Alice needs a secure decryption mechanism to read her emails, ...
    (sci.crypt)
  • Re: RSA ecnryption confusion
    ... From the core mathematical RSA ... -- RSA asymmetric encryption, which can be used to encrypt confidential ... The other exponent is kept private. ... of the private key is the knowledge of everything about the modulus. ...
    (sci.crypt)
  • Re: RSA ecnryption confusion
    ... From the core mathematical RSA ... -- RSA asymmetric encryption, which can be used to encrypt confidential ... The other exponent is kept private. ... of the private key is the knowledge of everything about the modulus. ...
    (sci.crypt)
  • Re: Name this key exchange
    ... RSA is faster than DH at encryption and slower at decryption. ... Bob generates a secret by choosing a random number r and setting ...
    (sci.crypt)