@@ -275,6 +275,76 @@ static PyObject *channelBindings(PyObject *self, PyObject *args, PyObject* keywd
275275 return Py_BuildValue ("N" , pychan_bindings );
276276}
277277
278+ static PyObject * authGSSSign (PyObject * self , PyObject * args , PyObject * keywds )
279+ {
280+ gss_client_state * state = NULL ;
281+ PyObject * pystate = NULL ;
282+ PyObject * pytoken = NULL ;
283+ char * message = NULL ;
284+ char * token = NULL ;
285+ static char * kwlist [] = {"context" , "message" , "qop" , NULL };
286+ int result = 0 ;
287+ unsigned int qop = 0 ;
288+
289+ if (! PyArg_ParseTupleAndKeywords (args , keywds , "Os|I" , kwlist , & pystate , & message , & qop )) {
290+ return NULL ;
291+ }
292+
293+ if (! PyCObject_Check (pystate )) {
294+ PyErr_SetString (PyExc_TypeError , "Expected a context object" );
295+ return NULL ;
296+ }
297+
298+ state = (gss_client_state * )PyCObject_AsVoidPtr (pystate );
299+
300+ if (state == NULL ) {
301+ return NULL ;
302+ }
303+
304+ result = authenticate_gss_sign (state , message , qop , & token );
305+ if (result == AUTH_GSS_ERROR ) {
306+ return NULL ;
307+ }
308+
309+ pytoken = PyString_FromString (token );
310+ free (token );
311+
312+ return pytoken ;
313+ }
314+
315+ static PyObject * authGSSVerify (PyObject * self , PyObject * args , PyObject * keywds )
316+ {
317+ gss_client_state * state = NULL ;
318+ PyObject * pystate = NULL ;
319+ char * message = NULL ;
320+ char * token = NULL ;
321+ static char * kwlist [] = {"context" , "message" , "token" , "qop" , NULL };
322+ int result = 0 ;
323+ unsigned int qop = 0 ;
324+
325+ if (! PyArg_ParseTupleAndKeywords (args , keywds , "Oss|I" , kwlist , & pystate , & message , & token , & qop )) {
326+ return NULL ;
327+ }
328+
329+ if (! PyCObject_Check (pystate )) {
330+ PyErr_SetString (PyExc_TypeError , "Expected a context object" );
331+ return NULL ;
332+ }
333+
334+ state = (gss_client_state * )PyCObject_AsVoidPtr (pystate );
335+
336+ if (state == NULL ) {
337+ return NULL ;
338+ }
339+
340+ result = authenticate_gss_verify (state , message , token , qop );
341+ if (result == AUTH_GSS_ERROR ) {
342+ return NULL ;
343+ }
344+
345+ return Py_BuildValue ("i" , result );
346+ }
347+
278348static PyObject * authGSSClientStep (PyObject * self , PyObject * args , PyObject * keywds )
279349{
280350 gss_client_state * state = NULL ;
@@ -725,6 +795,16 @@ static PyMethodDef KerberosMethods[] = {
725795 getServerPrincipalDetails , METH_VARARGS ,
726796 "Return the service principal for a given service and hostname."
727797 },
798+ {
799+ "authGSSSign" ,
800+ (PyCFunction )authGSSSign , METH_VARARGS | METH_KEYWORDS ,
801+ "Compute MIC of the message" ,
802+ },
803+ {
804+ "authGSSVerify" ,
805+ (PyCFunction )authGSSVerify , METH_VARARGS | METH_KEYWORDS ,
806+ "Verify MIC of the message" ,
807+ },
728808 {
729809 "authGSSClientInit" ,
730810 (PyCFunction )authGSSClientInit , METH_VARARGS | METH_KEYWORDS ,
0 commit comments