Skip to content

Commit

Permalink
Update to mirage-crypto-rng 1.0 API
Browse files Browse the repository at this point in the history
  • Loading branch information
talex5 committed Nov 28, 2024
1 parent fcf4449 commit c9cc9a3
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 23 deletions.
20 changes: 9 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ jobs:
os:
- ubuntu-latest
ocaml-version:
- 4.07.0
- 4.13.0

runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Use OCaml ${{ matrix.ocaml-version }}
uses: avsm/setup-ocaml@v1
uses: avsm/setup-ocaml@v3
with:
ocaml-version: ${{ matrix.ocaml-version }}
ocaml-compiler: ${{ matrix.ocaml-version }}

- name: Deps
run: |
Expand All @@ -42,21 +42,19 @@ jobs:
os:
- ubuntu-latest
ocaml-version:
- 4.08.1
- 4.10.2
- 4.11.2
- 4.12.0
- 4.14.0
- 5

runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Use OCaml ${{ matrix.ocaml-version }}
uses: avsm/setup-ocaml@v1
uses: avsm/setup-ocaml@v3
with:
ocaml-version: ${{ matrix.ocaml-version }}
ocaml-compiler: ${{ matrix.ocaml-version }}

- name: Deps
run: |
Expand Down
2 changes: 1 addition & 1 deletion backends/postgresql/session_postgresql.ml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ let connect ?host ?hostaddr ?port ?dbname ?user ?password ?options ?tty ?require
new Postgresql.connection ?host ?hostaddr ?port ?dbname ?user ?password ?options ?tty ?requiressl ?conninfo ?startonly ()

let gensym () =
Base64.encode_string (Cstruct.to_string (Mirage_crypto_rng.generate 30))
Base64.encode_string (Mirage_crypto_rng.generate 30)

let now () =
Int64.of_float (Unix.time ())
Expand Down
2 changes: 1 addition & 1 deletion backends/redis/lwt/session_redis_lwt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ let _default_period =
Int64.of_int (60 * 60 * 24 * 7)

let gensym () =
Base64.encode_string (Cstruct.to_string (Mirage_crypto_rng.generate 30))
Base64.encode_string (Mirage_crypto_rng.generate 30)

let redis_key k = "session:" ^ k

Expand Down
2 changes: 1 addition & 1 deletion examples/cohttp_async_counter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ let main () =
Log.Global.info "cohttp_async_counter: listening on 0.0.0.0:%d%!" port

let _ =
Mirage_crypto_rng_unix.initialize ();
Mirage_crypto_rng_unix.initialize (module Mirage_crypto_rng.Fortuna);
Scheduler.go_main ~main ()
2 changes: 1 addition & 1 deletion examples/cohttp_lwt_counter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ let main () =
Printf.eprintf "cohttp_lwt_counter: lsitening on 0.0.0.0:%d\n%!" port

let () =
Mirage_crypto_rng_unix.initialize ();
Mirage_crypto_rng_unix.initialize (module Mirage_crypto_rng.Fortuna);
Lwt_main.run (main ())
2 changes: 1 addition & 1 deletion examples/webmachine_async_counter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ let main () =
Log.Global.info "webmachine_async_counter: listening on 0.0.0.0:%d%!" port

let _ =
Mirage_crypto_rng_unix.initialize ();
Mirage_crypto_rng_unix.initialize (module Mirage_crypto_rng.Fortuna);
Scheduler.go_main ~main ()
2 changes: 1 addition & 1 deletion examples/webmachine_lwt_counter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ let main () =
Printf.eprintf "cohttp_lwt_counter: lsitening on 0.0.0.0:%d\n%!" port

let () =
Mirage_crypto_rng_unix.initialize ();
Mirage_crypto_rng_unix.initialize (module Mirage_crypto_rng.Fortuna);
Lwt_main.run (main ())
2 changes: 1 addition & 1 deletion lib/memory.ml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type t =
; mutable default_period : period }

let gensym () =
Base64.encode_string (Cstruct.to_string (Mirage_crypto_rng.generate 30))
Base64.encode_string (Mirage_crypto_rng.generate 30)

let create () =
{ store = Hashtbl.create 10
Expand Down
2 changes: 1 addition & 1 deletion lib_test/memory/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ module Backend = struct
let name = "memory"
end

let () = Mirage_crypto_rng_unix.initialize ()
let () = Mirage_crypto_rng_unix.initialize (module Mirage_crypto_rng.Fortuna)
module Test = Test_session.Make(Backend)
2 changes: 1 addition & 1 deletion lib_test/postgresql/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ let () =
| Error e -> Some (Printf.sprintf "Postgresql.Error(%S)" (string_of_error e))
| _ -> None

let () = Mirage_crypto_rng_unix.initialize ()
let () = Mirage_crypto_rng_unix.initialize (module Mirage_crypto_rng.Fortuna)
module Test = Test_session.Make(Backend)
2 changes: 1 addition & 1 deletion lib_test/redis/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ module Backend = struct
Lwt_main.run (C.set ?expiry t key value)
end

let () = Mirage_crypto_rng_unix.initialize ()
let () = Mirage_crypto_rng_unix.initialize (module Mirage_crypto_rng.Fortuna)
module Test = Test_session.Make(Backend)
3 changes: 1 addition & 2 deletions session.opam
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ depends: [
"ocaml" {>= "4.07.0"}
"base-unix"
"dune" {>= "1.0"}
"mirage-crypto"
"mirage-crypto-rng"
"mirage-crypto-rng" {>= "1.0.0"}
"base64"
"ounit" {with-test & >= "1.0.2"}
]
Expand Down

0 comments on commit c9cc9a3

Please sign in to comment.