Subject: CAT: Now something completely different...

From: Michael Smith <[email-masked]>
Date: Thu, 28 Oct 1999 10:42:11 -0500

I seem to recall that when Java-GSS discussions 
first got underway, one of the contributors to this
list told us something about a GSS binding for 
the language Python. I don't seem to have kept 
that mail, annoyingly enough. Is there anybody 
on the list who knows about Python/GSS work? 
I've discovered a coven of secret Python cultists
here who have escaped from the C++, VB, and Java 
reservations and are now living in the woods and
eating roots and grubs. 

--Michael Smith
  [email-masked]

==========================================================================
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ietf-cat-wg" to [email-masked]

---

From: Dennis Glatting <[email-masked]>
Date: Thu, 28 Oct 1999 10:11:01 -0700

> reservations and are now living in the woods and

Here is the header and identifying trailer from the message. I have
the body but I am in the middle of moving between mail tools. I'll
send the body if requested.

>From [email-masked] Thu Nov  6 21:31:16 1997
Return-Path: <[email-masked]> 
Received: from pad-thai.cam.ov.com (pad-thai.cam.ov.com
[192.231.148.11])
        by btw.plaintalk.bellevue.wa.us (8.8.7/8.8.7) with ESMTP id
VAA01984
        for <[email-masked]>; Thu, 6 Nov 1997
21:30:58 -0800 (PST)
Received: (from daemon@localhost)
        by pad-thai.cam.ov.com (8.8.6/8.8.6) id WAA07190
        for cat-ietf-redist; Thu, 6 Nov 1997 22:40:14 -0500 (EST)
Date: Fri, 7 Nov 1997 13:39:56 +1000 (EST)   
From: Simon Gibson <[email-masked]>
To: CAT IETF Work Group <[email-masked]>
Cc: Tim Redhead <[email-masked]>
Subject: GSSAPI Python Bindings
Message-Id:
<[email-masked]>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Precedence: bulk

-------------------------------------------------------------------------
Simon Gibson,                                  Telephone: +61 7 3864
5120
Security Unit,                                 Facsimile: +61 7 3864
1282
Distributed Systems Technology Centre,
Queensland University of Technology,      
email:<[email-masked]>
Brisbane Qld 4001, Australia. 
-------------------------------------------------------------------------

---

From: Dennis Glatting <[email-masked]>
Date: Thu, 28 Oct 1999 10:44:37 -0700

> reservations and are now living in the woods and

Hopefully this message includes the Python message.

G'day All,

Recently I have been involved in a project integrating security into a prototype
middleware for distributed objects that is being developed in Python. A generic
method of security was needed so the GSSAPI was a perfect candidate, we also had a
GSSAPI prototype that had previously been developed that we could use as a test bed.
To facilitate this integration the C bindings were wrapped using SWIG (Simplified
Wrapper Interface Generator) to gain access from python. This involved writing
typemaps for the datatypes to be coerced from python to C and vice versa. 

After wrapping the functions an intermediate OO layer was added. This layer grouped
function calls that had commonality into classes. Each class also holds a type of
handle as an attribute of the object eg. the context_handle is an attribute of the
Context class. This OO interface gave a clean and simplified access to the standard
function calls. From this interface we have developed an OO python binding to the
GSSAPI. This is not meant as a standalone binding but as complementary to the C
binding.

This interface is currently working well. We have been able to use the GSSAPI for
security but also able to maintain the OO paradigm of the developing project. From a
personal point of view as I have added extra functionality to our GSSAPI
implementation I have found it easier and faster to do the testing from the python
interface.

The rest of this email is broken up into 2 parts:

Part 1: Shows the class structure and the python bindings.

Part 2: Shows simple example client and server programmes using the python bindings
to demonstrate usage. 

I would appreciate any comments/criticisms that you might have.

Simon

-------------------------------------------------------------------------
Simon Gibson,                                  Telephone: +61 7 3864 5120
Security Unit,                                 Facsimile: +61 7 3864 1282
Distributed Systems Technology Centre,
Queensland University of Technology,       email:<[email-masked]>
Brisbane Qld 4001, Australia.
-------------------------------------------------------------------------

Part 1
======

                        	PYTHON BINDINGS
                                ===============
Class Sets:

Name:
====
gss_compare_name()
gss_canonicalize_name()
gss_display_name()
gss_duplicate_name()
gss_export_name()
gss_import_name()
gss_release_name()

Credential:
==========
gss_acquire_cred()
gss_add-cred()
gss_inquire_cred()
gss_inquire_cred_by_mech()
gss_release_cred()

Context:
=======
gss_accept_sec_context()
gss_context_time()
gss_del_sec_context()
gss_export_sec_context()
gss_get_mic()
gss_import_sec_context()
gss_init_sec_context()
gss_inquire_context()
gss_process_context_token()
gss_unwrap()
gss_verify_mic()
gss_wrap()
gss_wrap_size_limit()

OIDset:
======
gss_add_oid_set_member()
gss_create_oid_set()
gss_inquire_mechs_for_name()
gss_inquire_names_for_mechs()
gss_release_oid_set()
gss_test_oid_set_member()

Support:
=======
gss_display_status()
gss_indicate_mechs()
gss_release_buffer()

********************************************************************************
                        Class Name
===============================================================================

gss_compare_name (		
			name_obj2)		# Python Name() object

		returns 
		[major_status,          #PyInteger
 		 minor_status,          #PyInteger
 		 name_equal ]           #PyInteger 0 = FALSE, 1 = TRUE
        eg.
	[maj,min,name_eq]=name.gss_compare_name(name2_obj)

gss_canonicalize_name (		
			mech-type ) 		# string

		returns 
		[major_status,          #PyInteger
 		 minor_status,          #PyInteger
 		 output_name ]          #string 

gss_display_name()

		returns
		[major_status,         	#PyInteger 
 		minor_status,          	#PyInteger
 		outbuffer,             	#string	
 		out_type ]             	#string
                        
	eg.
	[maj,min,out,type] = name.gss_display_name()                        

gss_duplicate_name ()
		
		returns
		[major_status,         	#PyInteger
 		minor_status,          	#PyInteger
 		dest_name ]            	#Python Name() object

gss_export_name ()
		returns

		[major_status,          #PyInteger
 		 minor_status,          #PyInteger
 		 exported_name ]	#Python Name() object

gss_import-name (	
			input_name,		#string
                        input_nme_type) 	#string eg. 
                                      	            GSS_C_NO_OID
		returns
		[major_status,  	#PyInteger
  		minor_status ]  	#PyInteger
              
	eg.
	[maj,min] = name.gss_import_name("simon",'GSS_C_NO_OID')

gss_release_name()
		returns

		[major_status           #PyInteger
 		minor_status]  	#PyInteger 
	eg.
	[maj,min] = name.gss_release_name()

********************************************************************************
                        Class Credential

********************************************************************************
gss_acquire_cred (                
                     	name_obj,	#Python Name() object
                        time_rec,	#PyInteger
                        desired_mechs,  #string or
                                            # OIDset() object 
                                            # eg.
                                            # GSS_C_NO_OID_SET
                        cred-usage)	#PyInteger

		returns
		[major_status,      	#PyInteger
 		minor_status,      	#PyInteger
 		act_mech,              	#Python OIDset() object
 		time_rec ]             	#PyInteger

	eg.
	[maj,min,mech,time] = credential.gss_acquire_cred(name_obj,
                                                  100,'GSS_C_NO_OID_SET',
                                                  GSS_C_INITIATE)

