diff options
author | Daniel Willmann <dwillmann@sysmocom.de> | 2015-10-08 16:10:24 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2015-10-12 09:05:48 +0200 |
commit | 6cf0249dacc4ae46eb0857c007906c9a3f128a3e (patch) | |
tree | 16a90d9a92558440de4e390965d58773865dea62 /openbsc/src/gprs/gprs_sgsn.c | |
parent | cdeb815c78f4cdd5eb38995ea3f8550c637a1561 (diff) |
gprs: Use RAND_bytes for p-tmsi
[hfreyther: Link to libcrypto, include header, add uint8_t* cast]
Diffstat (limited to 'openbsc/src/gprs/gprs_sgsn.c')
-rw-r--r-- | openbsc/src/gprs/gprs_sgsn.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c index f40de0b3c..9b11c3510 100644 --- a/openbsc/src/gprs/gprs_sgsn.c +++ b/openbsc/src/gprs/gprs_sgsn.c @@ -41,6 +41,8 @@ #include <time.h> +#include <openssl/rand.h> + #define GPRS_LLME_CHECK_TICK 30 extern struct sgsn_instance *sgsn; @@ -525,7 +527,9 @@ uint32_t sgsn_alloc_ptmsi(void) int max_retries = 100; restart: - ptmsi = rand(); + if (RAND_bytes((uint8_t *) &ptmsi, sizeof(ptmsi)) != 1) + goto failed; + /* Enforce that the 2 MSB are set without loosing the distance between * identical values. Since rand() has no duplicate values within a * period (because the size of the state is the same like the size of |