wbond / oscrypto

Compiler-free Python crypto library backed by the OS, supporting CPython and PyPy
MIT License
320 stars 70 forks source link

oscrypto 1.1.0 and cffi 1.13.2 dumps lots of warnings #34

Closed sfc-gh-stakeda closed 4 years ago

sfc-gh-stakeda commented 4 years ago

Lots of warnings are dumped when importing oscrypto.asymmetric in the environment including cffi 1.13.2:

> python -c 'from oscrypto import asymmetric'
/private/tmp/k1/lib/python3.7/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecRandomDefault' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/private/tmp/k1/lib/python3.7/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecPaddingKey' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/private/tmp/k1/lib/python3.7/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecPaddingPKCS7Key' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/private/tmp/k1/lib/python3.7/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecPaddingPKCS5Key' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
...

My test environment is as follows:

> system_profiler SPSoftwareDataType

Software:

    System Software Overview:

      System Version: macOS 10.14.6 (18G1012)
      Kernel Version: Darwin 18.7.0

Python Version is as follows.

> python --version
Python 3.7.4

pip output is

> pip list
Package    Version
---------- -------
asn1crypto 1.2.0
cffi       1.13.2
oscrypto   1.1.0
pip        19.0.3
pycparser  2.19
setuptools 40.8.0

If cffi is not included, no warning is dumped. Also cffi==1.13.0 doesn't show any warning too.

I suspect cffi added more strict checking on the global variables?

sakins-turner commented 4 years ago

In case it helps, I ran into this recently and was poking around and found that cffi 1.13.1 did in fact make a change to the way cdef works: https://cffi.readthedocs.io/en/latest/whatsnew.html#v1-13-1

On a mac I get warnings about various global variables declared in https://github.com/wbond/oscrypto/blob/93758bef0f0bbcbb89e8583bcd1772f8cf48eeea/oscrypto/_mac/_security_cffi.py

wbond commented 4 years ago

I'm a little back-logged right now. Would either of you be interested in making the requisite changes and sending a PR?

wbond commented 4 years ago

This has been fixed with version 1.1.1