RSA key pair generation and FIPS 140-2, 186-4 I need to securely generate RSA key pair and I need to have access to private exponent in order to process it further.

What's the difference in FIPS 140-2 and FIPS 186-4 in connection with RSA key pair generation?

If I understand it correctly generating RSA key pair in FIPS 140-2 compliant environment will never show the private part of the RSA key pair as it is protected by cryptographic module.

FIPS 186-4 is about validating that RSA key pair was correctly generated and fulfils requirements about primes and exponents.

So if I want to securely generate RSA key pair and I want to have access to its private part in a clear-text form, I need to use FIPS 186-4 compliant generation and validation.

Am I correct? Do I understand these correctly?
FIPS 140-2 specifies conditions applicable to the environment of RSA (and other) key generation, and refers to FIPS 186-4 for the generation itself.

Several recent Java Card Smart Cards can internally generate RSA-2048 key pairs per FIPS 186-4, with security policy and FIPS 140-2 level 3 certificate to attest that. Here is the one on top of the list at time of writing. A trivial Java Card applet runnign in that Smart Card's Java Card Virtual Machine can generate such RSA key, and export the private key, in clear if you want that. Such key would be for a FIPS-approved algorithm (certs# 1506-1507), and generated according to FIPS 186-4, as attested by a FIPS 140-2 level 3 certificate. That's not enough to pretend that the key was generated in a FIPS 140-2 compliant environment, because the security policy mentions


"The module is a limited operational environment under the FIPS 140-2 definitions";
accordingly the FIPS 140-2 level 3 certificate does not cover "operation environment";
"firmware loaded into this module (..) requires a separate FIPS 140-2 validation" where my reading is that this sentence applies to Java Card applets.


However a (less trivial) Java Card applet could "securely generate RSA key pair (with) access to private exponent in order to process it further" (as asked), for some definition of process like encryption of the private key under a master public key (a form of key escrow). I do not rule out that a FIPS 140-2 validation of that applet could be obtained, such that it would then be correct to tell that the RSA key pair was generated in a FIPS 140-2 validated environment.