Hi,
When encrypting in CCM mode, if the nonce is too short, it triggers an assertion failure.
In contrast, the corresponding error message when decrypting is a nicer invalid_arg "CCM: nonce length %d" nsize.
let () =
let key =
Nocrypto.Cipher_block.AES.CCM.of_secret ~maclen:16 (Cstruct.create 16)
in
let nonce = Cstruct.empty in
ignore (Nocrypto.Cipher_block.AES.CCM.encrypt ~key ~nonce Cstruct.empty)
Output:
Fatal error: exception "Assert_failure src/ccm.ml:8:2"
Thanks!