Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crypto++ and upcoming change for byte definition due to C++17 #42

Open
noloader opened this issue Jul 17, 2017 · 1 comment · May be fixed by #47
Open

Crypto++ and upcoming change for byte definition due to C++17 #42

noloader opened this issue Jul 17, 2017 · 1 comment · May be fixed by #47

Comments

@noloader
Copy link

The Crypto++ library is getting ready to change the scope of its definition for a byte. The short of it is, Crypto++ byte and C++17 std::byte can cause compile failures due to ambiguous resolutions; and the behavior of byte and std::byte are incompatible. More information can be found at:

We are looking for testers to provide early feedback. Please see:

Recommendations for user programs which rely the library can be found at:

The change will exist in Master, and then be part of the Crypto++ 6.0 release. The change needs a major version bump because it is so disruptive to user programs. We would like to release Crypto++ in the next month or two.

My apologies for opening an issue. Please label it as an enhancement or feature request.

@noloader
Copy link
Author

noloader commented Jul 17, 2017

Here are the results from Pycryptopp. It appears Pycryptopp did not import the entire std:: or CryptoPP:: namespace, so they avoided the collisions that would have occurred in C++17.

Pycryptopp needed the following due to the upcoming Crypto++ changes. The changes made to Pycryptopp are compatible with the old version (::byte) and new version (CryptoPP::byte) of the Crypto++ library.

$ cat pycryptopp.diff
diff --git a/src/pycryptopp/cipher/aesmodule.cpp b/src/pycryptopp/cipher/aesmodule.cpp
index 360827d..3d0b95a 100644
--- a/src/pycryptopp/cipher/aesmodule.cpp
+++ b/src/pycryptopp/cipher/aesmodule.cpp
@@ -20,6 +20,9 @@ typedef int Py_ssize_t;
 #include <src-cryptopp/aes.h>
 #endif

+// https://github.com/weidai11/cryptopp/issues/442
+typedef unsigned char byte;
+
 static const char*const aes___doc__ = "_aes counter mode cipher\n\
 You are advised to run aes.start_up_self_test() after importing this module.";

diff --git a/src/pycryptopp/cipher/xsalsa20module.cpp b/src/pycryptopp/cipher/xsalsa20module.cpp
index ab29787..a0b7c71 100644
--- a/src/pycryptopp/cipher/xsalsa20module.cpp
+++ b/src/pycryptopp/cipher/xsalsa20module.cpp
@@ -16,6 +16,9 @@ typedef int Py_ssize_t;
 #include <src-cryptopp/salsa.h>
 #endif

+// https://github.com/weidai11/cryptopp/issues/442
+typedef unsigned char byte;
+
 static const char* const xsalsa20__doc__ = "_xsalsa20 cipher";

 static PyObject *xsalsa20_error;
diff --git a/src/pycryptopp/hash/sha256module.cpp b/src/pycryptopp/hash/sha256module.cpp
index bf9d8e3..8272e6c 100644
--- a/src/pycryptopp/hash/sha256module.cpp
+++ b/src/pycryptopp/hash/sha256module.cpp
@@ -21,6 +21,9 @@ typedef int Py_ssize_t;
 #include <src-cryptopp/filters.h>
 #endif

+// https://github.com/weidai11/cryptopp/issues/442
+typedef unsigned char byte;
+
 static const char*const sha256___doc__ = "_sha256 hash function";

 static PyObject *sha256_error;

Note from Crypto++ and JW: we used Pycryptopp as a test run of the proposed changes. If Pycryptopp merges the change above, then it should not have problems with existing versions of the library or new versions of the library.

The same report was filed at pypa/pypi-legacy | issue tracker. See Issue 671, Crypto++ and upcoming change for byte definition due to C++17.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant