Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have noticed that when I am using GnuPG to encrypt a file for multiple recipie

ID: 657593 • Letter: I

Question

I have noticed that when I am using GnuPG to encrypt a file for multiple recipients, the size of the encrypted message does not seem to be directly proportional to the number of recipients.

For example, a file that I tested is 836 bytes in plaintext.

- encrypted for 1 recipient, it is 1090 bytes
- encrypted for 2 recipients , it is 1619 bytes (810 bytes per recipient)
- encrypted for 9 recipients, it is 4738 bytes (526 bytes per recipient)
- encrypted for 51 recipients, 26,397 bytes (517 bytes per recipient)

Since encrypted data should look random, I am thinking that the difference is not due to compression. Not all of the 51 keys are the same key size/algorithm, but I do not see how this could account for such a dramatic average file size.

How is it that I can encrypt an 836 byte file for 51 people, so that they can all decrypt my file back to its original size without appending at least 836 bytes per recipient?

Explanation / Answer

Because the entire message is not encrypted separately for each recipient.

Instead, a single symmetric encryption key is chosen at random, the message is encrypted once using that key, and then the encryption key is itself encrypted separately for each recipient, using that recipient's public key, and appended to the encrypted message.

Each recipient decrypts the message by first using their private key to decrypt the symmetric encryption, and then decrypts the message using that key.

Since keys are typically much shorter than the plaintext, this saves a lot of space. (It also lets the recipients know they've all decrypted the same message. If the messages were encrypted separately for recipient, a devious sender could send different messages to each recipient, pretending they were all carbon copies of the same message.)

With your data, adding the second recipient added 527 bytes. That second recipient probably had a 512-byte key, plus 15 bytes to identify the recipient. Successive recipients will have had different key lengths and different identifying data, so the amount added for each will vary.