summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2015-05-12 23:17:16 +0200
committerNiels Möller <nisse@lysator.liu.se>2015-05-12 23:17:16 +0200
commitf1a54f2abf9057a30a5b5d5f2c64b3175d3b07da (patch)
treecb1c22554cd0b31a91f4a6758995d9c9d599763f
parentfce23774c8071761c44b2bd633bb37b2678c21e1 (diff)
downloadnettle-f1a54f2abf9057a30a5b5d5f2c64b3175d3b07da.tar.gz
Added nettle_version_major and nettle_version_minor functions.
-rw-r--r--ChangeLog9
-rw-r--r--Makefile.in1
-rw-r--r--testsuite/.test-rules.make3
-rw-r--r--testsuite/Makefile.in2
-rw-r--r--testsuite/version-test.c41
-rw-r--r--version.c48
-rw-r--r--version.h.in7
7 files changed, 110 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index bb86bf0d..9aff6e1a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2015-05-12 Niels Möller <nisse@lysator.liu.se>
+
+ * version.c (nettle_version_major, nettle_version_minor): New
+ file. New functions, returning the value of the corresponding
+ preprocessor constant.
+ * Makefile.in (nettle_SOURCES): Added version.c.
+ * testsuite/version-test.c: New testcase.
+ * testsuite/Makefile.in (TS_NETTLE_SOURCES): Added version-test.c.
+
2015-04-29 Niels Möller <nisse@lysator.liu.se>
* arm/v6/sha256-compress.asm: Fix syntax error in offset
diff --git a/Makefile.in b/Makefile.in
index 08efb7df..1bb750de 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -133,6 +133,7 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt.c \
umac-nh.c umac-nh-n.c umac-l2.c umac-l3.c \
umac-poly64.c umac-poly128.c umac-set-key.c \
umac32.c umac64.c umac96.c umac128.c \
+ version.c \
write-be32.c write-le32.c write-le64.c \
yarrow256.c yarrow_key_event.c
diff --git a/testsuite/.test-rules.make b/testsuite/.test-rules.make
index 5d793208..aaab7a76 100644
--- a/testsuite/.test-rules.make
+++ b/testsuite/.test-rules.make
@@ -100,6 +100,9 @@ serpent-test$(EXEEXT): serpent-test.$(OBJEXT)
twofish-test$(EXEEXT): twofish-test.$(OBJEXT)
$(LINK) twofish-test.$(OBJEXT) $(TEST_OBJS) -o twofish-test$(EXEEXT)
+version-test$(EXEEXT): version-test.$(OBJEXT)
+ $(LINK) version-test.$(OBJEXT) $(TEST_OBJS) -o version-test$(EXEEXT)
+
knuth-lfib-test$(EXEEXT): knuth-lfib-test.$(OBJEXT)
$(LINK) knuth-lfib-test.$(OBJEXT) $(TEST_OBJS) -o knuth-lfib-test$(EXEEXT)
diff --git a/testsuite/Makefile.in b/testsuite/Makefile.in
index 6bc1907c..f5264baa 100644
--- a/testsuite/Makefile.in
+++ b/testsuite/Makefile.in
@@ -23,7 +23,7 @@ TS_NETTLE_SOURCES = aes-test.c arcfour-test.c arctwo-test.c \
sha384-test.c sha512-test.c sha512-224-test.c sha512-256-test.c \
sha3-permute-test.c sha3-224-test.c sha3-256-test.c \
sha3-384-test.c sha3-512-test.c \
- serpent-test.c twofish-test.c \
+ serpent-test.c twofish-test.c version-test.c \
knuth-lfib-test.c \
cbc-test.c ctr-test.c gcm-test.c eax-test.c ccm-test.c \
poly1305-test.c chacha-poly1305-test.c \
diff --git a/testsuite/version-test.c b/testsuite/version-test.c
new file mode 100644
index 00000000..a472e3b6
--- /dev/null
+++ b/testsuite/version-test.c
@@ -0,0 +1,41 @@
+/* version-test.c
+
+ Copyright (C) 2015 Niels Möller
+
+ This file is part of GNU Nettle.
+
+ GNU Nettle is free software: you can redistribute it and/or
+ modify it under the terms of either:
+
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at your
+ option) any later version.
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ or both in parallel, as here.
+
+ GNU Nettle is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received copies of the GNU General Public License and
+ the GNU Lesser General Public License along with this program. If
+ not, see http://www.gnu.org/licenses/.
+*/
+
+#include "testutils.h"
+
+void
+test_main (void)
+{
+ /* This also checks that we don't by accident link with a different
+ version of nettle which is installed on the system. */
+ ASSERT (nettle_version_major () == NETTLE_VERSION_MAJOR);
+ ASSERT (nettle_version_minor () == NETTLE_VERSION_MINOR);
+}
diff --git a/version.c b/version.c
new file mode 100644
index 00000000..836f4eb8
--- /dev/null
+++ b/version.c
@@ -0,0 +1,48 @@
+/* version.c
+
+ Copyright (C) 2015 Niels Möller
+
+ This file is part of GNU Nettle.
+
+ GNU Nettle is free software: you can redistribute it and/or
+ modify it under the terms of either:
+
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at your
+ option) any later version.
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ or both in parallel, as here.
+
+ GNU Nettle is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received copies of the GNU General Public License and
+ the GNU Lesser General Public License along with this program. If
+ not, see http://www.gnu.org/licenses/.
+*/
+
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "version.h"
+
+int
+nettle_version_major (void)
+{
+ return NETTLE_VERSION_MAJOR;
+}
+
+int
+nettle_version_minor (void)
+{
+ return NETTLE_VERSION_MINOR;
+}
diff --git a/version.h.in b/version.h.in
index 447e933e..cf429f25 100644
--- a/version.h.in
+++ b/version.h.in
@@ -3,6 +3,7 @@
Information about library version.
Copyright (C) 2015 Red Hat, Inc.
+ Copyright (C) 2015 Niels Möller
This file is part of GNU Nettle.
@@ -50,6 +51,12 @@ extern "C" {
# define GMP_NUMB_BITS @GMP_NUMB_BITS@
#endif
+int
+nettle_version_major (void);
+
+int
+nettle_version_minor (void);
+
#ifdef __cplusplus
}
#endif