This commit is contained in:
swrup 2026-02-13 09:34:03 +01:00
parent 6670b763f3
commit cdd490fbb8
6 changed files with 33 additions and 0 deletions

View file

@ -35,6 +35,7 @@
bin
angstrom
mirage-crypto
kdf
digestif
duration
jsont

View file

@ -22,6 +22,7 @@ depends: [
"bin"
"angstrom"
"mirage-crypto"
"kdf"
"digestif"
"duration"
"jsont"

View file

@ -17,6 +17,7 @@
caqti-driver-pgx
bin
mirage-crypto
kdf.hkdf
digestif
duration
vif

9
src/fdh.ml Normal file
View file

@ -0,0 +1,9 @@
module Kdf = struct
module XTR = Hkdf.Make (Digestif.SHA512)
module PRF = Hkdf.Make (Digestif.SHA256)
let kdf ~xts ~ikm ~ctx ~len =
let prk = XTR.extract ~salt:xts ikm in
let okm = PRF.expand ~prk ~info:ctx len in
okm
end

0
src/rsa.ml Normal file
View file

View file

@ -73,3 +73,24 @@ let () =
in
()
let () =
(* kdf *)
let salt = "94KPT83PCNS7J83KC5P78Y8" in
let ikm = "94KPT83MD1JJ0WV5CDS6AX10D5Q70XBM41NPAY90DNGQ8SBJD5GPR" in
let ctx =
"94KPT83141HPYVKMCNW78833D1TPWTSC41GPRWVF41NPWVVQDRG62WS04XMPWSKF4WG6JVH0EHM6A82J8S1G"
in
let out_len = 64 in
let out =
"GTMR4QT05Z9WF5HKVG0WK9RPXGHSMHJNW377G9GJXCA8B0FEKPF4D27RJMSJZYWSQNTBJ5EYVV7ZW18B48Z0JVJJ80RHB706Y96Q358"
in
let xts = salt |> decode in
let ikm = ikm |> decode in
let ctx = ctx |> decode in
let okm = Fdh.Kdf.kdf ~xts ~ikm ~ctx ~len:out_len in
let okm = okm |> encode in
assert (okm = out);
()