From patchwork Mon Jun 1 14:24:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max X-Patchwork-Id: 479053 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (tmp.osmocom.org [144.76.43.76]) by ozlabs.org (Postfix) with ESMTP id C2B8C140FD9 for ; Tue, 2 Jun 2015 00:25:12 +1000 (AEST) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id 602A56EF5; Mon, 1 Jun 2015 14:25:11 +0000 (UTC) X-Original-To: baseband-devel@lists.osmocom.org Delivered-To: baseband-devel@lists.osmocom.org Received: from hylle06.itea.ntnu.no (hylle06.itea.ntnu.no [129.241.56.235]) by lists.osmocom.org (Postfix) with ESMTP id 9AD156EED for ; Mon, 1 Jun 2015 14:25:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hylle06.itea.ntnu.no (Postfix) with ESMTP id 20E4A6615EC for ; Mon, 1 Jun 2015 16:25:10 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at hylle06.itea.ntnu.no Received: from alumnimail01.it.ntnu.no (alumnimail01.it.ntnu.no [129.241.18.54]) by hylle06.itea.ntnu.no (Postfix) with ESMTP id 5111E661357 for ; Mon, 1 Jun 2015 16:25:08 +0200 (CEST) Received: from localhost (nat.sec.t-labs.tu-berlin.de [130.149.230.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: suraev) by alumnimail01.it.ntnu.no (Postfix) with ESMTPSA id 2D6D555260 for ; Mon, 1 Jun 2015 16:25:08 +0200 (CEST) From: Max To: baseband-devel@lists.osmocom.org Subject: [PATCH] Remove osmo_a5_1 and osmo_a5_2 from public API - use generic osmo_a5() instead Date: Mon, 1 Jun 2015 16:24:46 +0200 Message-Id: <1433168686-1229-1-git-send-email-max.suraev@fairwaves.co> X-Mailer: git-send-email 2.1.4 X-BeenThere: baseband-devel@lists.osmocom.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: OsmocomBB - open source GSM baseband firmware List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: baseband-devel-bounces@lists.osmocom.org Sender: "baseband-devel" Signed-off-by: Max --- TODO-RELEASE | 1 + include/osmocom/gsm/a5.h | 2 - src/gsm/a5.c | 98 ++++++++++++++++++++++++------------------------ src/gsm/libosmogsm.map | 2 - 4 files changed, 49 insertions(+), 54 deletions(-) diff --git a/TODO-RELEASE b/TODO-RELEASE index d03aa49..ddae4c9 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -1,2 +1,3 @@ #library what description / commit summary line +libosmogsm api-change remove osmo_a5_1 and osmo_a5_2 - generic osmo_a5 should suffice for all use cases libosmogb abi-change bssgp: Fix bssgp_tx_fc_bvc parameter type diff --git a/include/osmocom/gsm/a5.h b/include/osmocom/gsm/a5.h index d22cdbb..9d12b03 100644 --- a/include/osmocom/gsm/a5.h +++ b/include/osmocom/gsm/a5.h @@ -54,7 +54,5 @@ osmo_a5_fn_count(uint32_t fn) * (converted internally to fn_count) */ int osmo_a5(int n, const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul); -void osmo_a5_1(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul); -void osmo_a5_2(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul); /*! @} */ diff --git a/src/gsm/a5.c b/src/gsm/a5.c index d0c7c5f..225ff87 100644 --- a/src/gsm/a5.c +++ b/src/gsm/a5.c @@ -101,54 +101,6 @@ _a5_3(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul, bool fn_correct) _a5_4(ck, fn, dl, ul, fn_correct); } -/*! \brief Main method to generate a A5/x cipher stream - * \param[in] n Which A5/x method to use - * \param[in] key 8 or 16 (for a5/4) byte array for the key (as received from the SIM) - * \param[in] fn Frame number - * \param[out] dl Pointer to array of ubits to return Downlink cipher stream - * \param[out] ul Pointer to array of ubits to return Uplink cipher stream - * \returns 0 for success, -ENOTSUP for invalid cipher selection. - * - * Currently A5/[0-4] are supported. - * Either (or both) of dl/ul can be NULL if not needed. - */ -int -osmo_a5(int n, const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul) -{ - switch (n) - { - case 0: - if (dl) - memset(dl, 0x00, 114); - if (ul) - memset(ul, 0x00, 114); - break; - - case 1: - osmo_a5_1(key, fn, dl, ul); - break; - - case 2: - osmo_a5_2(key, fn, dl, ul); - break; - - case 3: - _a5_3(key, fn, dl, ul, true); - break; - - case 4: - _a5_4(key, fn, dl, ul, true); - break; - - default: - /* a5/[5..7] not supported here/yet */ - return -ENOTSUP; - } - - return 0; -} - - /* ------------------------------------------------------------------------ */ /* A5/1&2 common stuff */ /* ------------------------------------------------------------------------ */ @@ -261,7 +213,7 @@ _a5_1_get_output(uint32_t r[]) * Either (or both) of dl/ul can be NULL if not needed. */ void -osmo_a5_1(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul) +_a5_1(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul) { uint32_t r[3] = {0, 0, 0}; uint32_t fn_count; @@ -378,7 +330,7 @@ _a5_2_get_output(uint32_t r[]) * Either (or both) of dl/ul can be NULL if not needed. */ void -osmo_a5_2(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul) +_a5_2(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul) { uint32_t r[4] = {0, 0, 0, 0}; uint32_t fn_count; @@ -437,5 +389,51 @@ osmo_a5_2(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul) ul[i] = _a5_2_get_output(r); } } +/*! \brief Main method to generate a A5/x cipher stream + * \param[in] n Which A5/x method to use + * \param[in] key 8 or 16 (for a5/4) byte array for the key (as received from the SIM) + * \param[in] fn Frame number + * \param[out] dl Pointer to array of ubits to return Downlink cipher stream + * \param[out] ul Pointer to array of ubits to return Uplink cipher stream + * \returns 0 for success, -ENOTSUP for invalid cipher selection. + * + * Currently A5/[0-4] are supported. + * Either (or both) of dl/ul can be NULL if not needed. + */ +int +osmo_a5(int n, const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul) +{ + switch (n) + { + case 0: + if (dl) + memset(dl, 0x00, 114); + if (ul) + memset(ul, 0x00, 114); + break; + + case 1: + _a5_1(key, fn, dl, ul); + break; + + case 2: + _a5_2(key, fn, dl, ul); + break; + + case 3: + _a5_3(key, fn, dl, ul, true); + break; + + case 4: + _a5_4(key, fn, dl, ul, true); + break; + + default: + /* a5/[5..7] not supported here/yet */ + return -ENOTSUP; + } + + return 0; +} /*! @} */ diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index 22428a2..56f33d9 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -201,8 +201,6 @@ ms_pwr_ctl_lvl; ms_pwr_dbm; osmo_a5; -osmo_a5_1; -osmo_a5_2; osmo_auth_alg_name; osmo_auth_alg_parse;