1

I had Crypto++ library v.5.6.2 in one of my projects. It used to compile (as a static .lib) very cleanly.

Now I see the need to upgrade to the latest available version 6.1.0 with Visual Studio 2008, but when I tried to compile it gave me 63 warning messages listed below.

I know those are just warnings and many people ignore them. I personally do not.

So I was wondering if there's a resolution for those?

Building and assembling rdrand.asm
 Assembling: c:\Users\User\C++\cryptopp610\rdrand.asm
Performing Custom Build Step
        1 file(s) copied.
Compiling...
pch.cpp
c:\users\User\c++\cryptopp610\cryptlib.h(1318) : warning C4505: 'CryptoPP::AuthenticatedSymmetricCipher::AlgorithmName' : unreferenced local function has been removed
Compiling...
vmac.cpp
twofish.cpp
ttmac.cpp
trdlocal.cpp
tigertab.cpp
tiger.cpp
tftables.cpp
tea.cpp
strciphr.cpp
squaretb.cpp
square.cpp
sosemanuk.cpp
socketft.cpp
c:\users\User\c++\cryptopp610\socketft.h(197) : warning C4355: 'this' : used in base member initializer list
c:\users\User\c++\cryptopp610\socketft.h(213) : warning C4355: 'this' : used in base member initializer list
skipjack.cpp
simple.cpp
sharkbox.cpp
shark.cpp
c:\users\User\c++\cryptopp610\algparam.h(409) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(410) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(411) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
shacal2.cpp
sha3.cpp
sha.cpp
Compiling...
serpent.cpp
seed.cpp
seal.cpp
salsa.cpp
safer.cpp
rw.cpp
rsa.cpp
c:\users\User\c++\cryptopp610\oaep.h(50) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
rng.cpp
ripemd.cpp
rijndael.cpp
rdtables.cpp
rdrand.cpp
rc6.cpp
rc5.cpp
rc2.cpp
c:\users\User\c++\cryptopp610\algparam.h(409) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(410) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(411) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
randpool.cpp
rabin.cpp
c:\users\User\c++\cryptopp610\oaep.h(50) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
queue.cpp
pubkey.cpp
pssr.cpp
Compiling...
polynomi.cpp
poly1305.cpp
c:\users\User\c++\cryptopp610\algparam.h(409) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(410) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(411) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
pkcspad.cpp
panama.cpp
osrng.cpp
c:\users\User\c++\cryptopp610\osrng.h(256) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
oaep.cpp
c:\users\User\c++\cryptopp610\oaep.h(50) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
network.cpp
nbtheory.cpp
c:\users\User\c++\cryptopp610\algparam.h(409) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(410) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(411) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
mqv.cpp
mqueue.cpp
modes.cpp
c:\users\User\c++\cryptopp610\algparam.h(409) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(410) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(411) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
misc.cpp
md5.cpp
md4.cpp
md2.cpp
marss.cpp
mars.cpp
luc.cpp
c:\users\User\c++\cryptopp610\oaep.h(50) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\dh.h(169) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
keccak.cpp
integer.cpp
c:\users\User\c++\cryptopp610\algparam.h(409) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(410) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(411) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
Compiling...
idea.cpp
ida.cpp
c:\users\User\c++\cryptopp610\ida.h(73) : warning C4355: 'this' : used in base member initializer list
c:\users\User\c++\cryptopp610\ida.h(121) : warning C4355: 'this' : used in base member initializer list
hrtimer.cpp
hmac.cpp
hex.cpp
gzip.cpp
gost.cpp
gfpcrypt.cpp
gf2n.cpp
gf2_32.cpp
gf256.cpp
gcm.cpp
c:\users\User\c++\cryptopp610\algparam.h(409) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(410) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(411) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
fipstest.cpp
c:\users\User\c++\cryptopp610\algparam.h(409) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(410) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(411) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\dh.h(169) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\ecpoint.h(49) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\ecpoint.h(82) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\osrng.h(256) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\oaep.h(50) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
fips140.cpp
filters.cpp
files.cpp
esign.cpp
emsa2.cpp
elgamal.cpp
ecp.cpp
c:\users\User\c++\cryptopp610\ecpoint.h(49) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\ecpoint.h(82) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
Compiling...
ec2n.cpp
c:\users\User\c++\cryptopp610\ecpoint.h(49) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\ecpoint.h(82) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
eax.cpp
c:\users\User\c++\cryptopp610\algparam.h(409) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(410) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(411) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
dsa.cpp
dh2.cpp
dh.cpp
c:\users\User\c++\cryptopp610\dh.h(169) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
dessp.cpp
des.cpp
default.cpp
cryptlib.cpp
c:\users\User\c++\cryptopp610\osrng.h(256) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
crc.cpp
cpu.cpp
cmac.cpp
channels.cpp
chacha.cpp
ccm.cpp
c:\users\User\c++\cryptopp610\algparam.h(409) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(410) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(411) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
cbcmac.cpp
casts.cpp
cast.cpp
camellia.cpp
blumshub.cpp
Compiling...
blowfish.cpp
blake2.cpp
c:\users\User\c++\cryptopp610\algparam.h(409) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(410) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(411) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
bfinit.cpp
basecode.cpp
base64.cpp
base32.cpp
authenc.cpp
asn.cpp
arc4.cpp
algparam.cpp
c:\users\User\c++\cryptopp610\algparam.h(409) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(410) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(411) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
algebra.cpp
adler32.cpp
Compiling...
3way.cpp
zlib.cpp
zinflate.cpp
zdeflate.cpp
xtrcrypt.cpp
xtr.cpp
c:\users\User\c++\cryptopp610\algparam.h(409) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(410) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
c:\users\User\c++\cryptopp610\algparam.h(411) : warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
winpipes.cpp
whrlpool.cpp
wake.cpp
wait.cpp
Compiling...
iterhash.cpp
c:\users\User\c++\cryptopp610\cryptlib.h(1318) : warning C4505: 'CryptoPP::AuthenticatedSymmetricCipher::AlgorithmName' : unreferenced local function has been removed
dll.cpp
c:\users\User\c++\cryptopp610\cryptlib.h(1318) : warning C4505: 'CryptoPP::AuthenticatedSymmetricCipher::AlgorithmName' : unreferenced local function has been removed
Creating library...
Results 


