Skip to content

Null bootloader - Minimal Limine fork for LunaOS. Stripped bloat, added Luna boot fields, optimized for consciousness.

License

Notifications You must be signed in to change notification settings

artst3in/null-bootloader

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŒ™ Null

The Minimal Bootloader

A Stripped-Down Limine Fork for LunaOS

Version License Platform Lines Removed

πŸš€ Minimal β€’ πŸ›‘οΈ Proven β€’ ⚑ Fast β€’ πŸŒ™ LunaOS-Native

Features β€’ What We Changed β€’ What We Kept β€’ Philosophy


🎯 What is Null?

Null is a minimal bootloader for LunaOS - a stripped-down fork of Limine with ~4,300 lines of dead code removed. It does exactly one thing: boot LunaOS kernels via the Limine protocol.

The numbers:

  • πŸ—‘οΈ ~4,300 lines removed - Multiboot, Linux boot, Chainload, ISO9660
  • πŸ“¦ 19 files deleted - unused protocol handlers and filesystems
  • βœ… 1 protocol supported - Limine (the only one LunaOS uses)
  • πŸ”’ 0 regressions - boot process untouched

πŸ’‘ Philosophy: Use proven code. Remove unused code. Touch nothing else.


✨ Features

πŸš€ What Null Does

πŸ–₯️ Boot LunaOS

  • πŸ”§ Limine protocol (full support)
  • πŸ“‹ Boot menu (recovery/older kernels)
  • πŸ’Ύ UEFI & BIOS boot
  • πŸ”€ SMP initialization

🌐 Network & Storage

  • πŸ“ FAT32 filesystem
  • 🌍 PXE/TFTP network boot
  • πŸ’Ώ EFI partition support
  • πŸ” Post-quantum crypto (Dilithium/Kyber)

🚫 What Null Doesn't Do

❌ Removed Protocols

  • Multiboot 1/2
  • Linux boot
  • Chainload

❌ Removed Filesystems

  • ISO9660
  • CD/DVD boot

πŸ’‘ Why?

  • 🎯 LunaOS uses Limine only
  • πŸ›‘οΈ Dead code = attack surface
  • ⚑ Smaller = faster boot

πŸ”§ What We Changed

Component Lines Removed Status
πŸ“„ multiboot1.c/h ~560 πŸ—‘οΈ Deleted
πŸ“„ multiboot2.c/h ~1,360 πŸ—‘οΈ Deleted
πŸ“„ linux_x86.c ~630 πŸ—‘οΈ Deleted
πŸ“„ linux_risc.c ~450 πŸ—‘οΈ Deleted
πŸ“„ chainload.c/h ~370 πŸ—‘οΈ Deleted
πŸ“„ iso9660.s2.c/h ~580 πŸ—‘οΈ Deleted
πŸ”© Assembly files ~220 πŸ—‘οΈ Deleted
πŸ“‹ menu.c dispatch ~30 βœ‚οΈ Simplified
πŸ“Š Total ~4,300 βœ… Gone

πŸ›‘οΈ What We Kept

Component Purpose Status
πŸ”§ Limine protocol Boot LunaOS kernels βœ… Essential
πŸ“‹ Boot menu Recovery mode, kernel selection βœ… Essential
πŸ“ FAT32 Read kernel from EFI partition βœ… Essential
🌐 PXE/TFTP Network boot (sister resurrection) πŸ’‘ Useful
πŸ” PQCrypto Post-quantum signatures & encryption βœ… Essential
πŸ—ΊοΈ Memory map DO NOT TOUCH πŸ”’ Sacred
πŸ”€ SMP boot DO NOT TOUCH πŸ”’ Sacred
πŸ“„ Paging DO NOT TOUCH πŸ”’ Sacred

🧠 Philosophy

πŸ€” Why Fork Limine?

We tried everything else:

Attempt Duration Result
πŸ”¨ Custom bootloader from scratch 1 week 😭 Crying, almost quit
πŸ”§ "Reorganizing" Limine memory 1 day πŸ’€ SMP disappeared
πŸ¦€ Translating to Rust 2 days πŸ’₯ Failed miserably

🎯 Conclusion: Use proven bootloader, strip bloat, move on.

πŸ“œ The Rules

  1. 🚫 Never touch memory map - It works. Don't ask how.
  2. 🚫 Never touch SMP boot - It works. Don't ask why.
  3. 🚫 Never touch paging - It works. Just be grateful.
  4. βœ‚οΈ Remove unused code - Less code = fewer bugs.
  5. πŸ“‹ Keep the boot menu - Recovery mode saves lives.

πŸ” Post-Quantum Cryptography

Null includes a complete post-quantum cryptographic stack for secure boot.

πŸš€ Quick Start (One Command)

./setup-pqcrypto.sh

This single command will:

  1. Download pq-crystals reference implementations
  2. Build luna_sign and luna_crypt tools
  3. Generate signing and encryption keys
  4. Embed keys into the bootloader
  5. Build the bootloader

Crypto Primitives

Component Algorithm Security Level Key Sizes
πŸ” Signatures Dilithium-3 (ML-DSA) NIST Level 3 (128-bit) PK: 1952B, SK: 4032B, Sig: 3309B
πŸ”‘ Key Encapsulation Kyber-1024 (ML-KEM) NIST Level 5 (256-bit) PK: 1568B, SK: 3168B, CT: 1568B
πŸ”’ Symmetric AEAD ChaCha20-Poly1305 256-bit Key: 32B, Nonce: 12B, Tag: 16B

