Under section 1201 of the Digital Millenium Copyright, it would be illegal to install a custom ROM or repair your phone without permission from the manufacturer.
However, the Copyright office get to make official exceptions to the law and they made an exception for jailbreaking a phone. I'm not sure about repairing or installing custom ROMs. Those might fall into different categories.