Coder Social home page Coder Social logo

petlib's Introduction

petlib

A python library that implements a number of Privacy Enhancing Technologies (PETs).

Pre-requisites

On Ubuntu / debian use apt-get to install package libssl-dev. Ensure you also install libffi-dev and python-dev:

sudo apt-get install python-dev
sudo apt-get install libssl-dev
sudo apt-get install libffi-dev

On MacOS, install OpenSSL 1.1.x using homebrew:

brew install [email protected]

On Windows, install 32 bit or 64 bit OpenSSL binary edition matching your Python installation. Ensure libeay32.dll is on the system PATH (https://www.openssl.org/related/binaries.html). Configure the path variables of Microsoft VS compilers for 32 bit or 64 bit architectures, by executing the command vcvars32.bat or vcvarsx86_amd64.bat.

Quick install

If you have pip installed the following command should install petlib:

pip install petlib

Test your installation:

python -c "import petlib; petlib.run_tests()"

Build & Test

You may use setuptools and tox to build and test the library:

python setup.py build_ext

To run all tests simply do:

tox

petlib's People

Contributors

benlaurie avatar bogdan-kulynych avatar gdanezis avatar louridas avatar mavroudisv avatar ravirahman avatar the-skas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

petlib's Issues

Invalid comparisons result in recursive exceptions

If you compare Bn to anything that is not a Bn...

Bn(42) == "something"

...petlib falls into a recursive death:

Output:
AttributeError                            Traceback (most recent call last)
~/Workspace/zkc/venv/lib/python3.6/site-packages/petlib/bn.py in __inner_cmp__(self, other)
    283         try:
--> 284             sig = int(_C.BN_cmp(self.bn, other.bn))
    285             return sig

AttributeError: 'NotImplementedType' object has no attribute 'bn'

During handling of the above exception, another exception occurred:

RecursionError                            Traceback (most recent call last)
<ipython-input-2-ea31e540b152> in <module>()
----> 1 Bn(42) == "statast"

~/Workspace/zkc/venv/lib/python3.6/site-packages/petlib/bn.py in __eq__(self, other)
    294
    295     def __eq__(self, other):
--> 296         return self.__inner_cmp__(other) == 0
    297
    298     def __ne__(self, other):

~/Workspace/zkc/venv/lib/python3.6/site-packages/petlib/bn.py in __inner_cmp__(self, other)
    285             return sig
    286         except AttributeError:
--> 287             return self.__inner_cmp__(Bn.from_num(other))
    288
    289     def __lt__(self, other):

... last 1 frames repeated, from the frame below ...

~/Workspace/zkc/venv/lib/python3.6/site-packages/petlib/bn.py in __inner_cmp__(self, other)
    285             return sig
    286         except AttributeError:
--> 287             return self.__inner_cmp__(Bn.from_num(other))
    288
    289     def __lt__(self, other):

RecursionError: maximum recursion depth exceeded while calling a Python object

KeyError: 'OPENSSL_CONF

When I installing petlib on win,there is an error:
ERROR: Command errored out with exit status 1: command: 'd:\python3\python3.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\12711\\AppData\\Local\\Temp\\pip-install-_5s5ibkx\\petlib\\setup.py'"'"'; __file__='"'"'C:\\Users\\12711\\AppData\\Local\\Temp\\pip-install-_5s5ibkx\\petlib\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\12711\AppData\Local\Temp\pip-install-_5s5ibkx\petlib\pip-egg-info' cwd: C:\Users\12711\AppData\Local\Temp\pip-install-_5s5ibkx\petlib\ Complete output (27 lines): Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Users\12711\AppData\Local\Temp\pip-install-_5s5ibkx\petlib\setup.py", line 40, in <module> zip_safe=False, File "d:\python3\lib\site-packages\setuptools\__init__.py", line 145, in setup return distutils.core.setup(**attrs) File "d:\python3\lib\distutils\core.py", line 108, in setup _setup_distribution = dist = klass(attrs) File "d:\python3\lib\site-packages\setuptools\dist.py", line 448, in __init__ k: v for k, v in attrs.items() File "d:\python3\lib\distutils\dist.py", line 281, in __init__ self.finalize_options() File "d:\python3\lib\site-packages\setuptools\dist.py", line 740, in finalize_options ep.load()(self) File "d:\python3\lib\site-packages\setuptools\dist.py", line 747, in _finalize_setup_keywords ep.load()(self, ep.name, value) File "d:\python3\lib\site-packages\cffi\setuptools_ext.py", line 211, in cffi_modules add_cffi_module(dist, cffi_module) File "d:\python3\lib\site-packages\cffi\setuptools_ext.py", line 49, in add_cffi_module execfile(build_file_name, mod_vars) File "d:\python3\lib\site-packages\cffi\setuptools_ext.py", line 25, in execfile exec(code, glob, glob) File "petlib/compile.py", line 34, in <module> openssl_conf = os.environ["OPENSSL_CONF"] File "d:\python3\lib\os.py", line 669, in __getitem__ raise KeyError(key) from None KeyError: 'OPENSSL_CONF' ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

errors uring "pip install petlib"

Very long error output when I follow the instruction of readme to install petlib(Ubuntu 14.04.6 LTS, python 2.7.6) The end of the error msg is :

error: command 'i686-linux-gnu-gcc' failed with exit status 1
----------------------------------------

ERROR: Command "/usr/bin/python -u -c 'import setuptools, tokenize;file='"'"'/tmp/pip-install-H3NHgN/petlib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-4D7FJ1/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-H3NHgN/petlib/

Any one can help figure it out?

Bn's constructor does not check its parameter is a number

Which results in Bn.__init__ serving arbitrary objects to abs(). According to the doc, the following types are acceptable:

"The argument may be a plain or long integer or a floating point number. If the argument is a complex number, its magnitude is returned."

You could either make Bn be an int or float, make its constructor explicitely reject wrong input types, or build a copy constructor (is that even a thing in Python!?).

petlib fails to compile with openssl 1.1

 Running setup.py develop for petlib
    Complete output from command /home/kali/Virtualenvs/petlib/bin/python2 -c "import setuptools, tokenize;__file__='/home/kali/leap/petlib/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" develop --no-deps:
    running develop
    running egg_info
    writing requirements to petlib.egg-info/requires.txt
    writing petlib.egg-info/PKG-INFO
    writing top-level names to petlib.egg-info/top_level.txt
    writing dependency_links to petlib.egg-info/dependency_links.txt
    reading manifest file 'petlib.egg-info/SOURCES.txt'
    writing manifest file 'petlib.egg-info/SOURCES.txt'
    running build_ext
    generating cffi module 'build/temp.linux-x86_64-2.7/petlib._petlib.c'
    creating build
    creating build/temp.linux-x86_64-2.7
    building 'petlib._petlib' extension
    creating build/temp.linux-x86_64-2.7/build
    creating build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-HVkOs2/python2.7-2.7.13=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/petlib._petlib.c -o build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/petlib._petlib.o -Wno-deprecated-declarations
    build/temp.linux-x86_64-2.7/petlib._petlib.c: In function ‘hmac_ctx_size’:
    build/temp.linux-x86_64-2.7/petlib._petlib.c:462:19: error: invalid application of ‘sizeof’ to incomplete type ‘HMAC_CTX {aka struct hmac_ctx_st}’
         return sizeof(HMAC_CTX);
                       ^~~~~~~~
    build/temp.linux-x86_64-2.7/petlib._petlib.c: At top level:
    build/temp.linux-x86_64-2.7/petlib._petlib.c:466:41: error: macro "ERR_load_crypto_strings" passed 1 arguments, but takes just 0
     extern void ERR_load_crypto_strings(void);
                                             ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c:468:34: error: macro "ERR_free_strings" passed 1 arguments, but takes just 0
     extern void ERR_free_strings(void);
                                      ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c:535:5: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
     int setup_ssl_threads() {
         ^~~~~~~~~~~~~~~~~
    build/temp.linux-x86_64-2.7/petlib._petlib.c:1037:56: error: field ‘y’ has incomplete type
     struct _cffi_align_typedef_HMAC_CTX { char x; HMAC_CTX y; };
                                                            ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c: In function ‘_cffi_d_BN_init’:
    build/temp.linux-x86_64-2.7/petlib._petlib.c:1882:3: warning: implicit declaration of function ‘BN_init’ [-Wimplicit-function-declaration]
       BN_init(x0);
       ^~~~~~~
    build/temp.linux-x86_64-2.7/petlib._petlib.c: In function ‘_cffi_d_CRYPTO_lock’:
    build/temp.linux-x86_64-2.7/petlib._petlib.c:3013:3: warning: implicit declaration of function ‘CRYPTO_lock’ [-Wimplicit-function-declaration]
       CRYPTO_lock(x0, x1, x2, x3);
       ^~~~~~~~~~~
    build/temp.linux-x86_64-2.7/petlib._petlib.c: In function ‘_cffi_d_HMAC_CTX_cleanup’:
    build/temp.linux-x86_64-2.7/petlib._petlib.c:7195:3: warning: implicit declaration of function ‘HMAC_CTX_cleanup’ [-Wimplicit-function-declaration]
       HMAC_CTX_cleanup(x0);
       ^~~~~~~~~~~~~~~~
    build/temp.linux-x86_64-2.7/petlib._petlib.c: In function ‘_cffi_d_HMAC_CTX_init’:
    build/temp.linux-x86_64-2.7/petlib._petlib.c:7231:3: warning: implicit declaration of function ‘HMAC_CTX_init’ [-Wimplicit-function-declaration]
       HMAC_CTX_init(x0);
       ^~~~~~~~~~~~~
    build/temp.linux-x86_64-2.7/petlib._petlib.c: In function ‘_cffi_checkfld__ECDSA_SIG’:
    build/temp.linux-x86_64-2.7/petlib._petlib.c:7897:23: error: dereferencing pointer to incomplete type ‘ECDSA_SIG {aka struct ECDSA_SIG_st}’
       { BIGNUM * *tmp = &p->r; (void)tmp; }
                           ^~
    build/temp.linux-x86_64-2.7/petlib._petlib.c: At top level:
    build/temp.linux-x86_64-2.7/petlib._petlib.c:7900:51: error: field ‘y’ has incomplete type
     struct _cffi_align__ECDSA_SIG { char x; ECDSA_SIG y; };
                                                       ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c: In function ‘_cffi_checkfld__EVP_CIPHER_CTX’:
    build/temp.linux-x86_64-2.7/petlib._petlib.c:7907:33: error: dereferencing pointer to incomplete type ‘EVP_CIPHER_CTX {aka struct evp_cipher_ctx_st}’
       { EVP_CIPHER const * *tmp = &p->cipher; (void)tmp; }
                                     ^~
    build/temp.linux-x86_64-2.7/petlib._petlib.c: At top level:
    build/temp.linux-x86_64-2.7/petlib._petlib.c:7916:61: error: field ‘y’ has incomplete type
     struct _cffi_align__EVP_CIPHER_CTX { char x; EVP_CIPHER_CTX y; };
                                                                 ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c: In function ‘_cffi_checkfld__EVP_CIPHER’:
    build/temp.linux-x86_64-2.7/petlib._petlib.c:7923:12: error: dereferencing pointer to incomplete type ‘EVP_CIPHER {aka struct evp_cipher_st}’
       (void)((p->nid) | 0);  /* check that 'EVP_CIPHER.nid' is an integer */
                ^~
    build/temp.linux-x86_64-2.7/petlib._petlib.c: At top level:
    build/temp.linux-x86_64-2.7/petlib._petlib.c:7929:53: error: field ‘y’ has incomplete type
     struct _cffi_align__EVP_CIPHER { char x; EVP_CIPHER y; };
                                                         ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8090:3: error: invalid use of incomplete typedef ‘ECDSA_SIG {aka struct ECDSA_SIG_st}’
       { "r", offsetof(ECDSA_SIG, r),
       ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8093:3: error: invalid use of incomplete typedef ‘ECDSA_SIG {aka struct ECDSA_SIG_st}’
       { "s", offsetof(ECDSA_SIG, s),
       ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8096:3: error: invalid use of incomplete typedef ‘EVP_CIPHER_CTX {aka struct evp_cipher_ctx_st}’
       { "cipher", offsetof(EVP_CIPHER_CTX, cipher),
       ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8099:3: error: invalid use of incomplete typedef ‘EVP_CIPHER_CTX {aka struct evp_cipher_ctx_st}’
       { "encrypt", offsetof(EVP_CIPHER_CTX, encrypt),
       ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8102:3: error: invalid use of incomplete typedef ‘EVP_CIPHER_CTX {aka struct evp_cipher_ctx_st}’
       { "buf_len", offsetof(EVP_CIPHER_CTX, buf_len),
       ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8105:3: error: invalid use of incomplete typedef ‘EVP_CIPHER_CTX {aka struct evp_cipher_ctx_st}’
       { "num", offsetof(EVP_CIPHER_CTX, num),
       ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8108:3: error: invalid use of incomplete typedef ‘EVP_CIPHER_CTX {aka struct evp_cipher_ctx_st}’
       { "key_len", offsetof(EVP_CIPHER_CTX, key_len),
       ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8111:3: error: invalid use of incomplete typedef ‘EVP_CIPHER_CTX {aka struct evp_cipher_ctx_st}’
       { "flags", offsetof(EVP_CIPHER_CTX, flags),
       ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8114:3: error: invalid use of incomplete typedef ‘EVP_CIPHER_CTX {aka struct evp_cipher_ctx_st}’
       { "final_used", offsetof(EVP_CIPHER_CTX, final_used),
       ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8117:3: error: invalid use of incomplete typedef ‘EVP_CIPHER_CTX {aka struct evp_cipher_ctx_st}’
       { "block_mask", offsetof(EVP_CIPHER_CTX, block_mask),
       ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8120:3: error: invalid use of incomplete typedef ‘EVP_CIPHER {aka struct evp_cipher_st}’
       { "nid", offsetof(EVP_CIPHER, nid),
       ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8123:3: error: invalid use of incomplete typedef ‘EVP_CIPHER {aka struct evp_cipher_st}’
       { "block_size", offsetof(EVP_CIPHER, block_size),
       ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8126:3: error: invalid use of incomplete typedef ‘EVP_CIPHER {aka struct evp_cipher_st}’
       { "key_len", offsetof(EVP_CIPHER, key_len),
       ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8129:3: error: invalid use of incomplete typedef ‘EVP_CIPHER {aka struct evp_cipher_st}’
       { "iv_len", offsetof(EVP_CIPHER, iv_len),
       ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8132:3: error: invalid use of incomplete typedef ‘EVP_CIPHER {aka struct evp_cipher_st}’
       { "flags", offsetof(EVP_CIPHER, flags),
       ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8157:12: error: invalid application of ‘sizeof’ to incomplete type ‘HMAC_CTX {aka struct hmac_ctx_st}’
         sizeof(HMAC_CTX), offsetof(struct _cffi_align_typedef_HMAC_CTX, y), 2, 0 },
                ^~~~~~~~
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8157:5: error: initializer element is not constant
         sizeof(HMAC_CTX), offsetof(struct _cffi_align_typedef_HMAC_CTX, y), 2, 0 },
         ^~~~~~
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8157:5: note: (near initialization for ‘_cffi_struct_unions[9].size’)
    In file included from /usr/include/sched.h:28:0,
                     from /usr/include/pthread.h:23,
                     from /usr/include/openssl/crypto.h:406,
                     from /usr/include/openssl/bio.h:20,
                     from /usr/include/openssl/err.h:21,
                     from build/temp.linux-x86_64-2.7/petlib._petlib.c:435:
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8157:23: error: initializer element is not constant
         sizeof(HMAC_CTX), offsetof(struct _cffi_align_typedef_HMAC_CTX, y), 2, 0 },
                           ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8157:23: note: (near initialization for ‘_cffi_struct_unions[9].alignment’)
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8159:12: error: invalid application of ‘sizeof’ to incomplete type ‘ECDSA_SIG {aka struct ECDSA_SIG_st}’
         sizeof(ECDSA_SIG), offsetof(struct _cffi_align__ECDSA_SIG, y), 2, 2 },
                ^~~~~~~~~
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8159:5: error: initializer element is not constant
         sizeof(ECDSA_SIG), offsetof(struct _cffi_align__ECDSA_SIG, y), 2, 2 },
         ^~~~~~
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8159:5: note: (near initialization for ‘_cffi_struct_unions[10].size’)
    In file included from /usr/include/sched.h:28:0,
                     from /usr/include/pthread.h:23,
                     from /usr/include/openssl/crypto.h:406,
                     from /usr/include/openssl/bio.h:20,
                     from /usr/include/openssl/err.h:21,
                     from build/temp.linux-x86_64-2.7/petlib._petlib.c:435:
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8159:24: error: initializer element is not constant
         sizeof(ECDSA_SIG), offsetof(struct _cffi_align__ECDSA_SIG, y), 2, 2 },
                            ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8159:24: note: (near initialization for ‘_cffi_struct_unions[10].alignment’)
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8161:12: error: invalid application of ‘sizeof’ to incomplete type ‘EVP_CIPHER_CTX {aka struct evp_cipher_ctx_st}’
         sizeof(EVP_CIPHER_CTX), offsetof(struct _cffi_align__EVP_CIPHER_CTX, y), 4, 8 },
                ^~~~~~~~~~~~~~
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8161:5: error: initializer element is not constant
         sizeof(EVP_CIPHER_CTX), offsetof(struct _cffi_align__EVP_CIPHER_CTX, y), 4, 8 },
         ^~~~~~
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8161:5: note: (near initialization for ‘_cffi_struct_unions[11].size’)
    In file included from /usr/include/sched.h:28:0,
                     from /usr/include/pthread.h:23,
                     from /usr/include/openssl/crypto.h:406,
                     from /usr/include/openssl/bio.h:20,
                     from /usr/include/openssl/err.h:21,
                     from build/temp.linux-x86_64-2.7/petlib._petlib.c:435:
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8161:29: error: initializer element is not constant
         sizeof(EVP_CIPHER_CTX), offsetof(struct _cffi_align__EVP_CIPHER_CTX, y), 4, 8 },
                                 ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8161:29: note: (near initialization for ‘_cffi_struct_unions[11].alignment’)
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8163:12: error: invalid application of ‘sizeof’ to incomplete type ‘EVP_CIPHER {aka struct evp_cipher_st}’
         sizeof(EVP_CIPHER), offsetof(struct _cffi_align__EVP_CIPHER, y), 12, 5 },
                ^~~~~~~~~~
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8163:5: error: initializer element is not constant
         sizeof(EVP_CIPHER), offsetof(struct _cffi_align__EVP_CIPHER, y), 12, 5 },
         ^~~~~~
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8163:5: note: (near initialization for ‘_cffi_struct_unions[12].size’)
    In file included from /usr/include/sched.h:28:0,
                     from /usr/include/pthread.h:23,
                     from /usr/include/openssl/crypto.h:406,
                     from /usr/include/openssl/bio.h:20,
                     from /usr/include/openssl/err.h:21,
                     from build/temp.linux-x86_64-2.7/petlib._petlib.c:435:
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8163:25: error: initializer element is not constant
         sizeof(EVP_CIPHER), offsetof(struct _cffi_align__EVP_CIPHER, y), 12, 5 },
                             ^
    build/temp.linux-x86_64-2.7/petlib._petlib.c:8163:25: note: (near initialization for ‘_cffi_struct_unions[12].alignment’)
    build/temp.linux-x86_64-2.7/petlib._petlib.c: In function ‘hmac_ctx_size’:
    build/temp.linux-x86_64-2.7/petlib._petlib.c:463:1: warning: control reaches end of non-void function [-Wreturn-type]
     }
     ^
    At top level:
    build/temp.linux-x86_64-2.7/petlib._petlib.c:507:13: warning: ‘_ssl_thread_locking_function’ defined but not used [-Wunused-function]
     static void _ssl_thread_locking_function(int mode, int n, const char *file,
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    
    ----------------------------------------

Attribute Error when trying to import petlib.pack

When attempting to import petlib.pack I get the following error:

Support not loading the library to build docs without compiling.
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/petlib-0.0.43-py2.7-linux-armv7l.egg/petlib/pack.py", line 32, in
from .ec import EcGroup, EcPt
File "/usr/local/lib/python2.7/dist-packages/petlib-0.0.43-py2.7-linux-armv7l.egg/petlib/ec.py", line 2, in
from .bn import Bn, force_Bn, get_ctx
File "/usr/local/lib/python2.7/dist-packages/petlib-0.0.43-py2.7-linux-armv7l.egg/petlib/bn.py", line 794, in
zero = Bn(0)
File "/usr/local/lib/python2.7/dist-packages/petlib-0.0.43-py2.7-linux-armv7l.egg/petlib/bn.py", line 222, in init
self.bn = _C.BN_new()
AttributeError: 'NoneType' object has no attribute 'BN_new'

I tried following the error put was left puzzled when it came down to /usr/local/lib/python2.7/dist-packages/petlib-0.0.43-py2.7-linux-armv7l.egg/petlib/

Can provide debug information as needed.

Return type of `get_tag` should be `bytes`

Example (quick_gcm_enc uses get_tag and in here tag is the return value of get_tag):

>>> from os import urandom
>>> from petlib.cipher import Cipher
>>> message = "hello"
>>> plaintext = message.encode("utf8")
>>> aes = Cipher("aes-128-gcm")
>>> iv = urandom(16)
>>> key = urandom(16)
>>> ciphertext, tag = aes.quick_gcm_enc(key, iv, plaintext)
>>> type(tag)
<type '_cffi_backend.CDataOwn'>
>>> tag is str
False
>>> tag is bytes
False

"pip install petlib" error on Windows

When runnung
pip install petlib
under Windows, installation fails with the following error
OSError: ctypes.util.find_library() did not manage to locate a library called 'crypto'
Error occurs with all available 64bit OpenSSL versions 1.1.1d, 1.10L and 1.0.2t.

Linux installation works fine though!

AttributeError: 'NoneType' object has no attribute 'EC_GROUP_new_by_curve_name'

He,

just installed petlib and now trying to create a new EcGroup instance the following exception occurs.
Any recommendations to make it work?

Python 2.7.10 (default, Oct 23 2015, 19:19:21) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import petlib
>>> from petlib.ec import EcGroup
Support not loading the library to build docs without compiling.
>>> G = EcGroup()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/sebastian/Developer/.envs/pet/lib/python2.7/site-packages/petlib/ec.py", line 62, in __init__
    self.ecg = _C.EC_GROUP_new_by_curve_name(nid)
AttributeError: 'NoneType' object has no attribute 'EC_GROUP_new_by_curve_name'

Little typo in the doc

I think there is little typo in the documentation of the function do_ecdsa_verify in petlib.ecdsa: it is a copy-paste of do_ecdsa_sign (see attached screenshot)

screen shot 2017-06-20 at 17 04 58

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.