@@ -171,8 +171,7 @@ module Auth = struct
171
171
172
172
let digest s =
173
173
(* string -> sha256 as a hex string *)
174
- Mirage_crypto.Hash. (digest `SHA256 (Cstruct. of_string s))
175
- |> Compat. cstruct_to_hex_string
174
+ Digestif.SHA256. (digest_string s |> to_hex)
176
175
177
176
let make_amz_headers ?body time =
178
177
(* Return x-amz-date and x-amz-sha256 headers *)
@@ -239,16 +238,12 @@ module Auth = struct
239
238
Printf. sprintf " AWS4-HMAC-SHA256\n %s\n %s\n %s" time_str scope_str hashed_req
240
239
241
240
let make_signing_key ?date ~region ~service ~secret_access_key () =
242
- let mac k v =
243
- Mirage_crypto.Hash. (mac `SHA256 ~key: k (Cstruct. of_string v))
244
- in
241
+ let mac k v = Digestif.SHA256. (hmac_string ~key: k v |> to_raw_string) in
245
242
let date' =
246
243
match date with None -> Date. today ~zone: Time.Zone. utc | Some d -> d
247
244
in
248
245
let date_str = Date. to_string_iso8601_basic date' in
249
- let date_key =
250
- mac (Cstruct. of_string (" AWS4" ^ secret_access_key)) date_str
251
- in
246
+ let date_key = mac (" AWS4" ^ secret_access_key) date_str in
252
247
let date_region_key = mac date_key (string_of_region region) in
253
248
let date_region_service_key =
254
249
mac date_region_key (string_of_service service)
@@ -278,14 +273,12 @@ module Auth = struct
278
273
(string_of_service service)
279
274
in
280
275
let signature =
281
- Mirage_crypto.Hash. (
282
- mac `SHA256 ~key: signing_key (Cstruct. of_string string_to_sign))
276
+ Digestif.SHA256. (hmac_string ~key: signing_key string_to_sign |> to_hex)
283
277
in
284
278
let auth_header =
285
279
Printf. sprintf
286
280
" AWS4-HMAC-SHA256 Credential=%s,SignedHeaders=%s,Signature=%s" creds
287
- signed_headers
288
- (Compat. cstruct_to_hex_string signature)
281
+ signed_headers signature
289
282
in
290
283
[ (" Authorization" , auth_header) ]
291
284
end
0 commit comments