Beliefs can't possibly be legal or illegal since they can't be chosen. I guess what's really illegal is voicing them, eh?
The fool hath said in his heart, There is a God. They are corrupt, they have done abominable works, there is none that doeth good.
Psalm 14, KJV revised edition