def program_otp(self, slot, public_id, private_id, key): try: key = a2b_hex(key) public_id = modhex_decode(public_id) private_id = a2b_hex(private_id) with self._open_device(TRANSPORT.OTP) as dev: controller = OtpController(dev.driver) controller.program_otp(slot, key, public_id, private_id) except YkpersError as e: return e.errno
def program_otp(self, slot, public_id, private_id, key): try: key = a2b_hex(key) public_id = modhex_decode(public_id) private_id = a2b_hex(private_id) with self._open_device(TRANSPORT.OTP) as dev: controller = OtpController(dev.driver) controller.program_otp(slot, key, public_id, private_id) return {'success': True, 'error': None} except YkpersError as e: if e.errno == 3: return {'success': False, 'error': 'write error'} return {'success': False, 'error': str(e)} except Exception as e: return {'success': False, 'error': str(e)}