7-Zip Password KDF Iteration Count Explained

When encrypting archives, 7-Zip relies on a key derivation function (KDF) that applies \(2^{19}\)—or exactly 524,288—iterations of SHA-256 to convert a user password into an encryption key. This article explains the specific key derivation mechanism used by 7-Zip, the role of its 524,288-cycle iteration count, and how this process protects archives against brute-force and dictionary attacks.

7-Zip’s Key Derivation Mechanism

7-Zip protects .7z archives using AES-256 encryption in CBC (Cipher Block Chaining) mode. Because AES-256 requires a 256-bit binary key rather than a plain text password, 7-Zip must derive the key using a cryptographic hash function.

Instead of standard PBKDF2 or Argon2 algorithms, 7-Zip implements a custom key derivation routine built directly on SHA-256. The derivation process functions as follows:

  • Iteration Count: 7-Zip executes \(2^{19}\) (524,288) cycles of SHA-256.
  • Salt Usage: A pseudo-random salt (typically up to 16 bytes) is combined with the user-supplied password to ensure identical passwords do not generate identical keys.
  • Key Generation: The password bytes and salt are iteratively hashed through SHA-256 across all 524,288 cycles. The final 32-byte (256-bit) digest serves directly as the AES-256 encryption key.

Purpose of the 524,288 Iteration Count

The primary objective of key stretching is to slow down attackers attempting to guess the password.

Without key stretching, an attacker utilizing high-performance hardware (such as modern GPUs or ASICs) could test billions of SHA-256 hashes per second. By enforcing 524,288 iterations per attempt, 7-Zip forces the attacker's hardware to compute over half a million SHA-256 rounds for every single password candidate. This dramatically reduces the rate at which automated password cracking tools can test combinations.

For legitimate users, running 524,288 iterations introduces a sub-second delay during archive creation or extraction—an imperceptible performance cost that provides substantial defense against offline dictionary attacks.

Scope of Protection

This KDF process applies to:

  1. File Data: Encrypting the payload of the files stored within the .7z archive.
  2. Archive Headers: When the "Encrypt file names" option is enabled, 7-Zip applies the same derived key to encrypt the entire archive directory, masking file names, file sizes, and directory structures from unauthorized viewers.