While Apple has released iOS 4.0.2 for iPhone 4, 3GS and 3G, the important thing is that they haven’t updated the baseband. What this means is that 05.13.04 baseband which accompanies iOS 4.0.2 is still unlockable with ultrasn0w provided that you manage to jailbreak your iOS device. At the moment, only iPhone 3G and iPod touch 2G (Non-MC model) can be jailbroken on this latest firmware using the latest version of Redsn0w. So technically, you can only unlock iPhone 3G on iOS 4.0.2.
The steps for unlocking are as follows.
Step 1: First up, you will need to jailbreak your iPhone 3G on iOS 4.0.2 with Redsn0w. Full step by step guide is posted here.
Step 2: Since Redsn0w doesn’t hacktivate iPhone 3G, you will need to first activate it using original official supported carrier SIM, or the phonebook SIM card trick, guide for which can be found here.
Step 3: Once activated, you can now unlock your iPhone 3G to run it on any carrier you like by unlocking it using ultrasn0w from Cydia. Steps for installing ultrasn0w can be found here.