Add checks to verify correctness of RSA/DSA keys

When the various components are assembled into an RSA
or a DSA key via the construct() method, we must verify
as much as possible if the result is indeed a valid key.