mirror of
https://github.com/subhobhai943/SUB-OS.git
synced 2026-10-26 00:52:50 +00:00
feat(rust,gui): Rust checksum engine + Game of Life desktop app
Rust kernel expansion:
- rust/src/checksum/mod.rs (new): memory-safe CRC-32C (Castagnoli), Adler-32,
and FNV-1a-64 with thin C-ABI shims. Registered in lib.rs with a boot-time
self-test (crc32c("SUB-OS")=0x61e96ce9, verified against a reference impl).
- include/kernel/rust.h: FFI declarations; rust/rust_fallback.c: matching C
fallbacks so aarch64/armv8i (no native rustc target) get identical results.
- LazyBox: new `cksum <text>` applet printing all three via the Rust engine.
GUI expansion:
- gui/gui_apps.c: Conway's Game of Life -- an interactive B3/S23 cellular
automaton with Play/Pause/Step/Random/Clear toolbar, click-to-toggle cells,
a live generation/population readout, and a board that scales with the
window. The Random button seeds from the Rust ChaCha20 CSPRNG. Toolbar and
cell input are gated on the MOUSE_DOWN edge so they do not re-fire while held.
- Registered "Life" (flask icon) in the desktop app table and on the desktop.
Verified: clean build on x86_64/aarch64/armv8i; boots through the SUB login to
the desktop (screenshotted) with the checksum self-test and 0 panics/0 OOM.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Fh5z6V7nGPbHvqVG5p4CXX
This commit is contained in:
1 parent
c982d6b538
commit
e93b994469
8 files changed
+341
-1
No files matched your search
@@ -215,3 +215,39 @@ int rust_aead_decrypt(const uint8_t* key, const uint8_t* nonce, const uint8_t* a
|
||||
if (cipher && plain_out && cipher_len > 0) memcpy(plain_out, cipher, cipher_len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// --- Checksums & non-cryptographic hashing (C fallback for non-x86 targets) ---
|
||||
// These mirror rust/src/checksum/mod.rs bit-for-bit so callers get identical
|
||||
// results whether the native Rust staticlib or this bridge is linked.
|
||||
uint32_t rust_crc32c(const uint8_t* data, size_t len) {
|
||||
if (!data) return 0;
|
||||
uint32_t crc = 0xFFFFFFFFu;
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
crc ^= data[i];
|
||||
for (int b = 0; b < 8; b++) {
|
||||
uint32_t mask = -(crc & 1u);
|
||||
crc = (crc >> 1) ^ (0x82F63B78u & mask);
|
||||
}
|
||||
}
|
||||
return ~crc;
|
||||
}
|
||||
|
||||
uint32_t rust_adler32(const uint8_t* data, size_t len) {
|
||||
if (!data) return 1;
|
||||
uint32_t a = 1, b = 0;
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
a = (a + data[i]) % 65521u;
|
||||
b = (b + a) % 65521u;
|
||||
}
|
||||
return (b << 16) | a;
|
||||
}
|
||||
|
||||
uint64_t rust_fnv1a64(const uint8_t* data, size_t len) {
|
||||
uint64_t hash = 0xcbf29ce484222325ull;
|
||||
if (!data) return hash;
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
hash ^= data[i];
|
||||
hash *= 0x00000100000001B3ull;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
Reference in new issue
Block a user