diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2016-06-01 20:33:22 -0700 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2016-06-01 20:33:22 -0700 |
commit | 0f11ab36e36073e4cfeb23d476c4e6940671a263 (patch) | |
tree | f85da9d7e52193dcbd453f602cfcebecad924755 | |
parent | 7fc994e413f7f5abd9a3a3493ce8cd54dd8a0106 (diff) | |
parent | 936030680de624fcda780352f619d5f2ec997bab (diff) | |
download | pyopenssl-0f11ab36e36073e4cfeb23d476c4e6940671a263.tar.gz |
Merge pull request #474 from alex/the-great-opaquening
We have always been at war with easy to read code.
-rw-r--r-- | src/OpenSSL/SSL.py | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/src/OpenSSL/SSL.py b/src/OpenSSL/SSL.py index 98c34b4..c0fbc1d 100644 --- a/src/OpenSSL/SSL.py +++ b/src/OpenSSL/SSL.py @@ -1637,11 +1637,14 @@ class Connection(object): :return: A string representing the state """ - if self._ssl.session == _ffi.NULL: + session = _lib.SSL_get_session(self._ssl) + if session == _ffi.NULL: return None - return _ffi.buffer( - self._ssl.s3.server_random, - _lib.SSL3_RANDOM_SIZE)[:] + length = _lib.SSL_get_server_random(self._ssl, _ffi.NULL, 0) + assert length > 0 + outp = _ffi.new("char[]", length) + _lib.SSL_get_server_random(self._ssl, outp, length) + return _ffi.buffer(outp, length)[:] def client_random(self): """ @@ -1649,11 +1652,15 @@ class Connection(object): :return: A string representing the state """ - if self._ssl.session == _ffi.NULL: + session = _lib.SSL_get_session(self._ssl) + if session == _ffi.NULL: return None - return _ffi.buffer( - self._ssl.s3.client_random, - _lib.SSL3_RANDOM_SIZE)[:] + + length = _lib.SSL_get_client_random(self._ssl, _ffi.NULL, 0) + assert length > 0 + outp = _ffi.new("char[]", length) + _lib.SSL_get_client_random(self._ssl, outp, length) + return _ffi.buffer(outp, length)[:] def master_key(self): """ @@ -1661,11 +1668,15 @@ class Connection(object): :return: A string representing the state """ - if self._ssl.session == _ffi.NULL: + session = _lib.SSL_get_session(self._ssl) + if session == _ffi.NULL: return None - return _ffi.buffer( - self._ssl.session.master_key, - self._ssl.session.master_key_length)[:] + + length = _lib.SSL_SESSION_get_master_key(session, _ffi.NULL, 0) + assert length > 0 + outp = _ffi.new("char[]", length) + _lib.SSL_SESSION_get_master_key(session, outp, length) + return _ffi.buffer(outp, length)[:] def sock_shutdown(self, *args, **kwargs): """ |