-4

Let's suppose I want to send you an encrypted and signed message, to demonstrating authenticity and integrity, together with the natural security of asymmetric key cryptography. The procedure is, if I'm not wrong, the following one:

  • I create a message I want to send you.
  • I generate a hash version of that message (the digest).
  • I encrypt the digest with my private key.
  • I send you a composed message consisting of the message, the encrypted digest and my public key, in a secure way (for example, encrypting again the complete package with your public key).
  • You receive and decrypt the package with your private key, and decrypt the digest with the attached public key. If decryption finishes successfully, you ensure my authenticity, because I'm the only person who can has that private key.
  • You generate again the hash version of the attached message to check integrity, because if digests agree, means the message was not corrupted on the way.

But in such case, if you decrypt the message with my public key, you can decrypt the message and, about getting my private key, isn't it easier now?

The reason of encrypting a message to you with your public key, is because a sniffer hasn't the other "factor" (ok, I know the public key is the combination of two huge prime numbers and a third prime number, and the private key is a module arithmetic based key, based on these three prime numbers; but let's me call them "the two factors" for simplicity).

But if both factors comes "together" and there's no risk at all, what would be the reason of keeping the private key in secret?

8
  • How would they get the private key?
    – EEAA
    Oct 24, 2014 at 19:18
  • 2
    That's not what digital signatures are. Please see en.wikipedia.org/wiki/Digital_signature - you may be confusing encryption with digital signatures.
    – Mark Allen
    Oct 24, 2014 at 19:19
  • 2
    I'd recommend you have a read. I think you have several strong misunderstandings here.
    – EEAA
    Oct 24, 2014 at 19:19
  • 3
    All I can think of is: "Magnets, how do they work?!" Oct 24, 2014 at 19:21
  • @EvanAnderson You referring to this gem?
    – EEAA
    Oct 24, 2014 at 19:25

2 Answers 2

3

You were on the right track, until "and, obviously, get my private key".

There's a lot of mathematics that goes into how the keys operate.

The way public/private keypairs work is that with the public key, you can verify the matching private key was used, without ever knowing what the private key is. From having the public key, there's no easy way to figure out the private key.

The signature proves that someone who knew the entire private key signed the file. The public key is used only to verify that signature is valid and that the message hasn't been altered or replaced. They can also be used the other way around - using the public key to encrypt a message to you, only the person who knows the private key can decrypt and read it.

The entire public/private key system is setup to make it easier to communicate without an existing secure channel. You can publish the public key far and wide to everyone who might want it, without compromising the private key.

4
  • I've changed my question to complete it with more details. Please check it.
    – ABu
    Oct 24, 2014 at 19:46
  • @Peregring-lk even with the updated question, I'm still not sure why you believe someone can get the private key. Can you please explain how you think a person you send a message to gets the private part of the key?
    – Grant
    Oct 24, 2014 at 19:54
  • Statistically? I don't now, but, turning the question around, if encrypting with the private key is so sure as using only public keys, why I need to encrypt a message with your public key to send it to you? Why do you need to generate key pairs each time you want to speak with somebody using ssh, for example? It would be only neccesary to use the keys of one of the sides each time, saving lot of users of generating key-pairs.
    – ABu
    Oct 24, 2014 at 20:03
  • @Peregring-lk The secure channel is only one way. For signing, someone signing something with your public key means absolutely nothing, since everyone has the public key. But signing with your private key (which you have, hopefully, kept private) means you signed it. For encryption, you encrypt with my public key. Only the my private key will decrypt it. Having my public key lets you verify I sent a signed message, or send me an encrypted message. But it does nothing to show who sent me that encrypted message, or who reads my signed message.
    – Grant
    Oct 24, 2014 at 20:09
0

When you encrypt plain-text with a private key, then you can decrypt cipher-text with the public key. Only one person should have the private key. The entire world has access to the public key.

When you have cipher text decrypted by the public key, you only get the plain-text back - the private key is still private as you did not obtain that.

Not the answer you're looking for? Browse other questions tagged .