1524bc
From 7839408010ba413f766e950192dd5a0632234ce7 Mon Sep 17 00:00:00 2001
1524bc
From: Andreas Schneider <asn@samba.org>
1524bc
Date: Wed, 20 Feb 2019 15:52:49 +0100
1524bc
Subject: [PATCH 038/187] s4:torture: Use GnuTLS RC4 for RAP SAM test
1524bc
1524bc
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14031
1524bc
1524bc
Signed-off-by: Andreas Schneider <asn@samba.org>
1524bc
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
1524bc
(cherry picked from commit 811c412da5c24d7274f9aa4c7d653bbb1191e6a6)
1524bc
---
1524bc
 source4/torture/rap/sam.c | 19 +++++++++++++++++--
1524bc
 1 file changed, 17 insertions(+), 2 deletions(-)
1524bc
1524bc
diff --git a/source4/torture/rap/sam.c b/source4/torture/rap/sam.c
1524bc
index 4ca7b793dec..3c13849b398 100644
1524bc
--- a/source4/torture/rap/sam.c
1524bc
+++ b/source4/torture/rap/sam.c
1524bc
@@ -26,10 +26,12 @@
1524bc
 #include "torture/util.h"
1524bc
 #include "libcli/rap/rap.h"
1524bc
 #include "torture/rap/proto.h"
1524bc
-#include "../lib/crypto/crypto.h"
1524bc
 #include "../libcli/auth/libcli_auth.h"
1524bc
 #include "torture/rpc/torture_rpc.h"
1524bc
 
1524bc
+#include <gnutls/gnutls.h>
1524bc
+#include <gnutls/crypto.h>
1524bc
+
1524bc
 #define TEST_RAP_USER "torture_rap_user"
1524bc
 
1524bc
 static char *samr_rand_pass(TALLOC_CTX *mem_ctx, int min_len)
1524bc
@@ -137,6 +139,11 @@ static bool test_oemchangepassword_args(struct torture_context *tctx,
1524bc
 	char *newpass = samr_rand_pass(tctx, 9);
1524bc
 	uint8_t old_pw_hash[16];
1524bc
 	uint8_t new_pw_hash[16];
1524bc
+	gnutls_cipher_hd_t cipher_hnd = NULL;
1524bc
+	gnutls_datum_t pw_key = {
1524bc
+		.data = old_pw_hash,
1524bc
+		.size = sizeof(old_pw_hash),
1524bc
+	};
1524bc
 
1524bc
 	r.in.UserName = username;
1524bc
 
1524bc
@@ -144,7 +151,15 @@ static bool test_oemchangepassword_args(struct torture_context *tctx,
1524bc
 	E_deshash(newpass, new_pw_hash);
1524bc
 
1524bc
 	encode_pw_buffer(r.in.crypt_password, newpass, STR_ASCII);
1524bc
-	arcfour_crypt(r.in.crypt_password, old_pw_hash, 516);
1524bc
+
1524bc
+	gnutls_cipher_init(&cipher_hnd,
1524bc
+			   GNUTLS_CIPHER_ARCFOUR_128,
1524bc
+			   &pw_key,
1524bc
+			   NULL);
1524bc
+	gnutls_cipher_encrypt(cipher_hnd,
1524bc
+			      r.in.crypt_password,
1524bc
+			      516);
1524bc
+	gnutls_cipher_deinit(cipher_hnd);
1524bc
 	E_old_pw_hash(new_pw_hash, old_pw_hash, r.in.password_hash);
1524bc
 
1524bc
 	torture_comment(tctx, "Testing rap_NetOEMChangePassword(%s)\n", r.in.UserName);
1524bc
-- 
1524bc
2.23.0
1524bc