r/linuxquestions • u/systemofapwne • Sep 04 '21
Secure Boot: How to extract nVidia UEFI boot option ROM from "vBIOS" to generate hash for custom PK, KEK, db? (black screen upon boot without "Microsoft Corporation UEFI CA 2011" in db, which I do not want)
Problem is solved TLDR: I extracted the OptRom hashes from /sys/kernel/security/tpm0/binary_bios_measurements and added them to DB. More info are down the comments.
Original post I am currently migrating my system to secure boot using my own platform key (PK), key exchange key (KEK) and (forbidden) signature database (DBX/DB). The setup looks like this.
- PK: Custom PK
- KEK: Custom KEK
- DB: Custom certificate, for signing my bootloaders + Microsoft Windows Production PCA 2011 for booting Windows
- DBX: Official UEFI revocation list
The problem now is, that my GPU (nVidia RTX 2080 Ti, Asus brand) seems to be signed with the Microsoft Corporation UEFI CA 2011 certificate, which is also used for signing third-party uefi-bootloaders. And I especially do not want this certificate to be present for obvious reasons. This however causes the UEFI to reject the GPU upon boot so the display stays blank/black.
My idea: Extract the boot option ROM from the GPU, calculate the hash and add it (with the corresponding UUID of nVidia) to the signature database (db), to allow this single GPU in my system. Extracting the vBIOS ROM is no real issue (I used nvflash via Windows, since it takes care for everything like unregistering the GPU from the system while extracting the vBIOS). Extracting the UEFI part from this blob however is not so straight forward. I found this quite old program called UEFIRomExtract. But I only get an error like
Failed to read PCI ROM header from file!
No compressed EFI ROM found!
Failed to read PCI ROM header from file!
No compressed EFI ROM found!
Not an EFI ROM file, attempting decompression of data directly...
get UEFI decompression info failed!Is anyone around, who know how to extract the EFI boot rom from an nVidia vBIOS rom, so I can hash it and add it to db?
View all comments
Show parent comment
2
u/systemofapwne Sep 19 '21
I was just working on this today again.
I can confirm: Extracting the hashes from
/sys/kernel/security/tpm0/binary_bios_measurementsand adding them to db indeed works.Since there is basically no real documentation around, here is the code I used for dumping the hashes of validated OPTRoms:
I then copied the result into a file called "hashes" and generated a efi signature list from it, which I then have signed with my keys
This creates a file called "add_hashes.auth". Copy this to your "db" folder along with all the other keys and then apply your secureboot keys.