secure state machine