]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
security: implement central CSPRNG with real entropy (M8)
authorTulio A M Mendes <[email protected]>
Thu, 11 Jun 2026 00:56:29 +0000 (21:56 -0300)
committerTulio A M Mendes <[email protected]>
Thu, 11 Jun 2026 00:56:29 +0000 (21:56 -0300)
commitdd145fccc709e82a1644f0d7729ad7762cb03c29
treee56c6c8d5624f31e45afcbad982df232e0bd8a39
parent4419fc9381af39d8e7809d34b9f74196a824a712
security: implement central CSPRNG with real entropy (M8)

- Create src/kernel/csprng.c with ChaCha20-based DRBG
- Entropy sources: RDTSC, timer ticks, interrupt timing, user input
- Add csprng_init() called at boot in kernel_main()
- Add csprng_get_bytes(), csprng_get_u32(), csprng_get_u64() APIs
- Add csprng_add_entropy() for /dev/random writes
- Update src/kernel/devfs.c:
  - Remove local PRNG (prng_state, prng_next)
  - Use csprng_get_bytes() in dev_random_read()
  - Use csprng_add_entropy() in dev_random_write()
- Spinlock protection for SMP safety
- Reseed mechanism every 256 entropy additions

Validation:
- make -j12: PASS
- make test-host: PASS (111/111)
- make test SMOKE_SMP=4: PASS (127/127)
- make test-battery: PASS (153/153)
- make analyzer: PASS

Addresses M8 from docs/URGENT_SECURITY_STATUS_2026-06-09.md
include/csprng.h [new file with mode: 0644]
src/kernel/csprng.c [new file with mode: 0644]
src/kernel/devfs.c
src/kernel/main.c