Better error handling in encrypt_ctx_init() and encrypt_ctx_setup_iv()