gss_add_cred (
                     	desired_name,		#Python Name() object
                        desired_mech,		#String
                        cred_usage,		#PyInteger
                        init_time_req,		#PyInteger               
                        accept_time_req 	#PyInteger
                        out_cred_handle)	#Python Credential() 
                                            	    # object or 'NULL'
		returns
		[major_status,          #PyInteger
 		minor_status,          	#PyInteger
 		output_cred,         	#Python Credential() object
 		actual_mechs,          	#Python OIDset() object
 		init_time_rec,         	#PyInteger
 		accept_time_rec]	#PyInteger

gss_inquire_cred ()

		returns
		[major_status,          #PyInteger
 		minor_status,         	#PyInteger
 		name,                 	#Name object
 		lifetime,             	#PyInteger
 		usage,                	#PyInteger
 		mechanism ]           	#Python OIDset() object

	eg.
	[maj,min,nme_obj,lifetime,cred_usage,mechan] = credential.gss_inquire_cred()

gss_inquire_cred_by_mech (
           		mech_type )		#string

		returns
		[major_status,          #PyInteger
 		minor_status,          	#PyInteger
 		name_obj,              	#Python Name() object
 		init_lifetime,        	#PyInteger
 		accept_lifetime,	#PyInteger
 		cred_usage ]            #PyInteger

gss_release_cred()
		returns
		[major_status,          #PyInteger
		 minor_status]  	#PyInteger
	eg.
	[maj,min] = credential.gss_release_cred()

********************************************************************************
                        Class Context

********************************************************************************
gss_accept_sec_context(
   			context,	  	#string eg.
                                                    #GSS_C_NO_CONTEXT OR
                                       	            #Context object
                       	credential,    		#Credential object
                        token_in,   		#string
                        chan_bind)    		#string eg. NULL

		returns
		[major_status,         	#PyInteger
 		minor_status,          	#PyInteger
 		newname,               	#Name() object
 		mech_type,             	#Python pointer
 		tokenout,              	#string
 		ret_flags,             	#PyInteger
 		time_rec,              	#PyInteger
 		del_cred]              	#Python Credential() object
	 	
	eg.
 	[maj,min,newname,mech,dataout,retflg,time_rec,delcred] = \
     	context.gss_accept_sec_context('GSS_C_NO_CONTEXT',cred,datain,'NULL')

gss_context_time()

		returns
		[major_status,          #PyInteger
 		minor_status,          	#PyInteger
 		time ]                 	#PyInteger in seconds
                 
	eg.
	[maj,min,time] = context.gss_context_time()

gss_delete_sec_context()
	
		returns
		[major_status,          #PyInteger
 		minor_status,          	#PyInteger
 		data ]                 	#string
                = 
	
	eg.
	[maj,min,data] = context.gss_delete_sec_context()

gss_export_sec_context ()	

		returns

		[major_status,          #PyInteger
		 minor_status,          #PyInteger
 		interprocess_token] 	#String

gss_get_mic(          qop_req,		#PyInteger
                      msg_buffer)	#string
		
		returns
		[major_status,          #PyInteger
 		minor_status,          	#PyInteger
 		msg_token ]            	#string
 
	eg.
	[maj,min,dataout] = context.get_mic(1,datain)

gss_import_sec_context(
			interproc_tok)		#string

		returns
		[major_status,          #PyInteger
		 minor_status ]         #PyInteger

gss_init_sec_context(	
			cred_obj,		#Credential() object
                        context,		#string eg.
                                            	    #GSS_C_NO_CONTEXT OR
                                            	    #Context object
                    	targ_nme,		#python Name() object
                        mech_type,		#String eg.
                                            	    #GSS_C_NO_OID
                        req_flgs,		#PyInteger
                        time_req,		#PyInteger
                        ch_bind,		#string eg. NULL
                        in_token)		#string eg. 
                                            	    #GSS_C_NO_BUFFER	

		returns
		[ major_status,         #PyInteger
  		minor_status,         	#PyInteger
  		act_mech_type         	#python string
  		token,                	#string
  		flags,                	#PyInteger
  		time_rec ]            	#PyInteger
                                        
	eg.
	[maj,min,act_mech_type,token,flags,time_rec] = context.gss_init_context\
                            (Cred,'GSS_C_NO_CONTEXT',name,'GSS_C_NO_OID', \
                                        0,10,'NULL','GSS_C_NO_BUFFER')

