Exemplo n.º 1
0
 def slots_status(self):
     with self._open_device([OtpConnection]) as conn:
         session = YubiOtpSession(conn)
         state = session.get_config_state()
         slot1 = state.is_configured(1)
         slot2 = state.is_configured(2)
         ans = [slot1, slot2]
         return success({'status': ans})
Exemplo n.º 2
0
 def call():
     otp = session
     if need_reboot:
         protocol = session.backend.protocol
         if transport == TRANSPORT.NFC:
             protocol.connection.connection.disconnect()
             conn = protocol.connection
             conn.connection.connect()
         else:
             ManagementSession(protocol.connection).write_device_config(reboot=True)
             await_reboot()
             conn = connect_to_device(info.serial, [SmartCardConnection])[0]
         otp = YubiOtpSession(conn)
         session.backend = otp.backend
     return otp.get_config_state()
Exemplo n.º 3
0
def otp_info():
    lines = []
    lines.append("Detected YubiKeys over HID OTP:")
    for dev in list_otp_devices():
        lines.append(f"\t{dev!r}")
        with dev.open_connection(OtpConnection) as conn:
            lines.extend(mgmt_info(conn))
            otp = YubiOtpSession(conn)
            try:
                config = otp.get_config_state()
                lines.append(f"\tOTP: {config!r}")
            except ValueError as e:
                lines.append(f"\tCouldn't read OTP state: {e}")
        lines.append("")
    lines.append("")
    return lines