Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: be more specific about the limitations of AE-2 #97

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions docs/advanced-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ This is useful to keep the total number of bytes down as much as possible. This

## Password protection / encryption

The data of ZIP files can be password protected / encrypted by passing a password as the `password` parameter to `stream_zip`.
The data of ZIP files can be password protected / encrypted by passing a password as the `password` parameter to `stream_zip`. This encrypts the data with AES-256, adhering to the [WinZip AE-2 specification](https://www.winzip.com/en/support/aes-encryption/).

```python
import secrets
Expand All @@ -54,10 +54,18 @@ password = secrets.token_urlsafe(32)
encrypted_zipped_chunks = stream_zip(member_files(), password=password)
```

Notes:

1. This encrypts the data with AES-256, adhering to the [WinZip AE-2 specification](https://www.winzip.com/en/support/aes-encryption/).

2. This is seen as more secure than ZipCrypto, the original mechanism of password protecting ZIP files, but fewer clients can open such ZIP files.

3. While a step forward from ZipCrypto, it has flaws that you should be aware of before using it. See ["Attacking and Repairing the WinZip Encryption Scheme" by Tadayoshi Kohno](https://homes.cs.washington.edu/~yoshi/papers/WinZip/winzip.pdf) and [fgrieu's answer to a question about WinZip's AE-1 and AE-2 on Crytography Stack Exchange](https://crypto.stackexchange.com/a/109269/113464).
You should use a long and random password, for example one generated by the [Python secrets module](https://docs.python.org/3/library/secrets.html).

> ### Warnings
>
> While AE-2 is seen as more secure than ZipCrypto, the original mechanism of password protecting ZIP files, fewer clients support AE-2 than ZipCrypto.
>
> More importantly, AE-2 has flaws. These include:
>
> - Not encrypting metadata, for example member file names, modification times, permissions, and sizes.
>
> - Not including sufficient mechanisms to alert recipients if data or metadata has been intercepted and changed. This can itself lead to information leakage.
>
> - A higher risk of information leakage when there's a higher number of member files in the ZIP encrypted with the same password, as stream-zip and most other ZIP writers do.
>
> See ["Attacking and Repairing the WinZip Encryption Scheme" by Tadayoshi Kohno](https://homes.cs.washington.edu/~yoshi/papers/WinZip/winzip.pdf) and [fgrieu's answer to a question about WinZip's AE-1 and AE-2 on Crytography Stack Exchange](https://crypto.stackexchange.com/a/109269/113464) for more information.