The Secure Boot and Kernel Integrity Verification System implements a cryptographic Chain of Trust that prevents unauthorized kernel execution. This document describes the system architecture, component design, and security model.
┌─────────────────────────────────────────────────────────────────────────────┐
│ BOOT PROCESS │
└─────────────────────────────────────────────────────────────────────────────┘
┌──────────────┐
│ Power On / │
│ Reset │
└──────┬───────┘
│
▼
┌──────────────┐
│ Bootloader │
│ (GRUB) │
└──────┬───────┘
│
▼
┌───────────────┐
│ Load Kernel │
│ & Signature │
└───────┬───────┘
│
▼
┌───────────────┐ ┌───────────────┐
│ Check Key │────>│ Key Revoked? │──── YES ──▶ HALT
│ Revocation │ └───────────────┘
└───────┬───────┘ │ NO
│ <<───────────────────┘
▼
┌───────────────┐ ┌───────────────┐
│ Verify │────>│ Expired? │──── YES ──▶ HALT
│ Timestamp │ └───────────────┘
└───────┬───────┘ │ NO
│<<──────────────────┘
▼
┌───────────────┐
│ Compute │
│ SHA-256 Hash │
└───────┬───────┘
│
▼
┌───────────────┐
│ RSA Verify │
│ Signature │
└───────┬───────┘
│
┌───────┴───────┐
│ │
▼ ▼
┌────────┐ ┌────────────┐
│ VALID │ │ INVALID │
└───┬────┘ └─────┬──────┘
│ │
▼ ▼
┌────────┐ ┌────────────┐
│ Boot │ │ HALT │
│ Kernel │ │ + Alert │
└────────┘ └────────────┘
┌─────────────────────────────────────────────────────────────────────────────┐
│ SYSTEM COMPONENTS │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────────────────────────────────────────────────────────┐ │
│ │ CRYPTOGRAPHIC LAYER │ │
│ │ ┌──────────────────────┐ ┌───────────────────────────────────┐ │ │
│ │ │ crypto_utils.c │ │ crypto_utils.h │ │ │
│ │ │ • sha256_file() │ │ • API definitions │ │ │
│ │ │ • sha256_buffer() │ │ • Return code constants │ │ │
│ │ │ • rsa_sign() │ │ • Key size definitions │ │ │
│ │ │ • rsa_verify() │ │ │ │ │
│ │ │ • generate_keypair()│ │ │ │ │
│ │ └──────────────────────┘ └───────────────────────────────────┘ │ │
│ └──────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────────────────┐ │
│ │ SECURITY LAYER (NEW) │ │
│ │ ┌──────────────────────┐ ┌───────────────────────────────────┐ │ │
│ │ │ key_revocation.c │ │ timestamp_verify.c │ │ │
│ │ │ • revoke_key() │ │ • create_timestamp() │ │ │
│ │ │ • is_key_revoked() │ │ • verify_timestamp() │ │ │
│ │ │ • get_fingerprint() │ │ • check_expiry() │ │ │
│ │ └──────────────────────┘ └───────────────────────────────────┘ │ │
│ └──────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────────────────┐ │
│ │ SIGNING LAYER │ │
│ │ ┌──────────────────────┐ ┌───────────────────────────────────┐ │ │
│ │ │ kernel_signer.c │ │ Scripts │ │ │
│ │ │ • cmd_sign() │ │ • generate_keys.sh │ │ │
│ │ │ • cmd_verify() │ │ • sign_kernel.sh │ │ │
│ │ │ • cmd_genkeys() │ │ • run_benchmark.sh │ │ │
│ │ └──────────────────────┘ └───────────────────────────────────┘ │ │
│ └──────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────────────────┐ │
│ │ VERIFICATION LAYER │ │
│ │ ┌──────────────────────┐ ┌───────────────────────────────────┐ │ │
│ │ │ boot_verifier.c │ │ integrity_check.c │ │ │
│ │ │ • verify_kernel() │ │ • check_file_exists() │ │ │
│ │ │ • check_revocation()│ │ • check_file_size() │ │ │
│ │ │ • check_timestamp() │ │ • check_suspicious_patterns() │ │ │
│ │ └──────────────────────┘ └───────────────────────────────────┘ │ │
│ └──────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────────────────┐ │
│ │ LOGGING LAYER │ │
│ │ ┌──────────────────────┐ ┌───────────────────────────────────┐ │ │
│ │ │ security_logger.c │ │ performance_benchmark.c │ │ │
│ │ │ • log_event() │ │ • run_benchmark() │ │ │
│ │ │ • log_tampering() │ │ • measure_hash_time() │ │ │
│ │ │ • log_revocation() │ │ • measure_sign_time() │ │ │
│ │ └──────────────────────┘ └───────────────────────────────────┘ │ │
│ └──────────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘
| Property | Implementation | Protection Against |
|---|---|---|
| Integrity | SHA-256 hash verification | Kernel modification, corruption |
| Authenticity | RSA digital signatures | Unauthorized kernel signing |
| Non-repudiation | Asymmetric cryptography | Signature forgery |
| Key Revocation | Fingerprint blocklist | Compromised key usage |
| Anti-Replay | Timestamp verification | Signature reuse attacks |
| Audit Trail | Security logging | Post-incident forensics |
Prevents compromised keys from being used:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Compromised │────>│ Add to Revoke │────>│ Key Blocked │
│ Key Detected │ │ List │ │ From Signing │
└─────────────────┘ └─────────────────┘ └─────────────────┘
Storage: keys/revoked_keys.csv
Prevents signature reuse (anti-replay):
┌─────────────────────────────────────────────────────────────┐
│ SIGNATURE TIMESTAMP │
├─────────────────────────────────────────────────────────────┤
│ Sign Time: 2024-12-09 18:00:00 │
│ Expiry Time: 2025-12-09 18:00:00 │
│ Status: VALID (365 days remaining) │
└─────────────────────────────────────────────────────────────┘
- Output: 256 bits (32 bytes)
- Collision Resistance: 2^128 operations
- Purpose: Create unique fingerprint of kernel
- Key Size: 2048 bits
- Security Level: ~112 bits
- Purpose: Sign and verify kernel hash
Signature = RSA_Sign(SHA256(Kernel), PrivateKey)
Valid = RSA_Verify(Signature, SHA256(Kernel), PublicKey)
Typical performance on modern hardware:
| Operation | Time (512KB kernel) | Notes |
|---|---|---|
| SHA-256 Hash | ~5 ms | Proportional to file size |
| RSA-2048 Sign | ~15 ms | Constant time |
| RSA-2048 Verify | ~2 ms | Constant time |
| Total Overhead | ~22 ms | Negligible boot impact |
Run benchmarks: make benchmark
| Feature | This Project | UEFI Secure Boot | Windows Trusted Boot |
|---|---|---|---|
| Hash Algorithm | SHA-256 | SHA-256 | SHA-256 |
| Signature Algorithm | RSA-2048 | RSA-2048/ECDSA | RSA-2048 |
| Key Storage | File-based | UEFI Variables | TPM |
| Key Revocation | ✅ | ✅ | ✅ |
| Timestamps | ✅ | ❌ | ✅ |
| Recovery Mode | ✅ | ✅ | ✅ |
- Rootkit Injection - Kernel modification detected via hash mismatch
- Bootkit Installation - Replaced kernel fails signature verification
- Unsigned Kernel Boot - All kernels must have valid signature
- Signature Bypass - Without private key, valid signatures impossible
- Replay Attacks - Timestamps prevent reuse of old signatures
- Compromised Key Usage - Key revocation blocks known-bad keys
- Firmware-level attacks - Requires UEFI Secure Boot
- Physical access attacks - Requires TPM + full disk encryption
- Key compromise prevention - Requires HSM and secure key management
- Side-channel attacks - Requires specialized countermeasures