diff options
author | Heikki Toivonen <heikki@heikkitoivonen.net> | 2006-11-22 19:40:33 +0000 |
---|---|---|
committer | Heikki Toivonen <heikki@heikkitoivonen.net> | 2006-11-22 19:40:33 +0000 |
commit | d7e77e3c43d56315376c6ade4bbf339ebb61a136 (patch) | |
tree | b0a8b2f07815441cefb7941bdb53c7c879f12017 | |
parent | 6b088ac9a3d8c0d28698f417bdb2d9c6ec974341 (diff) | |
download | m2crypto-d7e77e3c43d56315376c6ade4bbf339ebb61a136.tar.gz |
Bug 7045, fixed twisted wrapper to work with >16kb BIO buffers, by Martin Paljak.
git-svn-id: http://svn.osafoundation.org/m2crypto/trunk@482 2715db39-9adf-0310-9c64-84f055769b4b
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | M2Crypto/SSL/TwistedProtocolWrapper.py | 39 |
2 files changed, 21 insertions, 19 deletions
@@ -3,6 +3,7 @@ - Added m2urllib2, by James Bowes (python 2.4 and later, at least for now) - Fixed m2urllib.open_https to return the response headers, otherwise code that relied on that would break (for example msnlib-3.5), by Arno bakker +- Fixed twisted wrapper to work with >16kb BIO buffers, by Martin Paljak - Added support for remaining ECs, by Larry Bugbee - Fixed DSA.save_key and DSA_.save_pub_key, by Larry Bugbee - SSL.Context.load_verify_locations raises ValueError if cafile and capath diff --git a/M2Crypto/SSL/TwistedProtocolWrapper.py b/M2Crypto/SSL/TwistedProtocolWrapper.py index 7e8aab1..b4a2d6f 100644 --- a/M2Crypto/SSL/TwistedProtocolWrapper.py +++ b/M2Crypto/SSL/TwistedProtocolWrapper.py @@ -373,18 +373,20 @@ class TLSProtocolWrapper(ProtocolWrapper): def _encrypt(self, data='', clientHello=0): # XXX near mirror image of _decrypt - refactor - self.data += data - g = m2.bio_ctrl_get_write_guarantee(self.sslBio._ptr()) - if g > 0 and self.data != '' or clientHello: - r = m2.bio_write(self.sslBio._ptr(), self.data) - if r <= 0: - assert(m2.bio_should_retry(self.sslBio._ptr())) - else: - assert(self.checked) - self.data = self.data[r:] - encryptedData = '' + self.data += data + while 1: + g = m2.bio_ctrl_get_write_guarantee(self.sslBio._ptr()) + if g > 0 and self.data != '' or clientHello: + r = m2.bio_write(self.sslBio._ptr(), self.data) + #pdb.set_trace() + if r <= 0: + assert(m2.bio_should_retry(self.sslBio._ptr())) + else: + assert(self.checked) + self.data = self.data[r:] + pending = m2.bio_ctrl_pending(self.networkBio) if pending: d = m2.bio_read(self.networkBio, pending) @@ -394,22 +396,21 @@ class TLSProtocolWrapper(ProtocolWrapper): assert(m2.bio_should_retry(self.networkBio)) else: break - return encryptedData def _decrypt(self, data=''): # XXX near mirror image of _encrypt - refactor self.encrypted += data - g = m2.bio_ctrl_get_write_guarantee(self.networkBio) - if g > 0 and self.encrypted != '': - r = m2.bio_write(self.networkBio, self.encrypted) - if r <= 0: - assert(m2.bio_should_retry(self.networkBio)) - else: - self.encrypted = self.encrypted[r:] - decryptedData = '' while 1: + g = m2.bio_ctrl_get_write_guarantee(self.networkBio) + if g > 0 and self.encrypted != '': + r = m2.bio_write(self.networkBio, self.encrypted) + if r <= 0: + assert(m2.bio_should_retry(self.networkBio)) + else: + self.encrypted = self.encrypted[r:] + pending = m2.bio_ctrl_pending(self.sslBio._ptr()) if pending: d = m2.bio_read(self.sslBio._ptr(), pending) |