Skip to content

Commit

Permalink
ccm: do not clobber tag (as remarked by @reynir)
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesm committed Mar 19, 2024
1 parent fb601c8 commit 906d5a0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/ccm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ let generation_encryption ~cipher ~key ~nonce ~maclen ~adata data =
let decryption_verification ~cipher ~key ~nonce ~maclen ~adata ~tag data =
valid_nonce nonce;
let cdata, t = crypto_core ~cipher ~mode:Decrypt ~key ~nonce ~maclen ~adata data in
crypto_t tag nonce cipher key ;
(* needs a eqaf release *)
match Eqaf.equal (Bytes.unsafe_to_string tag) (Bytes.unsafe_to_string t) with
crypto_t t nonce cipher key ;
match Eqaf.equal tag (Bytes.unsafe_to_string t) with
| true -> Some (Bytes.unsafe_to_string cdata)
| false -> None
1 change: 0 additions & 1 deletion src/cipher_block.ml
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@ module Modes = struct
cdata ^ ctag

let authenticate_decrypt_tag ~key ~nonce ?(adata = "") ~tag cs =
let tag = Bytes.of_string tag in
Ccm.decryption_verification ~cipher ~key ~nonce ~maclen:tag_size ~adata ~tag cs

let authenticate_decrypt ~key ~nonce ?adata data =
Expand Down

0 comments on commit 906d5a0

Please sign in to comment.