KEYS: Convert KEYCTL_DH_COMPUTE to use the crypto KPP API
Subsystems (2)
PATCH v3 1/1 KEYS: Convert KEYCTL_DH_COMPUTE to use the crypto KPP API
The initial Diffie-Hellman computation made direct use of the MPI library because the crypto module did not support DH at the time. Now that KPP is implemented, KEYCTL_DH_COMPUTE should use it to get rid of duplicate code and leverage possible hardware acceleration.
---
v2: Fix issue when DH computation results with leading zeros are used with
a KDF.
v3: Rebase on keys-fixes (v2 was on keys-next)
git tree at
https://git.kernel.org/pub/scm/linux/kernel/git/martineau/linux.git
(dh-refactor branch)
security/keys/Kconfig | 2 +- security/keys/dh.c | 272 +++++++++++++++++++++++++++++++------------------- 2 files changed, 171 insertions(+), 103 deletions(-)
security/keys/Kconfig +1 -1
@@ -93,9 +93,9 @@ config ENCRYPTED_KEYS config KEY_DH_OPERATIONS bool "Diffie-Hellman operations on retained keys" depends on KEYS - select MPILIB select CRYPTO select CRYPTO_HASH + select CRYPTO_DH help This option provides support for calculating Diffie-Hellman public keys and shared secrets using values stored as keys
security/keys/dh.c +170 -102
381 lines not on this page · raw message
Signature · 1 line
2.13.1
David Howells
maintainerQuoted 4 lines · Mat Martineau
The initial Diffie-Hellman computation made direct use of the MPI library because the crypto module did not support DH at the time. Now that KPP is implemented,
KEYCTL_DH_COMPUTEshould use it to get rid of duplicate code and leverage possible hardware acceleration.
If I'm going to take this as a fix instead of Eric's patch #3, this needs to say what it fixes.
David
David Howells
maintainerQuoted 7 lines · David Howells
Quoted 4 lines
The initial Diffie-Hellman computation made direct use of the MPI library because the crypto module did not support DH at the time. Now that KPP is implemented,
KEYCTL_DH_COMPUTEshould use it to get rid of duplicate code and leverage possible hardware acceleration.If I'm going to take this as a fix instead of Eric's patch #3, this needs to say what it fixes.
I propose adding the following paragraph, paraphrased from Eric:
This fixes an issue whereby the result of the Diffie-Hellman computation might be shorter than the input prime number - in which case we would include additional uninitialized memory in the KDF calculation.
David