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