Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# Pre-release

- Added a utility function for de-structuring version strings in `<common.hpp>`
- `std::tuple<std::string, std::string, std::string>
oqs::version(const std::string& version)` - Returns a tuple containing the
(major, minor, patch) versions
- A warning is issued only if the liboqs-cpp version's major and minor numbers
differ from those of liboqs, ignoring the patch version

# Version 0.12.0 - January 15, 2025

- Fixes https://github.com/open-quantum-safe/liboqs-cpp/issues/21. The API that
Expand Down
17 changes: 17 additions & 0 deletions include/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <ostream>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

Expand All @@ -39,6 +40,22 @@ inline std::string oqs_version() { return oqs::C::OQS_version(); }
*/
inline std::string oqs_cpp_version() { return LIBOQS_CPP_VERSION; }

/**
* \brief De-structure version string as a tuple (major, minor, patch)
* \return Version string as a tuple (major, minor, patch)
*/
inline std::tuple<std::string, std::string, std::string>
version(const std::string& version_str) {
std::stringstream ss(version_str);
std::string major, minor, patch;

std::getline(ss, major, '.');
std::getline(ss, minor, '.');
std::getline(ss, patch, '.');

return std::make_tuple(major, minor, patch);
}

/**
* \brief Sets to zero the content of \a v by invoking the liboqs
* OQS_MEM_cleanse() function. Use it to clean "hot" memory areas, such as
Expand Down
11 changes: 9 additions & 2 deletions include/oqs_cpp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -778,9 +778,16 @@ class Init final : public internal::Singleton<const Init> {
Init() {
C::OQS_init();
std::string oqs_ver = oqs_version();
std::string oqs_ver_major = std::get<0>(version(oqs_ver));
std::string oqs_ver_minor = std::get<1>(version(oqs_ver));

std::string oqs_cpp_ver = oqs_cpp_version();
if (oqs_ver != oqs_cpp_ver) {
std::cerr << "Warning! liboqs version " << oqs_ver
std::string oqs_cpp_ver_major = std::get<0>(version(oqs_cpp_ver));
std::string oqs_cpp_ver_minor = std::get<1>(version(oqs_cpp_ver));

if (!(oqs_ver_major == oqs_cpp_ver_major &&
oqs_ver_minor == oqs_cpp_ver_minor)) {
std::cerr << "Warning! liboqs version (major, minor) " << oqs_ver
<< " differs from liboqs-cpp version " << oqs_cpp_ver
<< std::endl;
}
Expand Down