Implement key generate command and added duration argument to hsm_key_factory functions.