[PATCH] Remove osmo_a5_1 and osmo_a5_2 from public API - use generic osmo_a5() instead
Max
max.suraev at fairwaves.co
Mon Jun 1 14:24:46 UTC 2015
Signed-off-by: Max <max.suraev at fairwaves.co>
---
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;
--
2.1.4
More information about the baseband-devel
mailing list