Skip to content

Authenticate CBC encrypted PKCS #8 keys with a MAC attribute - #6138

Open
randombit wants to merge 1 commit into
masterfrom
jack/pkcs8-add-mac
Open

randombit wants to merge 1 commit into
masterfrom
jack/pkcs8-add-mac

Conversation

@randombit

Copy link
Copy Markdown
Owner

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant