# Client-side self-service password-change tool over SSH.
#
# Same dlopen + libssh skeleton as opaque-ssh / opaque-register /
# opaque-unregister; only difference is the SPI used
# (gssspi_opaque_set_password_change, two passwords instead of one)
# and the resulting mode (3 = OPAQUE_MODE_PASSWORD_CHANGE). The plug-in
# emits TAG_PASSWORD_CHANGE_KE1 on the wire; the server runs a 4-iter
# (7-token) handshake — auth-leg via the OLD password, then a register-
# leg (MIC'd with the auth-leg session_key) for the NEW password —
# ending in an atomic_replace_file commit. See doc/design-notes.md
# "Password-change subprotocol design choice" (2026-05-17).

pkg_check_modules(LIBSSH REQUIRED IMPORTED_TARGET libssh)

add_executable(opaque-passwd opaque-passwd.c)

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

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

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