tools: add a simple script to generate EFI variables
This script generates EFI variables for U-Boot variable store format.
A few examples:
- Generating secure boot keys
$ openssl req -x509 -sha256 -newkey rsa:2048 -subj /CN=TEST_PK/ \
-keyout PK.key -out PK.crt -nodes -days 365
$ efisiglist -a -c PK.crt -o foo.esl
$ tools/efivar.py set -i ubootefi.var -n db -d foo.esl -t file
$ tools/efivar.py set -i ubootefi.var -n kek -d foo.esl -t file
$ tools/efivar.py set -i ubootefi.var -n pk -d foo.esl -t file
- Printing out variables
$ tools/efivar.py set -i ubootefi.var -n var1 -d foo -t str
$ tools/efivar.py set -i ubootefi.var -n var2 -d bar -t str
$ tools/efivar.py print -i ubootefi.var
var1:
8be4df61-93ca-11d2-aa0d-
00e098032b8c EFI_GLOBAL_VARIABLE_GUID
NV|BS|RT, DataSize = 0x3
0000000000: 66 6F 6F foo
var2:
8be4df61-93ca-11d2-aa0d-
00e098032b8c EFI_GLOBAL_VARIABLE_GUID
NV|BS|RT, DataSize = 0x3
0000000000: 62 61 72 bar
- Removing variables
$ tools/efivar.py del -i ubootefi.var -n var1
$ tools/efivar.py set -i ubootefi.var -n var1 -a nv,bs -d foo -t str
$ tools/efivar.py print -i ubootefi.var -n var1
var1:
8be4df61-93ca-11d2-aa0d-
00e098032b8c EFI_GLOBAL_VARIABLE_GUID
NV|BS, DataSize = 0x3
0000000000: 66 6F 6F foo
$ tools/efivar.py del -i ubootefi.var -n var1
err: attributes don't match
$ tools/efivar.py del -i ubootefi.var -n var1 -a nv,bs
$ tools/efivar.py print -i ubootefi.var -n var1
err: variable not found
Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Correct examples in commit message.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>