Apple recently released the new version of the firmware. The latest version is 3.1.2 and is unlockable via PwnageTool v3.1.4.
Do not try to update the iPhone with these firmwares, else you’ll loose unlock. Use PwnageTool to create a custom ipsw using these firmwares, the upgrade your iPhone using the new custom ipsw files.
Here are the direct download links for iPhone 3.1.2 firmware:
iPhone 3GS: Download
iPhone 3G: Download
iPhone 2G: Download