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

modify enc.disk size as 20M #80

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

HC-Chang
Copy link

@HC-Chang HC-Chang commented Dec 4, 2023

I follow the code on Tutorials of Disk Encryption Apr 13, 2020, and got some problem for luksChangeKey on enc.disk by step 3. It will show the enc.disk do not have enough size.
I try to use 20M as enc.disk size, and it works possible.

# 1. Let’s setup a new LUKS volume with a simple passphrase as key protector:
dd if=/dev/zero of=enc.disk bs=1M count=10
dd if=/dev/urandom of=disk.key bs=1 count=32
loopdevice=$(losetup -f) && sudo losetup $loopdevice enc.disk
sudo cryptsetup luksFormat --key-file=disk.key $loopdevice

# 2. Let’s start with creating and persisting a sealing object and sealing a random byte sequence as the disk key.

tpm2_createprimary -Q -C o -c prim.ctx
dd if=/dev/urandom bs=1 count=32 status=none | tpm2_create -Q -g sha256 -u seal.pub -r seal.priv -i- -C prim.ctx
tpm2_load -Q -C prim.ctx -u seal.pub -r seal.priv -n seal.name -c seal.ctx
tpm2_evictcontrol -C o -c seal.ctx 0x81010001

# 3. Now lets change the authentication from previously created disk.key to the new sealed secret and after that shred the disk.key since it’s no longer useful:

tpm2_unseal -Q -c 0x81010001 | sudo cryptsetup luksChangeKey enc.disk --key-file disk.key

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