History log of /u-boot/tools/efivar.py
Revision Date Author Comments
# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 4961ceef 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py unused variable

Unused variables should be called '_'.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 33abdb98 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py should check GUID when deleting

When deleting a variable we must check that the GUID provided by the
user matches the GUID of the variable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 45c0792c 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py: incorrect indentation

According to https://pep8.org/#indentation we should use 4 spaces per
indentation level.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 4f6ec775 08-Jan-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

tools: efivar.py without arguments

When tools: efivar.py is called without arguments an error occurs:

Traceback (most recent call last):
File "tools/efivar.py", line 380, in <module>
main()
File "tools/efivar.py", line 360, in main
args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'

Show the online help if the arguments do not specify a function.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>


# 73253d77 08-Dec-2020 Paulo Alcantara <pc@cjr.nz>

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>