How do Star Fleet officers command the computer? Sometimes they just speak commands, other times they also add a code like "Picard epsilon 7 9 3".
I presume the computer authenticates commands by voice recognition (now a real world technology). However that's vulnerable to replay attack (someone could record a command voiced by Picard, then play it back later).
Is that why they use the keys? If they were single use, that would thwart a replay attack. I guess they must be one-time only, else Picard wouldn't say his key loudly on the bridge.
In Ship in a Bottle Moriarty conducts a man in the middle attack. Picard believes he is giving his code to the Enterprise's computer, but he is really in conversation with the sim-Enterprise created by Moriarty. Moriarty then using Picard's code to take command of the real Enterprise. Does Star Fleet ever introduce a defence against that?