PyTomCrypt icon indicating copy to clipboard operation
PyTomCrypt copied to clipboard

Unhelpful error messages

Open mikeboers opened this issue 11 years ago • 3 comments

From @parke:

I switched from ctr mode to cbc mode, and got this error:

tomcrypt.LibError: Invalid argument provided.

I guess CBC mode needs the input to be a multiple of the block size. A more descriptive error message would have been helpful.

mikeboers avatar Aug 29 '13 05:08 mikeboers

A quicker (interim?) fix would be to document which ciphers require block length inputs.

parke avatar Aug 29 '13 16:08 parke

That is something that can be easily done.

In general, I would like to rework the error handling. Specifically, I think I would like to build a new exception tree, instead of just having Error and LibError.

At the most extreme, we would have an exception for each of the 2 dozen(ish) errors that the libtomcrypt gives us, and they would also inherit from the standard exceptions (usually ValueError or RuntimeError) as appropriate.

mikeboers avatar Aug 29 '13 18:08 mikeboers

For reference, the modes which require a block sized input are: ecb, cbc, and lrw.

mikeboers avatar Aug 29 '13 18:08 mikeboers