Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSSSP module #95

Merged
merged 28 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0178f70
sspi: ffi: handle credssp credentials
RRRadicalEdward Dec 16, 2022
989dc1f
sspi:
RRRadicalEdward Dec 16, 2022
4244da7
sspi: sspi_cred_ssp: implement CredSspState::NegoToken state
RRRadicalEdward Dec 16, 2022
759941a
sspi: sspi credssp: add tls encryption/decryption for the TsRequests
RRRadicalEdward Dec 17, 2022
3d618ce
sspi: ntlm: add more debug logs
RRRadicalEdward Dec 19, 2022
dc0ac6c
ffi: QueryContextAttributesW: add support of the following attributes:
RRRadicalEdward Dec 27, 2022
22233e3
QueryContextAttributes: implement SECPKG_ATTR_CERT_TRUST_STATUS and S…
RRRadicalEdward Jan 7, 2023
9e22b5c
tsspi finaly works under the mstsx
RRRadicalEdward Jan 13, 2023
3f51b3d
sspi: add doc comments, remove some (not all) debug logs
RRRadicalEdward Jan 13, 2023
d47813c
sspi: credssp: refactoring
RRRadicalEdward Jan 13, 2023
1b1ef64
sspi: sspi_cred_ssp: refactoring
RRRadicalEdward Jan 15, 2023
4e30a5c
ffi: refactoring
RRRadicalEdward Jan 15, 2023
129c0f7
sspi: add and implement Sspi::query_context_stream_sizes method;
RRRadicalEdward Jan 16, 2023
fc713c4
ffi: refactor AcquireCredentialsHandleW function: remove hardcoded cr…
RRRadicalEdward Jan 18, 2023
be009c2
ffi: refactoring
RRRadicalEdward Jan 19, 2023
af830bf
Merge branch 'master' into tsssp; fixed merge conflicts
RRRadicalEdward Jan 19, 2023
80e6a29
ffi: fix compilation on Linux
RRRadicalEdward Jan 19, 2023
a1e7f0b
sspi-rs & ffi: general refactoring
RRRadicalEdward Jan 20, 2023
f396fd3
sspi: SspiCredSsp: TlsConnection: fixed buffer length on TLS decrypt
RRRadicalEdward Jan 23, 2023
2cf1562
sspi & ffi: add doc comments about creds and sspi tables; small refac…
RRRadicalEdward Jan 25, 2023
d85b892
sspi: SspiCredSsp: improve conditional compilation
RRRadicalEdward Jan 25, 2023
70f5bba
sspi: add tsssp feature. improve conditional compilation
RRRadicalEdward Jan 25, 2023
a511e6d
ffi: add tsssp feature. sspi: improve tsssp feature
RRRadicalEdward Jan 25, 2023
c308584
run cargo fmt
RRRadicalEdward Jan 26, 2023
a9b950d
ffi: small refactoring
RRRadicalEdward Jan 26, 2023
629d553
ffi: add doc comment and link for the SEC_WINNT_AUTH_IDENTITY_EX2
RRRadicalEdward Jan 27, 2023
b605f8d
ci: fix Lints and Tests steps
CBenoit Jan 27, 2023
4f8c1bd
ffi: fix sec_pkj_info tests
RRRadicalEdward Jan 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ exclude = [
default = []
network_client = ["dep:reqwest", "dep:portpicker"]
dns_resolver = ["dep:trust-dns-resolver"]
# TSSSP should be used only on Windows as a native CREDSSP replacement
tsssp = ["dep:rustls"]

[dependencies]
byteorder = "1.2.7"
Expand Down Expand Up @@ -55,6 +57,7 @@ trust-dns-resolver = { version = "0.21.2", optional = true }
portpicker = { version = "0.1.1", optional = true }
num-bigint-dig = "0.8.1"
tracing = { version = "0.1.37" }
rustls = { version = "0.20.7", features = ["dangerous_configuration"], optional = true }

[target.'cfg(windows)'.dependencies]
winreg = "0.10"
Expand Down
5 changes: 4 additions & 1 deletion ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ crate-type = ["cdylib"]

[features]
debug_mode = ["dep:tracing", "dep:tracing-subscriber"]
tsssp = ["sspi/tsssp"]

[dependencies]
cfg-if = "0.1"
sspi = { path = "..", features = ["network_client", "dns_resolver"] }
libc = "0.2"
num-traits = "0.2"
whoami = "1.2.3"
sspi = { path = "..", features = ["network_client", "dns_resolver"] }

# For debugging only
tracing = { version = "0.1.37", optional = true }
tracing-subscriber = { version = "0.3.16", features = ["std", "fmt", "local-time", "env-filter"], optional = true }

[target.'cfg(windows)'.dependencies]
symbol-rename-macro = { path = "./symbol-rename-macro" }
winapi = "0.3.9"
windows-sys = { version = "0.42.0", features = ["Win32_Security_Authentication_Identity", "Win32_Security_Credentials", "Win32_Foundation"] }
6 changes: 4 additions & 2 deletions ffi/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ pub unsafe extern "system" fn DecryptMessage(
catch_panic! {
check_null!(ph_context);
check_null!(p_message);
check_null!(pf_qop);

let sspi_context = try_execute!(p_ctxt_handle_to_sspi_context(
&mut ph_context,
Expand All @@ -329,7 +328,10 @@ pub unsafe extern "system" fn DecryptMessage(
};

copy_to_c_sec_buffer((*p_message).p_buffers, &message, false);
*pf_qop = decryption_flags.bits().try_into().unwrap();
// `pf_qop` can be null if this library is used as a CredSsp security package
if !pf_qop.is_null() {
*pf_qop = decryption_flags.bits().try_into().unwrap();
}

try_execute!(result_status);

Expand Down
6 changes: 4 additions & 2 deletions ffi/src/sec_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use libc::c_char;
use libc::c_uint;
#[cfg(target_os = "windows")]
use libc::c_ulong;
use num_traits::FromPrimitive;
use num_traits::{FromPrimitive, ToPrimitive};
use sspi::{SecurityBuffer, SecurityBufferType};

#[cfg(target_os = "windows")]
Expand All @@ -18,6 +18,7 @@ pub struct SecBuffer {
}

#[cfg(not(target_os = "windows"))]
#[derive(Debug)]
#[repr(C)]
pub struct SecBuffer {
pub cb_buffer: c_uint,
Expand Down Expand Up @@ -66,7 +67,8 @@ pub(crate) unsafe fn copy_to_c_sec_buffer(to_buffers: PSecBuffer, from_buffers:
let buffer = &from_buffers[i];
let buffer_size = buffer.buffer.len();
to_buffers[i].cb_buffer = buffer_size.try_into().unwrap();
if allocate {
to_buffers[i].buffer_type = buffer.buffer_type.to_u32().unwrap();
if allocate || to_buffers[i].pv_buffer.is_null() {
let memory_layout = Layout::from_size_align_unchecked(buffer_size, 8);
to_buffers[i].pv_buffer = alloc(memory_layout) as *mut c_char;
}
Expand Down
Loading