No, it isn't illegal. In fact, that's part of why custom firmware is so readily available, you can even find versions distributed through the PlayStation Network.