Using SRP on TCPServer module

D

dcrespo

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_address = 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
 
P

Paul Rubin

dcrespo said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top