Actually I think a much simpler approach could be used.
Just send a new TAN hash along with your TAN in the AM (the AT data state is persistent).
But then a hacker could send a new hash as well we he has stolen a TAN sucessfully.
echo "Tan 4: " . md5("Secret Key"). "
";;
echo "Tan 3: " . md5(md5("Secret Key",true)) . "
";
echo "Tan 2: " . md5(md5(md5("Secret Key",true),true)) . "
";
echo "Tan 1: " . md5(md5(md5(md5("Secret Key",true),true),true)) . "
";
echo "Hash delivered in AT: " . md5(md5(md5(md5(md5("Secret Key",true),true),true),true)) . "
";
?>
Tan 4: 5eb6bb157528b365f84c27bb4784031b
Tan 3: 60639a308365b50c6f531b0b05018210
Tan 2: 56600d988bbaa252ac565d57dd1fc686
Tan 1: 0355f7b531a7ccc9d4287b664f1da644
Hash delivered in AT: e2603ffd11ae2f4fce1aa84cb461f6d5
To check wheather the delivered Tan is vaild, the delivered Tan has to be hashed several times. When it results in the "Hash delivered in AT" then the TAN is valid.
But the first TAN you use is the first TAN. Because if you deliver TAN 4 then all other TANs will be known.
EDIT: TAN5=Secret Key