From 3b63a6794a008b35cd7b5bc03bcc9e4f8d4124a4 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 11 Jun 2012 13:12:30 +0200 Subject: S3: Add ntlmssp_set_password_hash Signed-off-by: Stefan Metzmacher --- source3/libsmb/ntlmssp.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'source3/libsmb') diff --git a/source3/libsmb/ntlmssp.c b/source3/libsmb/ntlmssp.c index 95a5dc9ccb..fb41c3c487 100644 --- a/source3/libsmb/ntlmssp.c +++ b/source3/libsmb/ntlmssp.c @@ -106,6 +106,28 @@ NTSTATUS ntlmssp_set_password(struct ntlmssp_state *ntlmssp_state, const char *p return NT_STATUS_OK; } +NTSTATUS ntlmssp_set_password_hash(struct ntlmssp_state *state, + const char *pwhash) +{ + char nt_hash[16]; + size_t converted; + + converted = strhex_to_str( + nt_hash, sizeof(nt_hash), pwhash, strlen(pwhash)); + if (converted != sizeof(nt_hash)) { + return NT_STATUS_INVALID_PARAMETER; + } + + TALLOC_FREE(state->lm_hash); + TALLOC_FREE(state->nt_hash); + + state->nt_hash = (uint8_t *)talloc_memdup(state, nt_hash, 16); + if (!state->nt_hash) { + return NT_STATUS_NO_MEMORY; + } + return NT_STATUS_OK; +} + /** * Set a domain on an NTLMSSP context - ensures it is talloc()ed * -- cgit