Codebase list python-yubico / 9400308
Added zapping of slots. Dain Nilsson 8 years ago
1 changed file(s) with 11 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
9494 """
9595 Base class for configuration of all current types of YubiKeys.
9696 """
97 def __init__(self, ykver=None, capabilities=None, update=False, swap=False):
97 def __init__(self, ykver=None, capabilities=None, update=False, swap=False,
98 zap=False):
9899 """
99100 `ykver' is a tuple (major, minor) with the version number of the key
100101 you are planning to apply this configuration to. Not mandated, but
110111
111112 YubiKey >= 2.3 also supports swapping the configurations, making
112113 slot 1 be slot 2 and vice versa. Set swap=True for this.
114
115 YubiKeys support deleting a configuration, setting it in an
116 unprogrammed state. Set zap=True for this.
113117 """
114118 if capabilities is None:
115119 self.capabilities = yubikey_base.YubiKeyCapabilities(default_answer = True)
135139 self._require_version(major=2, minor=3)
136140 self._update_config = update
137141 self._swap_slots = swap
142 self._zap = zap
138143
139144 return None
140145
141146 def __repr__(self):
142 return '<%s instance at %s: mode %s, v=%s/%s, lf=%i, lu=%i, lk=%i, lac=%i, tf=%x, cf=%x, ef=%x, lu=%i, up=%s, sw=%s>' % (
147 return '<%s instance at %s: mode %s, v=%s/%s, lf=%i, lu=%i, lk=%i, lac=%i, tf=%x, cf=%x, ef=%x, lu=%i, up=%s, sw=%s, z=%s>' % (
143148 self.__class__.__name__,
144149 hex(id(self)),
145150 self._mode,
154159 len(self.unlock_code),
155160 self._update_config,
156161 self._swap_slots,
162 self._zap
157163 )
158164
159165 def version_required(self):
468474 if self._swap_slots:
469475 command = SLOT_SWAP
470476
477 if self._zap:
478 payload = b''
479
471480 return yubikey_frame.YubiKeyFrame(command=command, payload=payload)
472481
473482 def _require_version(self, major, minor=0):