Does FIPS 140-2 require specific key sizes, or does it have specific requirements for the data? In other words, if I encrypt a file, how I can check whether it is FIPS-compliant or not? Does only the key need to be checked, or does the encrypted file have to be checked too? If yes, is it possible to elaborate on how to check an encrypted file for FIPS compliance?
FIPS 140-2 only certifies cryptographic modules, not entire systems. So, to tell if your system is 140-2 compliant, it must be using a 140-2 certified module. NIST publishes a list of all FIPS 140-2 certified cryptographic modules.
It is important to remember, though, that 140-2 certification does not certify that the module is used in a secure manner. From the FIPS 140-2 document:
Similarly, the use of a validated cryptographic module in a computer or telecommunications system is not sufficient to ensure the security of the overall system.
Looking over the document, I don't see anything on specific key sizes. It discusses key management, including key storage. So you'd have to make sure keys are stored properly. I don't see anything in the document about requirements on the data which is to be encrypted. That makes sense though as you would want your module to be data agnostic.
So, there is no way to look at an encrypted file and tell if it is FIPS 140-2 compliant. You would have to look at the module that did the encrypting.
You cannot tell anything related to FIPS 140 by looking at a key or by looking at a file. FIPS 140 doesn't say anything about the choice of encryption algorithm, other than requiring that all every encryption algorithm must be “approved security function” (as defined in the glossary) and there must be at least 1.
FIPS 140 is all about the module, i.e. the software or hardware component that performs the encryption and decryption. The standard sets security requirements for how keys are stored, how access to keys is controlled and so on.
If you have an encrypted file, you cannot tell whether it was encrypted by a FIPS 140-compliant module or not: an encrypted file looks like any other encrypted file produced from the same plaintext with the same key no matter who or what performed the encryption. If you have a key, you cannot tell whether that key is used in a FIPS 140-compliant module or not; although if you can access the key outside the module, it's likely that either the module isn't compliant — because it shouldn't let keys escape — or an authorized operator misused the module and let the key leak. There is only a way to be sure that a key or encrypted file did not come from a FIPS 140-compliant module, which is if the key or algorithm is not one of the approved security functions (as defined in other standards).