# Client-side self-service unregister tool over SSH.
#
# Same dlopen + libssh skeleton as opaque-ssh / opaque-register; only
# difference is the OPAQUE mode (2 = OPAQUE_MODE_UNREGISTER) passed to
# gssspi_opaque_set_password. The plug-in emits TAG_UNREGISTER_KE1 on
# the wire; the server runs the 3-round auth handshake and, on
# successful KE3 verification, atomically unlinks the per-user record.
#
# See GSSAPI_IMPLEMENTATION_PLAN.md §5.7 + the protocol description
# for the wire format and unlink commit point.

pkg_check_modules(LIBSSH REQUIRED IMPORTED_TARGET libssh)

add_executable(opaque-unregister opaque-unregister.c)

target_link_libraries(opaque-unregister PRIVATE
    PkgConfig::LIBSSH
    PkgConfig::GSSAPI
    PkgConfig::SODIUM
    ${CMAKE_DL_LIBS})

target_compile_definitions(opaque-unregister PRIVATE
    _POSIX_C_SOURCE=200809L
    OPAQUE_PLUGIN_DEFAULT_PATH="${CMAKE_INSTALL_FULL_LIBDIR}/gssopaque/gssopaque.so")

install(TARGETS opaque-unregister
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
