TALLOC_CTX *mem_ctx,
struct loadparm_context *lp_ctx,
krb5_enctype enctype,
+ bool previous,
DATA_BLOB *key_blob)
{
struct smb_krb5_context *smb_krb5_context = NULL;
TALLOC_CTX *frame = talloc_stackframe();
if ((int)enctype == (int)ENCTYPE_ARCFOUR_HMAC) {
- struct samr_Password *nt_hash
- = cli_credentials_get_nt_hash(cred, frame);
+ struct samr_Password *nt_hash;
+
+ if (previous) {
+ nt_hash = cli_credentials_get_old_nt_hash(cred, frame);
+ } else {
+ nt_hash = cli_credentials_get_nt_hash(cred, frame);
+ }
+
if (nt_hash == NULL) {
TALLOC_FREE(frame);
return EINVAL;
return EINVAL;
}
- password = cli_credentials_get_password(cred);
+ if (previous) {
+ password = cli_credentials_get_old_password(cred);
+ } else {
+ password = cli_credentials_get_password(cred);
+ }
if (password == NULL) {
TALLOC_FREE(frame);
return EINVAL;
return ret;
}
-static PyObject *py_creds_get_kerberos_key(PyObject *self, PyObject *args)
+static PyObject *py_creds_get_kerberos_key_current_or_old(PyObject *self, PyObject *args, bool old)
{
struct loadparm_context *lp_ctx = NULL;
TALLOC_CTX *mem_ctx = NULL;
mem_ctx,
lp_ctx,
enctype,
+ old,
&key);
if (code != 0) {
PyErr_SetString(PyExc_RuntimeError,
return ret;
}
+static PyObject *py_creds_get_kerberos_key(PyObject *self, PyObject *args)
+{
+ return py_creds_get_kerberos_key_current_or_old(self, args, false);
+}
+
+static PyObject *py_creds_get_old_kerberos_key(PyObject *self, PyObject *args)
+{
+ return py_creds_get_kerberos_key_current_or_old(self, args, true);
+}
+
static PyObject *py_creds_encrypt_netr_crypt_password(PyObject *self,
PyObject *args)
{
"Generate a Kerberos key using the current password and\n"
"the salt on this credentials object",
},
+ {
+ .ml_name = "get_old_kerberos_key",
+ .ml_meth = py_creds_get_old_kerberos_key,
+ .ml_flags = METH_VARARGS,
+ .ml_doc = "S.get_old_kerberos_key(enctype, [lp]) -> bytes\n"
+ "Generate a Kerberos key using the old (previous) password and\n"
+ "the salt on this credentials object",
+ },
{
.ml_name = "encrypt_netr_crypt_password",
.ml_meth = py_creds_encrypt_netr_crypt_password,