Thanks for the detailed explanation. The DNS part is irrelevant as this is imap specific. Seems like you were right and that crypt() function is responsible.
Maybe check this article, which seems to the point:
Check if your Dovecot is 2.3.x as our friend here suggests, and if it is not, then you got the case. I see others have find the solution with these steps, so take a look.