Hi cap51!
The SSA website states that they make their calculations based on the wages you earn. They make no mention of whether the wages have been invested in a 401 or other tax-deferred account.
Here's a table that shows how they calculate the reduction in benefits for those who are working and younger than the normal retirement age:
I thought I would add an additional comment here. As I interpret this, your earnings would be directed to your 401k, thereby deferring your "income" tax. But you are not deferring your social security and medicare taxes. You are still paying into the SS fund with these 401k wages. So, you could potentially be increasing your SS income with these contributions. I know that wasn't your original question, but I think it is good to know this.
Good luck,
Kelly C, CPA