weidai11/cryptopp

CRYPTOPP_VERSION has reached its limits

noloader opened this issue · 3 comments

Crypto++ 8.9.0 was released on October 1, 2023. As part of the release process, we bump version numbers for semantic versioning per https://www.cryptopp.com/wiki/Release_Versioning#Increment.

Crypto++ has a CRYPTOPP_VERSION macro, but it cannot handle '10' in the minor position. We cannot go from:

#define CRYPTOPP_VERSION 890

to version 8.10.

An additional constraint is, CRYPTOPP_VERSION has always used 10-based numbers. They are not hexadecimal based.

This report will track the problem.


$ grep CRYPTOPP_VERSION *.h *.cpp
config_ver.h:/// \sa CRYPTOPP_VERSION, LibraryVersion(), HeaderVersion()
config_ver.h:/// \sa CRYPTOPP_VERSION, LibraryVersion(), HeaderVersion()
config_ver.h:/// \sa CRYPTOPP_VERSION, LibraryVersion(), HeaderVersion()
config_ver.h:/// \details CRYPTOPP_VERSION reflects the version of the library the headers
config_ver.h:#define CRYPTOPP_VERSION 8A0
cryptlib.h:     return CRYPTOPP_VERSION;
bench1.cpp:     oss << "\n<H1><A href=\"http://www.cryptopp.com\">Crypto++ " << CRYPTOPP_VERSION / 100;
bench1.cpp:     oss << '.' << (CRYPTOPP_VERSION % 100) / 10 << '.' << CRYPTOPP_VERSION % 10 << "</A> Benchmarks</H1>";
cryptlib.cpp:# define CRYPTOPP_BUILD_VERSION CRYPTOPP_VERSION
test.cpp:                       std::cout << CRYPTOPP_VERSION / 100 << '.' << (CRYPTOPP_VERSION % 100) / 10 << '.' << CRYPTOPP_VERSION % 10 << std::endl;

I think we need to use two digits for each component:

#define CRYPTOPP_VERSION 081000

It is also possible to get inspired by libcurl they use define macros for major , minor and patch versions as well as hexadecimal (24-bit , 6 digit) version identifier that can be used to compare older to newer version. I used exactly this when interacting with libcurl to check if building against a curl library version that is lower than a certain desired version.

for example , adapting from https://github.com/curl/curl/blob/master/include/curl/curlver.h . you could just go for hexadecimal 24-bit since its always comparable between recent and older versions and will never fall in the problem above for example :

#define CRYPTOPP_VERSION_HEX 0x0810AF

#define CRYPTOPP_VERSION_MAJOR 8
#define CRYPTOPP_VERSION_MINOR 10
#define CRYPTOPP_VERSION_PATCH 175

with a fictional 175 version patch number used only for demonstration purposes

irwir commented

Not sure about inspiration, but this is versioning in Windows: https://learn.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-makedllverull