def add_credential(self, name, key, oath_type, digits, algo, touch, password_key): dev = self._descriptor.open_device(TRANSPORT.CCID) controller = OathController(dev.driver) if controller.locked and password_key is not None: controller.validate(a2b_hex(password_key)) try: key = parse_b32_key(key) except Exception as e: return str(e) try: controller.put(key, name, oath_type, digits, algo=algo, require_touch=touch) except APDUError as e: # NEO doesn't return a no space error if full, # but a command aborted error. Assume it's because of # no space in this context. if e.sw == SW.NO_SPACE or e.sw == SW.COMMAND_ABORTED: return 'No space' else: raise
def add_credential(self, name, key, oath_type, digits, algo, touch, password_key): dev = self._descriptor.open_device(TRANSPORT.CCID) controller = OathController(dev.driver) if controller.locked and password_key is not None: controller.validate(a2b_hex(password_key)) try: key = parse_b32_key(key) except Exception as e: return str(e) controller.put(key, name, oath_type, digits, algo=algo, require_touch=touch)
def add_credential(self, name, secret, issuer, oath_type, algo, digits, period, touch): dev = self._descriptor.open_device(TRANSPORT.CCID) controller = OathController(dev.driver) self._unlock(controller) try: secret = parse_b32_key(secret) except Exception as e: return str(e) try: controller.put( CredentialData(secret, issuer, name, OATH_TYPE[oath_type], ALGO[algo], int(digits), int(period), 0, touch)) except APDUError as e: # NEO doesn't return a no space error if full, # but a command aborted error. Assume it's because of # no space in this context. if e.sw in (SW.NO_SPACE, SW.COMMAND_ABORTED): return 'No space' else: raise
def add_credential( self, name, secret, issuer, oath_type, algo, digits, period, touch): dev = self._descriptor.open_device(TRANSPORT.CCID) controller = OathController(dev.driver) self._unlock(controller) try: secret = parse_b32_key(secret) except Exception as e: return str(e) try: controller.put(CredentialData( secret, issuer, name, OATH_TYPE[oath_type], ALGO[algo], int(digits), int(period), 0, touch )) except APDUError as e: # NEO doesn't return a no space error if full, # but a command aborted error. Assume it's because of # no space in this context. if e.sw in (SW.NO_SPACE, SW.COMMAND_ABORTED): return 'No space' else: raise