Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does 'luks-setup.sh` can create password for multiple partitions? #74

Open
Dvergatal opened this issue Sep 23, 2024 · 5 comments
Open

Comments

@Dvergatal
Copy link
Contributor

I do not recall if password stored in tpm can be just one or many and was wondering if this use case which is in the subject is possible to achieve with the script, meaning I have 3 partitions which I would like to make encrypted.

@yizhao1
Copy link
Collaborator

yizhao1 commented Sep 25, 2024

Do you need to set a corresponding key for each partition? If so, the current luks-setup.sh doesn't support it. But you can patch this script, pass --key-slot argument to cryptsetup to specify different slot to store different key.

Here are some references from cryptsetup man page[1][2][3]:
--key-slot, -S <0-N>
For LUKS operations that add key material, this option allows
you to specify which key slot is selected for the new key.

--new-key-slot <0-N>
This option allows you to specify which key slot is selected
for the new key.

[1] https://man7.org/linux/man-pages/man8/cryptsetup-luksformat.8.html
[2] https://man7.org/linux/man-pages/man8/cryptsetup-luksOpen.8.html
[3] https://man7.org/linux/man-pages/man8/cryptsetup-luksAddKey.8.html

@Dvergatal
Copy link
Contributor Author

Dvergatal commented Oct 3, 2024

Hi @yizhao1,
thx for quick response and sorry for my long but I was on holidays.

Do you need to set a corresponding key for each partition? If so, the current luks-setup.sh doesn't support it. But you can patch this script, pass --key-slot argument to cryptsetup to specify different slot to store different key.

Yes that is what I need it for. I can give a shot :)

P.S. I was also thinking if it is worth doing? Isn't it sufficient to use just one key for all the partitions? If so than how can I re-use the key already in the TPM?

Here are some references from cryptsetup man page[1][2][3]: --key-slot, -S <0-N> For LUKS operations that add key material, this option allows you to specify which key slot is selected for the new key.

--new-key-slot <0-N> This option allows you to specify which key slot is selected for the new key.

[1] https://man7.org/linux/man-pages/man8/cryptsetup-luksformat.8.html [2] https://man7.org/linux/man-pages/man8/cryptsetup-luksOpen.8.html [3] https://man7.org/linux/man-pages/man8/cryptsetup-luksAddKey.8.html

Thx for informations.

@yizhao1
Copy link
Collaborator

yizhao1 commented Oct 6, 2024

Hi @yizhao1, thx for quick response and sorry for my long but I was on holidays.

Do you need to set a corresponding key for each partition? If so, the current luks-setup.sh doesn't support it. But you can patch this script, pass --key-slot argument to cryptsetup to specify different slot to store different key.

Yes that is what I need it for. I can give a shot :)

P.S. I was also thinking if it is worth doing? Isn't it sufficient to use just one key for all the partitions? If so than how can I re-use the key already in the TPM?

It is possible to use one key for all partitions. But it requires some tricks when using luks-setup.sh. When creating the first encrypted partition, you need to pass -e parameter to luks-setup.sh to evict the existing key in the tpm and create a new key. When creating subsequent encrypted partitions without -e parameter, these partitions will use the current key in the tpm.
Of course, you can also use cryptfs-tpm2 command to seal the key in tpm before creating the encrypted partition. Then use luks-setup.sh without -e parameter to create all encrypted partitions.

//Yi

Here are some references from cryptsetup man page[1][2][3]: --key-slot, -S <0-N> For LUKS operations that add key material, this option allows you to specify which key slot is selected for the new key.
--new-key-slot <0-N> This option allows you to specify which key slot is selected for the new key.
[1] https://man7.org/linux/man-pages/man8/cryptsetup-luksformat.8.html [2] https://man7.org/linux/man-pages/man8/cryptsetup-luksOpen.8.html [3] https://man7.org/linux/man-pages/man8/cryptsetup-luksAddKey.8.html

Thx for informations.

@Dvergatal
Copy link
Contributor Author

Dvergatal commented Oct 7, 2024

Thanks, this is working.

I have one more question for you but it concerns another thread. Could you please answer there?

@Dvergatal
Copy link
Contributor Author

Thanks, this is working.

I have one more question for you but it concerns another thread. Could you please answer there?

OK no need to answer in that thread. Actually I have forgotten a lot and thx to this blog I have recalled that PCR7 is responsible for Secure Boot State, so I turned it on in UEFI and it started to work...

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

No branches or pull requests

2 participants