I have always maintained that it is perfectly legal to "jailbreak" or do anything I want with the iphone that I purchased. Now a legal ruling has affirmed this (for the US at least), thanks to the EFF. ^
http://www.gadgetsdna.com/jailbreaki...eral-law/5038/
Ditto for unlocking your phone.