8 USC 1645 – Qualifying quarters
For purposes of this chapter, in determining the number of qualifying quarters of coverage under title II of the Social Security Act [42 U.S.C. 401 et seq.] an alien shall be credited with—
(1) all of the qualifying quarters of coverage as defined under title II of the Social Security Act worked by a parent of such alien before the date on which the alien attains age 18, and
(2) all of the qualifying quarters worked by a spouse of such alien during their marriage and the alien remains married to such spouse or such spouse is deceased.
No such qualifying quarter of coverage that is creditable under title II of the Social Security Act for any period beginning after December 31, 1996, may be credited to an alien under paragraph (1) or (2) if the parent or spouse (as the case may be) of such alien received any Federal means-tested public benefit (as provided under section 1613 of this title) during the period for which such qualifying quarter of coverage is so credited. Notwithstanding section 6103 of title 26, the Commissioner of Social Security is authorized to disclose quarters of coverage information concerning an alien and an alien’s spouse or parents to a government agency for the purposes of this chapter.