summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-12-16 10:37:51 +0100
committerStefan Metzmacher <metze@samba.org>2012-01-04 20:55:04 +0100
commit1d4cc2a64f6c4df84ee708888e0dd587c0987972 (patch)
treeadec9272b5e3da93a24b0f2a3b2ac9c2ae2c3d90 /source4
parent6ee628341fe25c258c49b43a111ff96b05dcd07b (diff)
downloadsamba-1d4cc2a64f6c4df84ee708888e0dd587c0987972.tar.gz
samba-1d4cc2a64f6c4df84ee708888e0dd587c0987972.tar.bz2
samba-1d4cc2a64f6c4df84ee708888e0dd587c0987972.zip
s4:pygensec: add session_key() method
metze
Diffstat (limited to 'source4')
-rw-r--r--source4/auth/gensec/pygensec.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/source4/auth/gensec/pygensec.c b/source4/auth/gensec/pygensec.c
index 858cbe915e..a683daf0e9 100644
--- a/source4/auth/gensec/pygensec.c
+++ b/source4/auth/gensec/pygensec.c
@@ -264,6 +264,33 @@ static PyObject *py_gensec_session_info(PyObject *self)
return py_session_info;
}
+static PyObject *py_gensec_session_key(PyObject *self)
+{
+ TALLOC_CTX *mem_ctx;
+ NTSTATUS status;
+ struct gensec_security *security = pytalloc_get_type(self, struct gensec_security);
+ DATA_BLOB session_key = data_blob_null;
+ static PyObject *session_key_obj = NULL;
+
+ if (security->ops == NULL) {
+ PyErr_SetString(PyExc_RuntimeError, "no mechanism selected");
+ return NULL;
+ }
+ mem_ctx = talloc_new(NULL);
+
+ status = gensec_session_key(security, mem_ctx, &session_key);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(mem_ctx);
+ PyErr_SetNTSTATUS(status);
+ return NULL;
+ }
+
+ session_key_obj = PyString_FromStringAndSize((const char *)session_key.data,
+ session_key.length);
+ talloc_free(mem_ctx);
+ return session_key_obj;
+}
+
static PyObject *py_gensec_start_mech_by_name(PyObject *self, PyObject *args)
{
char *name;
@@ -472,6 +499,8 @@ static PyMethodDef py_gensec_security_methods[] = {
"S.start_client(credentials)" },
{ "session_info", (PyCFunction)py_gensec_session_info, METH_NOARGS,
"S.session_info() -> info" },
+ { "session_key", (PyCFunction)py_gensec_session_key, METH_NOARGS,
+ "S.session_key() -> key" },
{ "start_mech_by_name", (PyCFunction)py_gensec_start_mech_by_name, METH_VARARGS,
"S.start_mech_by_name(name)" },
{ "start_mech_by_sasl_name", (PyCFunction)py_gensec_start_mech_by_sasl_name, METH_VARARGS,