If you buy an Iphone that is unlock, is it illegal?

Or If you buy an Iphone then unlock it is that illegal?

It is currently illegal to unlock cell phones yourself but you can legally buy it unlocked from reputable sellers, such as Amazon and Apple.

Legislation is being introduced which will make it legal again so it's really no big deal.

Unlocking A New iPhone Is Now Illegal, But Jailbreaking Is Still Safe. Unlocking A New iPhone Is Now Illegal, But Jailbreaking Is Still Safe. It can be easy to get "unlocking" and "jailbreaking" confused, but the two terms mean totally different things. Unlocking refers to freeing your phone to work on any carrier instead of just the one you bought it on. Jailbreaking is the process of circumventing Apple's security measures in iOS to install tweaks, hacks, and mods that aren't allowed in the App Store.
The US Library of Congress has ruled that it is now illegal for you to unlock your smartphone if it was bought after January 26th, 2013. Carriers can still legally unlock your device for you, but it's illegal to go through a third-party unlock vendor.
Jailbreaking your iPhone has been kept legal through 2015 under an exemption in the Digital Millennium Copyright Act (DMCA). The crazy catch is that jailbreaking the iPad has technically been made illegal, while the iPhone and iPod touch both remain exempt. So jailbreaking is safe mostly, but unofficial unlocking is not. This is important to mention as the iOS 6.1 jailbreak approaches.

No, phones that are bought unlocked are perfectly legal. This is why they haven't stopped Apple from selling the iPhone 4, 4S & 5 unlocked themselves as they do.

It is illegal to buy a phone & unlock it yourself, if the phone was bought on or after the 26th Jan.