security: In generateKeyPair, explicitly check for a valid keyType.