Skip to content

CCM mode: assertion failure when a short nonce is used #167

@emillon

Description

@emillon

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions