The problem is far easier to analyze. Let's take a look at the premises:
1. The enemy is able and willing to use torture and is able and willing to employ it to reach its goal.
2. You are a human being, able to feel pain, with a finite amount of willpower to resist torture, and unable to escape in a way that is favorable for you.
That's it. And no matter what else happens, it ends in a "don't care" position.
Whether you have that key does not matter. Because handing that key over does not end the torture, because if, in what way and for how long torture is applied is not within your control in any way. Yes, of course your torturer will promise you that it ends if you hand over what he wants, but do I really want to trust the word (because that is ALL I have, it's not like there's an enforceable contract between him and me) of someone willing to inflict pain upon me?
The torture ends only if your tormentor decides he wants to. This has little, if anything, to do with you handing over anything he wants.