gss_inquire_context()

		returns
		[major_status,          #PyInteger
 		minor_status,          	#PyInteger
 		initNme,               	#Python Name() object
 		acceptorNme,           	#Python Name() object
 		lifetime_rec,          	#PyInteger
 		mech_type,             	#Python string
 		ret_flag,              	#PyInteger
 		local_init,            	#PyInteger
		open ]			#PyInteger  

	eg.
 	[maj,min,init_nme,acc_nme,life_rec,mech_tpe,ret_flg,loc_init] =       \
                        	                context.inquire_context()

gss_process_context_token(
     			buffer)       		#string
		returns
		[major_status           #PyInteger
 		minor_status]          	#PyInteger	 
                                        
	eg.
	[maj,min] = context.gss_process_context_token (in_buff)

gss_unwrap(                
			in_token )		#string
		returns
		[major_status,          #PyInteger
		 minor_status,          #PyInteger
 		token_out,             	#string
 		conf,                  	#PyInteger -0 = signed, 1 = sealed
 		qop ]                  	#PyInteger
               
	eg.
	[maj,min,dataout,conf,qop] = context.gss_unwrap(inbuff)

gss_verify_mic(	
			message_buffer  	#string
                        token_buffer  ) 	#string
		returns
		[major_status,          #PyInteger
		 minor_status,          #PyInteger
 		qop ]                  	#PyInteger
                 
	eg.
	[maj,min,dataout,qop] = context.gss_verify_mic(message, token)
         Class Context

gss_wrap (                
			conf_req,		#PyInteger
                        qop_req, 		#PyInteger
                        data_out ) 		#string
		returns
		[major_status,          	#PyInteger
 		minor_status,        	#PyInteger
 		conf_state,           	#PyInteger
 		token_out ]        	#string
               
	eg.
	[maj,min,state,dataout] = context.gss_wrap(1,0,datain)

gss_wrap_size_limit (
            		conf_req,		#PyInteger
                      	qop_req,		#PyInteger
                    	req_out_size )		#PyInteger
		returns
		[major_status,          #PyInteger
 		minor_status,          	#PyInteger
 		max_input_size ]	#PyInteger

********************************************************************************
                        Class Support

********************************************************************************
gss_display_status (	
			stat_value,		#PyInteger
                        stat_type,		#PyInteger
                     	mech_type,		#string eg.
                                           	    #GSS_C_NO_OID 
                     	mesg_ctxt)		#PyInteger

		returns
		[major_status,          #PyInteger
 		minor_status,          	#PyInteger
 		mesg_ctxt              	#PyInteger
 		mesg]                  	#string
                 
	eg.
	[maj1,min1,mesg_ctxt,mesg] = support.gss_display_status(val,GSS_C_GSS_CODE, \
                        	  "GSS_C_NO_OID",0)

gss_indicate_mechs ()
		returns
		[major_status,          #PyInteger
		 minor_status,          #PyInteger
		 mech_set]              #Python OIDset() object

gss_release_buffer(
			buffer)               	#string	

		returns
		[major_status,          #PyInteger
		 minor_status,  	#PyInteger
		 buffer	]               #string
                = 
	
	eg.
	[maj,min,dataout] = support.gss_release_buffer(dataout)

********************************************************************************
                        Class OIDset

********************************************************************************

gss_add_oid_set_member (
       			member_oid)		#string eg.
                                              	    # GSS_C_MECH_DES
		returns
		[major_status,          #PyInteger
		 minor_status ]         #PyInteger

gss_create_oid_set ()
		returns
		[major_status,          #PyInteger
		 minor_status ]         #PyInteger