Build log was saved at "file://c:\Users\User\C++\cryptopp610\Win32\cryptlib\Debug\BuildLog.htm"
cryptlib - 0 error(s), 63 warning(s)

EDIT: Here's one of those warning C4355: 'this' : used in base member initializer list where m_sender is being initialized in constructor:

/// socket-based implementation of NetworkSink
class SocketSink : public NetworkSink, public Socket
{
public:
    SocketSink(socket_t s=INVALID_SOCKET, unsigned int maxBufferSize=0, unsigned int autoFlushBound=16*1024)
        : NetworkSink(maxBufferSize, autoFlushBound), Socket(s), m_sender(*this) {}

    void SendEof() {ShutDown(SD_SEND);}

private:
    NetworkSender & AccessSender() {return m_sender;}
    SocketSender m_sender;
};

Although while trying to correct it by doing this:

class SocketSink : public NetworkSink, public Socket
{
public:
    SocketSink(socket_t s=INVALID_SOCKET, unsigned int maxBufferSize=0, unsigned int autoFlushBound=16*1024)
        : NetworkSink(maxBufferSize, autoFlushBound), Socket(s)
    {
        m_sender = *this;
    }

    void SendEof() {ShutDown(SD_SEND);}

private:
    NetworkSender & AccessSender() {return m_sender;}
    SocketSender m_sender;
};

I get this error. But I'm not really that familiar with this library to make an assignment constructor myself:

error C2512: 'CryptoPP::SocketSender' : no appropriate default constructor available
error C2582: 'operator =' function is unavailable in 'CryptoPP::SocketSender'

So yeah, if anyone familiar with Crypto++ can help me with those, I'd appreciate it. There's too many bugs like this.

jww
  • 97,681
  • 90
  • 411
  • 885
