From 91bfca9bdd01f7d890ae2dc6ba84990229492166 Mon Sep 17 00:00:00 2001 From: Michael Baentsch <57787676+baentsch@users.noreply.github.com> Date: Wed, 3 Aug 2022 19:32:11 +0200 Subject: [PATCH] Add library version retrieval function (#1273) --- src/common/common.c | 4 ++++ src/common/common.h | 5 +++++ tests/test_kem.c | 2 ++ tests/test_sig.c | 2 ++ 4 files changed, 13 insertions(+) diff --git a/src/common/common.c b/src/common/common.c index f0d6cda7a8..2716022622 100644 --- a/src/common/common.c +++ b/src/common/common.c @@ -191,6 +191,10 @@ OQS_API void OQS_init(void) { return; } +OQS_API const char *OQS_version(void) { + return OQS_VERSION_TEXT; +} + OQS_API int OQS_MEM_secure_bcmp(const void *a, const void *b, size_t len) { /* Assume CHAR_BIT = 8 */ uint8_t r = 0; diff --git a/src/common/common.h b/src/common/common.h index 659f453749..a06064fea1 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -143,6 +143,11 @@ OQS_API int OQS_CPU_has_extension(OQS_CPU_EXT ext); */ OQS_API void OQS_init(void); +/** + * Return library version string. + */ +OQS_API const char *OQS_version(void); + /** * Constant time comparison of byte sequences `a` and `b` of length `len`. * Returns 0 if the byte sequences are equal or if `len`=0. diff --git a/tests/test_kem.c b/tests/test_kem.c index d156c2d039..492f47c5fa 100644 --- a/tests/test_kem.c +++ b/tests/test_kem.c @@ -204,6 +204,8 @@ void *test_wrapper(void *arg) { int main(int argc, char **argv) { + printf("Testing KEM algorithms using liboqs version %s\n", OQS_version()); + if (argc != 2) { fprintf(stderr, "Usage: test_kem algname\n"); fprintf(stderr, " algname: "); diff --git a/tests/test_sig.c b/tests/test_sig.c index 3840f84706..abf92084ed 100644 --- a/tests/test_sig.c +++ b/tests/test_sig.c @@ -183,6 +183,8 @@ void *test_wrapper(void *arg) { int main(int argc, char **argv) { + printf("Testing signature algorithms using liboqs version %s\n", OQS_version()); + if (argc != 2) { fprintf(stderr, "Usage: test_sig algname\n"); fprintf(stderr, " algname: ");