Skip to content

Commit

Permalink
Merge remote-tracking branch 'chusopr/cpp17-cryptopp-byte'
Browse files Browse the repository at this point in the history
* chusopr/cpp17-cryptopp-byte:
  Revert "try to use c++14 mode as c++17 introduces std::byte which breaks CryptoPP 5.x"
  Move bundled crypto++ byte type definition to CrytoPP namespace to avoid collision with C++17 following upstream: https://www.cryptopp.com/wiki/Std::byte
  • Loading branch information
ygrek committed Jul 29, 2024
2 parents 338880f + 4c7206b commit 51c64f9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
3 changes: 1 addition & 2 deletions config/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -1168,8 +1168,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 @@ -177,10 +177,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

0 comments on commit 51c64f9

Please sign in to comment.