stef / pysodium

wrapper for libsodium providing high level crypto primitives
Other
130 stars 50 forks source link

Newly added functions lack version checks #83

Closed jvarho closed 6 years ago

jvarho commented 6 years ago

Some of the constants/functions added in bca3999 do not exist in earlier versions of libsodium, like the one I have from Ubuntu 16.04, which is version 1.0.8. I get an error like:

  File "pysodium/__init__.py", line 144, in <module>
    crypto_pwhash_scryptsalsa208sha256_BYTES_MIN = sodium.crypto_pwhash_scryptsalsa208sha256_bytes_min()
  File "/usr/lib/python2.7/ctypes/__init__.py", line 375, in __getattr__
    func = self.__getitem__(name)
  File "/usr/lib/python2.7/ctypes/__init__.py", line 380, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /usr/lib/x86_64-linux-gnu/libsodium.so.18: undefined symbol: crypto_pwhash_scryptsalsa208sha256_bytes_min

I don't have time to figure out each of them at the moment or I would have tried to make a PR.

stef commented 6 years ago

damn. sorry. fixing it right now.

stef commented 6 years ago

hmmmm. looks like there are some constants that have been only added in 1.0.12 but the crypto_pwhash_scryptsalsa208sha256 interface existed previously already since at least 1.0.8. dunno what the best course is, remove the sanity checks entirely for that interface, or enable them only if libsodium is >=1.0.12, and let the previous versions fly blindly?

stef commented 6 years ago

please confirm the fix of this bug by b38db7d8583793a41569a5cd0f8dc761e3e56dba by closing this issue.

jvarho commented 6 years ago

I found one more instance, see #84 .

looks like there are some constants that have been only added in 1.0.12 but the crypto_pwhash_scryptsalsa208sha256 interface existed previously already since at least 1.0.8. dunno what the best course is, remove the sanity checks entirely for that interface, or enable them only if libsodium is >=1.0.12, and let the previous versions fly blindly?

Another option would be to hardcode the values of those constants in 1.0.8...<1.0.12.

stef commented 6 years ago

ah, the hardcoding thing seems like the right solution to this problem, i'll do that! thanks for the insight! keep this ticket open until i commit that fix.

stef commented 6 years ago

i hardcoded the missing values in case they do not exist, also i removed the sodium_version_checks which are made obsolete by this (and i reordered some of the constants to make them more human friendly) in 1d00f0c95b045211fefd9f05a643ac1feb5bb225.