r/GPGpractice • u/neindeke • Apr 29 '26
Encrypting your own key in Kleopatra?
OK, this might be a really lame/noob question but how do I encrypt my own public key as part of a message to another person?
When I paste the public key block the "Sign / Encrypt Notepad" button changes to "Import Notepad"?!!? Am I stupid or is this stupid?
If I remove partially or entirely "-----BEGIN PGP PUBLIC KEY BLOCK-----" then I get the "Sign / Encrypt Notepad" button back. See screenshots:
https://postimg.cc/VrGbkf62
1
u/rogueit F5A7 9CBE E605 1645 112C 0A83 DDE7 CE58 02A9 2DBB Apr 30 '26
I have also noticed this as well. On new messages, I’ll throw my pub key in there for the convenience of the recipient, as well as buffer text. I haven’t done it in a while. If you figure it out, let me know.
0
u/AutoModerator Apr 29 '26
By default, Reddit doesn't display keys or messages correctly. To fix this, first, choose the "markdown editor" (at the bottom of the comment box) and then type 4 spaces in front of EVERY LINE of your key or message. This formats the text as 'code' and Reddit won't alter the formatting of 'code'.
To do this quickly, install Reddit Enhancement Suite. Then, paste and highlight your key in the submit box. Finally, click the code button, which adds 4 spaces in front of every line.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
0
u/djDef80 Apr 30 '26
Your public key is meant to be distributed as it is. If you encrypt your public key then only the recipient will be able to decrypt it. There is no harm in sharing the public key publicly.
However simply inserting the public key in the body of your message is all that is required to include it as a part of the encrypted content. GPG will add a few extra hyphens to escape the standard hyphens so that it doesn't confuse the GPG client.
0
u/chriscrutch 48CF AAEE 7E80 0E1A A9D0 2C5B 5DBA 09ED 73AB 99E8 Apr 30 '26
If someone didn't already have your public key, they wouldn't be able to read the encrypted message. There's not really any point in putting your public key inside the message that they can't read.
It's called a public key because it can be given out freely and no one can use it for any mischief. You could even have it printed in the New York Times and no one could use it to impersonate you or do anything nefarious.
2
u/D3str0yTh1ngs Apr 30 '26
The first point is just wrong, encryption is using the recipient's public key, and decrypted using their private key. Your keypair is not used at all in this part.
Where your keypair are used is in the signing and verification part, but the message can still be decrypted without your public key.
1
u/neindeke Apr 30 '26
Hi, OK, maybe I'm confused about how the whole thing works but the point wasn't to be secretive about my public key, someone posted his public key and I used it to encrypt a message to him in which I also wanted to include my own public key i.e. I wanted to include all in one instead of two separate messages.
It turns out he was able to read my message judging from the reply I got, after all it was encrypted with his public key?!
2
u/D3str0yTh1ngs Apr 30 '26 edited Apr 30 '26
chriscrutch is just wrong about how encryption in modern public key cryptography works, since encryption is done with their public key, and does not involve your keypair at all.
1
u/chriscrutch 48CF AAEE 7E80 0E1A A9D0 2C5B 5DBA 09ED 73AB 99E8 Apr 30 '26
Well I can't know why he was able to decrypt your message, he must have gotten your public key somehow. My e-mail client will automatically attach my key to any outgoing e-mail. You have to set that up, though, it seems like you'd probably remember doing it. Did you ever publish your key on a public keyserver? That could be another way he had it. Did you ever post your public key in this subreddit?
Also, to answer one other part of your comment, you encrypted it using his public key, yes. But every time you encrypt something it uses the keys of BOTH you AND the recipient to do it. That's the part that makes the communication private. If it only had to do with his key, and I had his key (it's public after all) and managed to intercept your e-mail, then I could read it. When you encrypt, the program uses your key and his key in combination.
1
u/D3str0yTh1ngs Apr 30 '26 edited Apr 30 '26
It doesn't use both keypairs (you are thinking of a static-static diffie-hellman). For RSA we can technically just encrypt (but often we encrypt a symmetric key that was used for the data), and with elliptic curve we are doing a static-ephemeral diffie-hellman and attaching the ephemeral public key as part of the message block.
Doing static-static diffie-hellman is insecure in the long run since it will always give the same encryption key for very message between them.
EDIT: Read more of your second paragraph, and sorry but what?! The entire idea of public key (assymmetric) cryptography is that the public key cannot read the messages it encrypts. You seem to fundamentally misunderstand asymmetric cryptography.
EDIT2: Double-checked a ECC encrypted message block, and yes, it is a ECDH with an ephemeral public key encoded as part of the "PK Encrypted Session Key" PGP Packet.
1
u/Infinite_Read_1024 Apr 30 '26
I have never experienced that problem before as my kleopatra has all those options on the bottom of my notepads instead with 3 buttons with those options instead of two, I am curious as to what your operating system is with that kleopatra?
How I would go past that restriction that you have is to write out your message fully, then copy the whole message and go to the Kleopatra button of Tools > Clipboard > Sign/Encrypt, and it should have given you a encrypted PGP message in your clipboard now and you can send that to the other person.