Skip to content
New issue

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

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

Already on GitHub? # to your account

authvar: 4-byte EFI var attrs header in output files #98

Open
jandryuk opened this issue Sep 16, 2022 · 1 comment
Open

authvar: 4-byte EFI var attrs header in output files #98

jandryuk opened this issue Sep 16, 2022 · 1 comment

Comments

@jandryuk
Copy link

Hi,

authvar writes .auth files with 4-byte EFI var attrs header before the authenticated variable itself. This throws off the format (compared to sbsigntools sign-efi-sig-list), and firmware does not accept the file as valid. Removing the 4 bytes, the generated .auth file is equivalent to one generated by sbsigntools, which is accepted by my firmware setup screen. Is there a particular reason for the extra 4 bytes?

This code adds the attributes to the output file:

/* The attribute of the variable */
memcpy(ptr, &ctx->attr, sizeof(ctx->attr));
ptr += sizeof(ctx->attr);

My goal was to replace sign-efi-sig-list from sbsigntools with authvar to generate signed .auth files. For sbsigntools, I use:

cert-to-efi-sig-list -g $GUID PK.crt PK.esl
sign-efi-sig-list -t "$(date --date='1 second' +'%Y-%m-%d %H:%M:%S')" \
                  -k PK.key -c PK.crt PK PK.esl PK.auth

The authvar/efisecdb replacement is:

efisecdb -g "$GUID" -a -c PK.cer -o PK.esl
authvar -d "$nssdb" --set --valuefile PK.esl \
        --export PK.auth.tmp --sign "$signer" --name PK
dd if=PK.auth.tmp of=PK.auth bs=1 skip=4
@jandryuk
Copy link
Author

jandryuk commented Nov 2, 2022

efivarfs expects the 4-bytes of attrs ahead of the contents when writing. The generated files with the 4-byte header can be used to write efivars like so*:
cat db.auth > /sys/firmware/efi/efivars/db-$uuid

*I have written other UEFI variables this way, but this isn't working for db.auth.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant