mbedtls_cipher functions return 0 in invalid scenarios #5323
Labels
api-break
This issue/PR breaks the API and must wait for a new major version
bug
component-crypto
Crypto primitives and low-level interfaces
size-s
Estimated task size: small (~2d)
If you call
mbedtls_cipher_update_ad
ormbedtls_cipher_write_tag
ormbedtls_cipher_check_tag
on a non-AEAD algorithm, they return 0. This looks wrong: surely it's an application error, and it's easily detectable, so we should returnMBEDTLS_ERR_CIPHER_INVALID_CONTEXT
orMBEDTLS_ERR_CIPHER_BAD_INPUT_DATA
?Our unit tests indiscriminately call these functions on non-AEAD algorithms though. Is this just a test bug or is this deliberate? The documentation doesn't say anything explicit.
Similar pattern with
mbedtls_cipher_set_iv
on ECB.Since the unit tests validate the current behavior, if we change it, we should probably not change LTS branches.
Note: moot if we remove cipher.h as a public API.
The text was updated successfully, but these errors were encountered: