Just because a law gets passed by statute doesn't mnake it legal. Lots of legislation get overturned as unconstitutional. That means it wasn't legal all along.
But, unless the law banning something is unconstitutional, once it's passed, that thing is illegal.