Skip to contentSkip to conversation

Is there any userland implementations of fscrypt

DISCUSSION Eric Biggers 2 participants 3 messages Mar 20, 2023 – Mar 21, 2023 1 message not in the archive fscrypt: file system level encryption support

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Eric Biggers

author maintainer
#1 lore raw

[+Cc linux-fscrypt]

Quoted 6 lines · Xiubo Li

Hi Eric,

BTW, I am planing to support the fscrypt in userspace ceph client. Is there any userland implementation of fscrypt ? If no then what should I use instead ?

I assume that you mean userspace code that encrypts files the same way the kernel does?

There's some code in xfstests that reproduces all the fscrypt encryption for testing purposes
(https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git/tree/src/fscrypt-crypt-util.c?h=for-next).
It does *not* use production-quality implementations of the algorithms, though. It just has minimal implementations for testing without depending on OpenSSL.

Similar testing code can also be found in Android's vts_kernel_encryption_test
(https://android.googlesource.com/platform/test/vts-testcase/kernel/+/refs/heads/master/encryption).
It uses BoringSSL for the algorithms when possible, but unlike the xfstest it does not test filenames encryption.

There's also some code in mkfs.ubifs in mtd-utils
(http://git.infradead.org/mtd-utils.git) that supports creating encrypted files. However, it's outdated since it only supports policy version 1.

Which algorithms do you need to support? The HKDF-SHA512 + AES-256-XTS + AES-256-CTS combo shouldn't be hard to support if your program can depend on OpenSSL (1.1.0 or later).

- Eric

#2 lore raw
Quoted 11 lines · Eric Biggers

[+Cc linux-fscrypt]

Quoted 6 lines · Xiubo Li

Hi Eric,

BTW, I am planing to support the fscrypt in userspace ceph client. Is there any userland implementation of fscrypt ? If no then what should I use instead ?

I assume that you mean userspace code that encrypts files the same way the kernel does?

Yeah, a library just likes the fs/crypto/ in kernel space.

I found the libkcapi, Linux Kernel Crypto API User Space Interface Library(http://www.chronox.de/libkcapi.html)  seems exposing the APIs from crypto/ not the fs/crypto/.

Quoted 5 lines

There's some code in xfstests that reproduces all the fscrypt encryption for testing purposes
(https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git/tree/src/fscrypt-crypt-util.c?h=for-next).
It does *not* use production-quality implementations of the algorithms, though. It just has minimal implementations for testing without depending on OpenSSL.

This is performed in software.

Quoted 4 lines

Similar testing code can also be found in Android's vts_kernel_encryption_test
(https://android.googlesource.com/platform/test/vts-testcase/kernel/+/refs/heads/master/encryption).
It uses BoringSSL for the algorithms when possible, but unlike the xfstest it does not test filenames encryption.

This too.

Quoted 7 lines

There's also some code in mkfs.ubifs in mtd-utils
(http://git.infradead.org/mtd-utils.git) that supports creating encrypted files. However, it's outdated since it only supports policy version 1.

Which algorithms do you need to support? The HKDF-SHA512 + AES-256-XTS + AES-256-CTS combo shouldn't be hard to support if your program can depend on OpenSSL (1.1.0 or later).

Yeah, ceph has already depended on the OpenSSL.

I think the OpenSSL will be the best choice for now.

Thanks Eric,

- Xiubo

Quoted 2 lines

- Eric

author maintainer
#3 lore raw
Quoted 10 lines · Xiubo Li
Quoted 9 lines · Eric Biggers

[+Cc linux-fscrypt]

Quoted 6 lines · Xiubo Li

Hi Eric,

BTW, I am planing to support the fscrypt in userspace ceph client. Is there any userland implementation of fscrypt ? If no then what should I use instead ?

Quoted 8 lines
Quoted 2 lines

I assume that you mean userspace code that encrypts files the same way the kernel does?

Yeah, a library just likes the fs/crypto/ in kernel space.

I found the libkcapi, Linux Kernel Crypto API User Space Interface Library(http://www.chronox.de/libkcapi.html)  seems exposing the APIs from crypto/ not the fs/crypto/.

Much of fs/crypto/ is tightly coupled to how the Linux kernel implements filesystems, so I'm not sure what you are expecting exactly! The actual cryptography can definitely be replicated in userspace, though.

Quoted 6 lines
Quoted 5 lines

There's some code in xfstests that reproduces all the fscrypt encryption for testing purposes
(https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git/tree/src/fscrypt-crypt-util.c?h=for-next).
It does *not* use production-quality implementations of the algorithms, though. It just has minimal implementations for testing without depending on OpenSSL.

Quoted 8 lines

This is performed in software.

Quoted 4 lines

Similar testing code can also be found in Android's vts_kernel_encryption_test
(https://android.googlesource.com/platform/test/vts-testcase/kernel/+/refs/heads/master/encryption).
It uses BoringSSL for the algorithms when possible, but unlike the xfstest it does not test filenames encryption.

This too.

So you are looking for something that is *not* performed in software? What do you mean by that, exactly? Are you looking to use an off-CPU hardware crypto accelerator? The Linux kernel exposes those to userspace through AF_ALG. Though, it's worth noting that that style of crypto acceleration has fallen a bit out of favor these days, as modern CPUs have crypto instructions built-in.

Quoted 11 lines
Quoted 7 lines

There's also some code in mkfs.ubifs in mtd-utils
(http://git.infradead.org/mtd-utils.git) that supports creating encrypted files. However, it's outdated since it only supports policy version 1.

Which algorithms do you need to support? The HKDF-SHA512 + AES-256-XTS + AES-256-CTS combo shouldn't be hard to support if your program can depend on OpenSSL (1.1.0 or later).

Yeah, ceph has already depended on the OpenSSL.

I think the OpenSSL will be the best choice for now.

That seems like the right choice. Note that that is "software" too, but I think that's what you want!

- Eric