The reason I'm not jumping into this is because I think this is #2 behind only 9-11 as a hot-button topic. As soon as one thread dies, another pops up. I have cut & paste 9-11 stuff saved with NOTEPAD on my computer. Maybe I need to do the same with IFF and "Off codes" stuff.
The simple way to look at IFF is this: It's like an encoded air traffic transponder. A Transponder sits there idle until it is "interrogated" by a signal, which 90% of the time is piggybacked onto a radar. The standard transponder is what air traffic control (ATC) uses to monitor aircraft movement, NOT raw skin paint returns. A military IFF is much the same, except the unit is encoded with a rotating code which can be changed at any time.
For example, headquarters USAF says "The IFF code for 15 September is 'fji7f87hu98w89476' " This code is loaded into a box; crew chiefs take this thing (think of it like a USB thumb drive) and encode their jets. Theoretically, all friendly airplanes flying around on 15 Sep. have fji7f87hu98w89476 in their IFF.
I'm in my F-15, and I lock up a suspicious target. I mash the IFF button. My radar signal asks the target 2 things... "Do you have IFF on board? And if you do, what code do you have?" The target IFF responds to the signal, and sends the code fji7f87hu98w89476 back to me. So I know this guy is friendly. Let's say the target sends back hjkd8g6674jjf7, an incorrect code. I can tell he has our style of IFF on board, but he's got the wrong code. Is he enemy, spoofing me? I don't know.
The target can also simply turn off his IFF. In that case, I'll get no return at all.
IFF is not a guaranteed thing. Battle damage can cause IFF failure. So can plain old malfunction. Lack of IFF does not automatically mean I can shoot. It depends upon the ROE. In real life, a large number of factors come into play. Does AWACS have any idea? Did they take off from a known enemy base? etc.
IFF is considered "Co-operative target recognition" and is only one tool among many. There is also "NCTR" non co-operative target recognition, which is cosmic and secret stuff to identify a target without using any form of transponder.
What IFF is NOT... it is not a magic device, it cannot turn a weapons system on or off, it is useful only on like systems. For example, there is no Co-operative target recognition between F-22's and Su-27's, unless installed by 3rd parties onto both airplanes. The reality of IFF is much more complex than what I've described, and it is never relied upon 100%.
And no, there's no IFF on an AIM-9.