In the first case they (the US govmnt) could hold him (the citizen) in contempt (in a cell) indefinitely.

That’s false. Maybe a few hours but that’s it. The CBP are expressly not allowed to deny citizens entry into the US.

18 months is, by precedent, the limit on contempt for refusal to decrypt[0], but this administration is happy to disregard any precedent that does not agree with them.

[0] https://arstechnica.com/tech-policy/2020/02/man-who-refused-...

Actually no, they are required to allow you to enter the country, but they will make it a hassle, to the point of dehydrating you and/or refusing bathroom access, and confiscate the device in the end and access is through other technical means.