[PATCH] osmo-bsc[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
Mon Oct 30 13:45:11 UTC 2017


Hello Jenkins Builder,

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

    https://gerrit.osmocom.org/3819

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

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.

Change-Id: Ia57bf1300525cf3c247284fe966b1c415c2d53e2
Related: OS#1694
---
M configure.ac
M contrib/jenkins.sh
M debian/control
M src/osmo-bsc_nat/Makefile.am
M src/osmo-bsc_nat/bsc_nat.c
M tests/channel/Makefile.am
6 files changed, 8 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/19/3819/3

diff --git a/configure.ac b/configure.ac
index 79523d1..cf8cebe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -46,7 +46,6 @@
 PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.3.2)
 PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 0.1.0)
 PKG_CHECK_MODULES(LIBOSMOSIGTRAN, libosmo-sigtran >= 0.8.0)
-PKG_CHECK_MODULES(LIBCRYPTO, libcrypto >= 0.9.5)
 PKG_CHECK_MODULES(LIBOSMOLEGACYMGCP, libosmo-legacy-mgcp >= 0.0.1)
 PKG_CHECK_MODULES(LIBOSMOSCCP, libosmo-sccp >= 0.0.2)
 
diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 57954f0..6ae6732 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -18,7 +18,7 @@
 
 mkdir "$deps" || true
 
-osmo-build-dep.sh libosmocore "" ac_cv_path_DOXYGEN=false
+osmo-build-dep.sh libosmocore "" '--disable-doxygen --enable-gnutls'
 
 verify_value_string_arrays_are_terminated.py $(find . -name "*.[hc]")
 
diff --git a/debian/control b/debian/control
index e4a5b1f..061013f 100644
--- a/debian/control
+++ b/debian/control
@@ -10,7 +10,6 @@
                libtool,
                pkg-config,
                python-minimal,
-               libssl-dev (>= 0.9.5),
                libtalloc-dev,
                libosmocore-dev (>= 0.10.0),
                libosmo-sccp-dev (>= 0.0.2),
diff --git a/src/osmo-bsc_nat/Makefile.am b/src/osmo-bsc_nat/Makefile.am
index 23c2b67..ee0f1ae 100644
--- a/src/osmo-bsc_nat/Makefile.am
+++ b/src/osmo-bsc_nat/Makefile.am
@@ -12,7 +12,6 @@
 	$(LIBOSMOCTRL_CFLAGS) \
 	$(LIBOSMOSCCP_CFLAGS) \
 	$(LIBOSMOLEGACYMGCP_CFLAGS) \
-	$(LIBCRYPTO_CFLAGS) \
 	$(COVERAGE_CFLAGS) \
 	$(NULL)
 
@@ -51,7 +50,6 @@
 	$(LIBOSMOCTRL_LIBS) \
 	$(LIBOSMOSIGTRAN_LIBS) \
 	$(LIBOSMOLEGACYMGCP_LIBS) \
-	$(LIBCRYPTO_LIBS) \
 	$(LIBRARY_GSM) \
 	-lrt \
 	$(NULL)
diff --git a/src/osmo-bsc_nat/bsc_nat.c b/src/osmo-bsc_nat/bsc_nat.c
index 1548ea3..5569d2f 100644
--- a/src/osmo-bsc_nat/bsc_nat.c
+++ b/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
@@ -208,7 +206,7 @@
 		0x01, IPAC_IDTAG_UNITNAME,
 		0x01, IPAC_IDTAG_SERNR,
 	};
-
+	int rc;
 	uint8_t *mrand;
 	uint8_t id_req[sizeof(s_id_req) + (2+16)];
 	uint8_t *buf = &id_req[sizeof(s_id_req)];
@@ -221,19 +219,17 @@
 	buf = v_put(buf, 0x23);
 	mrand = bsc->last_rand;
 
-	if (RAND_bytes(mrand, 16) != 1)
-		goto failed_random;
+	rc = osmo_get_rand_id(mrand, 16);
+	if (rc < 0) {
+		/* the timeout will trigger and close this connection */
+		LOGP(DNAT, LOGL_ERROR, "osmo_get_rand_id() failed: %s\n", strerror(-rc));
+		return;
+	}
 
 	memcpy(buf, mrand, 16);
 	buf += 16;
 
 	bsc_send_data(bsc, id_req, sizeof(id_req), IPAC_PROTO_IPACCESS);
-	return;
-
-failed_random:
-	/* the timeout will trigger and close this connection */
-	LOGP(DNAT, LOGL_ERROR, "Failed to read from urandom.\n");
-	return;
 }
 
 static struct msgb *nat_create_rlsd(struct nat_sccp_connection *conn)
diff --git a/tests/channel/Makefile.am b/tests/channel/Makefile.am
index 395daf7..12f18f8 100644
--- a/tests/channel/Makefile.am
+++ b/tests/channel/Makefile.am
@@ -29,5 +29,4 @@
 	$(top_builddir)/src/libcommon/libcommon.a \
 	$(LIBOSMOCORE_LIBS) \
 	$(LIBOSMOGSM_LIBS) \
-	$(LIBCRYPTO_LIBS) \
 	$(NULL)

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ia57bf1300525cf3c247284fe966b1c415c2d53e2
Gerrit-PatchSet: 3
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list