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
This commit is contained in:
Max 2017-11-01 13:28:38 +01:00
parent d367aab6a0
commit ca7be8a5c2
8 changed files with 19 additions and 28 deletions

View File

@ -46,7 +46,6 @@ PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.9.5)
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)
# Enable/disable 3G aka IuPS + IuCS support?
AC_ARG_ENABLE([iu], [AS_HELP_STRING([--enable-iu], [Build 3G support, aka IuPS and IuCS interfaces])],

1
debian/control vendored
View File

@ -9,7 +9,6 @@ Build-Depends: debhelper (>=9),
automake,
libtool,
pkg-config,
libssl-dev,
libtalloc-dev,
libc-ares-dev,
libgtp-dev,

View File

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

View File

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

View File

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

View File

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

View File

@ -14,7 +14,6 @@ sndcp_xid_test_LDADD = \
$(LIBOSMOGSM_LIBS) \
$(LIBOSMOGB_LIBS) \
$(LIBCARES_LIBS) \
$(LIBCRYPTO_LIBS) \
$(LIBGTP_LIBS) \
-lrt -lm

View File

@ -30,7 +30,6 @@ xid_test_LDADD = \
$(LIBOSMOGSM_LIBS) \
$(LIBOSMOGB_LIBS) \
$(LIBCARES_LIBS) \
$(LIBCRYPTO_LIBS) \
$(LIBGTP_LIBS) \
-lrt \
-lm \