b6b438
From 90bdf8b2063c05576450975df0983953d6febd95 Mon Sep 17 00:00:00 2001
b6b438
From: Andrew Bartlett <abartlet@samba.org>
b6b438
Date: Thu, 25 Jul 2019 16:52:41 +1200
b6b438
Subject: [PATCH 047/187] s4:torture: Use init_samr_CryptPassword in
b6b438
 test_ChangePasswordUser2_ntstatus
b6b438
b6b438
This allows the use of GnuTLS for the RC4 crypto operation
b6b438
b6b438
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
b6b438
Reviewed-by: Andreas Schneider <asn@samba.org>
b6b438
(cherry picked from commit 1b1c302a7db23bf4377b8fa742ebf7ae913e3511)
b6b438
---
b6b438
 source4/torture/rpc/samr.c | 13 +++++++++++--
b6b438
 1 file changed, 11 insertions(+), 2 deletions(-)
b6b438
b6b438
diff --git a/source4/torture/rpc/samr.c b/source4/torture/rpc/samr.c
b6b438
index 6cc508a2d44..5bf758e2fb2 100644
b6b438
--- a/source4/torture/rpc/samr.c
b6b438
+++ b/source4/torture/rpc/samr.c
b6b438
@@ -2349,11 +2349,15 @@ static bool test_ChangePasswordUser2_ntstatus(struct dcerpc_pipe *p, struct tort
b6b438
 	struct dcerpc_binding_handle *b = p->binding_handle;
b6b438
 	uint8_t old_nt_hash[16], new_nt_hash[16];
b6b438
 	uint8_t old_lm_hash[16], new_lm_hash[16];
b6b438
+	DATA_BLOB old_nt_hash_blob
b6b438
+		= data_blob_const(old_nt_hash, sizeof(old_nt_hash));
b6b438
 
b6b438
 	struct samr_GetDomPwInfo dom_pw_info;
b6b438
 	struct samr_PwInfo info;
b6b438
 
b6b438
 	struct lsa_String domain_name;
b6b438
+	NTSTATUS crypt_status;
b6b438
+
b6b438
 	char *newpass;
b6b438
 	int policy_min_pw_len = 0;
b6b438
 
b6b438
@@ -2386,8 +2390,13 @@ static bool test_ChangePasswordUser2_ntstatus(struct dcerpc_pipe *p, struct tort
b6b438
 	arcfour_crypt(lm_pass.data, old_lm_hash, 516);
b6b438
 	E_old_pw_hash(new_nt_hash, old_lm_hash, lm_verifier.hash);
b6b438
 
b6b438
-	encode_pw_buffer(nt_pass.data, newpass, STR_UNICODE);
b6b438
-	arcfour_crypt(nt_pass.data, old_nt_hash, 516);
b6b438
+	crypt_status = init_samr_CryptPassword(newpass,
b6b438
+					       &old_nt_hash_blob,
b6b438
+					       &nt_pass);
b6b438
+	torture_assert_ntstatus_ok(tctx,
b6b438
+				   crypt_status,
b6b438
+				   "init_samr_CryptPassword failed");
b6b438
+
b6b438
 	E_old_pw_hash(new_nt_hash, old_nt_hash, nt_verifier.hash);
b6b438
 
b6b438
 	r.in.server = &server;
b6b438
-- 
b6b438
2.23.0
b6b438