Sanity check keys.

Taken from RFC 3447.