[PATCH] openbsc[master]: Migrate from OpenSSL to osmo_get_rand_id()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Fri Jun 9 12:26:58 UTC 2017


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/1464

to look at the new patch set (#7).

Migrate from OpenSSL to osmo_get_rand_id()

This avoids potential licensing incompatibility and makes integration of
Debian packaging patches easier.

Related: OS#1694
Change-Id: I270c33912bf107b3c7c217d199262cc74d56ffdb
---
M debian/control
M openbsc/configure.ac
M openbsc/src/gprs/Makefile.am
M openbsc/src/gprs/gb_proxy.c
M openbsc/src/gprs/gprs_gmm.c
M openbsc/src/gprs/gprs_llc.c
M openbsc/src/gprs/gprs_sgsn.c
M openbsc/src/libiu/Makefile.am
M openbsc/src/libmsc/Makefile.am
M openbsc/src/libmsc/auth.c
M openbsc/src/libmsc/db.c
M openbsc/src/osmo-bsc_nat/Makefile.am
M openbsc/src/osmo-bsc_nat/bsc_nat.c
M openbsc/src/osmo-nitb/Makefile.am
M openbsc/tests/channel/Makefile.am
M openbsc/tests/db/Makefile.am
M openbsc/tests/gbproxy/Makefile.am
M openbsc/tests/gbproxy/gbproxy_test.c
M openbsc/tests/mm_auth/Makefile.am
M openbsc/tests/mm_auth/mm_auth_test.c
M openbsc/tests/sgsn/Makefile.am
M openbsc/tests/sgsn/sgsn_test.c
M openbsc/tests/sndcp_xid/Makefile.am
M openbsc/tests/xid/Makefile.am
24 files changed, 44 insertions(+), 87 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/64/1464/7

diff --git a/debian/control b/debian/control
index 87b6f07..14108d2 100644
--- a/debian/control
+++ b/debian/control
@@ -15,7 +15,6 @@
                libosmo-netif-dev,
                libdbd-sqlite3,
                libpcap-dev,
-               libssl-dev,
                libc-ares-dev,
                libsmpp34-dev
 Standards-Version: 3.9.8
diff --git a/openbsc/configure.ac b/openbsc/configure.ac
index c6ae159..00fa891 100644
--- a/openbsc/configure.ac
+++ b/openbsc/configure.ac
@@ -38,11 +38,10 @@
 PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.9.5)
 PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.3.0)
 PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl)
-PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.9.5)
+PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.9.6)
 PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.2.0)
 PKG_CHECK_MODULES(LIBOSMOGB, libosmogb >= 0.6.4)
 PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 0.0.1)
