Change to more intuitive names LibraryVersion and HeaderVersion (Issue 371)
parent
6f7339c81b
commit
42af35fd2b
|
|
@ -950,7 +950,7 @@ void AuthenticatedKeyAgreementDomain::GenerateEphemeralKeyPair(RandomNumberGener
|
||||||
#ifndef CRYPTOPP_BUILD_VERSION
|
#ifndef CRYPTOPP_BUILD_VERSION
|
||||||
# define CRYPTOPP_BUILD_VERSION CRYPTOPP_VERSION
|
# define CRYPTOPP_BUILD_VERSION CRYPTOPP_VERSION
|
||||||
#endif
|
#endif
|
||||||
int BuildVersion()
|
int LibraryVersion()
|
||||||
{
|
{
|
||||||
return CRYPTOPP_BUILD_VERSION;
|
return CRYPTOPP_BUILD_VERSION;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
50
cryptlib.h
50
cryptlib.h
|
|
@ -2916,69 +2916,69 @@ public:
|
||||||
|
|
||||||
//! \brief Specifies the build-time version of the library
|
//! \brief Specifies the build-time version of the library
|
||||||
//! \returns integer representing the build-time version
|
//! \returns integer representing the build-time version
|
||||||
//! \details BuildVersion can help detect inadvertent mixing and matching of library
|
//! \details LibraryVersion can help detect inadvertent mixing and matching of library
|
||||||
//! versions. When using Crypto++ distributed by a third party, BuildVersion()
|
//! versions. When using Crypto++ distributed by a third party, LibraryVersion()
|
||||||
//! records the version of the shared object that was built by the third party.
|
//! records the version of the shared object that was built by the third party.
|
||||||
//! The BuildVersion() record resides in <tt>cryptlib.o</tt> on Unix compatibles
|
//! The LibraryVersion() record resides in <tt>cryptlib.o</tt> on Unix compatibles
|
||||||
//! and <tt>cryptlib.obj</tt> on Windows. It does not change when an app links
|
//! and <tt>cryptlib.obj</tt> on Windows. It does not change when an app links
|
||||||
//! to the library.
|
//! to the library.
|
||||||
//! \details BuildVersion() is declared with C linkage (<tt>extern "C"</tt>) within the
|
//! \details LibraryVersion() is declared with C linkage (<tt>extern "C"</tt>) within the
|
||||||
//! CryptoPP namespace to help programs locate the symbol. If the symbol is present, then
|
//! CryptoPP namespace to help programs locate the symbol. If the symbol is present, then
|
||||||
//! the library version is 5.7 or above. If it is missing, then the library version is
|
//! the library version is 5.7 or above. If it is missing, then the library version is
|
||||||
//! 5.6.5 or below.
|
//! 5.6.5 or below.
|
||||||
//! \details The function could be used as shown below.
|
//! \details The function could be used as shown below.
|
||||||
//! <pre>
|
//! <pre>
|
||||||
//! if (BuildVersion() != RuntimeVersion())
|
//! if (LibraryVersion() != HeaderVersion())
|
||||||
//! {
|
//! {
|
||||||
//! cout << "Potential version mismatch" << endl;
|
//! cout << "Potential version mismatch" << endl;
|
||||||
//!
|
//!
|
||||||
//! const int bmaj = (BuildVersion() / 100U) % 10;
|
//! const int lmaj = (LibraryVersion() / 100U) % 10;
|
||||||
//! const int bmin = (BuildVersion() / 10U) % 10;
|
//! const int lmin = (LibraryVersion() / 10U) % 10;
|
||||||
//! const int rmaj = (RuntimeVersion() / 100U) % 10;
|
//! const int hmaj = (HeaderVersion() / 100U) % 10;
|
||||||
//! const int rmin = (RuntimeVersion() / 10U) % 10;
|
//! const int hmin = (HeaderVersion() / 10U) % 10;
|
||||||
//!
|
//!
|
||||||
//! if(bmaj != rmaj)
|
//! if(lmaj != hmaj)
|
||||||
//! cout << "Major version mismatch" << endl;
|
//! cout << "Major version mismatch" << endl;
|
||||||
//! else if(bmin != rmin)
|
//! else if(lmin != hmin)
|
||||||
//! cout << "Minor version mismatch" << endl;
|
//! cout << "Minor version mismatch" << endl;
|
||||||
//! }
|
//! }
|
||||||
//! </pre>
|
//! </pre>
|
||||||
//! \sa RuntimeVersion(), <A HREF="http://github.com/weidai11/cryptopp/issues/371">GitHub Issue 371</A>.
|
//! \sa HeaderVersion(), <A HREF="http://github.com/weidai11/cryptopp/issues/371">GitHub Issue 371</A>.
|
||||||
//! \since Crypto++ 5.7
|
//! \since Crypto++ 5.7
|
||||||
extern "C" {
|
extern "C" {
|
||||||
int BuildVersion();
|
int LibraryVersion();
|
||||||
} // C linkage
|
} // C linkage
|
||||||
|
|
||||||
//! \brief Specifies the runtime version of the library
|
//! \brief Specifies the runtime version of the library
|
||||||
//! \returns integer representing the runtime version
|
//! \returns integer representing the runtime version
|
||||||
//! \details RuntimeVersion() can help detect inadvertent mixing and matching of library
|
//! \details HeaderVersion() can help detect inadvertent mixing and matching of library
|
||||||
//! versions. When using Crypto++ distributed by a third party, RuntimeVersion()
|
//! versions. When using Crypto++ distributed by a third party, HeaderVersion()
|
||||||
//! records the version of the headers used by the app when the app is compiled.
|
//! records the version of the headers used by the app when the app is compiled.
|
||||||
//! \details RuntimeVersion() is declared with C linkage (<tt>extern "C"</tt>) within the
|
//! \details HeaderVersion() is declared with C linkage (<tt>extern "C"</tt>) within the
|
||||||
//! CryptoPP namespace to help programs locate the symbol. If the symbol is present, then
|
//! CryptoPP namespace to help programs locate the symbol. If the symbol is present, then
|
||||||
//! the library version is 5.7 or above. If it is missing, then the library version is
|
//! the library version is 5.7 or above. If it is missing, then the library version is
|
||||||
//! 5.6.5 or below.
|
//! 5.6.5 or below.
|
||||||
//! \details The function could be used as shown below.
|
//! \details The function could be used as shown below.
|
||||||
//! <pre>
|
//! <pre>
|
||||||
//! if (BuildVersion() != RuntimeVersion())
|
//! if (LibraryVersion() != HeaderVersion())
|
||||||
//! {
|
//! {
|
||||||
//! cout << "Potential version mismatch" << endl;
|
//! cout << "Potential version mismatch" << endl;
|
||||||
//!
|
//!
|
||||||
//! const int bmaj = (BuildVersion() / 100U) % 10;
|
//! const int lmaj = (LibraryVersion() / 100U) % 10;
|
||||||
//! const int bmin = (BuildVersion() / 10U) % 10;
|
//! const int lmin = (LibraryVersion() / 10U) % 10;
|
||||||
//! const int rmaj = (RuntimeVersion() / 100U) % 10;
|
//! const int hmaj = (HeaderVersion() / 100U) % 10;
|
||||||
//! const int rmin = (RuntimeVersion() / 10U) % 10;
|
//! const int hmin = (HeaderVersion() / 10U) % 10;
|
||||||
//!
|
//!
|
||||||
//! if(bmaj != rmaj)
|
//! if(lmaj != hmaj)
|
||||||
//! cout << "Major version mismatch" << endl;
|
//! cout << "Major version mismatch" << endl;
|
||||||
//! else if(bmin != rmin)
|
//! else if(lmin != hmin)
|
||||||
//! cout << "Minor version mismatch" << endl;
|
//! cout << "Minor version mismatch" << endl;
|
||||||
//! }
|
//! }
|
||||||
//! </pre>
|
//! </pre>
|
||||||
//! \sa BuildVersion(), <A HREF="http://github.com/weidai11/cryptopp/issues/371">GitHub Issue 371</A>.
|
//! \sa LibraryVersion(), <A HREF="http://github.com/weidai11/cryptopp/issues/371">GitHub Issue 371</A>.
|
||||||
//! \since Crypto++ 5.7
|
//! \since Crypto++ 5.7
|
||||||
extern "C" {
|
extern "C" {
|
||||||
inline int RuntimeVersion()
|
inline int HeaderVersion()
|
||||||
{
|
{
|
||||||
return CRYPTOPP_VERSION;
|
return CRYPTOPP_VERSION;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -226,16 +226,16 @@ bool TestSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
// App and library versions, http://github.com/weidai11/cryptopp/issues/371
|
// App and library versions, http://github.com/weidai11/cryptopp/issues/371
|
||||||
const int bver = BuildVersion();
|
const int v1 = LibraryVersion();
|
||||||
const int rver = RuntimeVersion();
|
const int v2 = HeaderVersion();
|
||||||
if(bver/10 == rver/10)
|
if(v1/10 == v2/10)
|
||||||
cout << "passed: ";
|
cout << "passed: ";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cout << "FAILED: ";
|
cout << "FAILED: ";
|
||||||
pass = false;
|
pass = false;
|
||||||
}
|
}
|
||||||
cout << "Build version (library): " << bver << ", runtime version (app): " << rver << "\n";
|
cout << "Library version (library): " << v1 << ", header version (app): " << v2 << "\n";
|
||||||
|
|
||||||
#ifdef CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS
|
#ifdef CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS
|
||||||
// Don't assert the alignment of testvals. That's what this test is for.
|
// Don't assert the alignment of testvals. That's what this test is for.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue