Skip to content

extend_all.sh: support kernels with embedded initramfs#54

Merged
dpsmith merged 1 commit intoTrenchBoot:masterfrom
3mdeb:extend_all_noinitrd
Jul 27, 2020
Merged

extend_all.sh: support kernels with embedded initramfs#54
dpsmith merged 1 commit intoTrenchBoot:masterfrom
3mdeb:extend_all_noinitrd

Conversation

@krystian-hebel
Copy link
Member

Modify test for number of command line arguments. For one argument,
measure the file pointed by that argument assuming it is a Linux kernel
and simulate a PCR extend operation for just the LZ and the kernel's hash.

Signed-off-by: Krystian Hebel krystian.hebel@3mdeb.com

extend_all.sh Outdated
# see https://www.kernel.org/doc/html/latest/x86/boot.html#details-of-harder-fileds
KERNEL_PROT_SKIP=$((`hexdump "$1" -s0x1f1 -n1 -e '/1 "%u"'` * 512 + 512))
if [[ $# -eq 2 ]] && [[ -e "$1" ]] && [[ -e "$2" ]] ; then
extend_sha1 "$(extend_sha1)" "`dd if="$1" bs=1 skip=$KERNEL_PROT_SKIP 2>/dev/null | sha1sum`" "$2"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is logically correct but for me I find it easier to read/reason if the inner extend_shaXXX and its parameter is under the same subshell call, i.e.

extend_sha1 "$(extend_sha1 `dd if="$1" bs=1 skip=$KERNEL_PROT_SKIP 2>/dev/null | sha1sum`)" "$2"

Copy link
Collaborator

@dpsmith dpsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed-by: Daniel P. Smith dpsmith@apertussolutions.com

Modify test for number of command line arguments. For one argument,
measure the file pointed by that argument assuming it is a Linux kernel
and simulate a PCR extend operation for just the LZ and the kernel's hash.

This commit also refactors code for extend_shaXX functions and adds more
helpers - separate functions for calculating hashes of measured parts of
LZ and kernel.

Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
@dpsmith dpsmith merged commit 4dc904b into TrenchBoot:master Jul 27, 2020
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.

3 participants