Repository navigation
client, server: Fix padding with OpenSSL backend - #708
Open
michaelkuhn wants to merge 2 commits into
Open
michaelkuhn wants to merge 2 commits into
michaelkuhn wants to merge 2 commits into
Conversation
michaelkuhn
force-pushed
the
openssl-dh-padding
branch
from
November 20, 2026 22:11
45f3c1e to
c54123a
Compare
libsecret sometimes doesn't find stored secrets, for example, when using `git-credential-libsecret`: ``` libsecret-CRITICAL **: secret_value_get_text: assertion 'value' failed libsecret-CRITICAL **: secret_value_unref: assertion 'value != NULL' failed ``` `client/src/crypto/openssl.rs::generate_aes_key()` uses rust-openssl's `Dh::compute_key()`. It allocates a `DH_size()` buffer (128 bytes), calls `DH_compute_key()` and ignores the returned length. `DH_compute_key()` strips leading zero bytes: it moves the secret to the front of the buffer and zero-fills the tail. If the shared secret starts with a zero byte (about 1 in 256), oo7 gets `secret||00`, sees a 128-byte value and adds no padding. libsecret (>= 0.21.8, and gcrypt builds) uses the correct `00||secret`. HKDF then produces different AES keys, and that session can't decrypt anything. `server/src/gnome/crypto/openssl.rs::generate_aes_key_for_secret_exchange()` has the same bug with the 1536-bit group. It's used for the key exchange with the GNOME prompter, so occasionally an unlock prompt probably fails.
michaelkuhn
force-pushed
the
openssl-dh-padding
branch
from
November 20, 2026 22:16
c54123a to
7fb4fc0
Compare
📊 Code Coverage Report
Coverage report generated by cargo-tarpaulin |
bilelmoussaoui
left a comment
Collaborator
There was a problem hiding this comment.
Can you add a test case based on the script you shared confirming it works as expected?
Author
|
I've pushed a new commit that adds two tests that should catch the problem: main, openssl_crypto: main, native_crypto: main + patch, openssl_crypto: |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
libsecret sometimes doesn't find stored secrets, for example, when using
git-credential-libsecret:client/src/crypto/openssl.rs::generate_aes_key()uses rust-openssl'sDh::compute_key(). It allocates aDH_size()buffer (128 bytes), callsDH_compute_key()and ignores the returned length.DH_compute_key()strips leading zero bytes: it moves the secret to the front of the buffer and zero-fills the tail. If the shared secret starts with a zero byte (about 1 in 256), oo7 getssecret||00, sees a 128-byte value and adds no padding. libsecret (>= 0.21.8, and gcrypt builds) uses the correct00||secret. HKDF then produces different AES keys, and that session can't decrypt anything.server/src/gnome/crypto/openssl.rs::generate_aes_key_for_secret_exchange()has the same bug with the 1536-bit group. It's used for the key exchange with the GNOME prompter, so occasionally an unlock prompt probably fails.Fixes: #707