def unlock(self, password = None, otp = None):
if otp is not None and not self.version.have_unlock():<EOL><INDENT>raise pyhsm.exception.YHSM_Error("<STR_LIT>")<EOL><DEDENT>if password is not None:<EOL><INDENT>if self.version.have_key_storage_unlock():<EOL><INDENT>res = pyhsm.basic_cmd.YHSM_Cmd_Key_Storage_Unlock(self.stick, password).execute()<EOL><DEDENT>elif self.version.have_key_store_decrypt():<EOL><INDENT>res = pyhsm.basic_cmd.YHSM_Cmd_Key_Store_Decrypt(self.stick, password).execute()<EOL><DEDENT>else:<EOL><INDENT>raise pyhsm.exception.YHSM_Error("<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>res = True<EOL><DEDENT>if res and otp is not None:<EOL><INDENT>(public_id, otp,) = pyhsm.yubikey.split_id_otp(otp)<EOL>public_id = pyhsm.yubikey.modhex_decode(public_id).decode('<STR_LIT>')<EOL>otp = pyhsm.yubikey.modhex_decode(otp).decode('<STR_LIT>')<EOL>return pyhsm.basic_cmd.YHSM_Cmd_HSM_Unlock(self.stick, public_id, otp).execute()<EOL><DEDENT>return res<EOL>
Unlock the YubiHSM using the master key and/or a YubiKey OTP.

If the master key is given during configuration, all key handles will be
encrypted (with AES-256) using that passphrase.

If one or more admin Yubikey public id's are given during configuration,
an OTP from one of these must be provided to the YubiHSM for it to start
responding to cryptographic requests. The admin YubiKeys must be present
in the internal database for this validation to work.

@param password: The 'master key' set during YubiHSM configuration
@type password: NoneType or string
@param otp: A YubiKey OTP from an 'admin' YubiKey (modhex), to unlock YubiHSM.
@type otp: NoneType or string

@returns: Only returns (True) on success
@rtype: bool

@see: L{pyhsm.basic_cmd.YHSM_Cmd_Key_Storage_Unlock}
@see: L{pyhsm.basic_cmd.YHSM_Cmd_HSM_Unlock}