def testLeaks6(): import socket p = pk_generate(512) p2 = pk_generate(512) fn = mix_mktemp() dh = mix_mktemp() _ml.generate_cert(fn, p, p2, "A", "B", 100, 10000) dh_fname = os.environ.get("MM_TEST_DHPARAMS", None) if dh_fname and os.path.exists(dh_fname): dh = dh_fname elif dh_fname: _ml.generate_dh_parameters(dh_fname, 1, 512) dh = dh_fname else: _ml.generate_dh_parameters(dh, 1, 512) print "OK" context = _ml.TLSContext_new(fn, p)#XXXX, dh) listenSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) listenSock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) listenSock.bind(("127.0.0.1", 48999)) listenSock.listen(5) while 1: con, address = listenSock.accept() tls = context.sock(con, serverMode=1) tls.accept() while 1: r = tls.read(50) if r == 0: break while 1: r = tls.shutdown() if r == 1: break con.close()
def testLeaks3(): print "Trying to leak (certgen)" p = pk_generate(512) p2 = pk_generate(512) fn = mix_mktemp() while 1: _ml.generate_cert(fn, p, p2, "A", "B", 100, 10000)
def testLeaks4(): print "Trying to leak (SSL)" p = pk_generate(512) p2 = pk_generate(512) fn = mix_mktemp() dh = mix_mktemp() _ml.generate_cert(fn, p, p2, "A", "B", 100, 10000) dh_fname = os.environ.get("MM_TEST_DHPARAMS") if dh_fname and os.path.exists(dh_fname): dh = dh_fname elif dh_fname: _ml.generate_dh_parameters(dh_fname, 1, 512) dh = dh_fname else: _ml.generate_dh_parameters(dh, 1, 512) print "OK" context = _ml.TLSContext_new(fn, p, dh) while 1: if 1: context = _ml.TLSContext_new(fn, p, dh) _ = context.sock(0, 0) _ = context.sock(0, 1)