Commit Graph

117 Commits

Author SHA1 Message Date
Peter Jones
dc62a3c4dc Move includes around to clean the source tree up a bit.
Signed-off-by: Peter Jones <pjones@redhat.com>
2018-03-12 16:21:43 -04:00
Peter Jones
1d39ada8cb Revert lots of Cryptlib updates.
OpenSSL changes quite a bit of the key validation, and most of the keys
I can find in the wild aren't marked as trusted by the new checker.

Intel noticed this too: https://github.com/vathpela/edk2/commit/f536d7c3ed
but instead of fixing the compatibility error, they switched their test
data to match the bug.

So that's pretty broken.

For now, I'm reverting OpenSSL 1.1.0e, because we need those certs in
the wild to work.

This reverts commit 513cbe2aea.
This reverts commit e9cc33d6f2.
This reverts commit 80d49f758e.
This reverts commit 9bc647e2b2.
This reverts commit ae75df6232.
This reverts commit e883479f35.
This reverts commit 97469449fd.
This reverts commit e39692647f.
This reverts commit 0f3dfc01e2.
This reverts commit 4da6ac8195.
This reverts commit d064bd7eef.
This reverts commit 9bc86cfd6f.
This reverts commit ab9a05a10f.

Signed-off-by: Peter Jones <pjones@redhat.com>
2017-08-31 15:13:58 -04:00
Mathieu Trudel-Lapierre
5202f80c32 Rework looping in enter_mok_menu(), to allow multiple MOK changes
Rather than looping once through the possible actions (MokNew, MokDel, etc.),
revise the logic so that instead of rebooting immediately we get back to the
main menu setting a flag to replace "Continue booting" with a proper reboot.

Getting back to the menu means we can go make other changes before rebooting.
For instance, you might want to enable validation, but beforehand you also
need to enroll a MOK. You can already do so from userland; except the requests
were cleared as soon as one of them was processed.

This involves some extra cleanup of the states to avoid running the same
request more than once, removing the option from the menu once it's done, and
changing prompting functions to return an EFI_STATUS so we can better track
whether the process has succeeded.

Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
2017-08-18 12:45:02 -04:00
Gary Lin
ae75df6232 MokManager: Update to new openssl API
X509_get_notBefore -> X509_getm_notBefore
X509_get_notAfter  -> X509_getm_notAfter

Signed-off-by: Gary Lin <glin@suse.com>
2017-04-11 10:42:19 -04:00
Mathieu Trudel-Lapierre
8af6e22814 MokManager: list Extended Key Usage OIDs
Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
2016-09-21 13:32:53 -04:00
Gary Lin
903674a2c4 MokManager: free new_data after use
new_data in write_db() wasn't freed after SetVariable.

Signed-off-by: Gary Lin <glin@suse.com>
2016-09-09 12:07:26 -04:00
Gary Lin
e21068b499 MokManager: Try APPEND_WRITE first
Try to append the MOK/MOKX list first and then fallback to the normal
SetVariable if the firmware doesn't support EFI_VARIABLE_APPEND_WRITE.

Signed-off-by: Gary Lin <glin@suse.com>
2016-09-09 12:07:26 -04:00
Gary Lin
5597a493e2 MokManager: Remove the usage of APPEND_WRITE
We got the bug report about the usage of APPEND_WRITE that may cause the
failure when writing a variable in Lenovo machines. Although
EFI_VARIABLE_APPEND_WRITE already exists in the UEFI spec for years,
unfortunately, some vendors just ignore it and never implement the
attribute. This commit removes the usage of EFI_VARIABLE_APPEND_WRITE to
make MokManager work on those machines.

https://github.com/rhinstaller/shim/issues/55

Signed-off-by: Gary Lin <glin@suse.com>
2016-09-09 12:07:26 -04:00
Gary Lin
e571428e21 Update to openssl to 1.0.2e
Also update Cryptlib to edk2 r19218
- Undefine NO_BUILTIN_VA_FUNCS in Cryptlib/OpenSSL/ for x86_64 to use
  the gcc builtins and remove all EFIAPI from the functions
- Move the most of defines into the headers instead of Makefile
- Remove the global variable 'timeval'
- Remove the unused code: crypto/pqueue/* and crypto/ts/*
- Include bn.h in MokManager.c due to the changes in openssl

Signed-off-by: Gary Lin <glin@suse.com>
2016-09-06 15:05:34 -04:00
Peter Jones
1c0b567fd9 MokManager: Fix a -Wsign-compare bug on i?86
My favorite part of -Wsign-compare is how it shows different results on
different arches for no obvious reason.

Signed-off-by: Peter Jones <pjones@redhat.com>
2015-11-17 11:39:21 -05:00
Peter Jones
6d4803a1c0 MokManager: Nerf SHA-1 again for actual hashes and signatures.
Nobody should be deploying SHA-1.  No hardware deploys it, and the rate
of change on https://en.wikipedia.org/wiki/SHA-1#Attacks is wildly
uninspiring.

Signed-off-by: Peter Jones <pjones@redhat.com>
2015-06-16 11:46:14 -04:00
Gary Ching-Pang Lin
0807ec7cec MokManager: fix comparison between signed and unsigned integer
Patch from Johannes Segitz <jsegitz@suse.com>
2015-06-16 11:46:14 -04:00
Gary Ching-Pang Lin
efa9c47690 MokManager: Discard the list contains an invalid signature
Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
2015-06-16 11:46:14 -04:00
Gary Ching-Pang Lin
439f031711 MokManager: Support SHA224, SHA384, and SHA512
Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
2015-06-16 11:46:14 -04:00
Gary Ching-Pang Lin
7db9f7c71c MokManager: Add more key list safe checks
Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
2015-06-16 11:46:14 -04:00
Gary Ching-Pang Lin
ab9d755484 MokManager: fix the return value and type
There are some functions that the return value and the type
didn't match.

Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
2015-06-16 11:41:32 -04:00
Gary Ching-Pang Lin
8bd6b9cd5a MokManager: Support SHA1 hash in MOK
Add SHA1 hash support and amend the code to make it easier to support
other SHA digests.
2015-06-16 11:41:32 -04:00
Gary Ching-Pang Lin
cd15cc0efc MokManager: fix the hash list counting in delete
match_hash() requests the number of keys in a list and it was
mistakenly replaced with the size of the Mok node. This would
made MokManager to remove the whole Mok node instead of one
hash.

Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
2015-06-16 11:41:32 -04:00
Gary Ching-Pang Lin
8449925662 MokManager: calculate the variable size correctly
MokSize of the hash signature list includes the owner GUID,
so we should not add the 16bytes compensation.

Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
2015-06-16 11:41:32 -04:00
Gary Ching-Pang Lin
6068f51099 MokManager: Write the hash list properly
also return to the previous entry in the list

Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
2015-06-16 11:41:32 -04:00
Gary Ching-Pang Lin
de2acfb43e MokManager: Match all hashes in the list
Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
2015-06-16 11:41:32 -04:00
Gary Ching-Pang Lin
c0fd34674b MokManager: delete the hash properly
Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
2015-06-16 11:41:32 -04:00
Gary Ching-Pang Lin
a462c735fa MokManager: show the hash list properly
Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
2015-06-16 11:41:32 -04:00
Gary Ching-Pang Lin
64c5066ce0 Support MOK blacklist
The new blacklist, MokListX, stores the keys and hashes that are
banned.

Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
2015-06-16 11:41:32 -04:00
Peter Jones
d51739a416 gcc 5.0 changes some include bits, so copy what arm does on x86.
Basically they messed around with stdarg some and now we need to do it
the other way.

Signed-off-by: Peter Jones <pjones@redhat.com>
2015-04-13 19:55:25 -04:00
Peter Jones
c622b677d6 Make another integer compare be signed/unsigned safe as well.
Signed-off-by: Peter Jones <pjones@redhat.com>
2014-10-02 01:01:54 -04:00
Sebastian Krahmer
034466b773 OOB access when parsing MOK List/Certificates on MOK enrollment 2014-10-02 01:01:54 -04:00
Peter Jones
9db91ca0e1 Make list_keys() index variables all be signed.
We build with -Werror=signed-compare in fedora/rhel rpms, and this
showed up.

Signed-off-by: Peter Jones <pjones@redhat.com>
2014-09-21 16:25:28 -04:00
Gary Ching-Pang Lin
22254e2633 MokManager: handle the error status from ReadKeyStroke
On some machines, even though the key event was signaled, ReadKeyStroke
still got EFI_NOT_READY. This commit handles the error status to avoid
console_get_keystroke from returning unexpected keys.

Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>

Conflicts:
	MokManager.c
2014-06-25 10:02:18 -04:00
Gary Ching-Pang Lin
53a8f8721c MokManager: delete the BS+NV variables the right way
LibDeleteVariable assumes that the variable is RT+NV and it
won't work on a BS+NV variable.

Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
2014-06-25 09:57:10 -04:00
Gary Ching-Pang Lin
5f18e2e364 Check the first 4 bytes of the certificate
A non-DER encoding x509 certificate may be mistakenly enrolled into
db or MokList. This commit checks the first 4 bytes of the certificate
to ensure that it's DER encoding.

This commit also removes the iteration of the x509 signature list.
Per UEFI SPEC, each x509 signature list contains only one x509 certificate.
Besides, the size of certificate is incorrect. The size of the header must
be substracted from the signature size.

Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
2014-06-25 09:55:49 -04:00
Kees Cook
5495694c04 additional bounds-checking on section sizes
This adds additional bounds-checking on the section sizes. Also adds
-Wsign-compare to the Makefile and replaces some signed variables with
unsigned counteparts for robustness.

Signed-off-by: Kees Cook <kees@ubuntu.com>
2014-04-11 14:41:22 -04:00
Peter Jones
56fb385a17 Revert "additional bounds-checking on section sizes"
This reverts commit 21e40f0174.

In principle I like the idea of what's going on here, but
generate_hash() really does need to have the expected result.
2013-10-23 10:50:36 -04:00
Kees Cook
21e40f0174 additional bounds-checking on section sizes
This adds additional bounds-checking on the section sizes. Also adds
-Wsign-compare to the Makefile and replaces some signed variables with
unsigned counteparts for robustness.

Signed-off-by: Kees Cook <kees@ubuntu.com>
2013-10-22 11:23:51 -04:00
Josh Boyer
ef0383d008 Add support for disabling db for verification
Provide a mechanism for a physically present end user to disable the use
of db when doing signature verification.  This is handled by the OS passing
down a variable that contains a UINT32 and a SHA256 hash.  If this variable
is present, MokManager prompts the user to choose whether to enable or
disable the use of db for verification purposes (depending on the value of
the UINT32).  They are then asked to type the passphrase that matches the
hash.  This then saves a boot services variable which is checked by shim,
and if set will cause shim to not use db for verification purposes.  If
db is to be ignored, shim will export a runtime variable called
'MokIgnoreDB' for the OS to query at runtime.

Signed-off-by: Josh Boyer <jwboyer@fedoraproject.org>
2013-10-02 11:29:34 -04:00
Peter Jones
4537217422 Merge console_control.h and console.h
Since these are topically the same thing, they can live together.

Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-01 14:03:16 -04:00
Peter Jones
09a37bbc69 Make verbose stuff use console_notify
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-01 14:03:16 -04:00
Peter Jones
f7b849be1c MokManager needs to disable the graphics console.
Without this patch, on some machines we never see MokManager's UI.  This
protocol has never (I think?) been officially published, and yet I still
have new hardware that needs it.

If you're looking for a reference, look at:

EdkCompatibilityPkg/Foundation/Protocol/ConsoleControl/ConsoleControl.c

in the edk2 tree from Tiano.

Signed-off-by: Peter Jones <pjones@redhat.com>
2013-10-01 14:03:16 -04:00
Peter Jones
195e63f911 Don't use LibGetVariable(), since it doesn't give us real error codes. 2013-09-26 13:44:05 -04:00
Gary Ching-Pang Lin
7d602e843c Merge variable retrieving functions 2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
79424b09ca Merge signature.h into efiauthenticated.h and guid.h
Conflicts:
	shim.c
2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
9fd4e4a54e MokManager: check the suffix of the key file 2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
6212d9baa6 MokManager: fetch more info from X509 name 2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
09f11d6aae MokManager: reboot the system after clearing MOK password 2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
e727d6007c MokManager: enhance the password prompt for SB state 2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
f514439923 MokManager: rearrange the output of MOK info 2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
e9e320e474 MokManager: enhance the password prompt 2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
8494a1a323 MokManager: remove the duplicate get_keystroke() 2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
cc62e19d05 MokManager: draw the countdown screen 2013-09-26 11:58:02 -04:00
Gary Ching-Pang Lin
fc5f6d59f5 MokManager: Remove the unnecessary string duplication 2013-09-26 11:58:02 -04:00