gss_inquire_mechs_for_name (
    			input_name )		# Name object
		returns
		[major_status,          #PyInteger
 		minor_status ]         	#PyInteger

gss_inquire_names_for_mech (
        		mechanism )		#string or python ptr
		returns
		[major_status,          #PyInteger
		 minor_status ]         #PyInteger
                = 

gss_release_oid_set ()
		returns
		[major_status,          #PyInteger
		 minor_status ]         #PyInteger

gss_test_oid_set_member (
      			member )		#string eg.
                                            	    # GSS_C_MECH_DES 
		returns
		[major_status,          #PyInteger
 		minor_status,	    	#PyInteger
 		present ]              	#PyInteger
                
--------------------------------------------------------------------------------

Part 2:

#! /usr/local/bin/python

##
## server.py
##

## Server programme that accepts a security context from client programme. The server
## then receives messages and can decrypt using the context

import gssapi          ## OO interface to the python wrapped C gssapi functions
>from mysock import *   ## Some generic socket routines

AS_SERVER = 'typhoon.dstc.qut.edu.au'
as_port_number = 5333

GSS_C_BOTH     = 0          ## define some basic constants
GSS_C_INITIATE = 1
GSS_C_ACCEPT   = 2
GSS_C_GSS_CODE = 1

excBADNME  = 'excBADNME'    ## define some exceptions
excBADCRD  = 'excBADCRD'
excBADCTX  = 'excBADCTX'
excBADSEAL = 'excBADSEAL'

Nme     = gssapi.Name()            ## create some objects
Cred    = gssapi.Credential()
context = gssapi.Context()
support = gssapi.Support()

try :
    [maj,min] = Nme.gss_import_name(sys.argv[1],'GSS_C_NULL_OID')
    if maj != 0:
	Nme.gss_release_name()
	raise excBADNME,maj
    [maj,min,time_rec,mech] = Cred.gss_acquire_cred(Nme,86400,'GSS_C_NULL_OID_SET',\
                                                       GSS_C_BOTH)
    if maj != 0:
	Cred.gss_release_cred()
	raise excBADCRD,maj
    sock = socket(AF_INET,SOCK_STREAM)
    sock.bind(AS_SERVER,as_port_number)
    sock.listen(1)
    while 1 :
	print "Waiting for client connection..."
	conn,addr = sock.accept()
	print "Connection incoming"

	ctxt_est = 0       ## context established == FALSE
	ctxt = 'GSS_C_NO_CONTEXT' ## No context for first call to init-sec()
	while not ctxt_est:
 	    datain = conn.recv(1024)
	    [maj,min,newname,mech,token,retflg,time_rec,delcred] = \
	                context.gss_accept_sec_context(ctxt,Cred,datain,'NULL')
	    if len(token)>0: ## There is a token to be sent
		conn.send(token)
	    if maj > 1:     ## error
		[maj,min,data] = context.gss_delete_sec_context()
		raise excBADCTX,maj
	    if maj == 0 : ## complete
		ctxt_est = 1 ## context established
	    else:               ## maj == 1 ie gss_continue_needed
		ctxt = context  ## input itself to next call of accept-sec-ctxt

	[maj,min,init_nme,acc_nme,life_rec,mech_tpe,ret_flg,loc_init] =  \
 				   context.gss_inquire_context()

	[maj,min,out1,type] = init_nme.gss_display_name()
	print out1
	[maj,min,out,type] = acc_nme.gss_display_name()
	print out
	Finished = 0
	while Finished == 0:
	    inbuff = conn.recv(1024)
	    if inbuff == '':
		Finished = 1
	    else:
		[maj,min,dataout,conf,qop] = context.gss_unseal(inbuff)
		if maj != 0:
		    raise excBADCRD,maj
		print "Message buffer before decryption -->",inbuff
		print "------------"
		print 'Message received was ->',dataout,'\n'
		print "Message was signed and sealed by principal",out1,'\n'
	    print "--------------------------------"
	print "Closing connection"
	print '\n'

	[maj,min,data] = context.gss_delete_sec_context()
	[maj,min,dataout] = support.gss_release_buffer(dataout)
	[maj,min] = Nme.gss_release_name()
	[maj,min] = init_nme.gss_release_name()
	[maj,min] = acc_nme.gss_release_name()
	[maj,min] = Cred.gss_release_cred()
	sock_close(sock)

