Add sanity checks when generating new RSA keys.

The key size should be a multiple of 8 bits, and it should be between 1024 and
8192 bits.