Bundle Protocol Security (RFC 9172) - authentication and encryption for DTN
0
fork

Configure Feed

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

ocaml-bpsec: wire MDX RNG seeding + tighten README example

The README's bpsec example needs an RNG initialised — the BIB/BCB
helpers pull from the default generator. Add the
'Crypto_rng_unix.use_default ()' call at the top of the OCaml block
and pull in 'nox-crypto-rng.unix' via the (mdx ...) stanza so the
example compiles in the test sandbox.

While here, replace the throwaway '_valid'/'let () = match ... with
| _ -> ()' bindings with an 'assert ...' / a real let-binding so a
bug in verify_bib or decrypt_bcb actually fails the build.

+9 -6
+8 -5
README.md
··· 42 42 ## Usage 43 43 44 44 ```ocaml 45 + let () = Crypto_rng_unix.use_default () 45 46 let key = String.make 32 '\x42' 46 47 47 48 (* Create a Block Integrity Block *) ··· 54 55 () 55 56 56 57 (* Verify integrity *) 57 - let _valid = Bpsec.verify_bib ~key bib ~target_data:["payload data"] 58 + let () = assert (Bpsec.verify_bib ~key bib ~target_data:["payload data"]) 58 59 59 60 (* Create a Block Confidentiality Block *) 60 61 let bcb, encrypted = ··· 66 67 () 67 68 68 69 (* Decrypt *) 69 - let () = 70 - match Bpsec.decrypt_bcb ~key bcb ~ciphertext:[encrypted] with 71 - | Some [_plaintext] -> () 72 - | _ -> () 70 + let plaintext = 71 + match Bpsec.decrypt_bcb ~key bcb ~ciphertext:encrypted with 72 + | Some [p] -> p 73 + | _ -> failwith "decryption failed" 74 + 75 + let () = assert (plaintext = "secret payload") 73 76 ``` 74 77 75 78 ## Related Work
+1 -1
dune
··· 4 4 5 5 (mdx 6 6 (files README.md) 7 - (libraries bpsec bundle)) 7 + (libraries bpsec bundle nox-crypto-rng.unix))