b6b438
From 7ce6d4730f7ff8c5008ad91d665a172fec8e5ba8 Mon Sep 17 00:00:00 2001
b6b438
From: Andrew Bartlett <abartlet@samba.org>
b6b438
Date: Thu, 25 Jul 2019 17:43:23 +1200
b6b438
Subject: [PATCH 052/187] s4:torture: Use init_samr_CryptPassword in
b6b438
 test_ChangePasswordRandomBytes
b6b438
b6b438
This allows the use of GnuTLS for the underlying RC4 crypto
b6b438
b6b438
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
b6b438
Reviewed-by: Andreas Schneider <asn@samba.org>
b6b438
(cherry picked from commit 19d9c2c01a54957bc3852e2565d92c1cdd89498b)
b6b438
---
b6b438
 source4/torture/rpc/samr.c | 12 ++++++++++--
b6b438
 1 file changed, 10 insertions(+), 2 deletions(-)
b6b438
b6b438
diff --git a/source4/torture/rpc/samr.c b/source4/torture/rpc/samr.c
b6b438
index 20afa9392e2..10377850314 100644
b6b438
--- a/source4/torture/rpc/samr.c
b6b438
+++ b/source4/torture/rpc/samr.c
b6b438
@@ -2790,6 +2790,9 @@ bool test_ChangePasswordRandomBytes(struct dcerpc_pipe *p, struct torture_contex
b6b438
 	char *oldpass;
b6b438
 	struct dcerpc_binding_handle *b = p->binding_handle;
b6b438
 	uint8_t old_nt_hash[16], new_nt_hash[16];
b6b438
+	DATA_BLOB old_nt_hash_blob
b6b438
+		= data_blob_const(old_nt_hash,
b6b438
+				  sizeof(old_nt_hash));
b6b438
 	NTTIME t;
b6b438
 	struct samr_DomInfo1 *dominfo = NULL;
b6b438
 	struct userPwdChangeFailureInformation *reject = NULL;
b6b438
@@ -2893,8 +2896,13 @@ bool test_ChangePasswordRandomBytes(struct dcerpc_pipe *p, struct torture_contex
b6b438
 
b6b438
 	E_md4hash(newpass, new_nt_hash);
b6b438
 
b6b438
-	encode_pw_buffer(nt_pass.data, newpass, STR_UNICODE);
b6b438
-	arcfour_crypt(nt_pass.data, old_nt_hash, 516);
b6b438
+	status = init_samr_CryptPassword(newpass,
b6b438
+					 &old_nt_hash_blob,
b6b438
+					 &nt_pass);
b6b438
+	torture_assert_ntstatus_ok(tctx,
b6b438
+				   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