|
|
b6b438 |
From 0f56ee5720764eec28ce23bc82a01c16411df5fb Mon Sep 17 00:00:00 2001
|
|
|
b6b438 |
From: Andrew Bartlett <abartlet@samba.org>
|
|
|
b6b438 |
Date: Thu, 25 Jul 2019 13:07:48 +1200
|
|
|
b6b438 |
Subject: [PATCH 054/187] s4:torture: Use samba_gnutls_arcfour_confounded_md5()
|
|
|
b6b438 |
in test_ChangePasswordRandomBytes
|
|
|
b6b438 |
|
|
|
b6b438 |
This ensures GnuTLS is used as the underlying RC4 crypto engine
|
|
|
b6b438 |
|
|
|
b6b438 |
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
|
|
|
b6b438 |
Reviewed-by: Andreas Schneider <asn@samba.org>
|
|
|
b6b438 |
(cherry picked from commit 5740e9516f3587e3a9f72cf52cfe1eedd940b2a9)
|
|
|
b6b438 |
---
|
|
|
b6b438 |
source4/torture/rpc/samr.c | 25 +++++++++++++++----------
|
|
|
b6b438 |
1 file changed, 15 insertions(+), 10 deletions(-)
|
|
|
b6b438 |
|
|
|
b6b438 |
diff --git a/source4/torture/rpc/samr.c b/source4/torture/rpc/samr.c
|
|
|
b6b438 |
index 10bdd52fd47..4b3ad093bf6 100644
|
|
|
b6b438 |
--- a/source4/torture/rpc/samr.c
|
|
|
b6b438 |
+++ b/source4/torture/rpc/samr.c
|
|
|
b6b438 |
@@ -42,6 +42,7 @@
|
|
|
b6b438 |
#include "torture/util.h"
|
|
|
b6b438 |
#include "source4/librpc/rpc/dcerpc.h"
|
|
|
b6b438 |
#include "source3/rpc_client/init_samr.h"
|
|
|
b6b438 |
+#include "lib/crypto/gnutls_helpers.h"
|
|
|
b6b438 |
|
|
|
b6b438 |
#define TEST_ACCOUNT_NAME "samrtorturetest"
|
|
|
b6b438 |
#define TEST_ACCOUNT_NAME_PWD "samrpwdlastset"
|
|
|
b6b438 |
@@ -2777,9 +2778,6 @@ bool test_ChangePasswordRandomBytes(struct dcerpc_pipe *p, struct torture_contex
|
|
|
b6b438 |
struct samr_SetUserInfo s;
|
|
|
b6b438 |
union samr_UserInfo u;
|
|
|
b6b438 |
DATA_BLOB session_key;
|
|
|
b6b438 |
- DATA_BLOB confounded_session_key = data_blob_talloc(tctx, NULL, 16);
|
|
|
b6b438 |
- uint8_t confounder[16];
|
|
|
b6b438 |
- gnutls_hash_hd_t hash_hnd;
|
|
|
b6b438 |
|
|
|
b6b438 |
bool ret = true;
|
|
|
b6b438 |
struct lsa_String server, account;
|
|
|
b6b438 |
@@ -2797,6 +2795,11 @@ bool test_ChangePasswordRandomBytes(struct dcerpc_pipe *p, struct torture_contex
|
|
|
b6b438 |
struct samr_DomInfo1 *dominfo = NULL;
|
|
|
b6b438 |
struct userPwdChangeFailureInformation *reject = NULL;
|
|
|
b6b438 |
gnutls_cipher_hd_t cipher_hnd = NULL;
|
|
|
b6b438 |
+ uint8_t _confounder[16] = {0};
|
|
|
b6b438 |
+ DATA_BLOB confounder
|
|
|
b6b438 |
+ = data_blob_const(_confounder,
|
|
|
b6b438 |
+ sizeof(_confounder));
|
|
|
b6b438 |
+ DATA_BLOB pw_data;
|
|
|
b6b438 |
gnutls_datum_t old_nt_key = {
|
|
|
b6b438 |
.data = old_nt_hash,
|
|
|
b6b438 |
.size = sizeof(old_nt_hash),
|
|
|
b6b438 |
@@ -2821,6 +2824,8 @@ bool test_ChangePasswordRandomBytes(struct dcerpc_pipe *p, struct torture_contex
|
|
|
b6b438 |
|
|
|
b6b438 |
set_pw_in_buffer(u.info25.password.data, &new_random_pass);
|
|
|
b6b438 |
|
|
|
b6b438 |
+ pw_data = data_blob_const(u.info25.password.data, 516);
|
|
|
b6b438 |
+
|
|
|
b6b438 |
status = dcerpc_fetch_session_key(p, &session_key);
|
|
|
b6b438 |
if (!NT_STATUS_IS_OK(status)) {
|
|
|
b6b438 |
torture_result(tctx, TORTURE_FAIL, "SetUserInfo level %u - no session key - %s\n",
|
|
|
b6b438 |
@@ -2828,15 +2833,15 @@ bool test_ChangePasswordRandomBytes(struct dcerpc_pipe *p, struct torture_contex
|
|
|
b6b438 |
return false;
|
|
|
b6b438 |
}
|
|
|
b6b438 |
|
|
|
b6b438 |
- generate_random_buffer((uint8_t *)confounder, 16);
|
|
|
b6b438 |
+ generate_random_buffer(_confounder,
|
|
|
b6b438 |
+ sizeof(_confounder));
|
|
|
b6b438 |
|
|
|
b6b438 |
- gnutls_hash_init(&hash_hnd, GNUTLS_DIG_MD5);
|
|
|
b6b438 |
- gnutls_hash(hash_hnd, confounder, 16);
|
|
|
b6b438 |
- gnutls_hash(hash_hnd, session_key.data, session_key.length);
|
|
|
b6b438 |
- gnutls_hash_deinit(hash_hnd, confounded_session_key.data);
|
|
|
b6b438 |
+ samba_gnutls_arcfour_confounded_md5(&confounder,
|
|
|
b6b438 |
+ &session_key,
|
|
|
b6b438 |
+ &pw_data,
|
|
|
b6b438 |
+ SAMBA_GNUTLS_ENCRYPT);
|
|
|
b6b438 |
|
|
|
b6b438 |
- arcfour_crypt_blob(u.info25.password.data, 516, &confounded_session_key);
|
|
|
b6b438 |
- memcpy(&u.info25.password.data[516], confounder, 16);
|
|
|
b6b438 |
+ memcpy(&u.info25.password.data[516], _confounder, sizeof(_confounder));
|
|
|
b6b438 |
|
|
|
b6b438 |
torture_comment(tctx, "Testing SetUserInfo level 25 (set password ex) with a password made up of only random bytes\n");
|
|
|
b6b438 |
|
|
|
b6b438 |
--
|
|
|
b6b438 |
2.23.0
|
|
|
b6b438 |
|