From: Stefan Metzmacher Date: Mon, 28 Oct 2024 13:06:28 +0000 (+0100) Subject: pycredentials: make use of netlogon_creds_encrypt_samr_CryptPassword in py_creds_encr... X-Git-Tag: tdb-1.4.13~793 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ea792fa342deebefa75b77832c9057924cdcb6f6;p=thirdparty%2Fsamba.git pycredentials: make use of netlogon_creds_encrypt_samr_CryptPassword in py_creds_encrypt_netr_crypt_password These will simplify adding the logic for netr_ServerAuthenticateKerberos... BUG: https://bugzilla.samba.org/show_bug.cgi?id=15425 Signed-off-by: Stefan Metzmacher Reviewed-by: Douglas Bagnall --- diff --git a/auth/credentials/pycredentials.c b/auth/credentials/pycredentials.c index 8008bd0418d..9533392b623 100644 --- a/auth/credentials/pycredentials.c +++ b/auth/credentials/pycredentials.c @@ -1074,9 +1074,11 @@ static PyObject *py_creds_get_old_kerberos_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; @@ -1100,9 +1102,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);