Linear Feedback Shift Registers for OCaml
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

OCaml 84.2%
Dune 5.4%
Other 10.4%
20 1 0

Clone this repository

https://tangled.org/gazagnaire.org/ocaml-lfsr https://tangled.org/did:plc:jhift2vwcxhou52p3sewcrpx/ocaml-lfsr
git@git.recoil.org:gazagnaire.org/ocaml-lfsr git@git.recoil.org:did:plc:jhift2vwcxhou52p3sewcrpx/ocaml-lfsr

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

lfsr#

Linear Feedback Shift Registers for OCaml.

Configurable LFSRs (Fibonacci form) with up to 62-bit state. Includes a preset for CCSDS OID frame randomization (32-cell, polynomial x^32 + x^22 + x^2 + x + 1, per CCSDS 132.0-B-3 Annex D). Used for TRANSEC traffic flow confidentiality in satellite links.

Installation#

Install with opam:

$ opam install lfsr

If opam cannot find the package, it may not yet be released in the public opam-repository. Add the overlay repository, then install it:

$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install lfsr

Usage#

(* CCSDS OID frame randomization: noise XORs with frame data *)
let ccsds = Lfsr.ccsds_oid ()
let noise = Lfsr.generate ccsds 256
let () = Printf.printf "generated %d bytes of noise\n" (Bytes.length noise)

(* Custom LFSR *)
let custom = Lfsr.v ~taps:0xC0000401 ~seed:0xFFFFFFFF ~width:32
let () = Printf.printf "0x%02X\n" (Lfsr.next_byte custom)

API Overview#

  • type t -- Mutable LFSR state
  • v -- Create LFSR with custom taps, seed, and width (1-62 bits)
  • ccsds_oid -- Preset for CCSDS 132.0-B-3 OID frame randomization
  • step -- Advance one bit, return output bit (0 or 1)
  • next_byte -- Advance 8 bits, return byte (MSB-first)
  • fill -- Fill a buffer with pseudo-noise
  • generate -- Generate n bytes of pseudo-noise
  • state, width -- Query register state

License#

MIT