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*]
changes/88/3188/1
Daniel Willmann 7 years ago committed by Holger Hans Peter Freyther
parent b3cbd9aa3b
commit cdeb815c78
  1. 2
      openbsc/configure.ac
  2. 2
      openbsc/src/libmsc/Makefile.am
  3. 7
      openbsc/src/libmsc/db.c
  4. 2
      openbsc/src/osmo-nitb/Makefile.am
  5. 2
      openbsc/tests/channel/Makefile.am
  6. 2
      openbsc/tests/db/Makefile.am

@ -27,13 +27,13 @@ PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.7.0)
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])],
[osmo_ac_build_nat="$enableval"],[osmo_ac_build_nat="no"])
if test "$osmo_ac_build_nat" = "yes" ; then
PKG_CHECK_MODULES(LIBOSMOSCCP, libosmo-sccp >= 0.0.2)
PKG_CHECK_MODULES(LIBCRYPTO, libcrypto)
fi
AM_CONDITIONAL(BUILD_NAT, test "x$osmo_ac_build_nat" = "xyes")
AC_SUBST(osmo_ac_build_nat)

@ -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

@ -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;

@ -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)

@ -11,4 +11,4 @@ channel_test_LDADD = \
$(top_builddir)/src/libmsc/libmsc.a \
$(top_builddir)/src/libcommon/libcommon.a \
$(LIBOSMOCORE_LIBS) \
-ldbi $(LIBOSMOGSM_LIBS)
-ldbi $(LIBOSMOGSM_LIBS) $(LIBCRYPTO_LIBS)

@ -13,5 +13,5 @@ db_test_LDADD = $(top_builddir)/src/libbsc/libbsc.a \
$(top_builddir)/src/libtrau/libtrau.a \
$(top_builddir)/src/libcommon/libcommon.a \
$(LIBOSMOCORE_LIBS) $(LIBOSMOABIS_LIBS) \
$(LIBOSMOGSM_LIBS) $(LIBSMPP34_LIBS) $(LIBOSMOVTY_LIBS) -ldbi
$(LIBOSMOGSM_LIBS) $(LIBSMPP34_LIBS) $(LIBOSMOVTY_LIBS) $(LIBCRYPTO_LIBS) -ldbi

Loading…
Cancel
Save