I'm going to echo the other answers and say you shouldn't wait at all. I'm going to go further and say that you shouldn't have waited at all (past tense). Until you have an offer in hand and signed, you don't have a job or even a pretense of a job. Always keep interviewing, no matter what, even if you have a deadline on the offer letter and they told you when it's coming, still keep interviewing. The company can always cancel the offer or cancel the position or come up with some other reason they can't hire you.
When they sent you the message that your references came back good and they would be in touch, your immediate next step should have been "ok, fine" and then continue to send out more applications or schedule additional interviews with other companies. Companies are always looking at applicants, so applicants should always be looking at companies, until you're locked in with an offer letter.
Get out there and keep going! And if this company comes back with their offer in a month from now after you've already accepted an offer with another company, simply send them back a note saying something to the effect of "sorry, you took too long replaying to me and I took another offer".
In fact, if they do end up coming back with an offer at all, I might grill them about this anyway: "You took 2 months (or whatever) to get me back an offer letter; why would I believe that you would respect my time when I join the company, and what assurances do I have that this won't happen again?" You don't want to work for a company where such a situation might happen with, for example, your paycheque, and you want to iron that out before you even consider signing any sort of offer letter; if the company is acting so unprofessionally at this stage, that's a huge red flag that they'll also act unprofessionally at later stages as well.