What kind of tests can be performed on a public key to check if it is likely a valid key? The tests should be relatively fast – i.e. not computationally intensive – and not include modular exponentiation.
I’m asking this question as developers generally work (or should work) on the principle of fail fast, in which an error is thrown as soon as it can be detected.
As an example I could indicate that the public key should not include negative integers for the modulus and public exponent. Please assume that the RSA public key consists of two integer values; encoding related problems should be ignored.