| Class: cryptsock | src/cryptsock.py | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
This class provides a transparent layer of security for network transmissions when properly used. In this and other respects, it draws much from the goals of SSL and TLS. However, cryptsock's underlying cryptographic primitives are more efficient and consequently, impose less overhead in terms of memory, cycles and module size. This class basically wraps the traditional socket, providing a few new methods to be used. The raw socket is accessible as the sock attribute of the class. Zlib compression is used on all bulk data that passes through the socket. Uses 128 Bit AES in ECB mode, Elliptic curve Diffie-Hellman and Nyberg-Rueppel Signature / Verification. A record protocol based on TLS (rfc 2246) and cPickle is employed to manage message integrity. Sample usage: Echo program:
Server:
-------
from cryptsock.cryptsock import cryptsock
s=cryptsock(1)
s.bind("",12345)
s.listen(1)
print 'Listening...'
c=s.accept()
print 'Connect from ', c.addr
data = c.recv()
c.send(data)
c.close()
Client:
-------
from cryptsock.cryptsock import cryptsock
s=cryptsock()
s.connect('127.0.0.1',12345)
s.send('Hello World!')
data = s.recv()
s.close
As you can see, cryptsock's API is nearly identical to the standard python socket. This module requires the AES, ECC and CSPRNG classes from cryptkit in order to function properly.
|