On-chip security circuit for protection against hardware tampering