From f7c4bcdf84a636acb8073cc3ddadd9fa3043b5b2 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Thu, 28 Nov 2024 11:43:16 +0000 Subject: [PATCH] Update to mirage-crypto-rng 1.0 API --- .github/workflows/test.yml | 20 +++++++++----------- backends/postgresql/session_postgresql.ml | 2 +- backends/redis/lwt/session_redis_lwt.ml | 2 +- lib/memory.ml | 2 +- lib_test/memory/test.ml | 2 +- session.opam | 3 +-- 6 files changed, 14 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c0b491e..0d9d4d4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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: | @@ -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: | diff --git a/backends/postgresql/session_postgresql.ml b/backends/postgresql/session_postgresql.ml index bc2721b..6f3be60 100644 --- a/backends/postgresql/session_postgresql.ml +++ b/backends/postgresql/session_postgresql.ml @@ -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 ()) diff --git a/backends/redis/lwt/session_redis_lwt.ml b/backends/redis/lwt/session_redis_lwt.ml index c2dc7b2..b0ce81b 100644 --- a/backends/redis/lwt/session_redis_lwt.ml +++ b/backends/redis/lwt/session_redis_lwt.ml @@ -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 diff --git a/lib/memory.ml b/lib/memory.ml index cc5a18c..c21bb23 100644 --- a/lib/memory.ml +++ b/lib/memory.ml @@ -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 diff --git a/lib_test/memory/test.ml b/lib_test/memory/test.ml index 4a820a4..a1197d6 100644 --- a/lib_test/memory/test.ml +++ b/lib_test/memory/test.ml @@ -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) diff --git a/session.opam b/session.opam index b21004e..77ff51b 100644 --- a/session.opam +++ b/session.opam @@ -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"} ]