Skip to content
This repository has been archived by the owner on May 30, 2020. It is now read-only.

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

Closed
noloader opened this issue Jul 17, 2017 · 3 comments
Closed

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

noloader opened this issue Jul 17, 2017 · 3 comments

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 tahoe-lafs/pycryptopp | issue tracker. See Issue 42, Crypto++ and upcoming change for byte definition due to C++17.

@jamadden
Copy link
Collaborator

Thank you for your report! However, I do not believe this is the relevant tracker. This tracker is only for issues with the software that runs pypi.python.org itself, not for the software distributed there. It seems you've already found the trackers for the specific software you're concerned about and opened issues there, so I'm going to close this.

@noloader
Copy link
Author

@jamadden, Ack thanks. Sorry about the extra noise.

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

No branches or pull requests

2 participants