Skip to content

Private/public key for decrypt/encrypt reversed #20

@guydingmike

Description

@guydingmike

I think there is a typo in the following two sections:

https://cryptobook.nakov.com/encryption-symmetric-and-asymmetric.html?q=#private-keys

Message encryption and signing is done by a private key.

Shouldn't this be "Message decryption and signing is done by a private key." ?

https://cryptobook.nakov.com/encryption-symmetric-and-asymmetric.html?q=#public-keys

Message decryption and signature verification is done by the public key.

And shouldn't this be "Message encryption and signature verification is done by the public key." ?

Activity

azadkuh

azadkuh commented on Dec 1, 2019

@azadkuh

same mistake in:
key exchange and DHKE:

  • In a key transport scheme only one of the parties contributes to the shared secret and the other party obtains the secret from it. Key transport schemes are typically implemented through public-key cryptography, e.g. in the RSA key exchange the client encrypts a random session key by its private key and sends it to the server, where it is decrypted using the client's public key

regardless of algorithm, encrypting by a private key is useless as anybody has access to the public key, so anyone can easily decrypt and reads the original message (or session key)

ceduliocezar

ceduliocezar commented on Jan 6, 2020

@ceduliocezar

@guydingmike just realized the problem that u reported.

Since you reportd it a long time ago and the problem is still there I created a PR for it.

#29

Sejal-G

Sejal-G commented on Feb 12, 2020

@Sejal-G

same mistake in:
key exchange and DHKE:

  • In a key transport scheme only one of the parties contributes to the shared secret and the other party obtains the secret from it. Key transport schemes are typically implemented through public-key cryptography, e.g. in the RSA key exchange the client encrypts a random session key by its private key and sends it to the server, where it is decrypted using the client's public key

regardless of algorithm, encrypting by a private key is useless as anybody has access to the public key, so anyone can easily decrypt and reads the original message (or session key)

with reference to the last line!!
@azadkuh messge encrypted with a public key can be decrypted with private key, and not vice versa!
Correct me if I am wrong, I am a newbie at cryptosystems.

azadkuh

azadkuh commented on Feb 12, 2020

@azadkuh

@Sejal-G you're absolutely right.

some libs even issue an error if a private key is used for encryption, although it may be possible to extract the public key from the private key efficiently (as in RSA)

more ever, it may be mathematically impossible to decrypt a ciphered text by a public key as it does not contain all required bits for decryption.

regardless of mathematical possibility, using a private key for encryption is semantically wrong and compromises the security as everyone can obtain the public key.

ps. I'm not a guru either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ceduliocezar@azadkuh@guydingmike@Sejal-G

        Issue actions

          Private/public key for decrypt/encrypt reversed · Issue #20 · nakov/Practical-Cryptography-for-Developers-Book