Skip to content

Commit

Permalink
Add 32 bit ccm test case
Browse files Browse the repository at this point in the history
  • Loading branch information
reynir committed Feb 27, 2024
1 parent 3ebc0e3 commit cebe7a1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/test_cipher.ml
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,16 @@ let ccm_regressions =
match authenticate_decrypt ~key ~nonce ~adata cipher with
| Some x -> assert_cs_equal ~msg:"CCM decrypt of empty message" p x
| None -> assert_failure "decryption broken"
and long_adata _ =
let key = of_secret (vx "000102030405060708090a0b0c0d0e0f")
and nonce = vx "0001020304050607"
and plaintext = Cstruct.of_string "hello"
(* [adata] is greater than [1 lsl 16 - 1 lsl 8] *)
and adata = Cstruct.create 65280
and expected = vx "6592169e946f98973bc06d080f7c9dbb493a536f8a"
in
let cipher = authenticate_encrypt ~adata ~key ~nonce plaintext in
assert_cs_equal ~msg:"CCM encrypt 32 bit" expected cipher
in
[
test_case no_vs_empty_ad ;
Expand All @@ -389,6 +399,7 @@ let ccm_regressions =
test_case short_nonce_enc3 ;
test_case long_nonce_enc ;
test_case enc_dec_empty_message ;
test_case long_adata ;
]

let gcm_regressions =
Expand Down

0 comments on commit cebe7a1

Please sign in to comment.