Fix input checks wrt legacy code
Fix input checks wrt legacy code

In all legacy code ctx->cipher is dereferenced without checks, so it
makes no sense to jump there is ctx->cipher is NULL as it will just lead
to a crash. Catch it separately and return an error.

This is simlar to the fix in d2c2e49eab69c7446c1c2c7227f63f8618ca99a5

Signed-off-by: Simo Sorce <simo@redhat.com>

Reviewed-by: Richard Levitte <5fb523282dd7956571c80524edc2dccfa0bd8234@openssl.org>
Reviewed-by: Paul Dale <bc4a6b4cd7a8395c734c8eb5aef04a9c30188c85@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/9002)

openssl/openssl,openssl/openssl,openssl/openssl,openssl/openssl,openssl/openssl,openssl/openssl