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

Fix byte type collision in bundled crypto++ with C++17 #66

Merged
merged 2 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions config/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -1177,8 +1177,7 @@ echo "--------------------------------------"
DONKEY_SUI=no
else
AC_MSG_RESULT(yes)
ACX_CHECK_CXX_FLAGS(-std=c++14,cv_stdcxx14, CRYPTOPPFLAGS="-std=c++14")
ACX_CHECK_CXX_FLAGS(-fno-omit-frame-pointer,cv_no_omit_frame_pointer, CRYPTOPPFLAGS="$CRYPTOPPFLAGS -fno-omit-frame-pointer")
ACX_CHECK_CXX_FLAGS(-fno-omit-frame-pointer,cv_no_omit_frame_pointer, CRYPTOPPFLAGS="-fno-omit-frame-pointer")
ACX_CHECK_CXX_FLAGS(-mno-omit-leaf-frame-pointer,cv_no_omit_leaf_frame_pointer, CRYPTOPPFLAGS="$CRYPTOPPFLAGS -mno-omit-leaf-frame-pointer")
CXX=$NEWCXX
CXX_VERSION=`$CXX -dumpversion`
Expand Down
10 changes: 5 additions & 5 deletions src/utils/lib/CryptoPP.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9482,7 +9482,7 @@ inline void PokeUInt32(void* p, uint32_t nVal)
#define PRIVKEYSIZE 384

static Signer* s_signer = NULL;
static byte m_publicKey[MAXPUBKEYSIZE+1];
static CryptoPP::byte m_publicKey[MAXPUBKEYSIZE+1];
static unsigned long m_publicKeyLen = 0;

void cc_lprintf_nl(const char * msg, bool verb);
Expand Down Expand Up @@ -9555,7 +9555,7 @@ unsigned long loadKey(char privateKeyBase64[], char buf[]) {


// return signatureSize (buf)
int createSignature(byte *buf, int maxLen, byte *key, int keyLen, uint32_t cInt, uint8_t ipType, uint32_t ip) {
int createSignature(CryptoPP::byte *buf, int maxLen, CryptoPP::byte *key, int keyLen, uint32_t cInt, uint8_t ipType, uint32_t ip) {

int result = 0;

Expand All @@ -9570,7 +9570,7 @@ int createSignature(byte *buf, int maxLen, byte *key, int keyLen, uint32_t cInt,
CryptoPP::SecByteBlock sBB(s_signer->SignatureLength());
CryptoPP::AutoSeededRandomPool rng;

byte bArray[MAXPUBKEYSIZE+9];
CryptoPP::byte bArray[MAXPUBKEYSIZE+9];

memcpy(bArray,key,keyLen);
PokeUInt32(bArray+keyLen,cInt);
Expand All @@ -9597,7 +9597,7 @@ int createSignature(byte *buf, int maxLen, byte *key, int keyLen, uint32_t cInt,

}

int verifySignature(byte *key, int keyLen, byte *sig, int sigLen, uint32_t cInt, uint8_t ipType, uint32_t ip) {
int verifySignature(CryptoPP::byte *key, int keyLen, CryptoPP::byte *sig, int sigLen, uint32_t cInt, uint8_t ipType, uint32_t ip) {
using namespace CryptoPP;

bool result = false;
Expand All @@ -9607,7 +9607,7 @@ int verifySignature(byte *key, int keyLen, byte *sig, int sigLen, uint32_t cInt,
StringSource ss_Pubkey(key, keyLen,true,0);
Verifier pubKey(ss_Pubkey);

byte bArray[MAXPUBKEYSIZE+9];
CryptoPP::byte bArray[MAXPUBKEYSIZE+9];

memcpy(bArray,m_publicKey,m_publicKeyLen);
PokeUInt32(bArray+m_publicKeyLen,cInt);
Expand Down
3 changes: 1 addition & 2 deletions src/utils/lib/CryptoPP.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,9 @@
# define __USE_W32_SOCKETS
#endif

typedef unsigned char byte; // put in global namespace to avoid ambiguity with other byte typedefs

NAMESPACE_BEGIN(CryptoPP)

typedef unsigned char byte; // put in global namespace to avoid ambiguity with other byte typedefs
typedef unsigned short word16;
typedef unsigned int word32;

Expand Down