def _change_mode(self, mode, major, minor): """ Change mode of operation, with some sanity checks. """ if self._mode: if self._mode != mode: raise RuntimeError('Can\'t change mode (from %s to %s)' % (self._mode, this_mode)) self._require_version(major=major, minor=minor) self._mode = mode # when setting mode, we reset all flags self.ticket_flags = YubiKeyConfigBits(0x0) self.config_flags = YubiKeyConfigBits(0x0) self.extended_flags = YubiKeyConfigBits(0x0) self.ticket_flag(mode, True)
def __init__(self, ykver=None, capabilities=None, update=False, swap=False): """ `ykver' is a tuple (major, minor) with the version number of the key you are planning to apply this configuration to. Not mandated, but will get you an exception when trying to set flags for example, rather than the YubiKey just not operating as expected after programming. YubiKey >= 2.3 supports updating certain parts of a configuration (for example turning on/off APPEND_CR) without overwriting others (most notably the stored secret). Set `update' to True if this is what you want. The current programming must have flag 'ALLOW_UPDATE' set to allow configuration update instead of requiring complete reprogramming. YubiKey >= 2.3 also supports swapping the configurations, making slot 1 be slot 2 and vice versa. Set swap=True for this. """ if capabilities is None: self.capabilities = yubikey.YubiKeyCapabilities( default_answer=True) else: self.capabilities = capabilities # Minimum version of YubiKey this configuration will require self.yk_req_version = (0, 0) self.ykver = ykver self.fixed = '' self.uid = '' self.key = '' self.access_code = '' self.ticket_flags = YubiKeyConfigBits(0x0) self.config_flags = YubiKeyConfigBits(0x0) self.extended_flags = YubiKeyConfigBits(0x0) self.unlock_code = '' self._mode = '' if update or swap: self._require_version(major=2, minor=3) self._update_config = update self._swap_slots = swap return None
def __init__(self, ykver=None): # Minimum version of YubiKey this configuration will require self.yk_req_version = (1, 3) self.ykver = ykver self.fixed = '' self.uid = '' self.key = '' self.access_code = '' self.ticket_flags = YubiKeyConfigBits(0x0) self.config_flags = YubiKeyConfigBits(0x0) self.extended_flags = YubiKeyConfigBits(0x0) self.unlock_code = '' self._mode = '' return None