From: Harald Freudenberger <freude@linux.ibm.com>
To: herbert@gondor.apana.org.au, davem@davemloft.net, dengler@linux.ibm.com
Cc: linux-s390@vger.kernel.org, linux-crypto@vger.kernel.org
Subject: [PATCH v9 0/3] New s390 specific protected key hmac
Date: Thu, 2 Jan 2025 10:46:12 +0100 [thread overview]
Message-ID: <20250102094615.99181-1-freude@linux.ibm.com> (raw)
Add support for protected key hmac ("phmac") for s390 arch.
With the latest machine generation there is now support for
protected key (that is a key wrapped by a master key stored
in firmware) hmac for sha2 (sha224, sha256, sha384 and sha512)
for the s390 specific CPACF instruction kmac.
This patch adds support via 4 new hashes registered as
phmac(sha224), phmac(sha256), phmac(sha384) and phmac(sha512).
Changelog:
v1: Initial version
v2: Increase HASH_MAX_DESCSIZE generic (not just for arch s390).
Fix one finding to use kmemdup instead of kmalloc/memcpy from test
robot. Remove unneeded cpacf subfunctions checks. Simplify
clone_tfm() function. Rebased to s390/features.
v3: Feedback from Herbert: Use GFP_ATOMIC in setkey function.
Feedback from Holger: rework tfm clone function, move convert key
invocation from setkey to init function. Rebased to updated
s390/features from 11/7/2024. Ready for integration if there are
no complains on v3.
v4: Rewind back more or less to v2. Add code to check for non-sleeping
context. Non-sleeping context during attempt to derive the
protected key from raw key material is not accepted and
-EOPNOTSUPP is returned (also currently all derivation pathes
would in fact never sleep). In general the phmac implementation is
not to be used within non-sleeping context and the code header
mentions this. Tested with (patched) dm-integrity - works fine.
v5: As suggested by Herbert now the shashes have been marked as
'internal' and wrapped by ahashes which use the cryptd if an
atomic context is detected. So the visible phmac algorithms are
now ahashes. Unfortunately the dm-integrity implementation
currently requests and deals only with shashes and this phmac
implementation is not fitting to the original goal any more...
v6: As suggested by Herbert now a pure async phmac implementation.
Tested via AF_ALG interface. Untested via dm-integrity as this layer
only supports shashes. Maybe I'll develop a patch to switch the
dm-integrity to ahash as it is anyway the more flexible interface.
v7: Total rework of the implementation. Now uses workqueues and triggers
asynch requests for key convert, init, update, final and digest.
Tested with instrumented code and with a reworked version of
dm-integrity which uses asynchronous hashes. A patch for dm-integrity
is on the way but yet needs some last hone work.
v8: Added selftest. With the selftest comes some code which wraps the
clear key into a "clear key token" digestible by PKEY. The
selftest also uses import() and export(), so these are now also
implemented. Furthermore a finup() implementation is now also
available. Tested with AF_ALG testcases and dm-integrity, also
tested with some instrumented code to check that the asynch
workqueue functions do their job correctly. Coding is complete!
v9: As suggested by Herbert use ahash_request_complete() and surround it
with local_bh_disable().
Harald Freudenberger (2):
s390/crypto: New s390 specific protected key hash phmac
s390/crypto: Enable phmac selftest invocation
Holger Dengler (1):
s390/crypto: Add protected key hmac subfunctions for KMAC
arch/s390/configs/debug_defconfig | 1 +
arch/s390/configs/defconfig | 1 +
arch/s390/crypto/Makefile | 1 +
arch/s390/crypto/phmac_s390.c | 986 ++++++++++++++++++++++++++++++
arch/s390/include/asm/cpacf.h | 4 +
crypto/testmgr.c | 30 +
drivers/crypto/Kconfig | 12 +
include/linux/crypto.h | 5 +
8 files changed, 1040 insertions(+)
create mode 100644 arch/s390/crypto/phmac_s390.c
base-commit: fac04efc5c793dccbd07e2d59af9f90b7fc0dca4
--
2.43.0
next reply other threads:[~2025-01-02 9:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-02 9:46 Harald Freudenberger [this message]
2025-01-02 9:46 ` [PATCH v9 1/3] s390/crypto: Add protected key hmac subfunctions for KMAC Harald Freudenberger
2025-01-02 9:46 ` [PATCH v9 2/3] s390/crypto: New s390 specific protected key hash phmac Harald Freudenberger
2025-01-03 9:22 ` Holger Dengler
2025-01-02 9:46 ` [PATCH v9 3/3] s390/crypto: Enable phmac selftest invocation Harald Freudenberger
2025-01-13 7:45 ` Holger Dengler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250102094615.99181-1-freude@linux.ibm.com \
--to=freude@linux.ibm.com \
--cc=davem@davemloft.net \
--cc=dengler@linux.ibm.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).