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