diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2012-12-26 18:55:54 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2012-12-26 18:55:54 +0100 |
commit | 19cf0e81b336ead3c0a55d1c9d6722f986510bc0 (patch) | |
tree | f78ac1ca37b836aa3b7ff1dbfc6b861ac44ab5b4 /src | |
parent | 5f408f934ca868ff209049bd92f3b0896a0eccac (diff) |
ciphering: Handle ciphering support for A5/3 correctly
This was found and debugged by Sylvain. The BTS will always support
A5/0 so we do not keep track of that, the first bit of the flags is
used for A5/1, second for A5/2... but for RSL there is an offset to
go from RSL to A5(x). Add a testcase and change the code.
Diffstat (limited to 'src')
-rw-r--r-- | src/common/bts.c | 15 | ||||
-rw-r--r-- | src/common/rsl.c | 6 | ||||
-rw-r--r-- | src/osmo-bts-sysmo/main.c | 2 |
3 files changed, 20 insertions, 3 deletions
diff --git a/src/common/bts.c b/src/common/bts.c index 1375f4a5..8f6dc694 100644 --- a/src/common/bts.c +++ b/src/common/bts.c @@ -213,3 +213,18 @@ struct msgb *bts_agch_dequeue(struct gsm_bts *bts) return msgb_dequeue(&btsb->agch_queue); } + +int bts_supports_cipher(struct gsm_bts_role_bts *bts, int rsl_cipher) +{ + int sup; + + if (rsl_cipher < 1 || rsl_cipher > 8) + return -ENOTSUP; + + /* No encryption is always supported */ + if (rsl_cipher == 1) + return 1; + + sup = (1 << (rsl_cipher - 2)) & bts->support.ciphers; + return sup > 0; +} diff --git a/src/common/rsl.c b/src/common/rsl.c index d53e07b9..481686ed 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -593,11 +593,13 @@ static void copy_sacch_si_to_lchan(struct gsm_lchan *lchan) static int encr_info2lchan(struct gsm_lchan *lchan, const uint8_t *val, uint8_t len) { + int rc; struct gsm_bts_role_bts *btsb = bts_role_bts(lchan->ts->trx->bts); /* check if the encryption algorithm sent by BSC is supported! */ - if (!((1 << *val) & btsb->support.ciphers)) - return -ENOTSUP; + rc = bts_supports_cipher(btsb, *val); + if (rc != 1) + return rc; /* length can be '1' in case of no ciphering */ if (len < 1) diff --git a/src/osmo-bts-sysmo/main.c b/src/osmo-bts-sysmo/main.c index 137a0b16..a00120e4 100644 --- a/src/osmo-bts-sysmo/main.c +++ b/src/osmo-bts-sysmo/main.c @@ -257,7 +257,7 @@ int main(int argc, char **argv) exit(1); } btsb = bts_role_bts(bts); - btsb->support.ciphers = (1 << 0) | (1 << 1) | (1 << 2); + btsb->support.ciphers = CIPHER_A5(1) | CIPHER_A5(2) | CIPHER_A5(3); rc = vty_read_config_file(config_file, NULL); if (rc < 0) { |