aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2017-11-01 13:28:38 +0100
committerMax <msuraev@sysmocom.de>2017-12-27 11:10:42 +0000
commit3b6332f6dc1fa14dea6d1577a162b84bb304d4ef (patch)
tree3fd531726889a3650920da1a78bf769e36153def /tests
parent794693c09360382a222a00b031cf5159a8088303 (diff)
Migrate from OpenSSL to osmo_get_rand_id()
This avoids potential licensing incompatibility and makes integration of Debian packaging patches easier. The libosmocore version requirements are fine already but for jenkins tests to pass we have to have Ic77866ce65acf524b768882c751a4f9c0635740b merged into libosmocore master. Related: OS#1694 Change-Id: I2b687b7f07ef05bbd861b8479cad5a958a3dde92
Diffstat (limited to 'tests')
-rw-r--r--tests/gbproxy/Makefile.am3
-rw-r--r--tests/gbproxy/gbproxy_test.c19
-rw-r--r--tests/sgsn/Makefile.am3
-rw-r--r--tests/sgsn/sgsn_test.c18
-rw-r--r--tests/sndcp_xid/Makefile.am1
-rw-r--r--tests/xid/Makefile.am1
6 files changed, 19 insertions, 26 deletions
diff --git a/tests/gbproxy/Makefile.am b/tests/gbproxy/Makefile.am
index 3291839..ef38fb6 100644
--- a/tests/gbproxy/Makefile.am
+++ b/tests/gbproxy/Makefile.am
@@ -28,7 +28,7 @@ gbproxy_test_SOURCES = \
$(NULL)
gbproxy_test_LDFLAGS = \
- -Wl,--wrap=RAND_bytes \
+ -Wl,--wrap=osmo_get_rand_id \
$(NULL)
gbproxy_test_LDADD = \
@@ -46,6 +46,5 @@ gbproxy_test_LDADD = \
$(LIBOSMOVTY_LIBS) \
$(LIBOSMOABIS_LIBS) \
$(LIBRARY_DL) \
- $(LIBCRYPTO_LIBS) \
-lrt \
$(NULL)
diff --git a/tests/gbproxy/gbproxy_test.c b/tests/gbproxy/gbproxy_test.c
index e8a4ef9..3ebdccb 100644
--- a/tests/gbproxy/gbproxy_test.c
+++ b/tests/gbproxy/gbproxy_test.c
@@ -37,8 +37,6 @@
#include <osmocom/sgsn/gprs_gb_parse.h>
#include <osmocom/sgsn/debug.h>
-#include <openssl/rand.h>
-
#define REMOTE_BSS_ADDR 0x01020304
#define REMOTE_SGSN_ADDR 0x05060708
@@ -55,24 +53,23 @@ struct gbproxy_config gbcfg = {0};
struct llist_head *received_messages = NULL;
-/* override, requires '-Wl,--wrap=RAND_bytes' */
-int __real_RAND_bytes(unsigned char *buf, int num);
-int mock_RAND_bytes(unsigned char *buf, int num);
-int (*RAND_bytes_cb)(unsigned char *, int) =
- &mock_RAND_bytes;
+/* override, requires '-Wl,--wrap=osmo_get_rand_id' */
+int __real_osmo_get_rand_id(uint8_t *data, size_t len);
+int mock_osmo_get_rand_id(uint8_t *data, size_t len);
+int (*osmo_get_rand_id_cb)(uint8_t *, size_t) =
+ &mock_osmo_get_rand_id;
-int __wrap_RAND_bytes(unsigned char *buf, int num)
+int __wrap_osmo_get_rand_id(uint8_t *buf, size_t num)
{
- return (*RAND_bytes_cb)(buf, num);
+ return (*osmo_get_rand_id_cb)(buf, num);
}
static int rand_seq_num = 0;
-int mock_RAND_bytes(unsigned char *buf, int num)
+int mock_osmo_get_rand_id(uint8_t *buf, size_t num)
{
uint32_t val;
OSMO_ASSERT(num == sizeof(val));
- OSMO_ASSERT(__real_RAND_bytes(buf, num) == 1);
val = 0x00dead00 + rand_seq_num;
diff --git a/tests/sgsn/Makefile.am b/tests/sgsn/Makefile.am
index 36026dd..802811d 100644
--- a/tests/sgsn/Makefile.am
+++ b/tests/sgsn/Makefile.am
@@ -32,7 +32,7 @@ sgsn_test_SOURCES = \
$(NULL)
sgsn_test_LDFLAGS = \
- -Wl,--wrap=RAND_bytes \
+ -Wl,--wrap=osmo_get_rand_id \
-Wl,--wrap=sgsn_update_subscriber_data \
-Wl,--wrap=gprs_subscr_request_update_location \
-Wl,--wrap=gprs_subscr_request_auth_info \
@@ -67,7 +67,6 @@ sgsn_test_LDADD = \
$(LIBOSMOGSM_LIBS) \
$(LIBOSMOGB_LIBS) \
$(LIBCARES_LIBS) \
- $(LIBCRYPTO_LIBS) \
$(LIBGTP_LIBS) \
-lrt \
-lm \
diff --git a/tests/sgsn/sgsn_test.c b/tests/sgsn/sgsn_test.c
index a486794..219587a 100644
--- a/tests/sgsn/sgsn_test.c
+++ b/tests/sgsn/sgsn_test.c
@@ -100,21 +100,21 @@ int bssgp_tx_dl_ud(struct msgb *msg, uint16_t pdu_lifetime,
return 0;
}
-/* override, requires '-Wl,--wrap=RAND_bytes' */
-int __real_RAND_bytes(unsigned char *buf, int num);
-int mock_RAND_bytes(unsigned char *buf, int num);
-int (*RAND_bytes_cb)(unsigned char *, int) =
- &mock_RAND_bytes;
+/* override, requires '-Wl,--wrap=osmo_get_rand_id' */
+int __real_osmo_get_rand_id(uint8_t *data, size_t len);
+int mock_osmo_get_rand_id(uint8_t *data, size_t len);
+int (*osmo_get_rand_id_cb)(uint8_t *, size_t) =
+ &mock_osmo_get_rand_id;
-int __wrap_RAND_bytes(unsigned char *buf, int num)
+int __wrap_osmo_get_rand_id(uint8_t *buf, size_t num)
{
- return (*RAND_bytes_cb)(buf, num);
+ return (*osmo_get_rand_id_cb)(buf, num);
}
/* make results of A&C ref predictable */
-int mock_RAND_bytes(unsigned char *buf, int num)
+int mock_osmo_get_rand_id(uint8_t *buf, size_t num)
{
if (num > 1)
- return __real_RAND_bytes(buf, num);
+ return __real_osmo_get_rand_id(buf, num);
buf[0] = 0;
return 1;
}
diff --git a/tests/sndcp_xid/Makefile.am b/tests/sndcp_xid/Makefile.am
index d09c41b..fbcb36c 100644
--- a/tests/sndcp_xid/Makefile.am
+++ b/tests/sndcp_xid/Makefile.am
@@ -14,7 +14,6 @@ sndcp_xid_test_LDADD = \
$(LIBOSMOGSM_LIBS) \
$(LIBOSMOGB_LIBS) \
$(LIBCARES_LIBS) \
- $(LIBCRYPTO_LIBS) \
$(LIBGTP_LIBS) \
-lrt -lm
diff --git a/tests/xid/Makefile.am b/tests/xid/Makefile.am
index 6c3689f..92876ec 100644
--- a/tests/xid/Makefile.am
+++ b/tests/xid/Makefile.am
@@ -30,7 +30,6 @@ xid_test_LDADD = \
$(LIBOSMOGSM_LIBS) \
$(LIBOSMOGB_LIBS) \
$(LIBCARES_LIBS) \
- $(LIBCRYPTO_LIBS) \
$(LIBGTP_LIBS) \
-lrt \
-lm \