[PATCH] Remove osmo_a5_1 and osmo_a5_2 from public API - use generic osmo_a5() instead

Max Suraev Max.Suraev at fairwaves.co
Tue Jun 17 09:51:54 UTC 2014


Signed-off-by: Max Suraev <Max.Suraev at fairwaves.co>
---
 TODO-RELEASE             |  1 +
 include/osmocom/gsm/a5.h |  2 --
 src/gsm/a5.c             | 87 ++++++++++++++++++++++++------------------------
 src/gsm/libosmogsm.map   |  2 --
 4 files changed, 44 insertions(+), 48 deletions(-)

diff --git a/TODO-RELEASE b/TODO-RELEASE
index 43b1e8e..8a9f463 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -1 +1,2 @@
 #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
\ No newline at end of file
diff --git a/include/osmocom/gsm/a5.h b/include/osmocom/gsm/a5.h
index c076734..ffad902 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 de821e8..94fc679 100644
--- a/src/gsm/a5.c
+++ b/src/gsm/a5.c
@@ -39,46 +39,6 @@
 
 #include <osmocom/gsm/a5.h>
 
-/*! \brief Main method to generate a A5/x cipher stream
- *  \param[in] n Which A5/x method to use
- *  \param[in] key 8 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-2] 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;
-
-	default:
-		/* a5/[3..7] not supported here/yet */
-		return -ENOTSUP;
-	}
-
-	return 0;
-}
-
-
 /* ------------------------------------------------------------------------ */
 /* A5/1&2 common stuff                                                                     */
 /* ------------------------------------------------------------------------ */
@@ -190,8 +150,8 @@ _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)
+static void
+_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;
@@ -307,8 +267,8 @@ _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)
+static void
+_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;
@@ -368,4 +328,43 @@ osmo_a5_2(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul)
 	}
 }
 
+/*! \brief Main method to generate a A5/x cipher stream
+ *  \param[in] n Which A5/x method to use
+ *  \param[in] key 8 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-2] 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;
+
+	default:
+		/* a5/[3..7] not supported here/yet */
+		return -ENOTSUP;
+	}
+
+	return 0;
+}
+
 /*! @} */
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index cab4fc4..9b6657d 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -195,8 +195,6 @@ ms_pwr_ctl_lvl;
 ms_pwr_dbm;
 
 osmo_a5;
-osmo_a5_1;
-osmo_a5_2;
 
 osmo_auth_alg_name;
 osmo_auth_alg_parse;
-- 
1.9.1





More information about the baseband-devel mailing list