diff options
author | Daniel Willmann <dwillmann@sysmocom.de> | 2015-10-08 16:10:23 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2015-10-12 09:03:15 +0200 |
commit | cdeb815c78f4cdd5eb38995ea3f8550c637a1561 (patch) | |
tree | b86295be57ce68422e60e9b6837f3805f9f2070f /openbsc/src | |
parent | b3cbd9aa3b8e80060ff38b975e297a5b4a850fec (diff) |
libmsc: Use RAND_bytes when choosing a tmsi
Require openssl version to be >= 0.9.5 because we rely on the RAND_bytes
return value.
[hfreyther: Add cast to uint8_t*]
Diffstat (limited to 'openbsc/src')
-rw-r--r-- | openbsc/src/libmsc/Makefile.am | 2 | ||||
-rw-r--r-- | openbsc/src/libmsc/db.c | 7 | ||||
-rw-r--r-- | openbsc/src/osmo-nitb/Makefile.am | 2 |
3 files changed, 8 insertions, 3 deletions
diff --git a/openbsc/src/libmsc/Makefile.am b/openbsc/src/libmsc/Makefile.am index aa7d8ae99..18bfa0c92 100644 --- a/openbsc/src/libmsc/Makefile.am +++ b/openbsc/src/libmsc/Makefile.am @@ -1,6 +1,6 @@ AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir) AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOVTY_CFLAGS) \ - $(LIBOSMOABIS_CFLAGS) $(COVERAGE_CFLAGS) + $(LIBOSMOABIS_CFLAGS) $(COVERAGE_CFLAGS) $(LIBCRYPTO_CFLAGS) noinst_HEADERS = meas_feed.h diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c index 035202de8..4061fc102 100644 --- a/openbsc/src/libmsc/db.c +++ b/openbsc/src/libmsc/db.c @@ -38,6 +38,8 @@ #include <osmocom/core/statistics.h> #include <osmocom/core/rate_ctr.h> +#include <openssl/rand.h> + /* Semi-Private-Interface (SPI) for the subscriber code */ void subscr_direct_free(struct gsm_subscriber *subscr); @@ -1194,7 +1196,10 @@ int db_subscriber_alloc_tmsi(struct gsm_subscriber *subscriber) char *tmsi_quoted; for (;;) { - subscriber->tmsi = rand(); + if (RAND_bytes((uint8_t *) &subscriber->tmsi, sizeof(subscriber->tmsi)) != 1) { + LOGP(DDB, LOGL_ERROR, "RAND_bytes failed\n"); + return 1; + } if (subscriber->tmsi == GSM_RESERVED_TMSI) continue; diff --git a/openbsc/src/osmo-nitb/Makefile.am b/openbsc/src/osmo-nitb/Makefile.am index 57a928406..d3b97f8cb 100644 --- a/openbsc/src/osmo-nitb/Makefile.am +++ b/openbsc/src/osmo-nitb/Makefile.am @@ -16,4 +16,4 @@ osmo_nitb_LDADD = \ $(top_builddir)/src/libcommon/libcommon.a \ -ldbi $(LIBCRYPT) \ $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOCORE_LIBS) \ - $(LIBOSMOCTRL_LIBS) $(LIBOSMOABIS_LIBS) $(LIBSMPP34_LIBS) + $(LIBOSMOCTRL_LIBS) $(LIBOSMOABIS_LIBS) $(LIBSMPP34_LIBS) $(LIBCRYPTO_LIBS) |