Access `group->mont_data` conditionally in EC_GROUP_set_generator()
It appears that, in FIPS mode, `ec_precompute_mont_data()` always failed
but the error was ignored until commit
e3ab8cc from #6810.
The actual problem lies in the fact that access to the `mont_data` field
of an `EC_GROUP` struct should always be guarded by an
`EC_GROUP_VERSION(group)` check to avoid OOB accesses, because `group`
might come from the FIPS module, which does not define the `mont_data`
field inside the EC_GROUP structure.
This commit adds the required check before any access to
`group->mont_data` in `EC_GROUP_set_generator()`.
Fixes #7127
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/7135)