Commit dc7042cc authored by Sam Rushing's avatar Sam Rushing

allow curves params to come from private key (where openssl DER-encodes them).

parent 0ac2c550
......@@ -157,6 +157,7 @@ cdef extern from "openssl/evp.h":
cdef extern from "openssl/ec.h":
ctypedef struct EC_KEY
ctypedef struct EC_POINT
EC_KEY * EC_KEY_new ()
EC_KEY * EC_KEY_new_by_curve_name (int)
int EC_KEY_generate_key (EC_KEY *)
void EC_KEY_free (EC_KEY *)
......
......@@ -18,7 +18,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# -*- Mode: Pyrex -*-
# -*- Mode: Cython; indent-tabs-mode: nil -*-
from libc.errno cimport errno
......@@ -1283,16 +1283,20 @@ cdef class ecdsa:
def __init__ (self, object curve):
cdef int nid
if type(curve) is int:
nid = curve
if curve is None:
# no curve specified
self.key = EC_KEY_new()
else:
nid = OBJ_sn2nid (curve)
if nid == 0:
raise_ssl_error()
else:
self.key = EC_KEY_new_by_curve_name (nid)
if self.key is NULL:
if type(curve) is int:
nid = curve
else:
nid = OBJ_sn2nid (curve)
if nid == 0:
raise_ssl_error()
else:
self.key = EC_KEY_new_by_curve_name (nid)
if self.key is NULL:
raise_ssl_error()
def __dealloc__ (self):
if self.key is not NULL:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment