By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,908 Members | 1,850 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,908 IT Pros & Developers. It's quick & easy.

Using SRP on TCPServer module

P: n/a
Hi all,

Below, you can see a class that when it receives a host connection, it
gets validated. Then, if the validation returns True, then process the
request. Also, if I want to stop the server, I simply access the
self.QuitFlag in lock mode, and set it to 1.

Now that you know what I have, I would like to add SRP functionality to
the validation of each new connection.
What I need to add to my code to get SRP to work? I don't know where to
start. The docs are poor.

Thanks

Daniel

------------------------------------------------------

class TCPServer(SocketServer.ThreadingTCPServer):

def __init__(self,socket,lock):
self.socket = socket
SocketServer.ThreadingTCPServer.__init__(self,
socket,SocketServer.StreamRequestHandler)
SocketServer.ThreadingTCPServer.allow_reuse_addres s = True
self.timeout = 0.1
self.lock = lock
self.lock.acquire()
self.QuitFlag = 0
self.lock.release()

def get_request(self):
socklist = [self.socket]
while 1:
# Select with a timeout, then poll a quit flag. An
alternate
# approach would be to let the master thread "wake us up"
# with a socket connection.
ready = select.select(socklist, [], [], self.timeout)
self.lock.acquire()
time_to_quit = self.QuitFlag
self.lock.release()
if time_to_quit:
raise TimeToQuit # Get out now
if ready[0]: # A socket was ready to read
return
SocketServer.ThreadingTCPServer.get_request(self)
else: # We timed out, no connection yet
pass # Just go back to the select()

#Process the request
def process_request_thread(self,request,client_address ):
"""
This function gets triggered when the connection is accepted
"""
pass

#Verify the request
def verify_request(self,request,client_address):
"""
This function triggers when some host wants to connect
"""
if DoValidationOf(client_address):
return True
else:
return False

Oct 14 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"dcrespo" <dc*****@gmail.com> writes:
Now that you know what I have, I would like to add SRP functionality to
the validation of each new connection.
What I need to add to my code to get SRP to work? I don't know where to
start. The docs are poor.


I don't know of a Python SRP module that only does SRP. I've been
thinking of writing one.

TLSLite (http://trevp.net/tlslite) implements SRP as an extension to
TLS. Maybe it's what you should be using instead of just sending
cleartext through TCPServer. Connecting up TLSLite to TCPServer is
pretty straightforward and I think there's an example in the TLSLite docs.
Oct 14 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.