mirror of
https://codeberg.org/openpgp/notes.git
synced 2024-11-05 16:45:59 +01:00
25 lines
1.6 KiB
Markdown
25 lines
1.6 KiB
Markdown
<!--
|
|
SPDX-FileCopyrightText: 2023 The "Notes on OpenPGP" project
|
|
SPDX-License-Identifier: CC-BY-SA-4.0
|
|
-->
|
|
|
|
# Compression
|
|
|
|
Optional compression of data is one element of OpenPGP's composable functionality. Compression within OpenPGP can be convenient to applications.
|
|
|
|
In one use case, this functionality is particularly helpful: When encrypting a message, the encrypted output is by definition high-entropy, and cannot be compressed anymore - even if the plaintext message was low-entropy, and could have been compressed well (like, for example, a text-file).
|
|
|
|
|
|
This means that to use whatever potential for compression exists, the message must be compressed *before* encryption. OpenPGP offers an integrated compression mechanism to make this convenient (otherwise, messages would need to be compressed and decompressed before and after encryption, to achieve the same space-efficiency).
|
|
|
|
## Decompression yields a 'wrapped' OpenPGP packet stream
|
|
|
|
Compression in OpenPGP is a simple mechanism: A [Compressed Data packet](https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-12.html#name-compressed-data-packet-type) acts as a compressed container for a series of OpenPGP packets.
|
|
|
|
The compressed data packet consists of the specification of which compression algorithm is used, followed by a compressed representation of the contained data.
|
|
|
|
The series of OpenPGP packets inside the Compressed Data packet can be handled like any stream of OpenPGP packets.
|
|
|
|
## Typical usage
|
|
|
|
Compressed data packets are often used inside [encrypted data packets](/encryption), or wrapping the data of an [inline-signed message](inline-signature).
|