Change to more intuitive names LibraryVersion and HeaderVersion (Issue 371)

pull/378/head
Jeffrey Walton 2017-01-28 07:09:27 -05:00
parent 6f7339c81b
commit 42af35fd2b
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
3 changed files with 30 additions and 30 deletions

View File

@ -950,7 +950,7 @@ void AuthenticatedKeyAgreementDomain::GenerateEphemeralKeyPair(RandomNumberGener
#ifndef CRYPTOPP_BUILD_VERSION
# define CRYPTOPP_BUILD_VERSION CRYPTOPP_VERSION
#endif
int BuildVersion()
int LibraryVersion()
{
return CRYPTOPP_BUILD_VERSION;
}

View File

@ -2916,69 +2916,69 @@ public:
//! \brief Specifies the build-time version of the library
//! \returns integer representing the build-time version
//! \details BuildVersion can help detect inadvertent mixing and matching of library
//! versions. When using Crypto++ distributed by a third party, BuildVersion()
//! \details LibraryVersion can help detect inadvertent mixing and matching of library
//! versions. When using Crypto++ distributed by a third party, LibraryVersion()
//! 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
//! 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
//! the library version is 5.7 or above. If it is missing, then the library version is
//! 5.6.5 or below.
//! \details The function could be used as shown below.
//! <pre>
//! if (BuildVersion() != RuntimeVersion())
//! if (LibraryVersion() != HeaderVersion())
//! {
//! cout << "Potential version mismatch" << endl;
//!
//! const int bmaj = (BuildVersion() / 100U) % 10;
//! const int bmin = (BuildVersion() / 10U) % 10;
//! const int rmaj = (RuntimeVersion() / 100U) % 10;
//! const int rmin = (RuntimeVersion() / 10U) % 10;
//! const int lmaj = (LibraryVersion() / 100U) % 10;
//! const int lmin = (LibraryVersion() / 10U) % 10;
//! const int hmaj = (HeaderVersion() / 100U) % 10;
//! const int hmin = (HeaderVersion() / 10U) % 10;
//!
//! if(bmaj != rmaj)
//! if(lmaj != hmaj)
//! cout << "Major version mismatch" << endl;
//! else if(bmin != rmin)
//! else if(lmin != hmin)
//! cout << "Minor version mismatch" << endl;
//! }
//! </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
extern "C" {
int BuildVersion();
int LibraryVersion();
} // C linkage
//! \brief Specifies the runtime version of the library
//! \returns integer representing the runtime version
//! \details RuntimeVersion() can help detect inadvertent mixing and matching of library
//! versions. When using Crypto++ distributed by a third party, RuntimeVersion()
//! \details HeaderVersion() can help detect inadvertent mixing and matching of library
//! 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.
//! \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
//! the library version is 5.7 or above. If it is missing, then the library version is
//! 5.6.5 or below.
//! \details The function could be used as shown below.
//! <pre>
//! if (BuildVersion() != RuntimeVersion())
//! if (LibraryVersion() != HeaderVersion())
//! {
//! cout << "Potential version mismatch" << endl;
//!
//! const int bmaj = (BuildVersion() / 100U) % 10;
//! const int bmin = (BuildVersion() / 10U) % 10;
//! const int rmaj = (RuntimeVersion() / 100U) % 10;
//! const int rmin = (RuntimeVersion() / 10U) % 10;
//! const int lmaj = (LibraryVersion() / 100U) % 10;
//! const int lmin = (LibraryVersion() / 10U) % 10;
//! const int hmaj = (HeaderVersion() / 100U) % 10;
//! const int hmin = (HeaderVersion() / 10U) % 10;
//!
//! if(bmaj != rmaj)
//! if(lmaj != hmaj)
//! cout << "Major version mismatch" << endl;
//! else if(bmin != rmin)
//! else if(lmin != hmin)
//! cout << "Minor version mismatch" << endl;
//! }
//! </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
extern "C" {
inline int RuntimeVersion()
inline int HeaderVersion()
{
return CRYPTOPP_VERSION;
}

View File

@ -226,16 +226,16 @@ bool TestSettings()
}
// App and library versions, http://github.com/weidai11/cryptopp/issues/371
const int bver = BuildVersion();
const int rver = RuntimeVersion();
if(bver/10 == rver/10)
const int v1 = LibraryVersion();
const int v2 = HeaderVersion();
if(v1/10 == v2/10)
cout << "passed: ";
else
{
cout << "FAILED: ";
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
// Don't assert the alignment of testvals. That's what this test is for.