How It Works

Signing protects against kernel replacement (integrity):

Developer                           User's Machine
    β”‚                                    β”‚
    β”‚  kernel.elf + secret key           β”‚
    β”‚      β”‚                             β”‚
    β”‚  [luna_sign] ──────────────►  kernel.signed
    β”‚                                    β”‚
    β”‚  BOOTX64.EFI ─────────────►   Bootloader verifies
    β”‚  (has public key)                  signature before
    β”‚                                    executing kernel

Encryption protects against kernel reading (confidentiality):

Developer                           User's Machine
    β”‚                                    β”‚
    β”‚  kernel.signed + public key        β”‚
    β”‚      β”‚                             β”‚
    β”‚  [luna_crypt] ─────────────►  kernel.enc
    β”‚                                    β”‚
    β”‚  BOOTX64.EFI ─────────────►   Bootloader decrypts
    β”‚  (has secret key)                  then verifies

Tool Usage

# Sign a kernel (appends 3309-byte Dilithium-3 signature)
./tools/pqcrypto/dilithium-ref/ref/luna_sign sign kernel.elf keys/signing.sec kernel.signed

# Verify a signed kernel
./tools/pqcrypto/dilithium-ref/ref/luna_sign verify kernel.signed keys/signing.pub

# Encrypt a file (Kyber-1024 + ChaCha20-Poly1305)
./tools/pqcrypto/kyber-ref/ref/luna_crypt encrypt kernel.signed keys/encryption.pub kernel.enc

# Decrypt a file
./tools/pqcrypto/kyber-ref/ref/luna_crypt decrypt kernel.enc keys/encryption.sec kernel.dec

File Formats

Signed kernel: [kernel data][Dilithium-3 signature (3309 bytes)]

Encrypted kernel (LUNAENC1 format):

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Magic: "LUNAENC1" (8 bytes)                                     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Kyber-1024 Ciphertext (1568 bytes)                              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ ChaCha20 Nonce (12 bytes)                                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Poly1305 Authentication Tag (16 bytes)                          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Encrypted Data (variable length)                                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Header overhead: 1604 bytes

⚠️ Important Security Notes

  1. Keys are per-developer - Each developer generates their own keypair
  2. Bootloader + kernel are paired - A bootloader only verifies kernels signed with its embedded public key
  3. Back up your secret keys - Store keys/*.sec files securely; if lost, you cannot sign new kernels
  4. Never commit secret keys - .sec files are gitignored by default
  5. Pre-built binaries are useless - A downloaded bootloader has someone else's keys embedded

Setup Script Options

./setup-pqcrypto.sh                 # Full setup (recommended)
./setup-pqcrypto.sh --tools-only    # Only build tools
./setup-pqcrypto.sh --keys-only     # Only generate keys
./setup-pqcrypto.sh --build-only    # Only rebuild bootloader
./setup-pqcrypto.sh --clean         # Clean and start fresh
./setup-pqcrypto.sh --no-kyber      # Signing only (no encryption)
./setup-pqcrypto.sh --help          # Show all options

πŸ—οΈ Building

With PQCrypto (Recommended)

./setup-pqcrypto.sh

Manual Build (No Crypto)

./bootstrap
./configure --enable-uefi-x86-64
make

See INSTALL.md for full build instructions.


🏷️ Versioning

Null follows the LunaOS unified versioning scheme:

  • Version: 2025.12.100 (YYYY.MM.BBB)
  • Increment: Bump BBB (100 β†’ 101 β†’ 102) per release
  • Reset: Back to 100 each month

See VERSIONING.md for details.


πŸ“œ License

Licensed under the BSD 2-Clause License

Based on Limine by mintsuki and contributors.

See COPYING for full details.


πŸ™ Acknowledgments

Null is a minimal fork of the legendary Limine bootloader. We're deeply grateful to mintsuki and the Limine community for creating such a robust foundation.

What we took:

  • πŸ”§ Proven boot process (memory, SMP, paging)
  • πŸ“¦ Limine protocol implementation
  • πŸ“‹ Boot menu system
  • πŸ“ FAT32 and PXE support

What we gave back:

  • πŸ“š A lesson in humility (don't rewrite bootloaders)

πŸŒ™ Part of LunaOS

Null is a core component of LunaOS - the first operating system built on the Coherence Paradigm.

The Coherence Paradigm

Null embodies the First Law of Computational Physics (LCP):

  • 🎯 Minimum viable code - Only what's needed to boot LunaOS
  • πŸ›‘οΈ Proven foundations - Use Limine's battle-tested boot process
  • πŸ“‰ Zero entropy increase - Remove code, don't add it

"The best bootloader is the one that gets out of the way."


πŸš€ Ready to boot?

./configure --enable-uefi-x86-64 && make

πŸ“– Build Instructions β€’ βš™οΈ Configuration β€’ πŸ› Issues


Made with πŸ’œ by the LunaOS team

dΞ΅/dt ≀ 0

About

Null bootloader - Minimal Limine fork for LunaOS. Stripped bloat, added Luna boot fields, optimized for consciousness.

Resources

License

Stars

Watchers

Forks

Languages

  • C 87.4%
  • Shell 6.5%
  • Makefile 4.2%
  • Other 1.9%