wbond / oscrypto

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

Warnings for non-extern, non-static global variables #37

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hello! Looks like we're using your software, so thanks before anything else.

I have been looking into this series of warnings thrown when running some python commands, which complained about several global variables not having the extern keyword. I'm adding the warnings below.

I finally troubleshooted it down to your code, and temporarily fixed it by the obvious solution of adding the keyword where necessary.

My question is, do you think we should actually use extern here? I am not knowledgable about this domain, so any kind of information would be helpful. I'd be happy to open a PR.

Files affected:

_mac/_security_cffi.py
_mac/_core_foundation_cffi.py

Thanks!

The warning avalanche:

/Users/erinc/.virtualenvs/findapro/lib/python3.6/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,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/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,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/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,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecPaddingPKCS1Key' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecPaddingOAEPKey' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecPaddingNoneKey' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecModeCBCKey' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecTransformInputAttributeName' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecDigestTypeAttribute' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecDigestLengthAttribute' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecIVKey' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecAttrIsExtractable' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecDigestSHA1' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecDigestSHA2' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecDigestMD5' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecAttrKeyType' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecAttrKeyTypeRSA' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecAttrKeyTypeDSA' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecAttrKeyTypeECDSA' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecAttrKeySizeInBits' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecAttrLabel' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecAttrCanSign' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecAttrCanVerify' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecAttrKeyTypeAES' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecAttrKeyTypeRC4' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecAttrKeyTypeRC2' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecAttrKeyType3DES' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kSecAttrKeyTypeDES' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kCFAllocatorDefault' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kCFTypeArrayCallBacks' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kCFBooleanTrue' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kCFTypeDictionaryKeyCallBacks' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
/Users/erinc/.virtualenvs/findapro/lib/python3.6/site-packages/cffi/cparser.py:164: UserWarning: Global variable 'kCFTypeDictionaryValueCallBacks' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
  "(usually 'extern')" % (decl.name,))
ghost commented 4 years ago

Closed as I noticed this was a duplicate of https://github.com/wbond/oscrypto/issues/34.

wbond commented 4 years ago

This has been fixed as of 1.1.1