-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
203 lines (169 loc) · 6.74 KB
/
Makefile
File metadata and controls
203 lines (169 loc) · 6.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# Secure Boot and Kernel Integrity Verification System
# Makefile - Build System
#
# This Makefile compiles all components of the secure boot system.
# Requires: GCC, OpenSSL development libraries
#
# Author: OS Security Project
# Compiler and flags
CC = gcc
CFLAGS = -Wall -Wextra -O2 -g
LDFLAGS = -lssl -lcrypto
# Directories
SRC_DIR = src
BUILD_DIR = build
BIN_DIR = bin
# Source files
CRYPTO_SRC = $(SRC_DIR)/crypto/crypto_utils.c
LOGGER_SRC = $(SRC_DIR)/logger/security_logger.c
SIGNER_SRC = $(SRC_DIR)/signing/kernel_signer.c
VERIFIER_SRC = $(SRC_DIR)/bootloader/boot_verifier.c
INTEGRITY_SRC = $(SRC_DIR)/bootloader/integrity_check.c
# Object files
CRYPTO_OBJ = $(BUILD_DIR)/crypto_utils.o
LOGGER_OBJ = $(BUILD_DIR)/security_logger.o
SIGNER_OBJ = $(BUILD_DIR)/kernel_signer.o
VERIFIER_OBJ = $(BUILD_DIR)/boot_verifier.o
INTEGRITY_OBJ = $(BUILD_DIR)/integrity_check.o
# Output binaries
SIGNER_BIN = $(BIN_DIR)/kernel_signer
VERIFIER_BIN = $(BIN_DIR)/boot_verifier
# Header dependencies
CRYPTO_HEADERS = $(SRC_DIR)/crypto/crypto_utils.h
LOGGER_HEADERS = $(SRC_DIR)/logger/security_logger.h
INTEGRITY_HEADERS = $(SRC_DIR)/bootloader/integrity_check.h
# =============================================================================
# DEFAULT TARGET
# =============================================================================
.PHONY: all clean install help test
all: dirs $(SIGNER_BIN) $(VERIFIER_BIN)
@echo ""
@echo "╔══════════════════════════════════════════════════════════════╗"
@echo "║ BUILD SUCCESSFUL ║"
@echo "╚══════════════════════════════════════════════════════════════╝"
@echo ""
@echo "Binaries created:"
@echo " $(SIGNER_BIN) - Kernel signing tool"
@echo " $(VERIFIER_BIN) - Boot verification module"
@echo ""
@echo "Run 'make help' for usage information."
@echo ""
# =============================================================================
# DIRECTORY CREATION
# =============================================================================
dirs:
@mkdir -p $(BUILD_DIR)
@mkdir -p $(BIN_DIR)
@mkdir -p keys
@mkdir -p logs
# =============================================================================
# OBJECT FILE COMPILATION
# =============================================================================
$(CRYPTO_OBJ): $(CRYPTO_SRC) $(CRYPTO_HEADERS)
@echo "[CC] Compiling crypto_utils.c..."
$(CC) $(CFLAGS) -c $< -o $@
$(LOGGER_OBJ): $(LOGGER_SRC) $(LOGGER_HEADERS)
@echo "[CC] Compiling security_logger.c..."
$(CC) $(CFLAGS) -c $< -o $@
$(INTEGRITY_OBJ): $(INTEGRITY_SRC) $(INTEGRITY_HEADERS) $(LOGGER_HEADERS)
@echo "[CC] Compiling integrity_check.c..."
$(CC) $(CFLAGS) -c $< -o $@ -I$(SRC_DIR)/logger
$(SIGNER_OBJ): $(SIGNER_SRC) $(CRYPTO_HEADERS) $(LOGGER_HEADERS)
@echo "[CC] Compiling kernel_signer.c..."
$(CC) $(CFLAGS) -c $< -o $@ -I$(SRC_DIR)/crypto -I$(SRC_DIR)/logger
$(VERIFIER_OBJ): $(VERIFIER_SRC) $(CRYPTO_HEADERS) $(LOGGER_HEADERS) $(INTEGRITY_HEADERS)
@echo "[CC] Compiling boot_verifier.c..."
$(CC) $(CFLAGS) -c $< -o $@ -I$(SRC_DIR)/crypto -I$(SRC_DIR)/logger -I$(SRC_DIR)/bootloader
# =============================================================================
# BINARY LINKING
# =============================================================================
$(SIGNER_BIN): $(SIGNER_OBJ) $(CRYPTO_OBJ) $(LOGGER_OBJ)
@echo "[LD] Linking kernel_signer..."
$(CC) $^ -o $@ $(LDFLAGS)
$(VERIFIER_BIN): $(VERIFIER_OBJ) $(CRYPTO_OBJ) $(LOGGER_OBJ) $(INTEGRITY_OBJ)
@echo "[LD] Linking boot_verifier..."
$(CC) $^ -o $@ $(LDFLAGS)
# =============================================================================
# UTILITY TARGETS
# =============================================================================
clean:
@echo "Cleaning build artifacts..."
rm -rf $(BUILD_DIR) $(BIN_DIR)
rm -f keys/*.pem
rm -f *.sig
rm -f logs/*.log
@echo "Clean complete."
install: all
@echo "Installing to /usr/local/bin..."
cp $(SIGNER_BIN) /usr/local/bin/
cp $(VERIFIER_BIN) /usr/local/bin/
@echo "Installation complete."
# =============================================================================
# TESTING TARGETS
# =============================================================================
test: all
@echo ""
@echo "Running test suite..."
@chmod +x tests/test_suite.sh
./tests/test_suite.sh
demo: all
@echo ""
@echo "Running secure boot demonstration..."
@chmod +x scripts/demo.sh
./scripts/demo.sh
genkeys: all
@echo ""
@echo "Generating RSA key pair..."
$(SIGNER_BIN) genkeys keys/private_key.pem keys/public_key.pem
benchmark: all
@echo ""
@echo "Running performance benchmarks..."
@chmod +x scripts/run_benchmark.sh
./scripts/run_benchmark.sh
report: all
@echo ""
@echo "Generating HTML test report..."
@chmod +x scripts/generate_html_report.sh
./scripts/generate_html_report.sh
recovery:
@echo ""
@echo "Starting recovery mode..."
@chmod +x scripts/recovery_mode.sh
./scripts/recovery_mode.sh
attack: all
@echo ""
@echo "Running attack simulation..."
@chmod +x tests/simulate_attack.sh
./tests/simulate_attack.sh
# =============================================================================
# HELP
# =============================================================================
help:
@echo ""
@echo "╔══════════════════════════════════════════════════════════════╗"
@echo "║ SECURE BOOT BUILD SYSTEM - HELP ║"
@echo "╚══════════════════════════════════════════════════════════════╝"
@echo ""
@echo "Available targets:"
@echo ""
@echo " make all - Build all components (default)"
@echo " make clean - Remove all build artifacts"
@echo " make install - Install binaries to /usr/local/bin"
@echo " make test - Run automated test suite"
@echo " make demo - Run secure boot demonstration"
@echo " make genkeys - Generate RSA key pair"
@echo " make attack - Run attack simulation"
@echo " make benchmark - Run performance benchmarks"
@echo " make report - Generate HTML test report"
@echo " make recovery - Start recovery mode"
@echo " make help - Show this help message"
@echo ""
@echo "Requirements:"
@echo " - GCC compiler"
@echo " - OpenSSL development libraries (libssl-dev)"
@echo ""
@echo "Quick Start:"
@echo " 1. make all"
@echo " 2. make genkeys"
@echo " 3. make demo"
@echo ""