Giter Club home page Giter Club logo

pyecc's Introduction

PyECC: Python Elliptical Curve Cryptography

PyECC is a Python module wrapped around the libseccure library which itself is based off of code developed originally for the seccure(1) utility.

Build and Install

Since PyECC uses setuptools to build and install the PyECC module and corresponding library, you need to run:

% sudo python setup.py install

Author(s)

PyECC was developed by R. Tyler Ballance ([email protected]) at Slide, Inc.. The original seccure(1) binary however was developed by B. Poettering.

pyecc's People

Contributors

bithinalangot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pyecc's Issues

_pyecc.c: py_decrypt clobbers its input

Apparently ecc_decrypt clobbers its input (the cipher text to be decrypted). Here is a patch:

--- _pyecc.c~
+++ _pyecc.c
@@ -103,15 +103,16 @@
 ECC_State PyCObject \
 \n\
 ";
 static PyObject *py_decrypt(PyObject *self, PyObject *args, PyObject *kwargs)
 {
-    PyObject *temp_state, *temp_keypair;
+    PyObject *temp_state, *temp_keypair, *retval;
     ECC_State state;
     ECC_KeyPair keypair;
     ECC_Data encrypted;
     char *data;
+    char *dcopy;
     int datalen;

     if (!PyArg_ParseTuple(args, "s#OO", &data, &datalen, &temp_keypair,
             &temp_state)) {
         return NULL;
@@ -118,20 +119,28 @@
     }

     state = (ECC_State)(PyCObject_AsVoidPtr(temp_state));
     keypair = (ECC_KeyPair)(PyCObject_AsVoidPtr(temp_keypair));

+    if (!(dcopy = (char *)malloc(datalen))) { /* Make a copy of the encrypted input because ecc_decrypt is going to stomp on it */
+      Py_RETURN_NONE;
+    }
+
+    memcpy(dcopy, data, datalen);
+
     encrypted = ecc_new_data();
-    encrypted->data = data;
+    encrypted->data = dcopy;   /* Use the copy */
     encrypted->datalen = datalen;

     ECC_Data result = ecc_decrypt(encrypted, keypair, state);

     if ( (result == NULL) || (result->data == NULL) )
         Py_RETURN_NONE;

-    return PyString_FromStringAndSize((char *)(result->data), result->datalen);
+    retval = (PyObject *) PyString_FromStringAndSize((char *)(result->data), result->datalen);
+    free(dcopy);
+    return retval;
 }

 static char new_keypair_doc[] = "\
 Return a new ECC_KeyPair object that will contain the appropriate \
 references to the public and private keys in memory\n\

Error raised while installation

When I was trying to install pyECC in ubuntu 10.10 the following error was raised

building '_pyecc' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include -I/usr/local/include -I/usr/include/python2.7 -c seccure/libseccure.c -o build/temp.linux-x86_64-2.7/seccure/libseccure.o -Wall -Werror
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include -I/usr/local/include -I/usr/include/python2.7 -c seccure/numtheory.c -o build/temp.linux-x86_64-2.7/seccure/numtheory.o -Wall -Werror
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include -I/usr/local/include -I/usr/include/python2.7 -c seccure/ecc.c -o build/temp.linux-x86_64-2.7/seccure/ecc.o -Wall -Werror
seccure/ecc.c: In function ‘point_decompress’:
seccure/ecc.c:111:12: error: variable ‘rc’ set but not used [-Werror=unused-but-set-variable]
seccure/ecc.c: In function ‘pointmul’:
seccure/ecc.c:364:7: error: variable ‘rc’ set but not used [-Werror=unused-but-set-variable]
cc1: all warnings being treated as errors

Errors while installing

The following errors are generated while installing in mac 10.10.1 OS X
In file included from seccure/libseccure.c:32:
seccure/libseccure.h:20:9: error: 'LIBSECFURE_H' is used as a header guard
here, followed by #define of a different macro [-Werror,-Wheader-guard]

ifndef LIBSECFURE_H

    ^~~~~~~~~~~~~~

seccure/libseccure.h:21:9: note: 'LIBSECCURE_H' is defined here; did you mean
'LIBSECFURE_H'?

define LIBSECCURE_H

    ^~~~~~~~~~~~~~
    _LIBSECFURE_H_

seccure/libseccure.c:60:22: error: equality comparison with extraneous
parentheses [-Werror,-Wparentheses-equality]
if ( (keypair->pub == NULL) )
~~~~~~~~~~~~~^~~~~~~
seccure/libseccure.c:60:22: note: remove extraneous parentheses around the
comparison to silence this warning
if ( (keypair->pub == NULL) )
~ ^ ~
seccure/libseccure.c:60:22: note: use '=' to turn this equality comparison into
an assignment
if ( (keypair->pub == NULL) )
^~
=
seccure/libseccure.c:474:13: error: equality comparison with extraneous
parentheses [-Werror,-Wparentheses-equality]
if ( (data == NULL) ) {
~~~~~^~~~~~~
seccure/libseccure.c:474:13: note: remove extraneous parentheses around the
comparison to silence this warning
if ( (data == NULL) ) {
~ ^ ~
seccure/libseccure.c:474:13: note: use '=' to turn this equality comparison into
an assignment
if ( (data == NULL) ) {
^~
=
seccure/libseccure.c:682:13: error: equality comparison with extraneous
parentheses [-Werror,-Wparentheses-equality]
if ( (data == NULL) ) {
~~~~~^~~~~~~
seccure/libseccure.c:682:13: note: remove extraneous parentheses around the
comparison to silence this warning
if ( (data == NULL) ) {
~ ^ ~
seccure/libseccure.c:682:13: note: use '=' to turn this equality comparison into
an assignment
if ( (data == NULL) ) {
^~
=
4 errors generated.
error: command 'clang' failed with exit status 1

Allow variable curve specification

Instead of defaulting to the current curve (DEFAULT_CURVE) the ECC_Options structure should allow for the specifying of arbitrary curves.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.