aboutsummaryrefslogtreecommitdiffstats
path: root/src/gprs/gprs_sgsn.c
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2017-11-01 13:28:38 +0100
committerMax <msuraev@sysmocom.de>2017-12-27 11:10:42 +0000
commit3b6332f6dc1fa14dea6d1577a162b84bb304d4ef (patch)
tree3fd531726889a3650920da1a78bf769e36153def /src/gprs/gprs_sgsn.c
parent794693c09360382a222a00b031cf5159a8088303 (diff)
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
Diffstat (limited to 'src/gprs/gprs_sgsn.c')
-rw-r--r--src/gprs/gprs_sgsn.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/gprs/gprs_sgsn.c b/src/gprs/gprs_sgsn.c
index c4321f91..688eaed1 100644
--- a/src/gprs/gprs_sgsn.c
+++ b/src/gprs/gprs_sgsn.c
@@ -46,8 +46,6 @@
#include <time.h>
-#include <openssl/rand.h>
-
#include "../../bscconfig.h"
#if BUILD_IU
@@ -643,10 +641,11 @@ uint32_t sgsn_alloc_ptmsi(void)
{
struct sgsn_mm_ctx *mm;
uint32_t ptmsi = 0xdeadbeef;
- int max_retries = 100;
+ int max_retries = 100, rc = 0;
restart:
- if (RAND_bytes((uint8_t *) &ptmsi, sizeof(ptmsi)) != 1)
+ rc = osmo_get_rand_id((uint8_t *) &ptmsi, sizeof(ptmsi));
+ if (rc < 0)
goto failed;
/* Enforce that the 2 MSB are set without loosing the distance between
@@ -684,7 +683,7 @@ restart:
return ptmsi;
failed:
- LOGP(DGPRS, LOGL_ERROR, "Failed to allocate a P-TMSI\n");
+ LOGP(DGPRS, LOGL_ERROR, "Failed to allocate a P-TMSI: %d (%s)\n", rc, strerror(-rc));
return GSM_RESERVED_TMSI;
}