Skip to contentSkip to conversation

KEYS: Convert KEYCTL_DH_COMPUTE to use the crypto KPP API

PATCH Superseded Mat Martineau 2 participants 3 messages Jun 6, 2017

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

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
index 00b7431a8aeb..a7a23b5541f8 100644
@@ -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
maintainer
#1 lore raw
Quoted 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_COMPUTE should 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

maintainer
#2 lore raw
In reply to Mat Martineau
Quoted 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_COMPUTE should 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