Code to thread-safety in ChangeCipherState