Skip to content
This repository was archived by the owner on Jul 12, 2026. It is now read-only.

Fix legacy_decrypt to use password-derived Fernet key (#185)#202

Open
Yupsecous wants to merge 1 commit into
RaoFoundation:mainfrom
Yupsecous:fix/legacy-decrypt-185
Open

Fix legacy_decrypt to use password-derived Fernet key (#185)#202
Yupsecous wants to merge 1 commit into
RaoFoundation:mainfrom
Yupsecous:fix/legacy-decrypt-185

Conversation

@Yupsecous

Copy link
Copy Markdown

legacy_decrypt derived a key from the password via PBKDF2 but then discarded it and called Fernet::generate_key(), so decryption used a random key and always failed on real legacy keyfiles. Encode the PBKDF2-derived key with URL-safe base64 (matching Python cryptography's Fernet key format) and use it for decryption. Also replace the Fernet::new(...).unwrap() with proper KeyFileError propagation, and add a regression test covering the legacy decrypt path.

)

legacy_decrypt derived a key from the password via PBKDF2 but then
discarded it and called Fernet::generate_key(), so decryption used a
random key and always failed on real legacy keyfiles. Encode the
PBKDF2-derived key with URL-safe base64 (matching Python cryptography's
Fernet key format) and use it for decryption. Also replace the
Fernet::new(...).unwrap() with proper KeyFileError propagation, and add
a regression test covering the legacy decrypt path.

The regression test is gated to non-python-bindings builds: it drives
decrypt_keyfile_data, whose call graph reaches utils::print, which under
python-bindings executes Python via pyo3. A standalone Rust test binary
cannot link that under extension-module (libpython is intentionally not
linked), so the test runs under default features (e.g. cargo test) and
is skipped when python-bindings is enabled.
@Yupsecous
Yupsecous force-pushed the fix/legacy-decrypt-185 branch from dab602a to ce7970a Compare June 4, 2026 10:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant