[PATCH 2/2] KEYS: asymmetric: Fix PKCS#1 decryption of an empty message
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Wed Nov 11 16:48:29 UTC 2026
> From: Florian Bauckholt <florian.bauckholt at cispa.de>
>
> KEYCTL_PKEY_DECRYPT with enc=pkcs1 on a valid ciphertext of an empty
> message returns the key size instead of 0, and the output buffer is
> filled with the ciphertext.
>
> crypto_akcipher_sync_encrypt() returns 0 on success, so
> software_key_eds_op() maps a result of 0 to crypto_akcipher_maxsize().
> The mapping is applied to decryption as well, but
> crypto_akcipher_sync_decrypt() returns the length of the plaintext,
> which is 0 for an empty message. By then crypto_akcipher_sync_post()
> has copied its scratch buffer to the output. pkcs1pad copied nothing
> into that buffer, so it still holds the ciphertext.
>
> Only the caller's own input is returned, so nothing is disclosed, and
> messages that are not empty are decrypted correctly. An empty message
> is valid, though: RFC 8017 section 7.2 only limits the message length
> to k - 11 octets.
>
> Apply the mapping to encryption only.
>
> Fixes: 63ba4d67594a ("KEYS: asymmetric: Use new crypto interface without scatterlists")
> Cc: stable at vger.kernel.org # v6.5+
> Link: https://lore.kernel.org/all/20260919221742.3709658-1-benquike@gmail.com/
> Signed-off-by: Florian Bauckholt <florian.bauckholt at cispa.de>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261111-keyctl-pkey-fixes-v1-0-934ebaa267a7@cispa.de?part=2
More information about the Linux-security-module-archive
mailing list