Skip to content

Conversation

@ebiggers
Copy link
Collaborator

@ebiggers ebiggers commented Apr 22, 2025

Add support for hardware-wrapped inline crypto keys to fscryptctl.

This consists of:

  • New commands that wrap the BLKCRYPTOIMPORTKEY, BLKCRYPTOGENERATEKEY, BLKCRYPTOPREPAREKEY ioctls that were added in Linux 6.15.
  • Support for passing a wrapped key to fscryptctl add_key. This relies on the support for FSCRYPT_ADD_KEY_FLAG_HW_WRAPPED which was added in Linux 6.16.

Link to docs.kernel.org/ instead of www.kernel.org/doc/html/latest/.  It
makes the links shorter, and they point to the latest version.
It should say fscryptctl, not fscrypt.
Add a xzalloc() helper function to simplify error-checked allocations.
In preparation for supporting both raw keys (max size 64) and wrapped
keys (max size 128), make read_key() take a max_size parameter.
Also introduce a wipe_and_free() helper function.
The upcoming commands import_hw_wrapped_key, generate_hw_wrapped_key,
and prepare_hw_wrapped_key will write the wrapped keys they produce to
standard output.  Add a full_write() helper function for them to use.
Import <linux/fscrypt.h> from Linux v6.16.

This is needed to support adding hardware-wrapped keys.
Import <linux/blk-crypto.h> from Linux v6.16.

Needed for the definition of the blk-crypto ioctls.
Update the 'fscryptctl add_key' command to accept hardware-wrapped keys.
Previously, it only accepted raw keys.

This relies on the support for FSCRYPT_ADD_KEY_FLAG_HW_WRAPPED which is
available in Linux 6.16 and later.  For more details, see the Linux
kernel commit https://git.kernel.org/linus/c07d3aede2b26830
@ebiggers ebiggers force-pushed the wrapped-keys branch 3 times, most recently from 8ebbd97 to b433594 Compare October 29, 2025 23:09
Add fscryptctl commands that wrap the BLKCRYPTOIMPORTKEY,
BLKCRYPTOGENERATEKEY, and BLKCRYPTOPREPAREKEY ioctls that were added in
Linux 6.15.  These are needed to use hardware-wrapped keys.
@ebiggers ebiggers merged commit 9b84dc5 into master Oct 29, 2025
11 checks passed
@ebiggers ebiggers deleted the wrapped-keys branch October 29, 2025 23:33
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