except ValueError:
    print "Exception"

except KeyboardInterrupt:
    print "Interrupt. Closing down!"

except IndexError:
    print "Usage: ",sys.argv[0],"<server name>"

except excBADNME,val:
    [maj,min,mesg_ctxt,mesg] = support.gss_display_status(val,GSS_C_GSS_CODE, \
				  "GSS_C_NULL_OID",0)
    print "Error in name because of :",mesg
    
except excBADCRD,val:
    [maj,min,mesg_ctxt,mesg] = support.gss_display_status(val,GSS_C_GSS_CODE, \
				  "GSS_C_NULL_OID",0)
    print "Error in acquire_credential because of:",mesg
except excBADCTX,val:
    [maj,min,mesg_ctxt,mesg] = support.gss_display_status(val,GSS_C_GSS_CODE, \
				  "GSS_C_NULL_OID",0)
    print "Error in accept_sec_context because of:",mesg
except excBADSEAL,val:
    [maj,min,mesg_ctxt,mesg] = support.gss_display_status(val,GSS_C_GSS_CODE, \
				  "GSS_C_NULL_OID",0)
    print "Error in seal because of:",mesg

#! /usr/local/bin/python

## 
## client.py
##

## Sample client programme using GSSAPI. The client negotiates a mutually
## authenticated context. Then an encrypted message is sent to the server.

import gssapi          ## OO interface to the python wrapped C gssapi functions
>from mysock import *   ## Some generic socket routines

AS_SERVER = 'typhoon.dstc.qut.edu.au'
as_port_number = 5333

GSS_C_BOTH     = 0          ## define some constants
GSS_C_INITIATE = 1
GSS_C_ACCEPT   = 2
GSS_C_GSS_CODE = 1
FLAG           = 2          ## Mutual Auth

excBADNME  = 'excBADNME'    ## define some exceptions
excBADCRD  = 'excBADCRD'
excBADCTX  = 'excBADCTX'
excBADSEAL = 'excBADSEAL'

Nme     = gssapi.Name()            ## create some objects
TargNme = gssapi.Name()
Cred    = gssapi.Credential()
context = gssapi.Context()
support = gssapi.Support()

