Better error handling in encrypt_ctx_init() and encrypt_ctx_setup_iv() 36/232936/5
authorLukasz Pawelczyk <l.pawelczyk@samsung.com>
Fri, 8 May 2020 08:38:43 +0000 (10:38 +0200)
committerLukasz Pawelczyk <l.pawelczyk@samsung.com>
Fri, 26 Jun 2020 15:36:20 +0000 (17:36 +0200)
commit83386931220dbe26f558e7607fec16c20723e64b
tree1b7d93be2b0e14e4598992d5cdbfda3777b500b1
parent5229a9c1aba388d85bdb018bd381567694c90ee0
Better error handling in encrypt_ctx_init() and encrypt_ctx_setup_iv()

Some calls to encrypt_ctx_init() and encrypt_ctx_setup_iv() asserts
their return code that it cannot be EINVAL. But the OpenSSL functions
there (namely EVP_CIPHER_CTX_set_key_length() and EVP_CIPHER_CTX_ctrl)
can fail because of other reasons. Handle this properly.

Side effect of this change is that while setting wrong IVLEN for CCM
it's impossible to distinguish error codes, as OpenSSL does not set
them in most cases. Handle this internally.

Change-Id: Ib82871c8f4bf348c9ff4b90467886edcc19f6f9e
src/debug.c
src/encrypt.c