From patchwork Thu Oct 8 14:10:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Willmann X-Patchwork-Id: 527727 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (unknown [IPv6:2a01:4f8:191:444b::2:7]) by ozlabs.org (Postfix) with ESMTP id F1BF2140D9C for ; Fri, 9 Oct 2015 01:16:07 +1100 (AEDT) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id CA9309526; Thu, 8 Oct 2015 14:16:06 +0000 (UTC) X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org Received: from isonoe.totalueberwachung.de (unknown [IPv6:2a01:198:210:100::1]) by lists.osmocom.org (Postfix) with ESMTP id 0C5CB94B0 for ; Thu, 8 Oct 2015 14:16:00 +0000 (UTC) Received: from adrastea.totalueberwachung.de (ip5b4185b8.dynamic.kabel-deutschland.de [91.65.133.184]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by isonoe.totalueberwachung.de (Postfix) with ESMTPSA id 52B726007C; Thu, 8 Oct 2015 16:10:26 +0200 (CEST) Received: by adrastea.totalueberwachung.de (Postfix, from userid 1000) id 783745015; Thu, 8 Oct 2015 16:10:27 +0200 (CEST) From: Daniel Willmann To: OpenBSC Mailing List Subject: [openbsc 3/4] libmsc: Use RAND_bytes to choose auth tuple Date: Thu, 8 Oct 2015 16:10:25 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Development of the OpenBSC GSM base station controller List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Willmann Errors-To: openbsc-bounces@lists.osmocom.org Sender: "OpenBSC" From: Daniel Willmann --- openbsc/src/libmsc/auth.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c index 10d8edf..93ee71f 100644 --- a/openbsc/src/libmsc/auth.c +++ b/openbsc/src/libmsc/auth.c @@ -27,6 +27,8 @@ #include +#include + #include @@ -100,8 +102,11 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple, /* Generate a new one */ atuple->use_count = 1; atuple->key_seq = (atuple->key_seq + 1) % 7; - for (i=0; irand); i++) - atuple->rand[i] = random() & 0xff; + + if (RAND_bytes(atuple->rand, sizeof(atuple->rand)) != 1) { + LOGP(DMM, LOGL_NOTICE, "RAND_bytes failed, can't generate new auth tuple\n"); + return -1; + } switch (ainfo.auth_algo) { case AUTH_ALGO_NONE: