Skip to content

Commit

Permalink
Move includes around to clean the source tree up a bit.
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Jones <[email protected]>
  • Loading branch information
vathpela committed Mar 12, 2018
1 parent 1a44dbb commit dc62a3c
Show file tree
Hide file tree
Showing 27 changed files with 108 additions and 139 deletions.
36 changes: 13 additions & 23 deletions .syntastic_c_config
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
-I/home/pjones/devel/github.com/shim/master/Cryptlib/OpenSSL
-I/home/pjones/devel/github.com/shim/master/Cryptlib/OpenSSL/..
-I/home/pjones/devel/github.com/shim/master/Cryptlib/OpenSSL/../Include/
-I/home/pjones/devel/github.com/shim/master/Cryptlib/OpenSSL/crypto
-I/usr/lib/gcc/x86_64-redhat-linux/7/include
-I/home/pjones/devel/github.com/shim/master/Cryptlib/OpenSSL/../Include
-I/usr/include/efi
-I/usr/include/efi/x86_64
-I/usr/include/efi/protocol
-I/home/pjones/devel/github.com/shim/master/Cryptlib/OpenSSL/crypto/asn1
-I/home/pjones/devel/github.com/shim/master/Cryptlib/OpenSSL/crypto/evp
-I/home/pjones/devel/github.com/shim/master/Cryptlib/OpenSSL/crypto/modes
-I/home/pjones/devel/github.com/shim/master/Cryptlib/OpenSSL/crypto/include
-DL_ENDIAN
-D_CRT_SECURE_NO_DEPRECATE
-D_CRT_NONSTDC_NO_DEPRECATE
Expand All @@ -29,18 +16,21 @@
-Werror=sign-compare
-ffreestanding
-std=gnu89
-I/usr/lib/gcc/x86_64-redhat-linux/7/include
-nostdinc
-I/home/pjones/devel/github.com/shim/master/Cryptlib
-I/home/pjones/devel/github.com/shim/master/Cryptlib/Include
-I/usr/include/efi
-I/usr/include/efi/x86_64
-I/usr/include/efi/protocol
-I/home/pjones/devel/github.com/shim/master/include
-iquote
/home/pjones/devel/github.com/shim/master
-I/usr/lib/gcc/x86_64-redhat-linux/7/include
-ICryptlib/
-ICryptlib/Include/
-ICryptlib/OpenSSL/
-ICryptlib/OpenSSL/crypto/
-I/usr/include/efi/
-I/usr/include/efi/x86_64/
-I/usr/include/efi/protocol/
-ICryptlib/OpenSSL/crypto/asn1/
-ICryptlib/OpenSSL/crypto/evp/
-ICryptlib/OpenSSL/crypto/modes/
-ICryptlib/OpenSSL/crypto/include/
-iquote
/home/pjones/devel/github.com/shim/master
.
-mno-mmx
-mno-sse
-mno-red-zone
Expand Down
10 changes: 5 additions & 5 deletions Cryptlib/Include/OpenSslSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

#include <efi.h>
#include <efilib.h>
#include <Base.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/DebugLib.h>
#include "Base.h"
#include "Library/BaseLib.h"
#include "Library/BaseMemoryLib.h"
#include "Library/MemoryAllocationLib.h"
#include "Library/DebugLib.h"

/*
* Include stddef.h to avoid redefining "offsetof"
Expand Down
10 changes: 5 additions & 5 deletions Cryptlib/InternalCryptLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#ifndef __INTERNAL_CRYPT_LIB_H__
#define __INTERNAL_CRYPT_LIB_H__

#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseCryptLib.h>
#include "Library/BaseLib.h"
#include "Library/BaseMemoryLib.h"
#include "Library/MemoryAllocationLib.h"
#include "Library/DebugLib.h"
#include "Library/BaseCryptLib.h"

#include "OpenSslSupport.h"

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ TARGETS += $(MMNAME) $(FBNAME)
endif
OBJS = shim.o netboot.o cert.o replacements.o tpm.o version.o errlog.o
KEYS = shim_cert.h ocsp.* ca.* shim.crt shim.csr shim.p12 shim.pem shim.key shim.cer
ORIG_SOURCES = shim.c shim.h netboot.c include/PeImage.h include/wincert.h include/console.h replacements.c replacements.h tpm.c tpm.h version.h errlog.c
ORIG_SOURCES = shim.c netboot.c replacements.c tpm.c errlog.c shim.h version.h $(wildcard include/*.h)
MOK_OBJS = MokManager.o PasswordCrypt.o crypt_blowfish.o
ORIG_MOK_SOURCES = MokManager.c shim.h include/console.h PasswordCrypt.c PasswordCrypt.h crypt_blowfish.c crypt_blowfish.h
ORIG_MOK_SOURCES = MokManager.c PasswordCrypt.c crypt_blowfish.c shim.h $(wildcard include/*.h)
FALLBACK_OBJS = fallback.o tpm.o
ORIG_FALLBACK_SRCS = fallback.c

ifneq ($(origin ENABLE_HTTPBOOT), undefined)
OBJS += httpboot.o
SOURCES += httpboot.c httpboot.h
SOURCES += httpboot.c include/httpboot.h
endif

SOURCES = $(foreach source,$(ORIG_SOURCES),$(TOPDIR)/$(source)) version.c
Expand Down
9 changes: 1 addition & 8 deletions MokManager.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,8 @@
#include <openssl/x509v3.h>
#include <openssl/asn1.h>
#include <openssl/bn.h>

#include "shim.h"
#include "PeImage.h"
#include "PasswordCrypt.h"

#include "guid.h"
#include "console.h"
#include "variables.h"
#include "simple_file.h"
#include "efiauthenticated.h"

#define PASSWORD_MAX 256
#define PASSWORD_MIN 1
Expand Down
4 changes: 2 additions & 2 deletions PasswordCrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include <Library/BaseCryptLib.h>
#include <openssl/sha.h>
#include <openssl/md5.h>
#include "PasswordCrypt.h"
#include "crypt_blowfish.h"

#include "shim.h"

#define TRAD_DES_HASH_SIZE 13 /* (64/6+1) + (12/6) */
#define BSDI_DES_HASH_SIZE 20 /* (64/6+1) + (24/6) + 4 + 1 */
Expand Down
2 changes: 1 addition & 1 deletion crypt_blowfish.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#include <efilib.h>

/* Just to make sure the prototypes match the actual definitions */
#include "crypt_blowfish.h"
#include "shim.h"

typedef unsigned int BF_word;
typedef signed int BF_word_signed;
Expand Down
7 changes: 2 additions & 5 deletions httpboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@

#include <efi.h>
#include <efilib.h>
#include "str.h"
#include "console.h"
#include "Http.h"
#include "Ip4Config2.h"
#include "Ip6Config.h"

#include "shim.h"

#define perror(fmt, ...) ({ \
UINTN __perror_ret = 0; \
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions lib/configtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
#include <efi.h>
#include <efilib.h>

#include <guid.h>
#include <configtable.h>
#include "shim.h"

void *
configtable_get_table(EFI_GUID *guid)
Expand Down
9 changes: 1 addition & 8 deletions lib/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@
#include <openssl/err.h>
#include <openssl/crypto.h>

static EFI_GUID SHIM_LOCK_GUID = { 0x605dab50, 0xe046, 0x4300, {0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23} };

static int min(int a, int b)
{
if (a < b)
return a;
return b;
}
#include "shim.h"

static int
count_lines(CHAR16 *str_arr[])
Expand Down
3 changes: 1 addition & 2 deletions lib/execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
#include <efi.h>
#include <efilib.h>

#include <guid.h>
#include <execute.h>
#include "shim.h"

EFI_STATUS
generate_path(CHAR16* name, EFI_LOADED_IMAGE *li, EFI_DEVICE_PATH **path, CHAR16 **PathName)
Expand Down
2 changes: 1 addition & 1 deletion lib/security_policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <efi.h>
#include <efilib.h>

#include <guid.h>
#include "shim.h"
#include <variables.h>
#include <simple_file.h>
#include <errors.h>
Expand Down
2 changes: 1 addition & 1 deletion lib/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <efi.h>
#include <efilib.h>

#include <shell.h>
#include "shim.h"

EFI_STATUS
argsplit(EFI_HANDLE image, int *argc, CHAR16*** ARGV)
Expand Down
7 changes: 1 addition & 6 deletions lib/simple_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,8 @@
#include <efi.h>
#include <efilib.h>

#include <console.h>
#include <simple_file.h>
#include <efiauthenticated.h>
#include <execute.h> /* for generate_path() */
#include "shim.h"

static EFI_GUID IMAGE_PROTOCOL = LOADED_IMAGE_PROTOCOL;
static EFI_GUID SIMPLE_FS_PROTOCOL = SIMPLE_FILE_SYSTEM_PROTOCOL;
static EFI_GUID FILE_INFO = EFI_FILE_INFO_ID;
static EFI_GUID FS_INFO = EFI_FILE_SYSTEM_INFO_ID;

Expand Down
7 changes: 1 addition & 6 deletions lib/variables.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@
#include <efi.h>
#include <efilib.h>

#include <efiauthenticated.h>

#include <variables.h>
#include <guid.h>
#include <console.h>
#include <errors.h>
#include "shim.h"

EFI_STATUS
variable_create_esl(void *cert, int cert_len, EFI_GUID *type, EFI_GUID *owner,
Expand Down
3 changes: 1 addition & 2 deletions netboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@
*/

#include "shim.h"

#include <string.h>
#include "netboot.h"
#include "str.h"

#define ntohs(x) __builtin_bswap16(x) /* supported both by GCC and clang */
#define htons(x) ntohs(x)
Expand Down
4 changes: 1 addition & 3 deletions replacements.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@
#include <efi.h>
#include <efiapi.h>
#include <efilib.h>

#include "shim.h"
#include "replacements.h"
#include "console.h"
#include "errors.h"

static EFI_SYSTEM_TABLE *systab;

Expand Down
120 changes: 66 additions & 54 deletions shim.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,7 @@
#include <efi.h>
#include <efilib.h>

#include "PeImage.h"

extern EFI_GUID SHIM_LOCK_GUID;

INTERFACE_DECL(_SHIM_LOCK);

typedef
EFI_STATUS
(*EFI_SHIM_LOCK_VERIFY) (
IN VOID *buffer,
IN UINT32 size
);

typedef
EFI_STATUS
(*EFI_SHIM_LOCK_HASH) (
IN char *data,
IN int datasize,
PE_COFF_LOADER_IMAGE_CONTEXT *context,
UINT8 *sha256hash,
UINT8 *sha1hash
);

typedef
EFI_STATUS
(*EFI_SHIM_LOCK_CONTEXT) (
IN VOID *data,
IN unsigned int datasize,
PE_COFF_LOADER_IMAGE_CONTEXT *context
);

typedef struct _SHIM_LOCK {
EFI_SHIM_LOCK_VERIFY Verify;
EFI_SHIM_LOCK_HASH Hash;
EFI_SHIM_LOCK_CONTEXT Context;
} SHIM_LOCK;

extern EFI_STATUS shim_init(void);
extern void shim_fini(void);
extern EFI_STATUS LogError(const char *file, int line, const char *func, CHAR16 *fmt, ...);
extern EFI_STATUS VLogError(const char *file, int line, const char *func, CHAR16 *fmt, va_list args);
extern VOID PrintErrors(VOID);
extern VOID ClearErrors(VOID);
#define min(a, b) ({(a) < (b) ? (a) : (b);})

#ifdef __x86_64__
#ifndef DEFAULT_LOADER
Expand Down Expand Up @@ -108,23 +66,77 @@ extern VOID ClearErrors(VOID);
#endif
#endif

#include "netboot.h"
#include "httpboot.h"
#include "replacements.h"
#include "tpm.h"
#include "ucs2.h"
#include "include/configtable.h"
#include "include/console.h"
#include "include/crypt_blowfish.h"
#include "include/efiauthenticated.h"
#include "include/errors.h"
#include "include/execute.h"
#include "include/guid.h"
#include "include/Http.h"
#include "include/httpboot.h"
#include "include/Ip4Config2.h"
#include "include/Ip6Config.h"
#include "include/netboot.h"
#include "include/PasswordCrypt.h"
#include "include/PeImage.h"
#include "include/replacements.h"
#if defined(OVERRIDE_SECURITY_POLICY)
#include "include/security_policy.h"
#endif
#include "include/simple_file.h"
#include "include/str.h"
#include "include/tpm.h"
#include "include/ucs2.h"
#include "include/variables.h"

#include "guid.h"
#include "variables.h"
#include "efiauthenticated.h"
#include "security_policy.h"
#include "console.h"
#include "version.h"

#ifdef ENABLE_SHIM_CERT
#include "shim_cert.h"
#endif

extern EFI_GUID SHIM_LOCK_GUID;

INTERFACE_DECL(_SHIM_LOCK);

typedef
EFI_STATUS
(*EFI_SHIM_LOCK_VERIFY) (
IN VOID *buffer,
IN UINT32 size
);

typedef
EFI_STATUS
(*EFI_SHIM_LOCK_HASH) (
IN char *data,
IN int datasize,
PE_COFF_LOADER_IMAGE_CONTEXT *context,
UINT8 *sha256hash,
UINT8 *sha1hash
);

typedef
EFI_STATUS
(*EFI_SHIM_LOCK_CONTEXT) (
IN VOID *data,
IN unsigned int datasize,
PE_COFF_LOADER_IMAGE_CONTEXT *context
);

typedef struct _SHIM_LOCK {
EFI_SHIM_LOCK_VERIFY Verify;
EFI_SHIM_LOCK_HASH Hash;
EFI_SHIM_LOCK_CONTEXT Context;
} SHIM_LOCK;

extern EFI_STATUS shim_init(void);
extern void shim_fini(void);
extern EFI_STATUS LogError(const char *file, int line, const char *func, CHAR16 *fmt, ...);
extern EFI_STATUS VLogError(const char *file, int line, const char *func, CHAR16 *fmt, va_list args);
extern VOID PrintErrors(VOID);
extern VOID ClearErrors(VOID);

#define LogError(fmt, ...) LogError(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__)

#endif /* SHIM_H_ */
Loading

0 comments on commit dc62a3c

Please sign in to comment.