Skip to content

Latest commit

 

History

History
252 lines (209 loc) · 16 KB

File metadata and controls

252 lines (209 loc) · 16 KB

System Architecture

Overview

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 Flow Diagram

┌─────────────────────────────────────────────────────────────────────────────┐
│                              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   │
└────────┘    └────────────┘

Component Architecture

┌─────────────────────────────────────────────────────────────────────────────┐
│                          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()           │   │   │
│  │  └──────────────────────┘    └───────────────────────────────────┘   │   │
│  └──────────────────────────────────────────────────────────────────────┘   │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘

Security Properties

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

New Security Features

Key Revocation System

Prevents compromised keys from being used:

┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐
│  Compromised    │────>│ Add to Revoke   │────>│  Key Blocked    │
│  Key Detected   │     │     List        │     │  From Signing   │
└─────────────────┘     └─────────────────┘     └─────────────────┘

Storage: keys/revoked_keys.csv

Timestamp Verification

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)                   │
└─────────────────────────────────────────────────────────────┘

Cryptographic Details

SHA-256 (Secure Hash Algorithm)

  • Output: 256 bits (32 bytes)
  • Collision Resistance: 2^128 operations
  • Purpose: Create unique fingerprint of kernel

RSA-2048 (Rivest-Shamir-Adleman)

  • Key Size: 2048 bits
  • Security Level: ~112 bits
  • Purpose: Sign and verify kernel hash

Signature Scheme

Signature = RSA_Sign(SHA256(Kernel), PrivateKey)
Valid = RSA_Verify(Signature, SHA256(Kernel), PublicKey)

Performance Metrics

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


Comparison with Industry Standards

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

Threat Model

Attacks Prevented

  1. Rootkit Injection - Kernel modification detected via hash mismatch
  2. Bootkit Installation - Replaced kernel fails signature verification
  3. Unsigned Kernel Boot - All kernels must have valid signature
  4. Signature Bypass - Without private key, valid signatures impossible
  5. Replay Attacks - Timestamps prevent reuse of old signatures
  6. Compromised Key Usage - Key revocation blocks known-bad keys

Attacks NOT Prevented (Out of Scope)

  1. Firmware-level attacks - Requires UEFI Secure Boot
  2. Physical access attacks - Requires TPM + full disk encryption
  3. Key compromise prevention - Requires HSM and secure key management
  4. Side-channel attacks - Requires specialized countermeasures