try :
    [maj1,min1] = Nme.gss_import_name(sys.argv[2],'GSS_C_NULL_OID')
    if maj1 != 0:
        raise excBADNME,maj1
    [maj,min] = TargNme.gss_import_name(sys.argv[1],'GSS_C_NULL_OID')
    if maj != 0:
	raise excBADNME,maj
    [maj,min,eq] = Nme.gss_compare_name(TargNme)
    [maj,min,mechs,time_rec] = Cred.gss_acquire_cred                        \
                                      (Nme,100,'GSS_C_NULL_OID_SET'         \
				       ,GSS_C_INITIATE)
    if maj != 0:
        raise excBADCRD,maj
    [maj,min,nme,lifetime,cred_usage,mechan] = Cred.gss_inquire_cred()
    if maj != 0:
	raise excBADCRD,maj
    sock = open_sock(AS_SERVER,as_port_number)
    
    ctxt_est = 0   ## context established == FALSE
    ctxt    = 'GSS_C_NO_CONTEXT'
    datain  = 'GSS_C_NO_BUFFER'
    while ctxt_est == 0:
	[maj,min,act_mech_type,token,flags,time_rec] =                         \  
                                    context.gss_init_sec_context               \
				              (Cred,ctxt,TargNme,           \
							'GSS_C_NULL_OID',      \
							FLAG,200,'NULL',datain)
	if len(token) > 0: # There is a token to be sent
	    sock.send(token)
	if maj > 1: # error 
	    [maj,min,data] = context.gss_delete_sec_context()
	    raise excBADCTX,maj
	if maj == 1:   # continue needed
	    ctxt = context # input itself to next call of init-sec-ctxt
	    datain = sock.recv(1024) 
	else:        # context is now established ie maj == 0
	    ctxt_est = 1

    [maj,min,init_nme,acc_nme,life_rec,mech_tpe,ret_flg,loc_init] =       \
				    context.gss_inquire_context()
    if maj != 0:
	raise excBADCTX,maj
    print "There is ",life_rec,"seconds left in context"
    [maj,min,out,type] = Nme.gss_display_name()
    if maj != 0:
	raise excBADNME,maj
    [maj,min,time] = ctx.gss_context_time()
    if maj != 0:
	raise excBADCTX,maj
    Finished = 0
    print "To terminate, enter an empty buffer."
    qop = 1
    while Finished == 0:
	datain = raw_input("Enter data-->")
	if datain == '':  ## Terminate
	    Finished = 1
	    sock_write(sock,datain)
	    dataout = ''
	else:
	    [maj,min,state,dataout] = context.gss_seal(qop,0,datain)
	    if maj != 0:
		raise excBADSEAL,maj
	    [maj,min,time] = context.gss_context_time()
	    print time,' seconds left in context'
	    sock_write(sock,dataout)

    [maj,min,data] = context.gss_delete_sec_context()
    [maj,min,dataout] = support.gss_release_buffer(dataout)
    [maj,min] = Nme.gss_release_name()
    [maj,min] = TargNme.gss_release_name(
    [maj,min] = Cred.gss_release_cred()
    sock_close(sock)

except KeyboardInterrupt:
    print "interrupt"
    sock_write(sock,'')
    [maj,min,data] = context.gss_delete_sec_context()
    [maj,min] = TargNme.gss_release_name(
    [maj,min] = Nme.gss_release_name()
    [maj,min] = Cred.gss_release_cred()
    sock_close(sock)

except IndexError:
    print "Usage: ",sys.argv[0],"<server name> <client name> "

except excBADNME,val:
    [maj1,min1,mesg_ctxt,mesg] = support.gss_display_status(val,GSS_C_GSS_CODE, \
				  "GSS_C_NULL_OID",0)
    print "Error in init-sec-context because of :",mesg

except excBADCRD,val:
    [maj,min,mesg_ctxt,mesg] = support.gss_display_status(val,GSS_C_GSS_CODE, \
				  "GSS_C_NULL_OID",0)
    print "Error in acquire_credential because of:",mesg

except excBADCTX,val:
    [maj,min,mesg_ctxt,mesg] = support.gss_display_status(val,GSS_C_GSS_CODE, \
				  "GSS_C_NULL_OID",0)
    print "Error in init_sec_context because of:",mesg

except excBADSEAL,val:
    [maj,min,mesg_ctxt,mesg] = suportp.gss_display_status(val,GSS_C_GSS_CODE, \
				  "GSS_C_NULL_OID",0)
    print "Error in seal because of:",mesg

################################################################################

Reference URL's:

Python:
http://www.python.org

SWIG:
http://www.cs.utah.edu/~beazley/SWIG/swig.html

#  =============================================================================
#
#  Copyright (C) DSTC Pty Ltd (ACN 052 372 577) 1993, 1994, 1995, 1996, 1997.
#  Unpublished work.  All Rights Reserved.
#  This software is being provided "AS IS" without warranty of
#  any kind.  In no event shall DSTC Pty Ltd be liable for
#  damage of any kind arising out of or in connection with
#  the use or performance of this software.
#
#  =============================================================================