-PKG_CHECK_MODULES(LIBCRYPTO, libcrypto >= 0.9.5)
 
 # Enabke/disable the NAT?
 AC_ARG_ENABLE([nat], [AS_HELP_STRING([--enable-nat], [Build the BSC NAT. Requires SCCP])],
diff --git a/openbsc/src/gprs/Makefile.am b/openbsc/src/gprs/Makefile.am
index cb09979..fc6f862 100644
--- a/openbsc/src/gprs/Makefile.am
+++ b/openbsc/src/gprs/Makefile.am
@@ -15,7 +15,6 @@
 	$(LIBOSMOGB_CFLAGS) \
 	$(COVERAGE_CFLAGS) \
 	$(LIBCARES_CFLAGS) \
-	$(LIBCRYPTO_CFLAGS) \
 	$(LIBGTP_CFLAGS) \
 	$(NULL)
 if BUILD_IU
@@ -63,7 +62,6 @@
 osmo_gbproxy_LDADD = \
 	$(top_builddir)/src/libcommon/libcommon.a \
 	$(OSMO_LIBS) \
-	$(LIBCRYPTO_LIBS) \
 	-lrt \
 	$(NULL)
 
@@ -98,7 +96,6 @@
 	$(OSMO_LIBS) \
 	$(LIBOSMOABIS_LIBS) \
 	$(LIBCARES_LIBS) \
-	$(LIBCRYPTO_LIBS) \
 	$(LIBGTP_LIBS) \
 	-lrt \
 	-lm \
diff --git a/openbsc/src/gprs/gb_proxy.c b/openbsc/src/gprs/gb_proxy.c
index d95139f..f11b9b9 100644
--- a/openbsc/src/gprs/gb_proxy.c
+++ b/openbsc/src/gprs/gb_proxy.c
@@ -51,8 +51,6 @@
 #include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
 #include <openbsc/gprs_utils.h>
 
-#include <openssl/rand.h>
-
 static const struct rate_ctr_desc global_ctr_description[] = {
 	{ "inv-bvci",	    "Invalid BVC Identifier          " },
 	{ "inv-lai",	    "Invalid Location Area Identifier" },
@@ -236,7 +234,7 @@
 		bss_ptmsi = sgsn_ptmsi;
 	} else {
 		do {
-			if (RAND_bytes((uint8_t *) &bss_ptmsi, sizeof(bss_ptmsi)) != 1) {
+			if (osmo_get_rand_id((uint8_t *) &bss_ptmsi, sizeof(bss_ptmsi)) < 0) {
 				bss_ptmsi = GSM_RESERVED_TMSI;
 				break;
 			}
@@ -273,7 +271,7 @@
 	} else {
 		do {
 			/* create random TLLI, 0b01111xxx... */
-			if (RAND_bytes((uint8_t *) &sgsn_tlli, sizeof(sgsn_tlli)) != 1) {
+			if (osmo_get_rand_id((uint8_t *) &sgsn_tlli, sizeof(sgsn_tlli)) < 0) {
 				sgsn_tlli = 0;
 				break;
 			}
diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c
index e6751db..84cdc87 100644
--- a/openbsc/src/gprs/gprs_gmm.c
+++ b/openbsc/src/gprs/gprs_gmm.c
@@ -31,8 +31,6 @@
 #include <arpa/inet.h>
 #include <netdb.h>
 
-#include <openssl/rand.h>
-
 #include "bscconfig.h"
 
 #include <openbsc/db.h>
@@ -598,12 +596,9 @@
 	/* § 10.5.5.7: */
 	acreq->force_stby = force_standby;
 	/* 3GPP TS 24.008 § 10.5.5.19: */
-	if (RAND_bytes(&rbyte, 1) != 1) {
-		LOGP(DMM, LOGL_NOTICE, "RAND_bytes failed for A&C ref, falling "
-		     "back to rand()\n");
-		acreq->ac_ref_nr = rand();
-	} else
-		acreq->ac_ref_nr = rbyte;
+	if (osmo_get_rand_id(&rbyte, 1) < 0)
+		LOGP(DMM, LOGL_ERROR, "osmo_get_rand_id() failed for A&C ref, falling back to insecure random\n");
+	acreq->ac_ref_nr = rbyte;
 	mm->ac_ref_nr_used = acreq->ac_ref_nr;
 
 	/* Only if authentication is requested we need to set RAND + CKSN */
@@ -1373,8 +1368,8 @@
 		};
 		/* XXX: Hack to make 3G auth work with special SIM card */
 		ctx->auth_state = SGSN_AUTH_AUTHENTICATE;
-
-		RAND_bytes(tmp_rand, 16);
+		/* FIXME: check return value and propagate error */
+		osmo_get_rand_id(tmp_rand, 16);
 
 		memset(&ctx->auth_triplet.vec, 0, sizeof(ctx->auth_triplet.vec));
 		osmo_auth_gen_vec(&ctx->auth_triplet.vec, &auth, tmp_rand);
diff --git a/openbsc/src/gprs/gprs_llc.c b/openbsc/src/gprs/gprs_llc.c
index 2be663f..720d6c5 100644
--- a/openbsc/src/gprs/gprs_llc.c
+++ b/openbsc/src/gprs/gprs_llc.c
@@ -23,8 +23,6 @@
 #include <stdint.h>
 #include <stdbool.h>
 
-#include <openssl/rand.h>
-
 #include <osmocom/core/msgb.h>
 #include <osmocom/core/linuxlist.h>
 #include <osmocom/core/timer.h>
@@ -1070,11 +1068,8 @@
 	uint8_t *xid;
 
 	LOGP(DLLC, LOGL_NOTICE, "LLGM Reset\n");
-	if (RAND_bytes((uint8_t *) &llme->iov_ui, 4) != 1) {
-		LOGP(DLLC, LOGL_NOTICE, "RAND_bytes failed for LLC XID reset, "
-		     "falling back to rand()\n");
-		llme->iov_ui = rand();
-	}
+	if (osmo_get_rand_id((uint8_t *) &llme->iov_ui, 4) < 0)
+		LOGP(DLLC, LOGL_ERROR, "osmo_get_rand_id() failed for LLC XID reset, falling back to insecure random\n");
 
 	/* Generate XID message */
 	xid_bytes_len = gprs_llc_generate_xid_for_gmm_reset(xid_bytes,
@@ -1103,11 +1098,8 @@
 	uint8_t *xid;
 
 	LOGP(DLLC, LOGL_NOTICE, "LLGM Reset\n");
-	if (RAND_bytes((uint8_t *) &llme->iov_ui, 4) != 1) {
-		LOGP(DLLC, LOGL_NOTICE, "RAND_bytes failed for LLC XID reset, "
-		     "falling back to rand()\n");
-		llme->iov_ui = rand();
-	}
+	if (osmo_get_rand_id((uint8_t *) &llme->iov_ui, 4) < 0)
+		LOGP(DLLC, LOGL_ERROR, "osmo_get_rand_id() failed for LLC XID reset, falling back to insecure random\n");
 
 	/* Generate XID message */
 	xid_bytes_len = gprs_llc_generate_xid_for_gmm_reset(xid_bytes,
diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c
index 071dd97..ab4d3b4 100644
--- a/openbsc/src/gprs/gprs_sgsn.c
+++ b/openbsc/src/gprs/gprs_sgsn.c
@@ -45,8 +45,6 @@
 
 #include <time.h>
 
-#include <openssl/rand.h>
-
 #define GPRS_LLME_CHECK_TICK 30
 
 extern struct sgsn_instance *sgsn;
@@ -615,7 +613,7 @@
 	int max_retries = 100;
 
 restart:
-	if (RAND_bytes((uint8_t *) &ptmsi, sizeof(ptmsi)) != 1)
+	if (osmo_get_rand_id((uint8_t *) &ptmsi, sizeof(ptmsi)) < 0)
 		goto failed;
 
 	/* Enforce that the 2 MSB are set without loosing the distance between
diff --git a/openbsc/src/libiu/Makefile.am b/openbsc/src/libiu/Makefile.am
index e5f9e27..f78b411 100644
--- a/openbsc/src/libiu/Makefile.am
+++ b/openbsc/src/libiu/Makefile.am
@@ -7,7 +7,6 @@
 AM_CFLAGS = \
 	-Wall \
 	$(COVERAGE_CFLAGS) \
-	$(LIBCRYPTO_CFLAGS) \
 	$(LIBASN1C_CFLAGS) \
 	$(LIBOSMOCORE_CFLAGS) \
 	$(LIBOSMOVTY_CFLAGS) \
diff --git a/openbsc/src/libmsc/Makefile.am b/openbsc/src/libmsc/Makefile.am
index 9d966db..38b6e21 100644
--- a/openbsc/src/libmsc/Makefile.am
+++ b/openbsc/src/libmsc/Makefile.am
@@ -10,7 +10,6 @@
 	$(LIBOSMOVTY_CFLAGS) \
 	$(LIBOSMOABIS_CFLAGS) \
 	$(COVERAGE_CFLAGS) \
-	$(LIBCRYPTO_CFLAGS) \
 	$(LIBSMPP34_CFLAGS) \
 	$(NULL)
 
diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c
index 19def1e..09d411c 100644
--- a/openbsc/src/libmsc/auth.c
+++ b/openbsc/src/libmsc/auth.c
@@ -28,8 +28,6 @@
 #include <osmocom/gsm/comp128.h>
 #include <osmocom/core/utils.h>
 
-#include <openssl/rand.h>
-
 #include <stdlib.h>
 
 const struct value_string auth_action_names[] = {
@@ -123,8 +121,8 @@
 	}
 	atuple->use_count = 1;
 
-	if (RAND_bytes(atuple->vec.rand, sizeof(atuple->vec.rand)) != 1) {
-		LOGP(DMM, LOGL_NOTICE, "RAND_bytes failed, can't generate new auth tuple\n");
+	if (osmo_get_rand_id(atuple->vec.rand, sizeof(atuple->vec.rand)) < 0) {
+		LOGP(DMM, LOGL_ERROR, "osmo_get_rand_id() failed, can't generate new auth tuple\n");
 		return AUTH_ERROR;
 	}
 
diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c
index 5fe2a3c..6625047 100644
--- a/openbsc/src/libmsc/db.c
+++ b/openbsc/src/libmsc/db.c
@@ -41,8 +41,6 @@
 #include <osmocom/core/rate_ctr.h>
 #include <osmocom/core/utils.h>
 
-#include <openssl/rand.h>
-
 /* Semi-Private-Interface (SPI) for the subscriber code */
 void subscr_direct_free(struct gsm_subscriber *subscr);
 
@@ -1220,8 +1218,8 @@
 	char *tmsi_quoted;
 
 	for (;;) {
-		if (RAND_bytes((uint8_t *) &subscriber->tmsi, sizeof(subscriber->tmsi)) != 1) {
-			LOGP(DDB, LOGL_ERROR, "RAND_bytes failed\n");
+		if (osmo_get_rand_id((uint8_t *) &subscriber->tmsi, sizeof(subscriber->tmsi)) < 0) {
+			LOGP(DDB, LOGL_ERROR, "osmo_get_rand_id() failed\n");
 			return 1;
 		}
 		if (subscriber->tmsi == GSM_RESERVED_TMSI)
@@ -1300,8 +1298,8 @@
 	uint32_t try;
 
 	for (;;) {
-		if (RAND_bytes((uint8_t *) &try, sizeof(try)) != 1) {
-			LOGP(DDB, LOGL_ERROR, "RAND_bytes failed\n");
+		if (osmo_get_rand_id((uint8_t *) &try, sizeof(try)) < 0) {
+			LOGP(DDB, LOGL_ERROR, "osmo_get_rand_id() failed\n");
 			return 1;
 		}
 		if (!try) /* 0 is an invalid token */
diff --git a/openbsc/src/osmo-bsc_nat/Makefile.am b/openbsc/src/osmo-bsc_nat/Makefile.am
index be33d28..e7b78c9 100644
--- a/openbsc/src/osmo-bsc_nat/Makefile.am
+++ b/openbsc/src/osmo-bsc_nat/Makefile.am
@@ -13,7 +13,6 @@
 	$(LIBOSMOSCCP_CFLAGS) \
 	$(LIBOSMOABIS_CFLAGS) \
 	$(LIBOSMONETIF_CFLAGS) \
-	$(LIBCRYPTO_CFLAGS) \
 	$(COVERAGE_CFLAGS) \
 	$(NULL)
 
@@ -53,6 +52,5 @@
 	$(LIBOSMOCTRL_LIBS) \
 	$(LIBOSMOABIS_LIBS) \
 	$(LIBOSMONETIF_LIBS) \
-	$(LIBCRYPTO_LIBS) \
 	-lrt \
 	$(NULL)
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c
index daa066d..e510a0e 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c
@@ -74,8 +74,6 @@
 
 #include <osmocom/abis/ipa.h>
 
-#include <openssl/rand.h>
-
 #include "../../bscconfig.h"
 
 #define SCCP_CLOSE_TIME 20
@@ -221,7 +219,7 @@
 	buf = v_put(buf, 0x23);
 	mrand = bsc->last_rand;
 
-	if (RAND_bytes(mrand, 16) != 1)
+	if (osmo_get_rand_id(mrand, 16) < 0)
 		goto failed_random;
 
 	memcpy(buf, mrand, 16);
diff --git a/openbsc/src/osmo-nitb/Makefile.am b/openbsc/src/osmo-nitb/Makefile.am
index f4ef487..5ffaedf 100644
--- a/openbsc/src/osmo-nitb/Makefile.am
+++ b/openbsc/src/osmo-nitb/Makefile.am
@@ -13,7 +13,6 @@
 	$(LIBOSMOCTRL_CFLAGS) \
 	$(LIBOSMOABIS_CFLAGS) \
 	$(LIBSMPP34_CFLAGS) \
-	$(LIBCRYPTO_CFLAGS) \
 	$(NULL)
 
 AM_LDFLAGS = \
@@ -40,6 +39,5 @@
 	$(LIBOSMOCTRL_LIBS) \
 	$(LIBOSMOABIS_LIBS) \
 	$(LIBSMPP34_LIBS) \
-	$(LIBCRYPTO_LIBS) \
 	-ldbi \
 	$(NULL)
diff --git a/openbsc/tests/channel/Makefile.am b/openbsc/tests/channel/Makefile.am
index ca470ac..82ffb61 100644
--- a/openbsc/tests/channel/Makefile.am
+++ b/openbsc/tests/channel/Makefile.am
@@ -30,6 +30,5 @@
 	$(top_builddir)/src/libcommon/libcommon.a \
 	$(LIBOSMOCORE_LIBS) \
 	$(LIBOSMOGSM_LIBS) \
-	$(LIBCRYPTO_LIBS) \
 	-ldbi \
 	$(NULL)
diff --git a/openbsc/tests/db/Makefile.am b/openbsc/tests/db/Makefile.am
index 0eed5cd..7099645 100644
--- a/openbsc/tests/db/Makefile.am
+++ b/openbsc/tests/db/Makefile.am
@@ -43,6 +43,5 @@
 	$(LIBOSMOGSM_LIBS) \
 	$(LIBSMPP34_LIBS) \
 	$(LIBOSMOVTY_LIBS) \
-	$(LIBCRYPTO_LIBS) \
 	-ldbi \
 	$(NULL)
diff --git a/openbsc/tests/gbproxy/Makefile.am b/openbsc/tests/gbproxy/Makefile.am
index 2dd66df..0bd06be 100644
--- a/openbsc/tests/gbproxy/Makefile.am
+++ b/openbsc/tests/gbproxy/Makefile.am
@@ -28,7 +28,7 @@
 	$(NULL)
 
 gbproxy_test_LDFLAGS = \
-	-Wl,--wrap=RAND_bytes \
+	-Wl,--wrap=osmo_get_rand_id \
 	$(NULL)
 
 gbproxy_test_LDADD = \
@@ -49,6 +49,5 @@
 	$(LIBOSMOVTY_LIBS) \
 	$(LIBOSMOABIS_LIBS) \
 	$(LIBRARY_DL) \
-	$(LIBCRYPTO_LIBS) \
 	-lrt \
 	$(NULL)
diff --git a/openbsc/tests/gbproxy/gbproxy_test.c b/openbsc/tests/gbproxy/gbproxy_test.c
index 577daa9..370cd2a 100644
--- a/openbsc/tests/gbproxy/gbproxy_test.c
+++ b/openbsc/tests/gbproxy/gbproxy_test.c
@@ -37,8 +37,6 @@
 #include <openbsc/gprs_gb_parse.h>
 #include <openbsc/debug.h>
 
-#include <openssl/rand.h>
-
 #define REMOTE_BSS_ADDR 0x01020304
 #define REMOTE_SGSN_ADDR 0x05060708
 
@@ -53,30 +51,30 @@
 
 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 *data, size_t len)
 {
-	return (*RAND_bytes_cb)(buf, num);
+	return (*osmo_get_rand_id_cb)(data, len);
 }
 
 static int rand_seq_num = 0;
-int mock_RAND_bytes(unsigned char *buf, int num)
+int mock_osmo_get_rand_id(uint8_t *data, size_t len)
 {
 	uint32_t val;
 
-	OSMO_ASSERT(num == sizeof(val));
-	OSMO_ASSERT(__real_RAND_bytes(buf, num) == 1);
+	OSMO_ASSERT(len == sizeof(val));
+	OSMO_ASSERT(__real_osmo_get_rand_id(data, len) == 0);
 
 	val = 0x00dead00 + rand_seq_num;
 
 	rand_seq_num++;
 
-	memcpy(buf, &val, num);
+	memcpy(data, &val, len);
 
 	return 1;
 }
diff --git a/openbsc/tests/mm_auth/Makefile.am b/openbsc/tests/mm_auth/Makefile.am
index cb35198..a591d0a 100644
--- a/openbsc/tests/mm_auth/Makefile.am
+++ b/openbsc/tests/mm_auth/Makefile.am
@@ -8,7 +8,6 @@
 	$(LIBOSMOCORE_CFLAGS) \
 	$(LIBOSMOABIS_CFLAGS) \
 	$(LIBOSMOGSM_CFLAGS) \
-	$(LIBCRYPTO_CFLAGS) \
 	$(NULL)
 
 noinst_PROGRAMS = \
diff --git a/openbsc/tests/mm_auth/mm_auth_test.c b/openbsc/tests/mm_auth/mm_auth_test.c
index b8777a8..2adaf26 100644
--- a/openbsc/tests/mm_auth/mm_auth_test.c
+++ b/openbsc/tests/mm_auth/mm_auth_test.c
@@ -120,8 +120,8 @@
 	return auth_action;
 }
 
-/* override libssl RAND_bytes() to get testable crypto results */
-int RAND_bytes(uint8_t *rand, int len)
+/* override osmo_get_rand_id() to get testable crypto results */
+int osmo_get_rand_id(uint8_t *rand, size_t len)
 {
 	memset(rand, 23, len);
 	return 1;
diff --git a/openbsc/tests/sgsn/Makefile.am b/openbsc/tests/sgsn/Makefile.am
index f1606cb..2b8a671 100644
--- a/openbsc/tests/sgsn/Makefile.am
+++ b/openbsc/tests/sgsn/Makefile.am
@@ -32,7 +32,7 @@
 	$(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 \
@@ -66,7 +66,6 @@
 	$(LIBOSMOGSM_LIBS) \
 	$(LIBOSMOGB_LIBS) \
 	$(LIBCARES_LIBS) \
-	$(LIBCRYPTO_LIBS) \
 	$(LIBGTP_LIBS) \
 	-lrt \
 	-lm \
diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c
index 2f1513a..02e1086 100644
--- a/openbsc/tests/sgsn/sgsn_test.c
+++ b/openbsc/tests/sgsn/sgsn_test.c
@@ -100,21 +100,21 @@
 	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 *data, size_t num)
 {
+	uint8_t *buf = (uint8_t *)data;
 	if (num > 1)
-		return __real_RAND_bytes(buf, num);
+		return __real_osmo_get_rand_id(data, num);
 	buf[0] = 0;
 	return 1;
 }
diff --git a/openbsc/tests/sndcp_xid/Makefile.am b/openbsc/tests/sndcp_xid/Makefile.am
index d09c41b..fbcb36c 100644
--- a/openbsc/tests/sndcp_xid/Makefile.am
+++ b/openbsc/tests/sndcp_xid/Makefile.am
@@ -14,7 +14,6 @@
 	$(LIBOSMOGSM_LIBS) \
 	$(LIBOSMOGB_LIBS) \
 	$(LIBCARES_LIBS) \
-	$(LIBCRYPTO_LIBS) \
 	$(LIBGTP_LIBS) \
 	-lrt -lm
 
diff --git a/openbsc/tests/xid/Makefile.am b/openbsc/tests/xid/Makefile.am
index aaf17ed..9956f36 100644
--- a/openbsc/tests/xid/Makefile.am
+++ b/openbsc/tests/xid/Makefile.am
@@ -31,7 +31,6 @@
 	$(LIBOSMOGSM_LIBS) \
 	$(LIBOSMOGB_LIBS) \
 	$(LIBCARES_LIBS) \
-	$(LIBCRYPTO_LIBS) \
 	$(LIBGTP_LIBS) \
 	-lrt \
 	-lm \

-- 
To view, visit https://gerrit.osmocom.org/1464
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I270c33912bf107b3c7c217d199262cc74d56ffdb
Gerrit-PatchSet: 7
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: tnt <tnt at 246tNt.com>



More information about the gerrit-log mailing list