73 lines
2.2 KiB
Diff
73 lines
2.2 KiB
Diff
From 5b0f5925814742ca8b7e772f1a7f4558b770c45b Mon Sep 17 00:00:00 2001
|
|
From: Andreas Schneider <asn@samba.org>
|
|
Date: Fri, 1 Feb 2019 13:38:21 +0100
|
|
Subject: [PATCH 022/187] s4:libnet: Use GnuTLS RC4 in
|
|
libnet_SetPassword_samr_handle_24()
|
|
|
|
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14031
|
|
|
|
Signed-off-by: Andreas Schneider <asn@samba.org>
|
|
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
|
|
(cherry picked from commit 18937f9ceb5aca23899555c5a34fe359f6fcb126)
|
|
---
|
|
source4/libnet/libnet_passwd.c | 29 ++++++++++++++++++++++++++++-
|
|
1 file changed, 28 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/source4/libnet/libnet_passwd.c b/source4/libnet/libnet_passwd.c
|
|
index b2105121523..064ef98879a 100644
|
|
--- a/source4/libnet/libnet_passwd.c
|
|
+++ b/source4/libnet/libnet_passwd.c
|
|
@@ -386,6 +386,9 @@ static NTSTATUS libnet_SetPassword_samr_handle_24(struct libnet_context *ctx, TA
|
|
struct samr_SetUserInfo2 sui;
|
|
union samr_UserInfo u_info;
|
|
DATA_BLOB session_key;
|
|
+ gnutls_cipher_hd_t cipher_hnd = NULL;
|
|
+ gnutls_datum_t enc_session_key;
|
|
+ int rc;
|
|
|
|
if (r->samr_handle.in.info21) {
|
|
return NT_STATUS_INVALID_PARAMETER_MIX;
|
|
@@ -404,7 +407,28 @@ static NTSTATUS libnet_SetPassword_samr_handle_24(struct libnet_context *ctx, TA
|
|
return status;
|
|
}
|
|
|
|
- arcfour_crypt_blob(u_info.info24.password.data, 516, &session_key);
|
|
+ enc_session_key = (gnutls_datum_t) {
|
|
+ .data = session_key.data,
|
|
+ .size = session_key.length,
|
|
+ };
|
|
+
|
|
+ rc = gnutls_cipher_init(&cipher_hnd,
|
|
+ GNUTLS_CIPHER_ARCFOUR_128,
|
|
+ &enc_session_key,
|
|
+ NULL);
|
|
+ if (rc < 0) {
|
|
+ status = gnutls_error_to_ntstatus(rc, NT_STATUS_CRYPTO_SYSTEM_INVALID);
|
|
+ goto out;
|
|
+ }
|
|
+
|
|
+ rc = gnutls_cipher_encrypt(cipher_hnd,
|
|
+ u_info.info24.password.data,
|
|
+ 516);
|
|
+ gnutls_cipher_deinit(cipher_hnd);
|
|
+ if (rc < 0) {
|
|
+ status = gnutls_error_to_ntstatus(rc, NT_STATUS_CRYPTO_SYSTEM_INVALID);
|
|
+ goto out;
|
|
+ }
|
|
|
|
sui.in.user_handle = r->samr_handle.in.user_handle;
|
|
sui.in.info = &u_info;
|
|
@@ -421,6 +445,9 @@ static NTSTATUS libnet_SetPassword_samr_handle_24(struct libnet_context *ctx, TA
|
|
"SetUserInfo2 level 24 for [%s] failed: %s",
|
|
r->samr_handle.in.account_name, nt_errstr(status));
|
|
}
|
|
+
|
|
+out:
|
|
+ data_blob_clear(&session_key);
|
|
return status;
|
|
}
|
|
|
|
--
|
|
2.23.0
|
|
|