Skip to main content

windows_sspi_shim/
lib.rs

1//! windows-sspi-shim — thin client-side wrapper over the Devolutions `sspi`
2//! crate. Given an SPN and (implicit) credentials it produces a
3//! [`SspiClient`] that can drive the Negotiate token exchange and, once
4//! established, a [`SealedContext`] with `seal`/`unseal` closures suitable
5//! for wiring into `dcerpc` packet_privacy and `ldap3` GSS-SPNEGO SASL.
6//!
7//! # Status
8//!
9//! **Pre-alpha, `0.1.0-dev`.** The API surface is stable in shape but the
10//! Negotiate/seal machinery is only partially implemented — see
11//! `src/negotiate.rs` for the exact stub boundaries. Only the current-user
12//! Windows Negotiate flow is targeted; non-Windows targets compile but every
13//! constructor returns [`Error::NotSupported`].
14//!
15//! # Example (target-agnostic)
16//!
17//! ```no_run
18//! use windows_sspi_shim::{SspiClient, NegotiateStep};
19//!
20//! # fn main() -> windows_sspi_shim::Result<()> {
21//! let mut client = SspiClient::for_spn("HOST/dc.example.com")?;
22//! let mut peer: Option<Vec<u8>> = None;
23//! loop {
24//!     match client.negotiate(peer.as_deref())? {
25//!         NegotiateStep::SendToken(tok) => {
26//!             // send `tok` to the peer, receive next blob into `peer`
27//!             # peer = Some(tok); break;
28//!         }
29//!         NegotiateStep::Complete => break,
30//!     }
31//! }
32//! # Ok(()) }
33//! ```
34
35#![deny(rust_2018_idioms)]
36#![warn(missing_debug_implementations)]
37
38mod error;
39mod negotiate;
40mod sealed;
41
42pub use error::{Error, Result};
43pub use negotiate::{NegotiateStep, SspiClient};
44pub use sealed::{SealedContext, SecPkgSizes};
45
46/// Crate version string, mirrors `Cargo.toml`.
47pub const VERSION: &str = env!("CARGO_PKG_VERSION");
48
49/// Whether this build has a real backend wired up. `false` on non-Windows and
50/// on Windows builds where the backend has been feature-disabled.
51pub const HAS_BACKEND: bool = cfg!(windows);