b6b438
From 88d136aae60d4aa8b6fe622e0e92a8bddbba1b1e Mon Sep 17 00:00:00 2001
b6b438
From: Andrew Bartlett <abartlet@samba.org>
b6b438
Date: Thu, 25 Jul 2019 16:46:06 +1200
b6b438
Subject: [PATCH 046/187] s4:torture: Use init_samr_CryptPassword in
b6b438
 test_ChangePasswordUser2
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 dfda49472e0b4a81653963e80d8d65788f80a591)
b6b438
---
b6b438
 source4/torture/rpc/samr.c | 13 ++++++++++---
b6b438
 1 file changed, 10 insertions(+), 3 deletions(-)
b6b438
b6b438
diff --git a/source4/torture/rpc/samr.c b/source4/torture/rpc/samr.c
b6b438
index eb032905dc8..6cc508a2d44 100644
b6b438
--- a/source4/torture/rpc/samr.c
b6b438
+++ b/source4/torture/rpc/samr.c
b6b438
@@ -2259,11 +2259,13 @@ static bool test_ChangePasswordUser2(struct dcerpc_pipe *p, struct torture_conte
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
-
b6b438
+	DATA_BLOB old_nt_hash_blob
b6b438
+		= data_blob_const(old_nt_hash, sizeof(old_nt_hash));
b6b438
 	struct samr_GetDomPwInfo dom_pw_info;
b6b438
 	struct samr_PwInfo info;
b6b438
 
b6b438
 	struct lsa_String domain_name;
b6b438
+	NTSTATUS status;
b6b438
 
b6b438
 	domain_name.string = "";
b6b438
 	dom_pw_info.in.domain_name = &domain_name;
b6b438
@@ -2299,8 +2301,13 @@ static bool test_ChangePasswordUser2(struct dcerpc_pipe *p, struct torture_conte
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
+	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