diff options
author | Andy Lutomirski <luto@amacapital.net> | 2014-03-05 14:41:41 -0800 |
---|---|---|
committer | Andy Lutomirski <luto@amacapital.net> | 2014-03-05 14:41:41 -0800 |
commit | 9bca0edb8a68b5fdb23287d0412ed8205bc1d91a (patch) | |
tree | ecfbd5c3d9ca3e6b8cb63388d2b24f6f44c833a6 | |
parent | b4e5c8d71227afdead269fdcc7a81cfc674efaff (diff) | |
download | pyopenssl-9bca0edb8a68b5fdb23287d0412ed8205bc1d91a.tar.gz |
Add SSL.ELLIPTIC_CURVE_DESCRIPTIONS to expose the actual supported curves
Different OpenSSL builds support different curves. Determine the
supported curves at startup and expose the list.
-rw-r--r-- | OpenSSL/SSL.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/OpenSSL/SSL.py b/OpenSSL/SSL.py index a3e4cd0..9fe7001 100644 --- a/OpenSSL/SSL.py +++ b/OpenSSL/SSL.py @@ -266,6 +266,15 @@ NID_ipsec4 = _lib.NID_ipsec4 SN_ipsec4 = _ffi.string(_lib.SN_ipsec4) _Cryptography_HAS_EC = _lib.Cryptography_HAS_EC +ELLIPTIC_CURVE_DESCRIPTIONS = {} # In case there's no EC support +if _Cryptography_HAS_EC: + _num_curves = _lib.EC_get_builtin_curves(_ffi.NULL, 0) + _curves = _ffi.new('EC_builtin_curve[]', _num_curves) + if _lib.EC_get_builtin_curves(_curves, _num_curves) == _num_curves: + ELLIPTIC_CURVE_DESCRIPTIONS = {c.nid : _ffi.string(c.comment) + for c in _curves} + del _num_curves + del _curves class Error(Exception): |