Repository navigation
Conversation
PBES2 with CBC has no integrity protection, so an encrypted private key can be modified without detection. When encrypting with CBC, the PBES2 salt is now prefixed with a fixed label and an HMAC-SHA-256 attribute is added to the PrivateKeyInfo. On decryption, if the label is present in the salt field then the MAC is required; since the salt is part of the KDF input this prevents an attacker from stripping the MAC, which would otherwise be possible due to CBC's malleability. OpenSSL, GnuTLS, pyca, all older Botan versions, and most other libraries will simply ignore the unknown attribute. The notable exception is mbedtls which seems to have a bug that it does not ignore the optional attributes field.
randombit
force-pushed
the
jack/pkcs8-add-mac
branch
from
November 17, 2026 09:10
307cfd6 to
fb048c9
Compare
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.
PBES2 with CBC has no integrity protection, so an encrypted private key can be modified without detection. When encrypting with CBC, the PBES2 salt is now prefixed with a fixed label and an HMAC-SHA-256 attribute is added to the PrivateKeyInfo. On decryption, if the label is present in the salt field then the MAC is required; since the salt is part of the KDF input this prevents an attacker from stripping the MAC, which would otherwise be possible due to CBC's malleability.
OpenSSL, GnuTLS, pyca, all older Botan versions, and most other libraries will simply ignore the unknown attribute. The notable exception is mbedtls which seems to have a bug that it does not ignore the optional attributes field.