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
diff --git a/src/gprs/gprs_sgsn.c b/src/gprs/gprs_sgsn.c
index c4321f9..688eaed 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 @@
 {
 	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 @@
 	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;
 }