From fec25c3a627bfbb14cf0aaf8773f54e0e5017517 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 3 Aug 2011 09:33:29 +1000 Subject: ntlmssp: Add ntlmssp_blob_matches_magic() This avoids having the same check in 3 different parts of the code Andrew Bartlett Autobuild-User: Andrew Bartlett Autobuild-Date: Wed Aug 3 12:45:04 CEST 2011 on sn-devel-104 --- libcli/auth/ntlmssp.c | 10 ++++++++++ libcli/auth/ntlmssp.h | 2 ++ 2 files changed, 12 insertions(+) (limited to 'libcli') diff --git a/libcli/auth/ntlmssp.c b/libcli/auth/ntlmssp.c index b7f14c153cc..4817329314a 100644 --- a/libcli/auth/ntlmssp.c +++ b/libcli/auth/ntlmssp.c @@ -132,3 +132,13 @@ void ntlmssp_handle_neg_flags(struct ntlmssp_state *ntlmssp_state, ntlmssp_state->neg_flags |= NTLMSSP_REQUEST_TARGET; } } + +/* Does this blob looks like it could be NTLMSSP? */ +bool ntlmssp_blob_matches_magic(const DATA_BLOB *blob) +{ + if (blob->length > 8 && memcmp("NTLMSSP\0", blob->data, 8) == 0) { + return true; + } else { + return false; + } +} diff --git a/libcli/auth/ntlmssp.h b/libcli/auth/ntlmssp.h index 495d94f6a03..cf8bb8dd301 100644 --- a/libcli/auth/ntlmssp.h +++ b/libcli/auth/ntlmssp.h @@ -169,3 +169,5 @@ NTSTATUS ntlmssp_unwrap(struct ntlmssp_state *ntlmssp_stae, const DATA_BLOB *in, DATA_BLOB *out); NTSTATUS ntlmssp_sign_init(struct ntlmssp_state *ntlmssp_state); + +bool ntlmssp_blob_matches_magic(const DATA_BLOB *blob); -- cgit v1.2.1