4
$\begingroup$

This may sound weird: What if I don't let others know my public key, then use my private key to encrypt, and the public key to decrypt? Is this secure? Let me explain a little bit:


Common usuage: use private key to sign and disclose public key, then others can vefriy the data signature use public key


Weird usage: use private key to encrypt and don't disclose public key, in other end use public key to decrypt. notice here I will not disclose private key either so it's not swap In second scenario, if I can keep both keys secure(I mean don't disclose to otheres), does it secure?

$\endgroup$
3
  • 5
    $\begingroup$ from a mathematical point of view exponent $d$ and $e$ can be swapped, but if you use a common software library to generate your key, public exponent $e$ is usually chosen equal to 65537, so if you swap them you'll put your key under jeopardy. $\endgroup$
    – ddddavidee
    Sep 8, 2015 at 15:06
  • 1
    $\begingroup$ It works, but you still have to distribute a public key in order to let know to the others how to encrypt messages in a way that only you can decrypt... however, you should take a look at this question also... it seems to me that your question may be a duplicate $\endgroup$
    – pa5h1nh0
    Sep 8, 2015 at 16:13
  • $\begingroup$ Hi pa5h1nh0, thanks for your link, that one is not a duplicate , I read that link before I post this one. "but you still have to distribute a public key in order to let know to the others how to encrypt messages in a way that only you can decrypt"---------No, I don't need to if I don't need others send encrypted message to me $\endgroup$
    – Gerry
    Sep 8, 2015 at 22:14

3 Answers 3

10
$\begingroup$

No, you generally cannot swap the public and private keys.

Your public key consists of a public exponent and a modulus. The modulus should be known to the person doing the encryption. The public exponent - in general - is a relatively small prime such as 3 or 65537 (Fourth number of Fermat). So given the modulus all an attacker has to do is guess the public key. It's very easy to factor pretty small exponents (I've written software to generate public keys given a private key). The exponent of the private key on the other hand consists of a number that is about as large as the modulus. It cannot be easily factored; the security of RSA relies on this fact.

Currently the majority of software uses RSA with a small public exponent. It is however possible to create an RSA exponent that is the same size as the private exponent. In that case you would have something close to two private keys. Note however that the public key is generally not required to be private. So software may not protect the public key as much as the private key (with regards to e.g. side channel analysis). Sometimes the software may also use padding required for signature generation instead of those for encryption if you present it a public key - mainly due to some weird signature functions required for SSLv3 and TLS 1.0.

So even if your software would accept the public key - RSA is modular exponentiation after all - then by all practical means it not going to be secure.

$\endgroup$
1
$\begingroup$

If you keep both keys secret and use a random public exponent, you can use the private key to encrypt and the "public key" to decrypt. However, that is not necessarily a very good idea.

With both keys secret you would be better off using symmetric encryption, like AES. It is faster, more space efficient and requires only one key. You would probably need to use symmetric encryption anyway, in hybrid encryption with RSA, so you are not losing any security or trusting any additional algorithms.

Alternatively, if you want to use an RSA keypair, just use the public key to encrypt and the private key to decrypt. That lets you use a small public exponent, which normal tools will generate, making encryption faster.

$\endgroup$
1
  • $\begingroup$ I agree that one should just use symmetrci crypto here but I would prefer the default recommendation to be some AEAD cipher. :) $\endgroup$
    – Elias
    Feb 13, 2020 at 17:41
0
$\begingroup$

"Currently the majority of software uses RSA with a small public exponent"

If that is true, then the majority of the software is compromised. From https://www.tutorialspoint.com/cryptography/public_key_encryption.htm

"The strength of RSA encryption drastically goes down against attacks if the number p and q are not large primes and/ or chosen public key e is a small number."

$\endgroup$
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.