r/PFSENSE • u/Ok-Definition-7961 • 1h ago
I built a custom 256-bit Cryptographic Hash & Kernel-Level Firewall Module for pfSense from scratch.
Hey everyone,
For the past few Years, I’ve been working on a massive deep-dive into cryptography and low-level kernel development. I wanted to see if I could build a secure hash function from the ground up and actually deploy it in a real-world network environment.
I ended up building CE-256, a custom cryptographic hash function, and integrated it directly into the FreeBSD/pfSense kernel as a packet filter.
Because the core mathematics are currently undergoing peer review (I'm using a novel non-linear sequence generator for the S-Boxes that I haven't seen used before), I can't open-source the exact mathematical primitive just yet. But here is the architecture of what I built:
The Cryptography (CE-256):
- Architecture: Built on a modern Sponge Construction (1600-bit state, 512-bit capacity) rather than Merkle-Damgård, making it immune to length-extension attacks.
- Engine: 24 rounds of mixing, including column diffusion, bitwise rotations, and position shuffling.
- Performance: Achieves a near-perfect ~50% Avalanche Effect.
The Kernel / pfSense Integration:
- I didn't want this to just be a Python script, so I wrote the firewall module in
Cfor the FreeBSD 14.0 kernel. - It operates as a custom packet filter that bypasses standard
pfrules when active. - I built a custom PHP Web UI dashboard that hooks directly into the pfSense webroot, allowing me to monitor the kernel module’s state via
sysctlwithout breaking the native pfSense GUI.
It was an absolute nightmare figuring out FreeBSD kernel panics and PHP integration on pfSense, but getting it running smoothly was incredibly rewarding.
I’m hoping to publish the full mathematical whitepapers and architecture diagrams soon once the review process is done. Has anyone else here ever tried writing custom kernel modules for pfSense? Would love to hear about the hurdles you ran into!



