How do I encrypt arbitrary data using a private key in GPG?

3

All the sites I have been to illustrate how to encrypt data with a recipient. I know this means that you are using the recipient's public key to encrypt the data, encryption that can only be decrypted by the recipient's private key. What I want to know is how do you encrypt data with your private key, encrypted data that can only be decrypted with your public key?

I'm doing all this in GPG, and I've scoured the internet for examples and cheat-sheets and such to no avail.

How is this done?

Edit...

This is not what I am looking for. I'm pretty sure I know how to sign arbitrary data.

Steve Mucci

Posted 2017-08-17T16:08:00.583

Reputation: 151

"What I want to know is how do you encrypt data with your private key, encrypted data that can only be decrypted with your public key?" - If the data could be decrypted with the public key it means anyone could decrypt the data because the public key is the only key that is shared. If want that to be the case, then share both the public and private key, that way everyone can decrypt the file. – Ramhound – 2017-08-17T18:33:16.927

Do you mean encrypt so only you can decrypt it, with your key (you mean the private key probably). Doesn't using --recipient with your id work? – Xen2050 – 2017-08-23T12:21:13.040

Answers

1

I've figured it out. The purpose here would be to encrypt data with your private key so that only people with your public key can decrypt it. I'm implying here that the public key is somewhat a secret between a single person or group of people and the owner of the corresponding private key, but this is not how public key cryptography works; theoretically everyone can have a copy of the public key. This implies that the public key is not a shared secret but public, and therefore there would be no point in encrypting data that anyone and everyone can see; it might as well be unencrypted!

To achieve what I am trying to do we use not asymmetric encryption like public key cryptography, but symmetric cryptography, commonly known as private key cryptography. In symmetric cryptography we encrypt data with a shared secret (a password for example, though any data can be used as the shared secret or passphrase), and this secret is shared amongst a group of individuals. As long as the shared secret is kept secret by only those with said shared secret then only those individuals can encrypt and decrypt data with that shared secret. This is what I was searching for. Unfortunately symmetric encryption does not provide identification and non-repudiation; all you know about the sender of symmetric key encrypted data is that it came from someone whom has the symmetric key, hopefully from a party that rightfully should have the key, that the key is still secret.

If you really want all the qualities of asymmetric cryptography (identification, confidentiality, integrity, non-repudiation) then get a group together and grab each others' public keys and start sending individual messages using each others' public keys. This doesn't work in the way you send bulk messages to multiple recipients like with private key (symmetric) cryptography, but that doesn't really matter when public key cryptography provides many more benefits, and really, is sending multiple messages really that hard?

Steve Mucci

Posted 2017-08-17T16:08:00.583

Reputation: 151

A single message can be encrypted to multiple recipients at once, though... – user1686 – 2017-08-24T18:27:58.263

Yeah, you encrypt with your private key and the multple recipients whom have your public key can decrypt, or are you saying you can encrypt with multiple public keys? – Steve Mucci – 2017-08-25T03:45:53.167

1I'm saying the latter. It's something PGP has supported since day one (search this site for "hybrid" encryption). There is no need for hacks like a public-but-actually-secret key. – user1686 – 2017-08-25T04:12:54.783

Interesting. Linkey for all the folks out there; https://www.gnupg.org/gph/en/manual.html#AEN210

– Steve Mucci – 2017-08-25T15:08:34.357

3

You don't. As your public key is public, such an operation would be merely a weak, obscure alternative to signing, so it is neither implemented by GnuPG, nor defined by OpenPGP (RFC 4880).

(Besides that, it would also likely be limited to RSA keypairs only.)

user1686

Posted 2017-08-17T16:08:00.583

Reputation: 283 655