def otp_unlock(self):
if not self.hsm.version.have_unlock():<EOL><INDENT>return None<EOL><DEDENT>Params = PrimaryAdminYubiKey<EOL>YK = FakeYubiKey(pyhsm.yubikey.modhex_decode(Params[<NUM_LIT:0>]).decode('<STR_LIT>'),<EOL>Params[<NUM_LIT:1>].decode('<STR_LIT>'), Params[<NUM_LIT:2>].decode('<STR_LIT>')<EOL>)<EOL>YK.session_ctr = <NUM_LIT:0><EOL>use_ctr = <NUM_LIT:1> <EOL>while use_ctr < <NUM_LIT>:<EOL><INDENT>YK.use_ctr = use_ctr<EOL>otp = YK.from_key()<EOL>try:<EOL><INDENT>res = self.hsm.unlock(otp = otp)<EOL>self.assertTrue(res)<EOL>break<EOL><DEDENT>except pyhsm.exception.YHSM_CommandFailed as e:<EOL><INDENT>if e.status != pyhsm.defines.YSM_OTP_REPLAY:<EOL><INDENT>raise<EOL><DEDENT><DEDENT>use_ctr += <NUM_LIT:1><EOL><DEDENT>
Do OTP unlock of the YubiHSM keystore.

Since we don't always reprogram the YubiHSM, we might need to hunt for an unused OTP.