If I encrypt a file for multiple users how does the file size change?
Does the size of the output double for two users. How about 10 or 100 users?
Information Security Stack Exchange is a question and answer site for information security professionals. It only takes a minute to sign up.Sign up to join this community
GPG encrypts the file once with a symmetric key, then places a header identifying the target keypair and an encrypted version of the symmetric key. The intricate details of that are defined in section 5.1 of RFC 2440. When encrypted to multiple recipients, this header is placed multiple times providing a uniquely encrypted version of the same symmetric key for each recipient.
Thus, file size growth for each recipient is small and roughly linear. Some variation may exist for key length and padding so it's
not predictable different for different key sizes and algorithms, but it's small. In a quick test demonstration using no compression:
11,676,179 source 11,676,785 encrypted-to-one (+606 bytes) 11,677,056 encrypted-to-two (+277 bytes) 11,677,329 encrypted-to-three (+273 bytes)
In the OpenPGP format (that's the protocol PGP and GnuPG implement), a message is encrypted by first compressing it, then using symmetric encryption with a random key K; K is then encrypted with the public key of each of the recipient.
The compression step tends to reduce the size of the data, or not, depending on the data type (ASCII text compresses well, JPG pictures do not). Symmetric encryption increases the size by only a very small amount (like 20 bytes or so).
For each recipient, a "Public-Key Encrypted Session Key Packet" is added (see section 5.1 of OpenPGP). The size of such a packet depends on the public key type and length for that recipient; for instance, for a 2048-bit RSA key, that packet should have length 271 bytes (for 2048-bit ElGamal, that would be 529 bytes).
Finally, if the encrypted file is to be included in an email, it will be usually "ASCII-armored", i.e. encoded in Base64 (so that it travels unscathed through mail servers which expect text, not binary data); Base64 encoding increases the data length by +33%.
Bottom-line: size increase per recipient depends on the recipient key but not on the original file size. Size increase should be less than 1 kB per recipient.