|
|
b6b438 |
From 3f2ab4815d9ddf6a6d4a6d8904f528f05d1802cf Mon Sep 17 00:00:00 2001
|
|
|
b6b438 |
From: Isaac Boukris <iboukris@gmail.com>
|
|
|
b6b438 |
Date: Thu, 21 Nov 2019 14:02:03 +0100
|
|
|
b6b438 |
Subject: [PATCH 185/187] session: convert sess_crypt_blob to use gnutls
|
|
|
b6b438 |
|
|
|
b6b438 |
Signed-off-by: Isaac Boukris <iboukris@samba.org>
|
|
|
b6b438 |
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
|
|
|
b6b438 |
(cherry picked from commit a75ca8d5d515aef1229acf5a30489ee5f5ced3e1)
|
|
|
b6b438 |
---
|
|
|
b6b438 |
libcli/auth/proto.h | 4 +-
|
|
|
b6b438 |
libcli/auth/session.c | 42 ++++++++++++++++-----
|
|
|
b6b438 |
libcli/auth/tests/test_gnutls.c | 7 +++-
|
|
|
b6b438 |
source3/rpc_server/netlogon/srv_netlog_nt.c | 7 +++-
|
|
|
b6b438 |
source3/rpc_server/samr/srv_samr_nt.c | 27 +++++++++++--
|
|
|
b6b438 |
source3/rpcclient/cmd_samr.c | 25 ++++++++++--
|
|
|
b6b438 |
source4/rpc_server/samr/samr_password.c | 13 ++++++-
|
|
|
b6b438 |
source4/torture/rpc/samr.c | 16 ++++----
|
|
|
b6b438 |
8 files changed, 108 insertions(+), 33 deletions(-)
|
|
|
b6b438 |
|
|
|
b6b438 |
diff --git a/libcli/auth/proto.h b/libcli/auth/proto.h
|
|
|
b6b438 |
index 4c6d7af6763..09ff3687fb7 100644
|
|
|
b6b438 |
--- a/libcli/auth/proto.h
|
|
|
b6b438 |
+++ b/libcli/auth/proto.h
|
|
|
b6b438 |
@@ -90,8 +90,8 @@ union netr_LogonLevel *netlogon_creds_shallow_copy_logon(TALLOC_CTX *mem_ctx,
|
|
|
b6b438 |
|
|
|
b6b438 |
/* The following definitions come from /home/jeremy/src/samba/git/master/source3/../source4/../libcli/auth/session.c */
|
|
|
b6b438 |
|
|
|
b6b438 |
-void sess_crypt_blob(DATA_BLOB *out, const DATA_BLOB *in, const DATA_BLOB *session_key,
|
|
|
b6b438 |
- bool forward);
|
|
|
b6b438 |
+int sess_crypt_blob(DATA_BLOB *out, const DATA_BLOB *in, const DATA_BLOB *session_key,
|
|
|
b6b438 |
+ enum samba_gnutls_direction encrypt);
|
|
|
b6b438 |
DATA_BLOB sess_encrypt_string(const char *str, const DATA_BLOB *session_key);
|
|
|
b6b438 |
char *sess_decrypt_string(TALLOC_CTX *mem_ctx,
|
|
|
b6b438 |
DATA_BLOB *blob, const DATA_BLOB *session_key);
|
|
|
b6b438 |
diff --git a/libcli/auth/session.c b/libcli/auth/session.c
|
|
|
b6b438 |
index 10c728662db..4af70d361af 100644
|
|
|
b6b438 |
--- a/libcli/auth/session.c
|
|
|
b6b438 |
+++ b/libcli/auth/session.c
|
|
|
b6b438 |
@@ -29,10 +29,10 @@
|
|
|
b6b438 |
before calling, the out blob must be initialised to be the same size
|
|
|
b6b438 |
as the in blob
|
|
|
b6b438 |
*/
|
|
|
b6b438 |
-void sess_crypt_blob(DATA_BLOB *out, const DATA_BLOB *in, const DATA_BLOB *session_key,
|
|
|
b6b438 |
- bool forward)
|
|
|
b6b438 |
+int sess_crypt_blob(DATA_BLOB *out, const DATA_BLOB *in, const DATA_BLOB *session_key,
|
|
|
b6b438 |
+ enum samba_gnutls_direction encrypt)
|
|
|
b6b438 |
{
|
|
|
b6b438 |
- int i, k;
|
|
|
b6b438 |
+ int i, k, rc;
|
|
|
b6b438 |
|
|
|
b6b438 |
for (i=0,k=0;
|
|
|
b6b438 |
i<in->length;
|
|
|
b6b438 |
@@ -47,10 +47,14 @@ void sess_crypt_blob(DATA_BLOB *out, const DATA_BLOB *in, const DATA_BLOB *sessi
|
|
|
b6b438 |
}
|
|
|
b6b438 |
memcpy(key, &session_key->data[k], 7);
|
|
|
b6b438 |
|
|
|
b6b438 |
- des_crypt56(bout, bin, key, forward?1:0);
|
|
|
b6b438 |
+ rc = des_crypt56_gnutls(bout, bin, key, encrypt);
|
|
|
b6b438 |
+ if (rc != 0) {
|
|
|
b6b438 |
+ return rc;
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
|
|
|
b6b438 |
memcpy(&out->data[i], bout, MIN(8, in->length-i));
|
|
|
b6b438 |
}
|
|
|
b6b438 |
+ return 0;
|
|
|
b6b438 |
}
|
|
|
b6b438 |
|
|
|
b6b438 |
|
|
|
b6b438 |
@@ -67,6 +71,7 @@ DATA_BLOB sess_encrypt_string(const char *str, const DATA_BLOB *session_key)
|
|
|
b6b438 |
DATA_BLOB ret, src;
|
|
|
b6b438 |
int slen = strlen(str);
|
|
|
b6b438 |
int dlen = (slen+7) & ~7;
|
|
|
b6b438 |
+ int rc;
|
|
|
b6b438 |
|
|
|
b6b438 |
src = data_blob(NULL, 8+dlen);
|
|
|
b6b438 |
if (!src.data) {
|
|
|
b6b438 |
@@ -84,9 +89,13 @@ DATA_BLOB sess_encrypt_string(const char *str, const DATA_BLOB *session_key)
|
|
|
b6b438 |
memset(src.data+8, 0, dlen);
|
|
|
b6b438 |
memcpy(src.data+8, str, slen);
|
|
|
b6b438 |
|
|
|
b6b438 |
- sess_crypt_blob(&ret, &src, session_key, true);
|
|
|
b6b438 |
+ rc = sess_crypt_blob(&ret, &src, session_key, SAMBA_GNUTLS_ENCRYPT);
|
|
|
b6b438 |
|
|
|
b6b438 |
data_blob_free(&src;;
|
|
|
b6b438 |
+ if (rc != 0) {
|
|
|
b6b438 |
+ data_blob_free(&ret;;
|
|
|
b6b438 |
+ return data_blob(NULL, 0);
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
|
|
|
b6b438 |
return ret;
|
|
|
b6b438 |
}
|
|
|
b6b438 |
@@ -100,7 +109,7 @@ char *sess_decrypt_string(TALLOC_CTX *mem_ctx,
|
|
|
b6b438 |
DATA_BLOB *blob, const DATA_BLOB *session_key)
|
|
|
b6b438 |
{
|
|
|
b6b438 |
DATA_BLOB out;
|
|
|
b6b438 |
- int slen;
|
|
|
b6b438 |
+ int rc, slen;
|
|
|
b6b438 |
char *ret;
|
|
|
b6b438 |
|
|
|
b6b438 |
if (blob->length < 8) {
|
|
|
b6b438 |
@@ -112,7 +121,11 @@ char *sess_decrypt_string(TALLOC_CTX *mem_ctx,
|
|
|
b6b438 |
return NULL;
|
|
|
b6b438 |
}
|
|
|
b6b438 |
|
|
|
b6b438 |
- sess_crypt_blob(&out, blob, session_key, false);
|
|
|
b6b438 |
+ rc = sess_crypt_blob(&out, blob, session_key, SAMBA_GNUTLS_DECRYPT);
|
|
|
b6b438 |
+ if (rc != 0) {
|
|
|
b6b438 |
+ data_blob_free(&out;;
|
|
|
b6b438 |
+ return NULL;
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
|
|
|
b6b438 |
if (IVAL(out.data, 4) != 1) {
|
|
|
b6b438 |
DEBUG(0,("Unexpected revision number %d in session crypted string\n",
|
|
|
b6b438 |
@@ -149,6 +162,7 @@ DATA_BLOB sess_encrypt_blob(TALLOC_CTX *mem_ctx, DATA_BLOB *blob_in, const DATA_
|
|
|
b6b438 |
{
|
|
|
b6b438 |
DATA_BLOB ret, src;
|
|
|
b6b438 |
int dlen = (blob_in->length+7) & ~7;
|
|
|
b6b438 |
+ int rc;
|
|
|
b6b438 |
|
|
|
b6b438 |
src = data_blob_talloc(mem_ctx, NULL, 8+dlen);
|
|
|
b6b438 |
if (!src.data) {
|
|
|
b6b438 |
@@ -166,9 +180,13 @@ DATA_BLOB sess_encrypt_blob(TALLOC_CTX *mem_ctx, DATA_BLOB *blob_in, const DATA_
|
|
|
b6b438 |
memset(src.data+8, 0, dlen);
|
|
|
b6b438 |
memcpy(src.data+8, blob_in->data, blob_in->length);
|
|
|
b6b438 |
|
|
|
b6b438 |
- sess_crypt_blob(&ret, &src, session_key, true);
|
|
|
b6b438 |
+ rc = sess_crypt_blob(&ret, &src, session_key, SAMBA_GNUTLS_ENCRYPT);
|
|
|
b6b438 |
|
|
|
b6b438 |
data_blob_free(&src;;
|
|
|
b6b438 |
+ if (rc != 0) {
|
|
|
b6b438 |
+ data_blob_free(&ret;;
|
|
|
b6b438 |
+ return data_blob(NULL, 0);
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
|
|
|
b6b438 |
return ret;
|
|
|
b6b438 |
}
|
|
|
b6b438 |
@@ -180,7 +198,7 @@ NTSTATUS sess_decrypt_blob(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, const DAT
|
|
|
b6b438 |
DATA_BLOB *ret)
|
|
|
b6b438 |
{
|
|
|
b6b438 |
DATA_BLOB out;
|
|
|
b6b438 |
- int slen;
|
|
|
b6b438 |
+ int rc, slen;
|
|
|
b6b438 |
|
|
|
b6b438 |
if (blob->length < 8) {
|
|
|
b6b438 |
DEBUG(0, ("Unexpected length %d in session crypted secret (BLOB)\n",
|
|
|
b6b438 |
@@ -193,7 +211,11 @@ NTSTATUS sess_decrypt_blob(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, const DAT
|
|
|
b6b438 |
return NT_STATUS_NO_MEMORY;
|
|
|
b6b438 |
}
|
|
|
b6b438 |
|
|
|
b6b438 |
- sess_crypt_blob(&out, blob, session_key, false);
|
|
|
b6b438 |
+ rc = sess_crypt_blob(&out, blob, session_key, SAMBA_GNUTLS_DECRYPT);
|
|
|
b6b438 |
+ if (rc != 0) {
|
|
|
b6b438 |
+ data_blob_free(&out;;
|
|
|
b6b438 |
+ return gnutls_error_to_ntstatus(rc, NT_STATUS_ACCESS_DISABLED_BY_POLICY_OTHER);
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
|
|
|
b6b438 |
if (IVAL(out.data, 4) != 1) {
|
|
|
b6b438 |
DEBUG(2,("Unexpected revision number %d in session crypted secret (BLOB)\n",
|
|
|
b6b438 |
diff --git a/libcli/auth/tests/test_gnutls.c b/libcli/auth/tests/test_gnutls.c
|
|
|
b6b438 |
index a6692b9a913..707a1bcecc3 100644
|
|
|
b6b438 |
--- a/libcli/auth/tests/test_gnutls.c
|
|
|
b6b438 |
+++ b/libcli/auth/tests/test_gnutls.c
|
|
|
b6b438 |
@@ -494,11 +494,14 @@ static void torture_gnutls_sess_crypt_blob(void **state)
|
|
|
b6b438 |
};
|
|
|
b6b438 |
DATA_BLOB crypt = data_blob(NULL, 24);
|
|
|
b6b438 |
DATA_BLOB decrypt = data_blob(NULL, 24);
|
|
|
b6b438 |
+ int rc;
|
|
|
b6b438 |
|
|
|
b6b438 |
- sess_crypt_blob(&crypt, &clear, &key, true);
|
|
|
b6b438 |
+ rc = sess_crypt_blob(&crypt, &clear, &key, SAMBA_GNUTLS_ENCRYPT);
|
|
|
b6b438 |
+ assert_int_equal(rc, 0);
|
|
|
b6b438 |
assert_memory_equal(crypt.data, crypt_expected, 24);
|
|
|
b6b438 |
|
|
|
b6b438 |
- sess_crypt_blob(&decrypt, &crypt, &key, false);
|
|
|
b6b438 |
+ rc = sess_crypt_blob(&decrypt, &crypt, &key, SAMBA_GNUTLS_DECRYPT);
|
|
|
b6b438 |
+ assert_int_equal(rc, 0);
|
|
|
b6b438 |
assert_memory_equal(decrypt.data, clear.data, 24);
|
|
|
b6b438 |
}
|
|
|
b6b438 |
|
|
|
b6b438 |
diff --git a/source3/rpc_server/netlogon/srv_netlog_nt.c b/source3/rpc_server/netlogon/srv_netlog_nt.c
|
|
|
b6b438 |
index 124bae95064..cbbf9feedc7 100644
|
|
|
b6b438 |
--- a/source3/rpc_server/netlogon/srv_netlog_nt.c
|
|
|
b6b438 |
+++ b/source3/rpc_server/netlogon/srv_netlog_nt.c
|
|
|
b6b438 |
@@ -1220,7 +1220,12 @@ static NTSTATUS netr_set_machine_account_password(TALLOC_CTX *mem_ctx,
|
|
|
b6b438 |
status = NT_STATUS_NO_MEMORY;
|
|
|
b6b438 |
goto out;
|
|
|
b6b438 |
}
|
|
|
b6b438 |
- sess_crypt_blob(&out, &in, &session_key, true);
|
|
|
b6b438 |
+ rc = sess_crypt_blob(&out, &in, &session_key, SAMBA_GNUTLS_ENCRYPT);
|
|
|
b6b438 |
+ if (rc != 0) {
|
|
|
b6b438 |
+ status = gnutls_error_to_ntstatus(rc,
|
|
|
b6b438 |
+ NT_STATUS_ACCESS_DISABLED_BY_POLICY_OTHER);
|
|
|
b6b438 |
+ goto out;
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
memcpy(info18.nt_pwd.hash, out.data, out.length);
|
|
|
b6b438 |
|
|
|
b6b438 |
info18.nt_pwd_active = true;
|
|
|
b6b438 |
diff --git a/source3/rpc_server/samr/srv_samr_nt.c b/source3/rpc_server/samr/srv_samr_nt.c
|
|
|
b6b438 |
index 87214b2899e..91771e34502 100644
|
|
|
b6b438 |
--- a/source3/rpc_server/samr/srv_samr_nt.c
|
|
|
b6b438 |
+++ b/source3/rpc_server/samr/srv_samr_nt.c
|
|
|
b6b438 |
@@ -4411,6 +4411,8 @@ static NTSTATUS set_user_info_18(struct samr_UserInfo18 *id18,
|
|
|
b6b438 |
DATA_BLOB *session_key,
|
|
|
b6b438 |
struct samu *pwd)
|
|
|
b6b438 |
{
|
|
|
b6b438 |
+ int rc;
|
|
|
b6b438 |
+
|
|
|
b6b438 |
if (id18 == NULL) {
|
|
|
b6b438 |
DEBUG(2, ("set_user_info_18: id18 is NULL\n"));
|
|
|
b6b438 |
return NT_STATUS_INVALID_PARAMETER;
|
|
|
b6b438 |
@@ -4429,7 +4431,11 @@ static NTSTATUS set_user_info_18(struct samr_UserInfo18 *id18,
|
|
|
b6b438 |
in = data_blob_const(id18->nt_pwd.hash, 16);
|
|
|
b6b438 |
out = data_blob_talloc_zero(mem_ctx, 16);
|
|
|
b6b438 |
|
|
|
b6b438 |
- sess_crypt_blob(&out, &in, session_key, false);
|
|
|
b6b438 |
+ rc = sess_crypt_blob(&out, &in, session_key, SAMBA_GNUTLS_DECRYPT);
|
|
|
b6b438 |
+ if (rc != 0) {
|
|
|
b6b438 |
+ return gnutls_error_to_ntstatus(rc,
|
|
|
b6b438 |
+ NT_STATUS_ACCESS_DISABLED_BY_POLICY_OTHER);
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
|
|
|
b6b438 |
if (!pdb_set_nt_passwd(pwd, out.data, PDB_CHANGED)) {
|
|
|
b6b438 |
return NT_STATUS_ACCESS_DENIED;
|
|
|
b6b438 |
@@ -4445,7 +4451,11 @@ static NTSTATUS set_user_info_18(struct samr_UserInfo18 *id18,
|
|
|
b6b438 |
in = data_blob_const(id18->lm_pwd.hash, 16);
|
|
|
b6b438 |
out = data_blob_talloc_zero(mem_ctx, 16);
|
|
|
b6b438 |
|
|
|
b6b438 |
- sess_crypt_blob(&out, &in, session_key, false);
|
|
|
b6b438 |
+ rc = sess_crypt_blob(&out, &in, session_key, SAMBA_GNUTLS_DECRYPT);
|
|
|
b6b438 |
+ if (rc != 0) {
|
|
|
b6b438 |
+ return gnutls_error_to_ntstatus(rc,
|
|
|
b6b438 |
+ NT_STATUS_ACCESS_DISABLED_BY_POLICY_OTHER);
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
|
|
|
b6b438 |
if (!pdb_set_lanman_passwd(pwd, out.data, PDB_CHANGED)) {
|
|
|
b6b438 |
return NT_STATUS_ACCESS_DENIED;
|
|
|
b6b438 |
@@ -4487,6 +4497,7 @@ static NTSTATUS set_user_info_21(struct samr_UserInfo21 *id21,
|
|
|
b6b438 |
struct samu *pwd)
|
|
|
b6b438 |
{
|
|
|
b6b438 |
NTSTATUS status;
|
|
|
b6b438 |
+ int rc;
|
|
|
b6b438 |
|
|
|
b6b438 |
if (id21 == NULL) {
|
|
|
b6b438 |
DEBUG(5, ("set_user_info_21: NULL id21\n"));
|
|
|
b6b438 |
@@ -4517,7 +4528,11 @@ static NTSTATUS set_user_info_21(struct samr_UserInfo21 *id21,
|
|
|
b6b438 |
in = data_blob_const(id21->nt_owf_password.array, 16);
|
|
|
b6b438 |
out = data_blob_talloc_zero(mem_ctx, 16);
|
|
|
b6b438 |
|
|
|
b6b438 |
- sess_crypt_blob(&out, &in, session_key, false);
|
|
|
b6b438 |
+ rc = sess_crypt_blob(&out, &in, session_key, SAMBA_GNUTLS_DECRYPT);
|
|
|
b6b438 |
+ if (rc != 0) {
|
|
|
b6b438 |
+ return gnutls_error_to_ntstatus(rc,
|
|
|
b6b438 |
+ NT_STATUS_ACCESS_DISABLED_BY_POLICY_OTHER);
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
|
|
|
b6b438 |
pdb_set_nt_passwd(pwd, out.data, PDB_CHANGED);
|
|
|
b6b438 |
pdb_set_pass_last_set_time(pwd, time(NULL), PDB_CHANGED);
|
|
|
b6b438 |
@@ -4540,7 +4555,11 @@ static NTSTATUS set_user_info_21(struct samr_UserInfo21 *id21,
|
|
|
b6b438 |
in = data_blob_const(id21->lm_owf_password.array, 16);
|
|
|
b6b438 |
out = data_blob_talloc_zero(mem_ctx, 16);
|
|
|
b6b438 |
|
|
|
b6b438 |
- sess_crypt_blob(&out, &in, session_key, false);
|
|
|
b6b438 |
+ rc = sess_crypt_blob(&out, &in, session_key, SAMBA_GNUTLS_DECRYPT);
|
|
|
b6b438 |
+ if (rc != 0) {
|
|
|
b6b438 |
+ return gnutls_error_to_ntstatus(rc,
|
|
|
b6b438 |
+ NT_STATUS_ACCESS_DISABLED_BY_POLICY_OTHER);
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
|
|
|
b6b438 |
pdb_set_lanman_passwd(pwd, out.data, PDB_CHANGED);
|
|
|
b6b438 |
pdb_set_pass_last_set_time(pwd, time(NULL), PDB_CHANGED);
|
|
|
b6b438 |
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
|
|
|
b6b438 |
index 0cd8b50058e..de95eb2160d 100644
|
|
|
b6b438 |
--- a/source3/rpcclient/cmd_samr.c
|
|
|
b6b438 |
+++ b/source3/rpcclient/cmd_samr.c
|
|
|
b6b438 |
@@ -3044,6 +3044,7 @@ static NTSTATUS cmd_samr_setuserinfo_int(struct rpc_pipe_client *cli,
|
|
|
b6b438 |
uint8_t password_expired = 0;
|
|
|
b6b438 |
struct dcerpc_binding_handle *b = cli->binding_handle;
|
|
|
b6b438 |
TALLOC_CTX *frame = NULL;
|
|
|
b6b438 |
+ int rc;
|
|
|
b6b438 |
|
|
|
b6b438 |
if (argc < 4) {
|
|
|
b6b438 |
printf("Usage: %s username level password [password_expired]\n",
|
|
|
b6b438 |
@@ -3086,7 +3087,11 @@ static NTSTATUS cmd_samr_setuserinfo_int(struct rpc_pipe_client *cli,
|
|
|
b6b438 |
status = NT_STATUS_NO_MEMORY;
|
|
|
b6b438 |
goto done;
|
|
|
b6b438 |
}
|
|
|
b6b438 |
- sess_crypt_blob(&out, &in, &session_key, true);
|
|
|
b6b438 |
+ rc = sess_crypt_blob(&out, &in, &session_key, SAMBA_GNUTLS_ENCRYPT);
|
|
|
b6b438 |
+ if (rc != 0) {
|
|
|
b6b438 |
+ status = gnutls_error_to_ntstatus(rc,
|
|
|
b6b438 |
+ NT_STATUS_ACCESS_DISABLED_BY_POLICY_OTHER);
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
memcpy(nt_hash, out.data, out.length);
|
|
|
b6b438 |
}
|
|
|
b6b438 |
{
|
|
|
b6b438 |
@@ -3097,7 +3102,11 @@ static NTSTATUS cmd_samr_setuserinfo_int(struct rpc_pipe_client *cli,
|
|
|
b6b438 |
status = NT_STATUS_NO_MEMORY;
|
|
|
b6b438 |
goto done;
|
|
|
b6b438 |
}
|
|
|
b6b438 |
- sess_crypt_blob(&out, &in, &session_key, true);
|
|
|
b6b438 |
+ rc = sess_crypt_blob(&out, &in, &session_key, SAMBA_GNUTLS_ENCRYPT);
|
|
|
b6b438 |
+ if (rc != 0) {
|
|
|
b6b438 |
+ status = gnutls_error_to_ntstatus(rc,
|
|
|
b6b438 |
+ NT_STATUS_ACCESS_DISABLED_BY_POLICY_OTHER);
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
memcpy(lm_hash, out.data, out.length);
|
|
|
b6b438 |
}
|
|
|
b6b438 |
|
|
|
b6b438 |
@@ -3134,7 +3143,11 @@ static NTSTATUS cmd_samr_setuserinfo_int(struct rpc_pipe_client *cli,
|
|
|
b6b438 |
status = NT_STATUS_NO_MEMORY;
|
|
|
b6b438 |
goto done;
|
|
|
b6b438 |
}
|
|
|
b6b438 |
- sess_crypt_blob(&out, &in, &session_key, true);
|
|
|
b6b438 |
+ rc = sess_crypt_blob(&out, &in, &session_key, SAMBA_GNUTLS_ENCRYPT);
|
|
|
b6b438 |
+ if (rc != 0) {
|
|
|
b6b438 |
+ status = gnutls_error_to_ntstatus(rc,
|
|
|
b6b438 |
+ NT_STATUS_ACCESS_DISABLED_BY_POLICY_OTHER);
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
info.info21.nt_owf_password.array =
|
|
|
b6b438 |
(uint16_t *)talloc_memdup(frame, out.data, 16);
|
|
|
b6b438 |
}
|
|
|
b6b438 |
@@ -3142,7 +3155,11 @@ static NTSTATUS cmd_samr_setuserinfo_int(struct rpc_pipe_client *cli,
|
|
|
b6b438 |
DATA_BLOB in,out;
|
|
|
b6b438 |
in = data_blob_const(lm_hash, 16);
|
|
|
b6b438 |
out = data_blob_talloc_zero(frame, 16);
|
|
|
b6b438 |
- sess_crypt_blob(&out, &in, &session_key, true);
|
|
|
b6b438 |
+ rc = sess_crypt_blob(&out, &in, &session_key, SAMBA_GNUTLS_ENCRYPT);
|
|
|
b6b438 |
+ if (rc != 0) {
|
|
|
b6b438 |
+ status = gnutls_error_to_ntstatus(rc,
|
|
|
b6b438 |
+ NT_STATUS_ACCESS_DISABLED_BY_POLICY_OTHER);
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
info.info21.lm_owf_password.array =
|
|
|
b6b438 |
(uint16_t *)talloc_memdup(frame, out.data, 16);
|
|
|
b6b438 |
if (out.data == NULL) {
|
|
|
b6b438 |
diff --git a/source4/rpc_server/samr/samr_password.c b/source4/rpc_server/samr/samr_password.c
|
|
|
b6b438 |
index 4fa00bf6360..fba236ebdd7 100644
|
|
|
b6b438 |
--- a/source4/rpc_server/samr/samr_password.c
|
|
|
b6b438 |
+++ b/source4/rpc_server/samr/samr_password.c
|
|
|
b6b438 |
@@ -737,6 +737,7 @@ NTSTATUS samr_set_password_buffers(struct dcesrv_call_state *dce_call,
|
|
|
b6b438 |
DATA_BLOB session_key = data_blob(NULL, 0);
|
|
|
b6b438 |
DATA_BLOB in, out;
|
|
|
b6b438 |
NTSTATUS nt_status = NT_STATUS_OK;
|
|
|
b6b438 |
+ int rc;
|
|
|
b6b438 |
|
|
|
b6b438 |
nt_status = dcesrv_transport_session_key(dce_call, &session_key);
|
|
|
b6b438 |
if (NT_STATUS_EQUAL(nt_status, NT_STATUS_NO_USER_SESSION_KEY)) {
|
|
|
b6b438 |
@@ -761,7 +762,11 @@ NTSTATUS samr_set_password_buffers(struct dcesrv_call_state *dce_call,
|
|
|
b6b438 |
in = data_blob_const(lm_pwd_hash, 16);
|
|
|
b6b438 |
out = data_blob_talloc_zero(mem_ctx, 16);
|
|
|
b6b438 |
|
|
|
b6b438 |
- sess_crypt_blob(&out, &in, &session_key, false);
|
|
|
b6b438 |
+ rc = sess_crypt_blob(&out, &in, &session_key, SAMBA_GNUTLS_DECRYPT);
|
|
|
b6b438 |
+ if (rc != 0) {
|
|
|
b6b438 |
+ return gnutls_error_to_ntstatus(rc,
|
|
|
b6b438 |
+ NT_STATUS_ACCESS_DISABLED_BY_POLICY_OTHER);
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
|
|
|
b6b438 |
d_lm_pwd_hash = (struct samr_Password *) out.data;
|
|
|
b6b438 |
}
|
|
|
b6b438 |
@@ -769,7 +774,11 @@ NTSTATUS samr_set_password_buffers(struct dcesrv_call_state *dce_call,
|
|
|
b6b438 |
in = data_blob_const(nt_pwd_hash, 16);
|
|
|
b6b438 |
out = data_blob_talloc_zero(mem_ctx, 16);
|
|
|
b6b438 |
|
|
|
b6b438 |
- sess_crypt_blob(&out, &in, &session_key, false);
|
|
|
b6b438 |
+ rc = sess_crypt_blob(&out, &in, &session_key, SAMBA_GNUTLS_DECRYPT);
|
|
|
b6b438 |
+ if (rc != 0) {
|
|
|
b6b438 |
+ return gnutls_error_to_ntstatus(rc,
|
|
|
b6b438 |
+ NT_STATUS_ACCESS_DISABLED_BY_POLICY_OTHER);
|
|
|
b6b438 |
+ }
|
|
|
b6b438 |
|
|
|
b6b438 |
d_nt_pwd_hash = (struct samr_Password *) out.data;
|
|
|
b6b438 |
}
|
|
|
b6b438 |
diff --git a/source4/torture/rpc/samr.c b/source4/torture/rpc/samr.c
|
|
|
b6b438 |
index 4b3ad093bf6..1961c05b5f6 100644
|
|
|
b6b438 |
--- a/source4/torture/rpc/samr.c
|
|
|
b6b438 |
+++ b/source4/torture/rpc/samr.c
|
|
|
b6b438 |
@@ -1007,14 +1007,14 @@ static bool test_SetUserPass_18(struct dcerpc_pipe *p, struct torture_context *t
|
|
|
b6b438 |
DATA_BLOB in,out;
|
|
|
b6b438 |
in = data_blob_const(nt_hash, 16);
|
|
|
b6b438 |
out = data_blob_talloc_zero(tctx, 16);
|
|
|
b6b438 |
- sess_crypt_blob(&out, &in, &session_key, true);
|
|
|
b6b438 |
+ sess_crypt_blob(&out, &in, &session_key, SAMBA_GNUTLS_ENCRYPT);
|
|
|
b6b438 |
memcpy(u.info18.nt_pwd.hash, out.data, out.length);
|
|
|
b6b438 |
}
|
|
|
b6b438 |
{
|
|
|
b6b438 |
DATA_BLOB in,out;
|
|
|
b6b438 |
in = data_blob_const(lm_hash, 16);
|
|
|
b6b438 |
out = data_blob_talloc_zero(tctx, 16);
|
|
|
b6b438 |
- sess_crypt_blob(&out, &in, &session_key, true);
|
|
|
b6b438 |
+ sess_crypt_blob(&out, &in, &session_key, SAMBA_GNUTLS_ENCRYPT);
|
|
|
b6b438 |
memcpy(u.info18.lm_pwd.hash, out.data, out.length);
|
|
|
b6b438 |
}
|
|
|
b6b438 |
|
|
|
b6b438 |
@@ -1096,7 +1096,7 @@ static bool test_SetUserPass_21(struct dcerpc_pipe *p, struct torture_context *t
|
|
|
b6b438 |
in = data_blob_const(u.info21.lm_owf_password.array,
|
|
|
b6b438 |
u.info21.lm_owf_password.length);
|
|
|
b6b438 |
out = data_blob_talloc_zero(tctx, 16);
|
|
|
b6b438 |
- sess_crypt_blob(&out, &in, &session_key, true);
|
|
|
b6b438 |
+ sess_crypt_blob(&out, &in, &session_key, SAMBA_GNUTLS_ENCRYPT);
|
|
|
b6b438 |
u.info21.lm_owf_password.array = (uint16_t *)out.data;
|
|
|
b6b438 |
}
|
|
|
b6b438 |
|
|
|
b6b438 |
@@ -1105,7 +1105,7 @@ static bool test_SetUserPass_21(struct dcerpc_pipe *p, struct torture_context *t
|
|
|
b6b438 |
in = data_blob_const(u.info21.nt_owf_password.array,
|
|
|
b6b438 |
u.info21.nt_owf_password.length);
|
|
|
b6b438 |
out = data_blob_talloc_zero(tctx, 16);
|
|
|
b6b438 |
- sess_crypt_blob(&out, &in, &session_key, true);
|
|
|
b6b438 |
+ sess_crypt_blob(&out, &in, &session_key, SAMBA_GNUTLS_ENCRYPT);
|
|
|
b6b438 |
u.info21.nt_owf_password.array = (uint16_t *)out.data;
|
|
|
b6b438 |
}
|
|
|
b6b438 |
|
|
|
b6b438 |
@@ -1272,14 +1272,14 @@ static bool test_SetUserPass_level_ex(struct dcerpc_pipe *p,
|
|
|
b6b438 |
DATA_BLOB in,out;
|
|
|
b6b438 |
in = data_blob_const(u.info18.nt_pwd.hash, 16);
|
|
|
b6b438 |
out = data_blob_talloc_zero(tctx, 16);
|
|
|
b6b438 |
- sess_crypt_blob(&out, &in, &session_key, true);
|
|
|
b6b438 |
+ sess_crypt_blob(&out, &in, &session_key, SAMBA_GNUTLS_ENCRYPT);
|
|
|
b6b438 |
memcpy(u.info18.nt_pwd.hash, out.data, out.length);
|
|
|
b6b438 |
}
|
|
|
b6b438 |
{
|
|
|
b6b438 |
DATA_BLOB in,out;
|
|
|
b6b438 |
in = data_blob_const(u.info18.lm_pwd.hash, 16);
|
|
|
b6b438 |
out = data_blob_talloc_zero(tctx, 16);
|
|
|
b6b438 |
- sess_crypt_blob(&out, &in, &session_key, true);
|
|
|
b6b438 |
+ sess_crypt_blob(&out, &in, &session_key, SAMBA_GNUTLS_ENCRYPT);
|
|
|
b6b438 |
memcpy(u.info18.lm_pwd.hash, out.data, out.length);
|
|
|
b6b438 |
}
|
|
|
b6b438 |
|
|
|
b6b438 |
@@ -1290,7 +1290,7 @@ static bool test_SetUserPass_level_ex(struct dcerpc_pipe *p,
|
|
|
b6b438 |
in = data_blob_const(u.info21.lm_owf_password.array,
|
|
|
b6b438 |
u.info21.lm_owf_password.length);
|
|
|
b6b438 |
out = data_blob_talloc_zero(tctx, 16);
|
|
|
b6b438 |
- sess_crypt_blob(&out, &in, &session_key, true);
|
|
|
b6b438 |
+ sess_crypt_blob(&out, &in, &session_key, SAMBA_GNUTLS_ENCRYPT);
|
|
|
b6b438 |
u.info21.lm_owf_password.array = (uint16_t *)out.data;
|
|
|
b6b438 |
}
|
|
|
b6b438 |
if (fields_present & SAMR_FIELD_NT_PASSWORD_PRESENT) {
|
|
|
b6b438 |
@@ -1298,7 +1298,7 @@ static bool test_SetUserPass_level_ex(struct dcerpc_pipe *p,
|
|
|
b6b438 |
in = data_blob_const(u.info21.nt_owf_password.array,
|
|
|
b6b438 |
u.info21.nt_owf_password.length);
|
|
|
b6b438 |
out = data_blob_talloc_zero(tctx, 16);
|
|
|
b6b438 |
- sess_crypt_blob(&out, &in, &session_key, true);
|
|
|
b6b438 |
+ sess_crypt_blob(&out, &in, &session_key, SAMBA_GNUTLS_ENCRYPT);
|
|
|
b6b438 |
u.info21.nt_owf_password.array = (uint16_t *)out.data;
|
|
|
b6b438 |
}
|
|
|
b6b438 |
break;
|
|
|
b6b438 |
--
|
|
|
b6b438 |
2.23.0
|
|
|
b6b438 |
|