c00000fd
  • 20,994
  • 29
  • 177
  • 400
  • 2
    Yes there are *two* solutions: 1) You ask the author to fix them by reporting them as bugs. 2) You fix them yourself and *then* report them to the author together with your fixes. The library is, after all, open source with a [GitHub repository](https://github.com/weidai11/cryptopp) where you can create a fork and then push-requests for your changes. – Some programmer dude Apr 04 '18 at 18:52
  • @Someprogrammerdude: Yes, I was thinking to go into fixing them myself. Unfortunately that project is quite large, so I don't want to mess something up in crypto that way. – c00000fd Apr 04 '18 at 18:54
  • Your compiler is several versions too old for `extern template` – drescherjm Apr 04 '18 at 18:54
  • "my Visual Studio 2008" - word of advice; get yourself a compiler that's less than 10 years old. – Jesper Juhl Apr 04 '18 at 19:06
  • 1
    The compiler warns you that `extern template` [was a non-standard extension in 2008](https://stackoverflow.com/a/8133000/597607). In C++11 there now *is* a standardized feature [extern template](http://en.cppreference.com/w/cpp/language/class_template). The features seem to work *just about* the same, but not exactly. – Bo Persson Apr 04 '18 at 19:08
  • @JesperJuhl: OK, it's off topic here, but why is VS2018 bad? OK, it's 10 yrs old, but at least it loads in a flash, doesn't take GBs of disk space to install, doesn't want me to log in with my Microsoft account to work, and best of all, doesn't produce over-bloated executables just to name a few. – c00000fd Apr 04 '18 at 19:10
  • 2
    @c00000fd it also doen't support modern C++ (the most important point), has an inferior optimizer compared to newer versions and is no longer supported by MS (as far as I know). – Jesper Juhl Apr 04 '18 at 19:17
  • 2
    Visual studio warns of `this` in member initializer lists because `this` isn't done initializing yet and bad things could happen if you do more than just store `this`. I'm not sure you can get rid of that error without manually verifying that all uses of this in the initializer lists is safe and turning it off. The rest of it probably is the new library version is assuming you have a compiler supporting the more recent standards. MSVS 2015 might be as early as you can go. – user4581301 Apr 04 '18 at 19:23
  • @c00000fd - We tried to remove the warnings some time ago. We don't know how to fix some of them. Some attempts to fix the early VS warnings broke other compilers, like Clang on OS X. Also see [Issue 412, Crypto++ messes with user's warning config](https://github.com/weidai11/cryptopp/issues/412), where we backed-off on the warnings we suppress. – jww Apr 05 '18 at 08:07
  • @c00000fd - Also, in the case of the socket code above, you can just delete the source files if you are not using them. We are contemplating removing them from the library proper since they are not crypto related. Also see [Issue 208, Investigate moving OS specific Socket and Thread to the Patch Page](https://github.com/weidai11/cryptopp/issues/208) – jww Apr 05 '18 at 08:10
  • @jww: Thanks for your reply. You know it's somewhat tricky to remove something w/o knowing alot about the library. As for `m_sender(*this)` part where you instantiate it like that in the constructor, it is just wrong and may lead to crashes, like it was pointed out above. – c00000fd Apr 05 '18 at 08:12
  • Thanks @c00000fd. I think `m_sender(*this)` is just stashing away a reference for future use. But we would be happy to entertain patches for it (especially if we are wandering into UB). – jww Apr 05 '18 at 08:35
  • These warnings are produced by /Wall. You don't like all of them. Use /W3 or /W4. – Hans Passant Apr 05 '18 at 09:06
  • @jww: I was able to resolve `this : used in base member initializer list` warnings by excluding the following from the project: `socketft.h`, `socketft.cpp`, `ida.h`, `ida.cpp`. That last one, what does it do? – c00000fd Apr 05 '18 at 19:11
  • Also what to do with these warnings: `warning C4505: 'CryptoPP::AuthenticatedSymmetricCipher::AlgorithmName' : unreferenced local function has been removed`. I [found this page](https://stackoverflow.com/q/8107844/670017) that deals with the same issue, but for me, I don't want to disable it on the global scale for my entire project. – c00000fd Apr 05 '18 at 19:11
  • @c00000fd - Crypto++ 7.0 was released this weekend. It includes [Commit 62a9574f3fd6](https://github.com/weidai11/cryptopp/commit/62a9574f3fd6), which should squash the Visual Studio complaint about `AuthenticatedSymmetricCipher::AlgorithmName`. – jww Apr 08 '18 at 19:20
  • @jww: Oh, great. Thanks. I'll check it out tomorrow. You guys are cranking those out so quickly that it's hard to keep up. Which kinda concerns me. Say, if we compile our project with one version of cryptopp library, do you have a mailing list or something that can notify us of any critical vulnerabilities in that version that could be found later, and most importantly in which particular class those were found in? – c00000fd Apr 08 '18 at 22:36
  • @c00000fd - Crypto++ 7.0 was unplanned. We planned on riding Crypto++ 6.1 for a year or so. Crypto++ 7.0 was released to clear a memory error. I wanted it off the books to stop potential attacks. If you want another C++ security library, then try [Jack Lloyd's Botan](https://botan.randombit.net/). The mailing lists are at [Crypto++ Home Page | Mailing Lists](https://www.cryptopp.com/#lists). The memory error was announced at [Crypto++ 6.2 release](https://groups.google.com/d/msg/cryptopp-users/AudO2yrAeuw/2oxSbu8OAwAJ). We are fully transparent. There are no special lists. – jww Apr 08 '18 at 23:03
  • Thanks. And, no, I think I'll stick with Crypto++ for now. I'm somewhat invested in it too. I dug into some classed and checked them to be implemented "right" (for my liking.) What I like the most about Crypto++ is that it doesn't go crazy of the latest C++ trends and can be compiled with older versions of IDEs. VS2008 in my case. And also that (until this post) it used to compile very cleanly without any muted warnings or other cutting of corners. But like I said, I'll check v.7.0 next week. – c00000fd Apr 09 '18 at 01:28
  • @jww: Hmm. I'm not sure what to think about v.7.0. I've been trying to compile it for the last 2 days. It still has the same `this : used in base member initializer list` bug, which I can resolve by excluding `socketft` and `ida` files from the project. But now I'm [getting linker errors](https://i.imgur.com/bBkQr0Q.png) of unresolved external symbols when trying to compile a test project with the `.lib` file from v.7.0. – c00000fd Apr 11 '18 at 06:43

0 Answers0