As of just a few days ago, unlocking your iPhone, or any other wireless device for that matter, is no longer legal. The EFF (Electronic Frontier Foundation) has stepped forward to clarify exactly what that means and who it ultimately will affect. As it turns out, it isn't necessarily the end user that would be violating the law.
According to a report by 9to5Mac, it's actually the unlockers themselves that will most likely be affected according to the Electronic Frontier Foundation.
More likely, wireless carriers, or even federal prosecutors, will be emboldened to sue not individuals, but rather businesses that unlock and resell phones.
Basically, wireless carriers and big business aren't going to go after the end user. If you purchased an unlock from a site on the internet and you're walking around with an illegally unlocked phone, the odds of you getting in trouble for that are almost invisible. The liability would mainly lie on the company that provided the unlock to you.
Carriers such as AT&T will unlock your iPhone for you once you've fulfilled the commitment term of your contract. This can be done by completing the full term or upgrading to a new iPhone or other device, which in turn would allow your older iPhone to be unlocked legally.
As for jailbreak, that's still legal under the DMCA (Digital Millenium Copyright Act).
The legal shield for jailbreaking and rooting your phone remains up – it’ll protect us at least through 2015.
It's also worth noting that any device that was purchase before the new rule went into affect is still fair game. So if you've purchased an iPhone or other mobile device before that date, you're still legally entitled to unlock it, whether that's officially through your carrier or any other outlet.