Agreed. One advantage the NSA has is it can pay some of the best mathematicians to be full-time pure mathematicians. There are very few mathematicians that have the opportunity to do something like that -- even professors have to teach a few classes. I imagine it's a powerful draw to top talent and gives them the ability to spend more time on a problem than most others.
You would be recognized inside the NSA, a large technical population.
In addition, as with the CIA and other clandestine US government organizations, they appeal to patriotism and helping the national interest. That appeal seems to be fraying somewhat lately for the NSA.
Though I have no first-hand knowledge, I was under the impression that organizations like the NSA have internal peer-reviewed journals that their mathematicians can "publish" in, while remaining classified and unavailable to the public.
I have a friend who interned with the NSA in high school. Although what he did is classified, he was allowed to say that his work got published internally.
This is basically just a small step worse than many professions. Once you hit the pay wall on journal articles you want to read, how many people pay to go through?
Not everyone works for public recognition. There are enough people who are willing to work on neat problems in exchange for plenty of money who are also willing to forgo public recognition.
Never is a long time, in a decade or two you might be. BUT either way, some very brilliant NSA mathematicians know what you came up with and so do you. That's enough for a lot of people.