fixeria has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/30627 )


Change subject: trxcon: preserve A5 params during [P]DCH-to-DCH transition
......................................................................

trxcon: preserve A5 params during [P]DCH-to-DCH transition

This is not really needed because layer23 apps do send another
another L1CTL_CRYPTO_REQ message for the new DCH.  I wrote this
patch before I figured this out, but we may want to offload the
task of preserving the A5 params to the L1 some day...

Change-Id: I822a27a1bacc21dae7a3e31166a7609c7e1faeff
---
M src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h
M src/host/trxcon/src/trxcon_fsm.c
2 files changed, 24 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/27/30627/1

diff --git a/src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h 
b/src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h
index 9148771..103a047 100644
--- a/src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h
+++ b/src/host/trxcon/include/osmocom/bb/trxcon/trxcon.h
@@ -31,6 +31,11 @@
                uint16_t band_arfcn;
                uint8_t tx_power;
                int8_t ta;
+
+               /* A5 encryption state */
+               uint8_t a5_algo;
+               uint8_t a5_key_len;
+               uint8_t a5_key[128 / 8]; /* MAX_A5_KEY_LEN */
        } l1p;
 };

diff --git a/src/host/trxcon/src/trxcon_fsm.c b/src/host/trxcon/src/trxcon_fsm.c
index b575fd0..dbab84a 100644
--- a/src/host/trxcon/src/trxcon_fsm.c
+++ b/src/host/trxcon/src/trxcon_fsm.c
@@ -64,6 +64,11 @@
                trxcon->l1p.tx_power = 0;
                trxcon->l1p.ta = 0;

+               /* Reset the A5 state */
+               trxcon->l1p.a5_algo = 0;
+               trxcon->l1p.a5_key_len = 0;
+               memset(&trxcon->l1p.a5_key[0], 0x00, 
sizeof(trxcon->l1p.a5_key));
+
                phycmd.type = TRXCON_PHYIF_CMDT_RESET;
                trxcon_phyif_handle_cmd(trxcon->phyif, &phycmd);
                break;
@@ -359,6 +364,15 @@
                return;
        }

+       /* Reapply A5 ciphering parameters (if needed) */
+       if (config != GSM_PCHAN_PDCH && trxcon->l1p.a5_algo) {
+               rc = l1sched_start_ciphering(ts, trxcon->l1p.a5_algo,
+                                            &trxcon->l1p.a5_key[0],
+                                            trxcon->l1p.a5_key_len);
+               if (rc != 0)
+                       LOGPFSML(fi, LOGL_ERROR, "Failed to configure 
ciphering\n");
+       }
+
        if (config == GSM_PCHAN_PDCH)
                osmo_fsm_inst_state_chg(fi, TRXCON_ST_PACKET_DATA, 0, 0);
        else
@@ -492,6 +506,11 @@
                        LOGPFSML(fi, LOGL_ERROR, "Failed to configure 
ciphering\n");
                        return;
                }
+
+               trxcon->l1p.a5_algo = req->a5_algo;
+               trxcon->l1p.a5_key_len = req->key_len;
+               OSMO_ASSERT(req->key_len <= sizeof(trxcon->l1p.a5_key));
+               memcpy(&trxcon->l1p.a5_key[0], req->key, req->key_len);
                break;
        }
        case TRXCON_EV_TX_DATA_REQ:

--
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/30627
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: I822a27a1bacc21dae7a3e31166a7609c7e1faeff
Gerrit-Change-Number: 30627
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <[email protected]>
Gerrit-MessageType: newchange

Reply via email to