Commit Graph

37 Commits

Author SHA1 Message Date
Morten Linderud 947b6ba8e8
Formating: Added some misc formatting
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-09-05 14:42:31 +02:00
Oskar Kohout ea325ca46f fix: restrict key file permissions 2021-07-16 18:32:47 +02:00
Morten Linderud 78cdabfa6d
sbctl/sign: the -o option would fail on non-existing output file
A few options where mixes around during the refactor. We also need to
capture the off case of failing signature verification on the output
file when it doesn't exist.

Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-06-28 12:34:19 +02:00
Hugo Osvaldo Barrera 95458395f1 Update some references to latest go-uefi
Current `master` of both branches cannot build together otherwise.
2021-06-12 01:45:54 +02:00
Morten Linderud 7192e52fa1
keys: Move from sbsigntools to go-uefi
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-06-02 21:56:02 +02:00
Morten Linderud 2031e3a210
keys: Removed unused functions
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-06-02 21:56:02 +02:00
Morten Linderud 9587644626
sbctl/enroll-keys: Implement support for enrolling keys with go-uefi
This enrolls the keys using go-uefi. Essentially it reworks the
sbkeysync into a set of enroll commands taken from the go-uefi test
suite.

Preferably this should be more flexible e.g for key rotation.

Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-06-02 21:56:02 +02:00
Morten Linderud 1bf2810228
keys: Rework key creation
With go-uefi we don't need anything else then a certificate and a
keyfile. This simplifies the key creation to only care about these two
byte slices and saving them.

No signing is done here.

Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-06-02 21:55:37 +02:00
Morten Linderud 0781f6bb98
sbctl/create-keys: Move up the GUID logic
We also make a helper for creating directories in a proper way

Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-06-02 21:55:37 +02:00
Morten Linderud ba0cee8115
Make lint happy
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-05-30 14:47:46 +02:00
Morten Linderud 57a1c93eb9
Remove last of the log.* stuff
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-05-30 14:47:45 +02:00
Morten Linderud b49ebbb8bf
Added CanVerifyFiles
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-05-30 14:46:08 +02:00
Morten Linderud 6dfc186d43
enroll changes
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-05-30 14:46:08 +02:00
Morten Linderud 3f05d1df52
Propegate errors better
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-05-30 14:46:08 +02:00
Morten Linderud 235238c987
Fixed lint issues
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-05-30 14:46:07 +02:00
Morten Linderud a5e0551e56
GUID package
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-05-30 14:46:07 +02:00
Morten Linderud 877ab49ae6
Implement GetGUID
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-05-30 14:43:05 +02:00
Morten Linderud fb9b3c7b33
🤷
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-05-30 14:43:05 +02:00
Morten Linderud bb78cf9c01
Remove previous logging, improve error bubling
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-05-30 14:43:04 +02:00
igo95862 d3feae2791
Remove ioutil
Deprecated in GO 1.16
2021-05-16 21:14:42 +03:00
igo95862 7d6d2c76ab
Directly pass arguments to subprocesses instead of args spliting 2021-05-04 22:16:57 +03:00
Morten Linderud a6445c4a2b
sbctl: Create valid x509 certs for the kernel
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-04-16 22:13:55 +02:00
Morten Linderud 99efd2a5e3
keys: sbkeysync can have "Permissiond denide" errors
Signed-off-by: Morten Linderud <morten@linderud.pw>
2021-04-03 12:30:52 +02:00
Érico Rolim 92bb91172d Improve error propagation and permission checking.
- Introduces dependency on sys/unix for unix.Access. This is necessary
only in keys.go, since we run 'sbsign' as a command and can't check if
it failed due to permissions.

- Allows removing special casing in main.go for commands that don't
require root permissions.

- ReadFileDatabase() can now return errors due to the multiple ways in
which it can fail; it also warns the user about possibly requiring root.

- ReadFileDatabase() was using the global DBPath instead of its dbpath
parameter in multiple places. This has been fixed.

- VerifyESP() can now run without root.

- SignFile() checks if it can read the DB key before running sbsign.

Signed-off-by: Érico Rolim <erico.erc@gmail.com>
2021-01-11 00:49:45 -03:00
Érico Rolim 2b09a8e645
Change PrintGenerateError signature.
This avoid boilerplate calls to fmt.Sprintf in the main code.
2020-07-25 18:12:42 +02:00
Érico Rolim ed103661f0
Create PrintGenerateError and use it where possible.
It's a function for generating an error from a message and still
printing it. Helps in avoiding duplication.
2020-07-25 18:12:41 +02:00
Érico Rolim e3d74411cd
Propagate errors through SignFile, GenerateBundle.
This allows the application to try and sign as many files as it can, as
well as generate as many bundles as possible, but still exit with an
exit code different from 0. SignFile would exit the application before
signing other files, while GenerateBundle would fail without reporting
it in the exit code.
2020-07-25 18:12:41 +02:00
Érico Rolim 7992e9feec keys: use the correct verification in SignFile.
To be able to skip signing a file, we need to:
 - Verify that the output is signed; AND
 - Verify that the original file hasn't changed (via cksum)

This fixes an error where if you deleted the signed file from the
system, `sbctl verify` could see that the file wasn't signed (even if
the correct error would be that it didn't exist), but `sbctl sign-all`
would claim that it was already signed.
2020-07-09 23:49:16 -03:00
Morten Linderud d397102738
sbctl: Ensure we check if original file exists before signing
Signed-off-by: Morten Linderud <morten@linderud.pw>
2020-07-09 16:19:05 +02:00
Morten Linderud d03440ae4c
sbctl: Add original file checksums so we know when they changed
Signed-off-by: Morten Linderud <morten@linderud.pw>
2020-07-09 16:07:53 +02:00
Morten Linderud f6c1e805ea
Added short hands for KEK
Signed-off-by: Morten Linderud <morten@linderud.pw>
2020-06-12 00:13:38 +02:00
Morten Linderud 2c7b417b07
keys: ensure we are returning the UUID as a byte slice
Signed-off-by: Morten Linderud <morten@linderud.pw>
2020-06-07 15:29:58 +02:00
Morten Linderud 59a0e5ffd6
keys: Switch from uuidgen to google/uuid
Signed-off-by: Morten Linderud <morten@linderud.pw>
2020-06-07 00:00:45 +02:00
Morten Linderud b7504de9fd
Minor fixups from local debugging
Signed-off-by: Morten Linderud <morten@linderud.pw>
2020-05-17 13:43:10 +02:00
Morten Linderud bf45870d49
Slight modifications
Signed-off-by: Morten Linderud <morten@linderud.pw>
2020-05-16 15:38:23 +02:00
Morten Linderud 9792956939
Refactored GUID generation
Signed-off-by: Morten Linderud <morten@linderud.pw>
2020-05-08 21:51:47 +02:00
Morten Linderud 0b5d4a46ea
Init
Signed-off-by: Morten Linderud <morten@linderud.pw>
2020-05-03 19:41:09 +02:00