Yes, CD key generators are illegal to use — they generate unauthorized license keys, which is a form of software piracy. On top of the legal issues, key-gen programs are a notorious vehicle for malware, so they're best avoided entirely.