]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
pycredentials: make use of netlogon_creds_encrypt_samr_CryptPassword in py_creds_encr...
authorStefan Metzmacher <metze@samba.org>
Mon, 28 Oct 2024 13:06:28 +0000 (14:06 +0100)
committerJule Anger <janger@samba.org>
Wed, 13 Nov 2024 10:39:12 +0000 (10:39 +0000)
These will simplify adding the logic for netr_ServerAuthenticateKerberos...

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15425

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
(cherry picked from commit ea792fa342deebefa75b77832c9057924cdcb6f6)

auth/credentials/pycredentials.c

index a27e02d1aa53b9765e8b2225c2dda7898c933f80..cdba997b7d662bcfde389a049eb336d4af5286cb 100644 (file)
@@ -1024,9 +1024,11 @@ static PyObject *py_creds_get_aes256_key(PyObject *self, PyObject *args)
 static PyObject *py_creds_encrypt_netr_crypt_password(PyObject *self,
                                                      PyObject *args)
 {
-       DATA_BLOB data = data_blob_null;
        struct cli_credentials    *creds  = NULL;
        struct netr_CryptPassword *pwd    = NULL;
+       struct samr_CryptPassword spwd;
+       enum dcerpc_AuthType auth_type = DCERPC_AUTH_TYPE_NONE;
+       enum dcerpc_AuthLevel auth_level = DCERPC_AUTH_LEVEL_NONE;
        NTSTATUS status;
        PyObject *py_cp = Py_None;
 
@@ -1045,9 +1047,18 @@ static PyObject *py_creds_encrypt_netr_crypt_password(PyObject *self,
                /* pytalloc_get_type sets TypeError */
                return NULL;
        }
-       data.length = sizeof(struct netr_CryptPassword);
-       data.data   = (uint8_t *)pwd;
-       status = netlogon_creds_session_encrypt(creds->netlogon_creds, data);
+
+       memcpy(spwd.data, pwd->data, 512);
+       PUSH_LE_U32(spwd.data, 512, pwd->length);
+
+       status = netlogon_creds_encrypt_samr_CryptPassword(creds->netlogon_creds,
+                                                          &spwd,
+                                                          auth_type,
+                                                          auth_level);
+
+       memcpy(pwd->data, spwd.data, 512);
+       pwd->length = PULL_LE_U32(spwd.data, 512);
+       ZERO_STRUCT(spwd);
 
        PyErr_NTSTATUS_IS_ERR_RAISE(status);