From bso at inbox.lv Fri Jun 13 20:40:56 2014 From: bso at inbox.lv (parpar) Date: Fri, 13 Jun 2014 13:40:56 -0700 (PDT) Subject: Osmovom-BB on Raspberry Pi In-Reply-To: References: Message-ID: <1402692055965-4026518.post@n3.nabble.com> Hi Can anyone elaborate on the "compatible crosscompiled tool-chain"? I compiled mine (gnu arm toolchain) following these instructions, but it seems that RSSI and other firmwares compiled on raspberry are crashing (-110 dBm on all ARFCNs after certain operations - e.g. spectrum view). Host tools compiled on raspberry seem to work fine (e.g. osmocon loading firmware compiled on PC). Still they don't quite "talk" with different firmware version (from PC). Richard Menedetter wrote > I tried Motorola C118 and C155 with success. > > Everything you need is already described: > http://bb.osmocom.org/trac/wiki/GnuArmToolchain > http://bb.osmocom.org/trac/wiki/libosmocore > http://bb.osmocom.org/trac/wiki/Software/GettingStarted?redirectedfrom=GettingStarted > > My previous problem seems to have been a not fully compatible > crosscompiled toolchain. (it worked mostly, but I could not log-in to a > cell and the spectrum view crashed on the RSSI Firmware. -- View this message in context: http://baseband-devel.722152.n3.nabble.com/Osmovom-BB-on-Raspberry-Pi-tp4025859p4026518.html Sent from the baseband-devel mailing list archive at Nabble.com. From bso at inbox.lv Mon Jun 16 16:41:22 2014 From: bso at inbox.lv (parpar) Date: Mon, 16 Jun 2014 09:41:22 -0700 (PDT) Subject: Osmovom-BB on Raspberry Pi In-Reply-To: <1402692055965-4026518.post@n3.nabble.com> References: <1402692055965-4026518.post@n3.nabble.com> Message-ID: <1402936881999-4026537.post@n3.nabble.com> It seems that the -110 / -138 dBm level happens when using Sylvain testing branch of osmocom-bb. AFAIK it's not related to raspberry-pi (Testing branch produces this glitch on PC, Main branch runs fine on RPi). -- View this message in context: http://baseband-devel.722152.n3.nabble.com/Osmovom-BB-on-Raspberry-Pi-tp4025859p4026537.html Sent from the baseband-devel mailing list archive at Nabble.com. From Max.Suraev at fairwaves.co Fri Jun 13 10:45:16 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Fri, 13 Jun 2014 12:45:16 +0200 Subject: [PATCH] Update GPRS cipher API to comply with ETSI TS 155.22 In-Reply-To: <1395085252-7428-1-git-send-email-max.suraev@fairwaves.co> References: <1395085252-7428-1-git-send-email-max.suraev@fairwaves.co> Message-ID: <539AD63C.80908@fairwaves.co> I've just realized that this patch missing explicit comment. Old API assumed that GPRS key length is always 64 bit - ETSI TS 155.22 proves this assumption wrong. Thit patch removes this assumption. It also makes GPRS cipher API to match the style of GSM cipher API which does not make any assumptions on the key length. cheers, Max. From Max.Suraev at fairwaves.co Tue Jun 17 09:16:58 2014 From: Max.Suraev at fairwaves.co (Max Suraev) Date: Tue, 17 Jun 2014 11:16:58 +0200 Subject: [PATCH] Update internal GPRS cipher API to comply with ETSI TS 155.22 In-Reply-To: <1395085252-7428-1-git-send-email-max.suraev@fairwaves.co> References: <1395085252-7428-1-git-send-email-max.suraev@fairwaves.co> Message-ID: <1402996618-7967-1-git-send-email-Max.Suraev@fairwaves.co> Signed-off-by: Max Suraev --- TODO-RELEASE | 3 ++- include/osmocom/crypt/gprs_cipher.h | 8 ++++++-- src/gsm/gprs_cipher_core.c | 23 +++++++++++++++++++++-- src/gsm/libosmogsm.map | 1 + 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/TODO-RELEASE b/TODO-RELEASE index 43b1e8e..c7366ae 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -1 +1,2 @@ -#library what description / commit summary line +#library what description / commit summary line +libosmogsm internal API update Internal API for GPRS cipher implementors updated to accommodate for arbitrary key lengths \ No newline at end of file diff --git a/include/osmocom/crypt/gprs_cipher.h b/include/osmocom/crypt/gprs_cipher.h index 940b07b..d6edefa 100644 --- a/include/osmocom/crypt/gprs_cipher.h +++ b/include/osmocom/crypt/gprs_cipher.h @@ -9,6 +9,7 @@ enum gprs_ciph_algo { GPRS_ALGO_GEA1, GPRS_ALGO_GEA2, GPRS_ALGO_GEA3, + GPRS_ALGO_GEA4, _GPRS_ALGO_NUM }; @@ -27,7 +28,7 @@ struct gprs_cipher_impl { /* As specified in 04.64 Annex A. Uses Kc, IV and direction * to generate the 1523 bytes cipher stream that need to be * XORed wit the plaintext for encrypt / ciphertext for decrypt */ - int (*run)(uint8_t *out, uint16_t len, uint64_t kc, uint32_t iv, + int (*run)(uint8_t *out, uint16_t len, uint8_t *kc, uint32_t iv, enum gprs_cipher_direction direction); }; @@ -39,11 +40,14 @@ int gprs_cipher_load(const char *path); /* function to be called by core code */ int gprs_cipher_run(uint8_t *out, uint16_t len, enum gprs_ciph_algo algo, - uint64_t kc, uint32_t iv, enum gprs_cipher_direction dir); + uint8_t *kc, uint32_t iv, enum gprs_cipher_direction dir); /* Do we have an implementation for this cipher? */ int gprs_cipher_supported(enum gprs_ciph_algo algo); +/* Return key length for supported cipher, in bytes */ +unsigned gprs_cipher_key_length(enum gprs_ciph_algo algo); + /* GSM TS 04.64 / Section A.2.1 : Generation of 'input' */ uint32_t gprs_cipher_gen_input_ui(uint32_t iov_ui, uint8_t sapi, uint32_t lfn, uint32_t oc); diff --git a/src/gsm/gprs_cipher_core.c b/src/gsm/gprs_cipher_core.c index b9a22a1..e4fac04 100644 --- a/src/gsm/gprs_cipher_core.c +++ b/src/gsm/gprs_cipher_core.c @@ -53,12 +53,14 @@ int gprs_cipher_register(struct gprs_cipher_impl *ciph) int gprs_cipher_load(const char *path) { /* load all plugins available from path */ - return osmo_plugin_load_all(path); + if (path) + return osmo_plugin_load_all(path); + return 0; } /* function to be called by core code */ int gprs_cipher_run(uint8_t *out, uint16_t len, enum gprs_ciph_algo algo, - uint64_t kc, uint32_t iv, enum gprs_cipher_direction dir) + uint8_t *kc, uint32_t iv, enum gprs_cipher_direction dir) { if (algo >= ARRAY_SIZE(selected_ciphers)) return -ERANGE; @@ -73,6 +75,23 @@ int gprs_cipher_run(uint8_t *out, uint16_t len, enum gprs_ciph_algo algo, return selected_ciphers[algo]->run(out, len, kc, iv, dir); } +/*! \brief Obtain key lenght for given GPRS cipher + * \param[in] algo Enum representive GPRS cipher + * \returns unsigned integer key length for supported algorithms, + * for GEA0 and unknown ciphers will return 0 + */ +unsigned gprs_cipher_key_length(enum gprs_ciph_algo algo) +{ + switch (algo) { + case GPRS_ALGO_GEA0: return 0; + case GPRS_ALGO_GEA1: + case GPRS_ALGO_GEA2: + case GPRS_ALGO_GEA3: return 8; + case GPRS_ALGO_GEA4: return 16; + default: return 0; + } +} + int gprs_cipher_supported(enum gprs_ciph_algo algo) { if (algo >= ARRAY_SIZE(selected_ciphers)) diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index cab4fc4..7808be6 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -32,6 +32,7 @@ gprs_cipher_load; gprs_cipher_register; gprs_cipher_run; gprs_cipher_supported; +gprs_cipher_key_length; gprs_tlli_type; gprs_tmsi2tlli; -- 1.9.1 From Max.Suraev at fairwaves.co Tue Jun 17 09:22:37 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Tue, 17 Jun 2014 11:22:37 +0200 Subject: [PATCH] Update internal GPRS cipher API to comply with ETSI TS 155.22 In-Reply-To: <1402996618-7967-1-git-send-email-Max.Suraev@fairwaves.co> References: <1395085252-7428-1-git-send-email-max.suraev@fairwaves.co> <1402996618-7967-1-git-send-email-Max.Suraev@fairwaves.co> Message-ID: <53A008DD.7050201@fairwaves.co> To clarify - this patch does not change external API: it adds convenience function to external API and it changes internal API used by developers implementing GPRS ciphers. To the best of my knowledge the massive set of such devs amounts to only me at the moment :) -- best regards, Max, http://fairwaves.co From Max.Suraev at fairwaves.co Mon Jun 2 09:22:31 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Mon, 02 Jun 2014 11:22:31 +0200 Subject: GSMTAP LTE support Message-ID: <538C4257.1050709@fairwaves.co> Hi. I'd like to add LTE support to GSMTAP in libosmocore. How shall I proceed? Just add #define GSMTAP_TYPE_LTE 0x0d to include/osmocom/core/gsmtap.h and appropriate sub-types, than send patch? -- best regards, Max, http://fairwaves.co From 246tnt at gmail.com Mon Jun 2 11:09:07 2014 From: 246tnt at gmail.com (Sylvain Munaut) Date: Mon, 2 Jun 2014 13:09:07 +0200 Subject: GSMTAP LTE support In-Reply-To: <538C4257.1050709@fairwaves.co> References: <538C4257.1050709@fairwaves.co> Message-ID: Hi, > I'd like to add LTE support to GSMTAP in libosmocore. How shall I proceed? > Just add > > #define GSMTAP_TYPE_LTE 0x0d > > to include/osmocom/core/gsmtap.h and appropriate sub-types, than send patch? Yes. Although looking at other ones, it sometimes makes sense to have several 'types', I think it depends mostly on what make sense there for the dissectors in wireshark. #define GSMTAP_TYPE_UMTS_RLC_MAC 0x0b #define GSMTAP_TYPE_UMTS_RRC 0x0c Preferrably try to explain a bit the division you make between types / subtypes and what data ends up in the packet in the commit message. I'll let someone more familiar with LTE to actually comment on what divisions would make sense ... Cheers, Sylvain From mailman at lists.osmocom.org Mon Jun 2 09:28:34 2014 From: mailman at lists.osmocom.org (mailman at lists.osmocom.org) Date: Mon, 02 Jun 2014 11:28:34 +0200 Subject: Bounce action notification Message-ID: This is a Mailman mailing list bounce action notice: List: baseband-devel Member: 3304xfq at 163.com Action: Subscription disabled. Reason: Excessive or fatal bounces. The triggering bounce notice is attached below. Questions? Contact the Mailman site administrator at mailman at lists.osmocom.org. -------------- next part -------------- An embedded message was scrubbed... From: Postmaster at 163.com Subject: ???? Date: Mon, 2 Jun 2014 17:28:23 +0800 (CST) Size: 12145 URL: From Max.Suraev at fairwaves.co Tue Jun 3 16:07:45 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Tue, 03 Jun 2014 18:07:45 +0200 Subject: cmake support Message-ID: <538DF2D1.30203@fairwaves.co> Hi all I've recently have to use libosmocore from cmake-based project. In order to make it easier to use via simple find_package(libosmocore) I've created attached file. It's follows the example in cmake wiki which uses pkg-config to get proper paths and flags. The question is - shall we try to install it into CMAKE_MODULE_PATH while installing .deb package for example or shall I try to push it to cmake's modules repo? Another approach would be to generate libosmocore-config.cmake directly with correct paths and options at compile-time and supply that instead of relying on pkg-config. -- best regards, Max, http://fairwaves.co -------------- next part -------------- A non-text attachment was scrubbed... Name: Findlibosmocore.cmake Type: text/x-cmake Size: 1146 bytes Desc: not available URL: From xdae3v3a at gmail.com Wed Jun 4 11:09:08 2014 From: xdae3v3a at gmail.com (E:V:A) Date: Wed, 4 Jun 2014 04:09:08 -0700 (PDT) Subject: Documenting Samsung Radio variables from the ServiceMode Message-ID: <1401880148251-4026493.post@n3.nabble.com> Dear Baseband developers, We are a very small group of XDA developers and external people trying to realize our Android based IMSI-catcher Detector (AIMSICD) project. http://tinyurl.com/l6whse2 However, to realize such an ambitious feat we really need better access to the various RF variables and details of neighboring cells, among many other things. We have had partial success in that we're able to use the ServiceMode (SM) menu from the Samsung ServiceMode application. However, this is just a wrapper to accessing OEM_RAW_REQUESTS presented by code that is part of the baseband FW. Now, the tricky part for us non-GSM experts, is understanding what these variables really mean and represent. I have started 2 threads on XDA to: 1) completely map out the ServiceMode menu options, for an GT-I9195 (S4-mini) but should work on many similar and newer Samsung devices. 2) To map out the various MM timers and many other RF/GSM variables shown and available in the SM menu. http://tinyurl.com/qgcmbsv We need help from the baseband community to understand the vocabulary used in this information as presented in (2) above, so that we can start to fill in the catcher-catcher detection parameters from the table here: https://opensource.srlabs.de/projects/mobile-network-assessment-tools/wiki/CatcherCatcher We will be using a modified version of this to do our detection. I'd also like to invite anyone interested to participate in this free and open project. Everything we have done so far is available on github. There are also some hidden documents available to motivated developers who have shown an honest effort to help us out. Best Regards, E:V:A -- View this message in context: http://baseband-devel.722152.n3.nabble.com/Documenting-Samsung-Radio-variables-from-the-ServiceMode-tp4026493.html Sent from the baseband-devel mailing list archive at Nabble.com. From Max.Suraev at fairwaves.co Wed Jun 4 13:44:39 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Wed, 04 Jun 2014 15:44:39 +0200 Subject: Documenting Samsung Radio variables from the ServiceMode In-Reply-To: <1401880148251-4026493.post@n3.nabble.com> References: <1401880148251-4026493.post@n3.nabble.com> Message-ID: <538F22C7.9000205@fairwaves.co> You might want to look into https://github.com/2b-as/xgoldmon - maybe samsung devs reused for s4 some of the names from s3 04.06.2014 13:09, E:V:A ?????: > Dear Baseband developers, > > We are a very small group of XDA developers and external people trying > to realize our Android based IMSI-catcher Detector (AIMSICD) project. > http://tinyurl.com/l6whse2 > > However, to realize such an ambitious feat we really need better access > to the various RF variables and details of neighboring cells, among many > other things. We have had partial success in that we're able to use the > ServiceMode (SM) menu from the Samsung ServiceMode application. However, > this is just a wrapper to accessing OEM_RAW_REQUESTS presented by code > that is part of the baseband FW. Now, the tricky part for us non-GSM > experts, is understanding what these variables really mean and represent. > > I have started 2 threads on XDA to: > > 1) completely map out the ServiceMode menu options, for an GT-I9195 > (S4-mini) but should work on many similar and newer Samsung devices. > > 2) To map out the various MM timers and many other RF/GSM variables > shown and available in the SM menu. > http://tinyurl.com/qgcmbsv > > We need help from the baseband community to understand the vocabulary > used in this information as presented in (2) above, so that we can start to > fill in the catcher-catcher detection parameters from the table here: > https://opensource.srlabs.de/projects/mobile-network-assessment-tools/wiki/CatcherCatcher > We will be using a modified version of this to do our detection. > > > I'd also like to invite anyone interested to participate in this free and > open > project. Everything we have done so far is available on github. There are > also some hidden documents available to motivated developers who have > shown an honest effort to help us out. > > Best Regards, > E:V:A > > > > > > > > > > > > -- > View this message in context: http://baseband-devel.722152.n3.nabble.com/Documenting-Samsung-Radio-variables-from-the-ServiceMode-tp4026493.html > Sent from the baseband-devel mailing list archive at Nabble.com. > -- best regards, Max, http://fairwaves.co From xdae3v3a at gmail.com Wed Jun 4 20:30:23 2014 From: xdae3v3a at gmail.com (E:V:A) Date: Wed, 4 Jun 2014 13:30:23 -0700 (PDT) Subject: Documenting Samsung Radio variables from the ServiceMode In-Reply-To: <538F22C7.9000205@fairwaves.co> References: <1401880148251-4026493.post@n3.nabble.com> <538F22C7.9000205@fairwaves.co> Message-ID: <1401913823221-4026498.post@n3.nabble.com> ?-2 wrote > You might want to look into https://github.com/2b-as/xgoldmon - maybe > samsung devs > reused for s4 some of the names from s3 Yes, I have ran that already on my I9100, but that is specific for XMM (XGOLD) modems and not possible (AFAIK) for Qualcomm modems, unless they both happen to use the same debug output, which I doubt. Second, xgoldmon requires the device to be connected and externally via phone USB port, since the debug is coming directly from modem chip (CP) to USB port, and not via AP kernel. So unless someone knows more about how Androids are using RIL and modem RF debug output, that is not an option. -- View this message in context: http://baseband-devel.722152.n3.nabble.com/Documenting-Samsung-Radio-variables-from-the-ServiceMode-tp4026493p4026498.html Sent from the baseband-devel mailing list archive at Nabble.com. From Max.Suraev at fairwaves.co Wed Jun 4 17:07:41 2014 From: Max.Suraev at fairwaves.co (Max Suraev) Date: Wed, 4 Jun 2014 19:07:41 +0200 Subject: [PATCH 1/3] Add generic LE/BE load/store uint type convertors and use them in msgb Message-ID: <1401901663-16418-1-git-send-email-Max.Suraev@fairwaves.co> --- .gitignore | 3 +- include/Makefile.am | 7 ++ include/osmocom/core/bitXXgen.h.tpl | 101 +++++++++++++++++ include/osmocom/core/bits.h | 5 + include/osmocom/core/msgb.h | 23 ++-- tests/bits/bitrev_test.c | 218 +++++++++++++++++++++++++++++++++++- tests/bits/bitrev_test.ok | 31 +++++ 7 files changed, 376 insertions(+), 12 deletions(-) create mode 100644 include/osmocom/core/bitXXgen.h.tpl diff --git a/.gitignore b/.gitignore index 71b27f2..3fa1bbc 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,7 @@ tests/testsuite tests/testsuite.dir/ tests/testsuite.log +tests/utils/utils_test tests/sms/sms_test tests/timer/timer_test tests/msgfile/msgfile_test @@ -89,7 +90,7 @@ doc/html.tar src/crc*gen.c include/osmocom/core/crc*gen.h - +include/osmocom/core/bit*gen.h # vi files *.sw? diff --git a/include/Makefile.am b/include/Makefile.am index b035906..48ca7ea 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -2,6 +2,9 @@ nobase_include_HEADERS = \ osmocom/codec/codec.h \ osmocom/core/application.h \ osmocom/core/backtrace.h \ + osmocom/core/bit16gen.h \ + osmocom/core/bit32gen.h \ + osmocom/core/bit64gen.h \ osmocom/core/bits.h \ osmocom/core/bitvec.h \ osmocom/core/conv.h \ @@ -107,6 +110,10 @@ endif noinst_HEADERS = osmocom/core/timer_compat.h +osmocom/core/bit%gen.h: osmocom/core/bitXXgen.h.tpl + $(AM_V_GEN)$(MKDIR_P) $(dir $@) + $(AM_V_GEN)sed -e's/XX/$*/g' $< > $@ + osmocom/core/crc%gen.h: osmocom/core/crcXXgen.h.tpl $(AM_V_GEN)$(MKDIR_P) $(dir $@) $(AM_V_GEN)sed -e's/XX/$*/g' $< > $@ diff --git a/include/osmocom/core/bitXXgen.h.tpl b/include/osmocom/core/bitXXgen.h.tpl new file mode 100644 index 0000000..69ab492 --- /dev/null +++ b/include/osmocom/core/bitXXgen.h.tpl @@ -0,0 +1,101 @@ +/* + * bitXXgen.h + * + * Copyright (C) 2014 Max + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/*! \brief load unaligned n-byte integer (little-endian encoding) into uintXX_t + * \param[in] p Buffer where integer is stored + * \param[in] n Number of bytes stored in p + * \returns XX bit unsigned integer + */ +static inline uintXX_t osmo_loadXXle_ext(const void *p, uint8_t n) +{ + uint8_t i; + uintXX_t r = 0; + const uint8_t *q = (uint8_t *)p; + for(i = 0; i < n; r |= ((uintXX_t)q[i] << (8 * i)), i++); + return r; +} + +/*! \brief load unaligned n-byte integer (big-endian encoding) into uintXX_t + * \param[in] p Buffer where integer is stored + * \param[in] n Number of bytes stored in p + * \returns XX bit unsigned integer + */ +static inline uintXX_t osmo_loadXXbe_ext(const void *p, uint8_t n) +{ + uint8_t i; + uintXX_t r = 0; + const uint8_t *q = (uint8_t *)p; + for(i = 0; i < n; r |= ((uintXX_t)q[i] << (XX - 8* (1 + i))), i++); + return r; +} + + +/*! \brief store unaligned n-byte integer (little-endian encoding) into uintXX_t + * \param[in] x unsigned XX bit integer + * \param[out] p Buffer to store integer + * \param[in] n Number of bytes to store + */ +static inline void osmo_storeXXle_ext(uintXX_t x, uint8_t *p, uint8_t n) +{ + uint8_t i; + for(i = 0; i < n; p[i] = (x >> i * 8) & 0xFF, i++); +} + +/*! \brief store unaligned n-byte integer (big-endian encoding) into uintXX_t + * \param[in] x unsigned XX bit integer + * \param[out] p Buffer to store integer + * \param[in] n Number of bytes to store + */ +static inline void osmo_storeXXbe_ext(uintXX_t x, uint8_t *p, uint8_t n) +{ + uint8_t i; + for(i = 0; i < n; p[i] = (x >> ((n - 1 - i) * 8)) & 0xFF, i++); +} + + +/* Convenience function for most-used cases */ + + +/*! \brief load unaligned XX-bit integer (little-endian encoding) */ +static inline uintXX_t osmo_loadXXle(const void *p) +{ + return osmo_loadXXle_ext(p, XX / 8); +} + +/*! \brief load unaligned XX-bit integer (big-endian encoding) */ +static inline uintXX_t osmo_loadXXbe(const void *p) +{ + return osmo_loadXXbe_ext(p, XX / 8); +} + + +/*! \brief store unaligned XX-bit integer (little-endian encoding) */ +static inline void osmo_storeXXle(uintXX_t x, void *p) +{ + return osmo_storeXXle_ext(x, p, XX / 8); +} + +/*! \brief store unaligned XX-bit integer (big-endian encoding) */ +static inline void osmo_storeXXbe(uintXX_t x, void *p) +{ + return osmo_storeXXbe_ext(x, p, XX / 8); +} diff --git a/include/osmocom/core/bits.h b/include/osmocom/core/bits.h index 4c68532..5c9c7a6 100644 --- a/include/osmocom/core/bits.h +++ b/include/osmocom/core/bits.h @@ -2,6 +2,11 @@ #define _OSMO_BITS_H #include +#include + +#include +#include +#include /*! \defgroup bits soft, unpacked and packed bits * @{ diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h index 33e8081..44a4c1e 100644 --- a/include/osmocom/core/msgb.h +++ b/include/osmocom/core/msgb.h @@ -23,6 +23,7 @@ #include #include #include +#include /*! \defgroup msgb Message buffers * @{ @@ -205,8 +206,7 @@ static inline void msgb_put_u8(struct msgb *msgb, uint8_t word) static inline void msgb_put_u16(struct msgb *msgb, uint16_t word) { uint8_t *space = msgb_put(msgb, 2); - space[0] = word >> 8 & 0xFF; - space[1] = word & 0xFF; + osmo_store16be(word, space); } /*! \brief append a uint32 value to the end of the message @@ -216,10 +216,7 @@ static inline void msgb_put_u16(struct msgb *msgb, uint16_t word) static inline void msgb_put_u32(struct msgb *msgb, uint32_t word) { uint8_t *space = msgb_put(msgb, 4); - space[0] = word >> 24 & 0xFF; - space[1] = word >> 16 & 0xFF; - space[2] = word >> 8 & 0xFF; - space[3] = word & 0xFF; + osmo_store32be(word, space); } /*! \brief remove data from end of message @@ -236,6 +233,7 @@ static inline unsigned char *msgb_get(struct msgb *msgb, unsigned int len) msgb->len -= len; return tmp; } + /*! \brief remove uint8 from end of message * \param[in] msgb message buffer * \returns 8bit value taken from end of msgb @@ -245,6 +243,7 @@ static inline uint8_t msgb_get_u8(struct msgb *msgb) uint8_t *space = msgb_get(msgb, 1); return space[0]; } + /*! \brief remove uint16 from end of message * \param[in] msgb message buffer * \returns 16bit value taken from end of msgb @@ -252,8 +251,9 @@ static inline uint8_t msgb_get_u8(struct msgb *msgb) static inline uint16_t msgb_get_u16(struct msgb *msgb) { uint8_t *space = msgb_get(msgb, 2); - return space[0] << 8 | space[1]; + return osmo_load16be(space); } + /*! \brief remove uint32 from end of message * \param[in] msgb message buffer * \returns 32bit value taken from end of msgb @@ -261,7 +261,7 @@ static inline uint16_t msgb_get_u16(struct msgb *msgb) static inline uint32_t msgb_get_u32(struct msgb *msgb) { uint8_t *space = msgb_get(msgb, 4); - return space[0] << 24 | space[1] << 16 | space[2] << 8 | space[3]; + return osmo_load32be(space); } /*! \brief prepend (push) some data to start of message @@ -285,6 +285,7 @@ static inline unsigned char *msgb_push(struct msgb *msgb, unsigned int len) msgb->len += len; return msgb->data; } + /*! \brief remove (pull) a header from the front of the message buffer * \param[in] msgb message buffer * \param[in] len number of octets to be pulled @@ -324,6 +325,7 @@ static inline uint8_t msgb_pull_u8(struct msgb *msgb) uint8_t *space = msgb_pull(msgb, 1) - 1; return space[0]; } + /*! \brief remove uint16 from front of message * \param[in] msgb message buffer * \returns 16bit value taken from end of msgb @@ -331,8 +333,9 @@ static inline uint8_t msgb_pull_u8(struct msgb *msgb) static inline uint16_t msgb_pull_u16(struct msgb *msgb) { uint8_t *space = msgb_pull(msgb, 2) - 2; - return space[0] << 8 | space[1]; + return osmo_load16be(space); } + /*! \brief remove uint32 from front of message * \param[in] msgb message buffer * \returns 32bit value taken from end of msgb @@ -340,7 +343,7 @@ static inline uint16_t msgb_pull_u16(struct msgb *msgb) static inline uint32_t msgb_pull_u32(struct msgb *msgb) { uint8_t *space = msgb_pull(msgb, 4) - 4; - return space[0] << 24 | space[1] << 16 | space[2] << 8 | space[3]; + return osmo_load32be(space); } /*! \brief Increase headroom of empty msgb, reducing the tailroom diff --git a/tests/bits/bitrev_test.c b/tests/bits/bitrev_test.c index 5eca990..e963656 100644 --- a/tests/bits/bitrev_test.c +++ b/tests/bits/bitrev_test.c @@ -1,20 +1,192 @@ - +#include #include #include #include #include +#include +#include #include #include static const uint8_t input[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; static const uint8_t exp_out[] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; +static char s[18]; + +enum END {LE, BE}; + +const char * end2str(enum END e) { + if (e == LE) return "LE"; + return "BE"; +} + + +/* convenience wrappers */ + +inline uint64_t load64(enum END e, const uint8_t *buf, unsigned nbytes) { + return (e == BE) ? osmo_load64be_ext(buf, nbytes) : osmo_load64le_ext(buf, nbytes); +} + +inline uint32_t load32(enum END e, const uint8_t *buf, unsigned nbytes) { + return (e == BE) ? osmo_load32be_ext(buf, nbytes) : osmo_load32le_ext(buf, nbytes); +} + +inline uint16_t load16(enum END e, const uint8_t *buf) { + return (e == BE) ? osmo_load16be(buf) : osmo_load16le(buf); +} + +inline void store64(enum END e, uint64_t t, uint8_t *buf, unsigned nbytes) { + (e == BE) ? osmo_store64be_ext(t, buf, nbytes) : osmo_store64le_ext(t, buf, nbytes); +} + +inline void store32(enum END e, uint64_t t, uint8_t *buf, unsigned nbytes) { + (e == BE) ? osmo_store32be_ext(t, buf, nbytes) : osmo_store32le_ext(t, buf, nbytes); +} + +inline void store16(enum END e, uint64_t t, uint8_t *buf) { + (e == BE) ? osmo_store16be(t, buf) : osmo_store16le(t, buf); +} + + +/* helper functions */ + +inline bool printcheck(bool chk, unsigned nbytes, enum END e, bool b) +{ + if (!chk) { + printf("%u %s FAILED", nbytes * 8, end2str(e)); + return true; + } + printf("%u %s OK", nbytes * 8, end2str(e)); + return b; +} + +inline bool dumpcheck(const char *dump, const char *s, unsigned nbytes, bool chk, enum END e, bool b) +{ + bool x = printcheck(chk, nbytes, e, b); + if (!dump) return x; + + int m = memcmp(s, dump, nbytes); + if (0 == m) { + printf(", storage OK"); + return x; + } + printf(", [%d]", m); + + return true; +} + + +/* printcheckXX(): load/store 'test' and check against 'expected' value, compare to 'dump' buffer if given and print if necessary */ + +inline void printcheck64(enum END e, unsigned nbytes, uint64_t test, uint64_t expected, const char *dump, bool print) +{ + uint8_t buf[nbytes]; + + store64(e, test, buf, nbytes); + + char *s = osmo_hexdump_nospc(buf, nbytes); + uint64_t result = load64(e, buf, nbytes); + + print = dumpcheck(dump, s, nbytes, result == expected, e, print); + + if (print) + printf(": buffer %s known buffer %s loaded %.16" PRIx64 " expected %.16" PRIx64, s, dump, result, expected); + printf("\n"); +} + +inline void printcheck32(enum END e, unsigned nbytes, uint32_t test, uint32_t expected, const char *dump, bool print) +{ + uint8_t buf[nbytes]; + + store32(e, test, buf, nbytes); + + char *s = osmo_hexdump_nospc(buf, nbytes); + uint32_t result = load32(e, buf, nbytes); + + print = dumpcheck(dump, s, nbytes, result == expected, e, print); + + if (print) + printf(": buffer %s known buffer %s loaded %.8" PRIx32 " expected %.8" PRIx32, s, dump, result, expected); + printf("\n"); +} + +inline void printcheck16(enum END e, uint32_t test, uint32_t expected, const char *dump, bool print) +{ + uint8_t buf[2]; + + store16(e, test, buf); + + char *s = osmo_hexdump_nospc(buf, 2); + uint16_t result = load16(e, buf); + + print = dumpcheck(dump, s, 2, result == expected, e, print); + + if (print) + printf(": buffer %s known buffer %s loaded %.4" PRIx16 " expected %.4" PRIx16, s, dump, result, expected); + printf("\n"); +} + + +/* compute expected value - zero excessive bytes */ + +inline uint64_t exp64(enum END e, unsigned nbytes, uint64_t value) { + uint8_t adj = 64 - nbytes * 8; + uint64_t v = value << adj; + return (e == LE) ? v >> adj : v; +} + +inline uint32_t exp32(enum END e, unsigned nbytes, uint32_t value) { + uint8_t adj = 32 - nbytes * 8; + uint32_t v = value << adj; + return (e == LE) ? v >> adj : v; +} + + +/* run actual tests - if 'test' is 0 than generate random test value internally */ + +inline void check64(uint64_t test, uint64_t expected, unsigned nbytes, enum END e) +{ + bool print = true; + if (0 == test && 0 == expected) { + test = ((uint64_t)rand() << 32) + rand(); + expected = exp64(e, nbytes, test); + print = false; + } + snprintf(s, 17, "%.16" PRIx64, expected); + printcheck64(e, nbytes, test, expected, (BE == e) ? s : NULL, print); +} + +inline void check32(uint32_t test, uint32_t expected, unsigned nbytes, enum END e) +{ + bool print = true; + if (0 == test && 0 == expected) { + test = rand(); + expected = exp32(e, nbytes, test); + print = false; + } + snprintf(s, 17, "%.8" PRIx32, expected); + printcheck32(e, nbytes, test, expected, (BE == e) ? s : NULL, print); +} + +inline void check16(uint16_t test, enum END e) +{ + bool print = true; + if (0 == test) { + test = (uint16_t)rand(); + print = false; + } + snprintf(s, 17, "%.4" PRIx16, test); + printcheck16(e, test, test, (BE == e) ? s : NULL, print); +} + int main(int argc, char **argv) { uint8_t out[ARRAY_SIZE(input)]; unsigned int offs; + srand(time(NULL)); + for (offs = 0; offs < sizeof(out); offs++) { uint8_t *start = out + offs; uint8_t len = sizeof(out) - offs; @@ -32,5 +204,49 @@ int main(int argc, char **argv) printf("\n"); } + printf("checking byte packing...\n"); + + printf("running static tests...\n"); + + check64(0xDEADBEEFF00DCAFE, 0xDEADBEEFF00DCAFE, 8, BE); + check64(0xDEADBEEFF00DCAFE, 0xADBEEFF00DCAFE00, 7, BE); + check64(0xDEADBEEFF00DCAFE, 0xBEEFF00DCAFE0000, 6, BE); + check64(0xDEADBEEFF00DCAFE, 0xEFF00DCAFE000000, 5, BE); + + check64(0xDEADBEEFF00DCAFE, 0xDEADBEEFF00DCAFE, 8, LE); + check64(0xDEADBEEFF00DCAFE, 0x00ADBEEFF00DCAFE, 7, LE); + check64(0xDEADBEEFF00DCAFE, 0x0000BEEFF00DCAFE, 6, LE); + check64(0xDEADBEEFF00DCAFE, 0x000000EFF00DCAFE, 5, LE); + + check32(0xBABEFACE, 0xBABEFACE, 4, BE); + check32(0xBABEFACE, 0xBEFACE00, 3, BE); + + check32(0xBABEFACE, 0xBABEFACE, 4, LE); + check32(0xBABEFACE, 0x00BEFACE, 3, LE); + + check16(0xB00B, BE); + check16(0xB00B, LE); + + printf("running random tests...\n"); + + check64(0, 0, 8, BE); + check64(0, 0, 7, BE); + check64(0, 0, 6, BE); + check64(0, 0, 5, BE); + + check64(0, 0, 8, LE); + check64(0, 0, 7, LE); + check64(0, 0, 6, LE); + check64(0, 0, 5, LE); + + check32(0, 0, 4, BE); + check32(0, 0, 3, BE); + + check32(0, 0, 4, LE); + check32(0, 0, 3, LE); + + check16(0, BE); + check16(0, LE); + return 0; } diff --git a/tests/bits/bitrev_test.ok b/tests/bits/bitrev_test.ok index 47f402f..90cb295 100644 --- a/tests/bits/bitrev_test.ok +++ b/tests/bits/bitrev_test.ok @@ -22,3 +22,34 @@ REVERSED: 02 01 INORDER: 80 REVERSED: 01 +checking byte packing... +running static tests... +64 BE OK, storage OK: buffer deadbeeff00dcafe known buffer deadbeeff00dcafe loaded deadbeeff00dcafe expected deadbeeff00dcafe +56 BE OK, storage OK: buffer adbeeff00dcafe known buffer adbeeff00dcafe00 loaded adbeeff00dcafe00 expected adbeeff00dcafe00 +48 BE OK, storage OK: buffer beeff00dcafe known buffer beeff00dcafe0000 loaded beeff00dcafe0000 expected beeff00dcafe0000 +40 BE OK, storage OK: buffer eff00dcafe known buffer eff00dcafe000000 loaded eff00dcafe000000 expected eff00dcafe000000 +64 LE OK: buffer feca0df0efbeadde known buffer (null) loaded deadbeeff00dcafe expected deadbeeff00dcafe +56 LE OK: buffer feca0df0efbead known buffer (null) loaded 00adbeeff00dcafe expected 00adbeeff00dcafe +48 LE OK: buffer feca0df0efbe known buffer (null) loaded 0000beeff00dcafe expected 0000beeff00dcafe +40 LE OK: buffer feca0df0ef known buffer (null) loaded 000000eff00dcafe expected 000000eff00dcafe +32 BE OK, storage OK: buffer babeface known buffer babeface loaded babeface expected babeface +24 BE OK, storage OK: buffer beface known buffer beface00 loaded beface00 expected beface00 +32 LE OK: buffer cefabeba known buffer (null) loaded babeface expected babeface +24 LE OK: buffer cefabe known buffer (null) loaded 00beface expected 00beface +16 BE OK, storage OK: buffer b00b known buffer b00b loaded b00b expected b00b +16 LE OK: buffer 0bb0 known buffer (null) loaded b00b expected b00b +running random tests... +64 BE OK, storage OK +56 BE OK, storage OK +48 BE OK, storage OK +40 BE OK, storage OK +64 LE OK +56 LE OK +48 LE OK +40 LE OK +32 BE OK, storage OK +24 BE OK, storage OK +32 LE OK +24 LE OK +16 BE OK, storage OK +16 LE OK -- 1.9.1 From Max.Suraev at fairwaves.co Wed Jun 4 17:07:42 2014 From: Max.Suraev at fairwaves.co (Max Suraev) Date: Wed, 4 Jun 2014 19:07:42 +0200 Subject: [PATCH 2/3] Add left circular shift function In-Reply-To: <1401901663-16418-1-git-send-email-Max.Suraev@fairwaves.co> References: <1401901663-16418-1-git-send-email-Max.Suraev@fairwaves.co> Message-ID: <1401901663-16418-2-git-send-email-Max.Suraev@fairwaves.co> --- include/osmocom/core/bits.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/osmocom/core/bits.h b/include/osmocom/core/bits.h index 5c9c7a6..c2c4863 100644 --- a/include/osmocom/core/bits.h +++ b/include/osmocom/core/bits.h @@ -78,6 +78,16 @@ uint32_t osmo_revbytebits_8(uint8_t x); /* \brief reverse the bits of each byte in a given buffer */ void osmo_revbytebits_buf(uint8_t *buf, int len); +/*! \brief left circular shift + * \param[in] in The 16 bit unsigned integer to be rotated + * \param[in] shift Number of bits to shift \a in to, [0;16] bits + * \returns shifted value + */ +static inline uint16_t osmo_rol16(uint16_t in, unsigned shift) +{ + return (in << shift) | (in >> (16 - shift)); +} + /*! @} */ #endif /* _OSMO_BITS_H */ -- 1.9.1 From Max.Suraev at fairwaves.co Wed Jun 4 17:07:43 2014 From: Max.Suraev at fairwaves.co (Max Suraev) Date: Wed, 4 Jun 2014 19:07:43 +0200 Subject: [PATCH 3/3] Add Kasumi cipher implementation In-Reply-To: <1401901663-16418-1-git-send-email-Max.Suraev@fairwaves.co> References: <1401901663-16418-1-git-send-email-Max.Suraev@fairwaves.co> Message-ID: <1401901663-16418-3-git-send-email-Max.Suraev@fairwaves.co> --- .gitignore | 1 + include/osmocom/gsm/kasumi.h | 41 ++++++++++ src/gsm/Makefile.am | 2 +- src/gsm/kasumi.c | 190 +++++++++++++++++++++++++++++++++++++++++++ src/gsm/libosmogsm.map | 4 + tests/Makefile.am | 7 +- tests/kasumi/kasumi_test.c | 136 +++++++++++++++++++++++++++++++ tests/kasumi/kasumi_test.ok | 10 +++ tests/testsuite.at | 6 ++ 9 files changed, 394 insertions(+), 3 deletions(-) create mode 100644 include/osmocom/gsm/kasumi.h create mode 100644 src/gsm/kasumi.c create mode 100644 tests/kasumi/kasumi_test.c create mode 100644 tests/kasumi/kasumi_test.ok diff --git a/.gitignore b/.gitignore index 3fa1bbc..1299028 100644 --- a/.gitignore +++ b/.gitignore @@ -56,6 +56,7 @@ tests/testsuite.dir/ tests/testsuite.log tests/utils/utils_test +tests/kasumi/kasumi_test tests/sms/sms_test tests/timer/timer_test tests/msgfile/msgfile_test diff --git a/include/osmocom/gsm/kasumi.h b/include/osmocom/gsm/kasumi.h new file mode 100644 index 0000000..6acc959 --- /dev/null +++ b/include/osmocom/gsm/kasumi.h @@ -0,0 +1,41 @@ +/* + * KASUMI header + * + * See kasumi.c for details + * The parameters are described in TS 135 202. + */ + +#pragma once + +#include + +/*! \brief Single iteration of KASUMI cipher + * \param[in] P Block, 64 bits to be processed in this round + * \param[in] KLi1 Expanded subkeys + * \param[in] KLi2 Expanded subkeys + * \param[in] KOi1 Expanded subkeys + * \param[in] KOi2 Expanded subkeys + * \param[in] KOi3 Expanded subkeys + * \param[in] KIi1 Expanded subkeys + * \param[in] KIi2 Expanded subkeys + * \param[in] KIi3 Expanded subkeys + * \returns processed block of 64 bits + */ +uint64_t _kasumi(uint64_t P, const uint16_t *KLi1, const uint16_t *KLi2, const uint16_t *KOi1, const uint16_t *KOi2, const uint16_t *KOi3, const uint16_t *KIi1, const uint16_t *KIi2, const uint16_t *KIi3); + +/*! \brief Implementation of the KGCORE algorithm (used by A5/3, A5/4, GEA3, GEA4 and ECSD) + * \param[in] CA + * \param[in] cb + * \param[in] cc + * \param[in] cd + * \param[in] ck 8-bytes long key + * \param[out] co cl-dependent + * \param[in] cl + */ +void _kasumi_kgcore(uint8_t CA, uint8_t cb, uint32_t cc, uint8_t cd, const uint8_t *ck, uint8_t *co, uint16_t cl); + +/*! \brief Expand key into set of subkeys + * \param[in] key (128 bits) as array of bytes + * \param[out] arrays of round-specific subkeys - see TS 135 202 for details + */ +void _kasumi_key_expand(const uint8_t *key, uint16_t *KLi1, uint16_t *KLi2, uint16_t *KOi1, uint16_t *KOi2, uint16_t *KOi3, uint16_t *KIi1, uint16_t *KIi2, uint16_t *KIi3); diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am index 46698cd..94729c9 100644 --- a/src/gsm/Makefile.am +++ b/src/gsm/Makefile.am @@ -15,7 +15,7 @@ libosmogsm_la_SOURCES = a5.c rxlev_stat.c tlv_parser.c comp128.c comp128v23.c \ gsm_utils.c rsl.c gsm48.c gsm48_ie.c gsm0808.c sysinfo.c \ gprs_cipher_core.c gsm0480.c abis_nm.c gsm0502.c \ gsm0411_utils.c gsm0411_smc.c gsm0411_smr.c \ - lapd_core.c lapdm.c \ + lapd_core.c lapdm.c kasumi.c \ auth_core.c auth_comp128v1.c auth_comp128v23.c \ auth_milenage.c milenage/aes-encblock.c \ milenage/aes-internal.c milenage/aes-internal-enc.c \ diff --git a/src/gsm/kasumi.c b/src/gsm/kasumi.c new file mode 100644 index 0000000..c56f3ed --- /dev/null +++ b/src/gsm/kasumi.c @@ -0,0 +1,190 @@ +/* Kasumi cipher and KGcore functions */ + +/* (C) 2013 by Max + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include +#include +#include + +/* See TS 135 202 for constants and full Kasumi spec. */ +inline static uint16_t kasumi_FI(uint16_t I, uint16_t skey) +{ + static const uint16_t S7[] = { + 54, 50, 62, 56, 22, 34, 94, 96, 38, 6, 63, 93, 2, 18, 123, 33, + 55, 113, 39, 114, 21, 67, 65, 12, 47, 73, 46, 27, 25, 111, 124, 81, + 53, 9, 121, 79, 52, 60, 58, 48, 101, 127, 40, 120, 104, 70, 71, 43, + 20, 122, 72, 61, 23, 109, 13, 100, 77, 1, 16, 7, 82, 10, 105, 98, + 117, 116, 76, 11, 89, 106, 0,125,118, 99, 86, 69, 30, 57, 126, 87, + 112, 51, 17, 5, 95, 14, 90, 84, 91, 8, 35,103, 32, 97, 28, 66, + 102, 31, 26, 45, 75, 4, 85, 92, 37, 74, 80, 49, 68, 29, 115, 44, + 64, 107, 108, 24, 110, 83, 36, 78, 42, 19, 15, 41, 88, 119, 59, 3 + }; + static const uint16_t S9[] = { + 167, 239, 161, 379, 391, 334, 9, 338, 38, 226, 48, 358, 452, 385, 90, 397, + 183, 253, 147, 331, 415, 340, 51, 362, 306, 500, 262, 82, 216, 159, 356, 177, + 175, 241, 489, 37, 206, 17, 0, 333, 44, 254, 378, 58, 143, 220, 81, 400, + 95, 3, 315, 245, 54, 235, 218, 405, 472, 264, 172, 494, 371, 290, 399, 76, + 165, 197, 395, 121, 257, 480, 423, 212, 240, 28, 462, 176, 406, 507, 288, 223, + 501, 407, 249, 265, 89, 186, 221, 428,164, 74, 440, 196, 458, 421, 350, 163, + 232, 158, 134, 354, 13, 250, 491, 142,191, 69, 193, 425, 152, 227, 366, 135, + 344, 300, 276, 242, 437, 320, 113, 278, 11, 243, 87, 317, 36, 93, 496, 27, + 487, 446, 482, 41, 68, 156, 457, 131, 326, 403, 339, 20, 39, 115, 442, 124, + 475, 384, 508, 53, 112, 170, 479, 151, 126, 169, 73, 268, 279, 321, 168, 364, + 363, 292, 46, 499, 393, 327, 324, 24, 456, 267, 157, 460, 488, 426, 309, 229, + 439, 506, 208, 271, 349, 401, 434, 236, 16, 209, 359, 52, 56, 120, 199, 277, + 465, 416, 252, 287, 246, 6, 83, 305, 420, 345, 153,502, 65, 61, 244, 282, + 173, 222, 418, 67, 386, 368, 261, 101, 476, 291, 195,430, 49, 79, 166, 330, + 280, 383, 373, 128, 382, 408, 155, 495, 367, 388, 274, 107, 459, 417, 62, 454, + 132, 225, 203, 316, 234, 14, 301, 91, 503, 286, 424, 211, 347, 307, 140, 374, + 35, 103, 125, 427, 19, 214, 453, 146, 498, 314, 444, 230, 256, 329, 198, 285, + 50, 116, 78, 410, 10, 205, 510, 171, 231, 45, 139, 467, 29, 86, 505, 32, + 72, 26, 342, 150, 313, 490, 431, 238, 411, 325, 149, 473, 40, 119, 174, 355, + 185, 233, 389, 71, 448, 273, 372, 55, 110, 178, 322, 12, 469, 392, 369, 190, + 1, 109, 375, 137, 181, 88, 75, 308, 260, 484, 98, 272, 370, 275, 412, 111, + 336, 318, 4, 504, 492, 259, 304, 77, 337, 435, 21, 357, 303, 332, 483, 18, + 47, 85, 25, 497, 474, 289, 100, 269, 296, 478, 270, 106, 31, 104, 433, 84, + 414, 486, 394, 96, 99, 154, 511, 148, 413, 361, 409, 255, 162, 215, 302, 201, + 266, 351, 343, 144, 441, 365, 108, 298, 251, 34, 182, 509, 138, 210, 335, 133, + 311, 352, 328, 141, 396, 346, 123, 319, 450, 281, 429, 228, 443, 481, 92, 404, + 485, 422, 248, 297, 23, 213, 130, 466, 22, 217, 283, 70, 294, 360, 419, 127, + 312, 377, 7, 468, 194, 2, 117, 295, 463, 258, 224, 447, 247, 187, 80, 398, + 284, 353, 105, 390, 299, 471, 470, 184, 57, 200, 348, 63, 204, 188, 33, 451, + 97, 30, 310, 219, 94, 160, 129, 493, 64, 179, 263, 102, 189, 207, 114, 402, + 438, 477, 387, 122, 192, 42, 381, 5, 145, 118, 180, 449, 293, 323, 136, 380, + 43, 66, 60, 455, 341, 445, 202, 432, 8, 237, 15, 376, 436, 464, 59, 461 + }; + uint16_t L, R; + + /* Split 16 bit input into two unequal halves: 9 and 7 bits, same for subkey */ + L = I >> 7; /* take 9 bits */ + R = I & 0x7F; /* take 7 bits */ + + L = S9[L] ^ R; + R = S7[R] ^ (L & 0x7F); + + L ^= (skey & 0x1FF); + R ^= (skey >> 9); + + L = S9[L] ^ R; + R = S7[R] ^ (L & 0x7F); + + return (R << 9) + L; +} + +inline static uint32_t kasumi_FO(uint32_t I, const uint16_t *KOi1, const uint16_t *KOi2, const uint16_t *KOi3, const uint16_t *KIi1, const uint16_t *KIi2, const uint16_t *KIi3, unsigned i) +{ + uint16_t L = I >> 16, R = I; /* Split 32 bit input into Left and Right parts */ + + L ^= KOi1[i]; + L = kasumi_FI(L, KIi1[i]); + L ^= R; + + R ^= KOi2[i]; + R = kasumi_FI(R, KIi2[i]); + R ^= L; + + L ^= KOi3[i]; + L = kasumi_FI(L, KIi3[i]); + L ^= R; + + return (((uint32_t)R) << 16) + L; +} + +inline static uint32_t kasumi_FL(uint32_t I, const uint16_t *KLi1, const uint16_t *KLi2, unsigned i) +{ + uint16_t L = I >> 16, R = I, tmp; /* Split 32 bit input into Left and Right parts */ + + tmp = L & KLi1[i]; + R ^= osmo_rol16(tmp, 1); + + tmp = R | KLi2[i]; + L ^= osmo_rol16(tmp, 1); + + return (((uint32_t)L) << 16) + R; +} + +uint64_t _kasumi(uint64_t P, const uint16_t *KLi1, const uint16_t *KLi2, const uint16_t *KOi1, const uint16_t *KOi2, const uint16_t *KOi3, const uint16_t *KIi1, const uint16_t *KIi2, const uint16_t *KIi3) +{ + uint32_t i, L = P >> 32, R = P; /* Split 64 bit input into Left and Right parts */ + + for (i = 0; i < 8; i++) { + R ^= kasumi_FO(kasumi_FL(L, KLi1, KLi2, i), KOi1, KOi2, KOi3, KIi1, KIi2, KIi3, i); /* odd round */ + i++; + L ^= kasumi_FL(kasumi_FO(R, KOi1, KOi2, KOi3, KIi1, KIi2, KIi3, i), KLi1, KLi2, i); /* even round */ + } + return (((uint64_t)L) << 32) + R; /* Concatenate Left and Right 32 bits into 64 bit ciphertext */ +} + +/*! \brief Expand key into set of subkeys + * \param[in] key (128 bits) as array of bytes + * \param[out] arrays of round-specific subkeys - see TS 135 202 for details + */ +void _kasumi_key_expand(const uint8_t *key, uint16_t *KLi1, uint16_t *KLi2, uint16_t *KOi1, uint16_t *KOi2, uint16_t *KOi3, uint16_t *KIi1, uint16_t *KIi2, uint16_t *KIi3) +{ + uint16_t i, C[] = { 0x0123, 0x4567, 0x89AB, 0xCDEF, 0xFEDC, 0xBA98, 0x7654, 0x3210 }; + + /* Work with 16 bit subkeys and create prime subkeys */ + for (i = 0; i < 8; i++) + C[i] ^= osmo_load16be(key + i * 2); + /* C[] now stores K-prime[] */ + + /* Create round-specific subkeys */ + for (i = 0; i < 8; i++) { + KLi1[i] = osmo_rol16(osmo_load16be(key + i * 2), 1); + KLi2[i] = C[(i + 2) & 0x7]; + + KOi1[i] = osmo_rol16(osmo_load16be(key + ((2 * (i + 1)) & 0xE)), 5); + KOi2[i] = osmo_rol16(osmo_load16be(key + ((2 * (i + 5)) & 0xE)), 8); + KOi3[i] = osmo_rol16(osmo_load16be(key + ((2 * (i + 6)) & 0xE)), 13); + + KIi1[i] = C[(i + 4) & 0x7]; + KIi2[i] = C[(i + 3) & 0x7]; + KIi3[i] = C[(i + 7) & 0x7]; + } +} + +void _kasumi_kgcore(uint8_t CA, uint8_t cb, uint32_t cc, uint8_t cd, const uint8_t *ck, uint8_t *co, uint16_t cl) +{ + uint16_t KLi1[8], KLi2[8], KOi1[8], KOi2[8], KOi3[8], KIi1[8], KIi2[8], KIi3[8], i; + uint64_t A = ((uint64_t)cc) << 32, BLK = 0, _ca = ((uint64_t)CA << 16) ; + A |= _ca; + _ca = (uint64_t)((cb << 3) | (cd << 2)) << 24; + A |= _ca; + /* Register loading complete: see TR 55.919 8.2 and TS 55.216 3.2 */ + + uint8_t ck_km[16]; + for (i = 0; i < 16; i++) + ck_km[i] = ck[i] ^ 0x55; + /* Modified key established */ + + /* preliminary round with modified key */ + _kasumi_key_expand(ck_km, KLi1, KLi2, KOi1, KOi2, KOi3, KIi1, KIi2, KIi3); + A = _kasumi(A, KLi1, KLi2, KOi1, KOi2, KOi3, KIi1, KIi2, KIi3); + + /* Run Kasumi in OFB to obtain enough data for gamma. */ + _kasumi_key_expand(ck, KLi1, KLi2, KOi1, KOi2, KOi3, KIi1, KIi2, KIi3); + + /* i is a block counter */ + for (i = 0; i < cl / 64 + 1; i++) { + BLK = _kasumi(A ^ i ^ BLK, KLi1, KLi2, KOi1, KOi2, KOi3, KIi1, KIi2, KIi3); + osmo_store64be(BLK, co + (i * 8)); + } +} diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index cab4fc4..5f0d877 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -198,6 +198,10 @@ osmo_a5; osmo_a5_1; osmo_a5_2; +_kasumi; +_kasumi_key_expand; +_kasumi_kgcore; + osmo_auth_alg_name; osmo_auth_alg_parse; osmo_auth_gen_vec; diff --git a/tests/Makefile.am b/tests/Makefile.am index c6216d5..ddc13dc 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -4,7 +4,7 @@ check_PROGRAMS = timer/timer_test sms/sms_test ussd/ussd_test \ smscb/smscb_test bits/bitrev_test a5/a5_test \ conv/conv_test auth/milenage_test lapd/lapd_test \ gsm0808/gsm0808_test gsm0408/gsm0408_test \ - gb/bssgp_fc_test gb/gprs_ns_test \ + gb/bssgp_fc_test gb/gprs_ns_test kasumi/kasumi_test \ logging/logging_test fr/fr_test \ loggingrb/loggingrb_test strrb/strrb_test \ vty/vty_test comp128/comp128_test utils/utils_test @@ -19,6 +19,9 @@ utils_utils_test_LDADD = $(top_builddir)/src/libosmocore.la a5_a5_test_SOURCES = a5/a5_test.c a5_a5_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la +kasumi_kasumi_test_SOURCES = kasumi/kasumi_test.c +kasumi_kasumi_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la + comp128_comp128_test_SOURCES = comp128/comp128_test.c comp128_comp128_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la @@ -102,7 +105,7 @@ EXTRA_DIST = testsuite.at $(srcdir)/package.m4 $(TESTSUITE) \ lapd/lapd_test.ok gsm0408/gsm0408_test.ok \ gsm0808/gsm0808_test.ok gb/bssgp_fc_tests.err \ gb/bssgp_fc_tests.ok gb/bssgp_fc_tests.sh \ - gb/gprs_ns_test.ok \ + gb/gprs_ns_test.ok kasumi/kasumi_test.ok \ msgfile/msgfile_test.ok msgfile/msgconfig.cfg \ logging/logging_test.ok logging/logging_test.err \ fr/fr_test.ok loggingrb/logging_test.ok \ diff --git a/tests/kasumi/kasumi_test.c b/tests/kasumi/kasumi_test.c new file mode 100644 index 0000000..9101407 --- /dev/null +++ b/tests/kasumi/kasumi_test.c @@ -0,0 +1,136 @@ +#include +#include +#include +#include +#include + +#include +#include +#include + +/* Test vectors are taken from TS 135 202 */ + +inline int _compare_mem(uint8_t * x, uint8_t * y, size_t len) +{ + if (0 != memcmp(x, y, len)) { + printf ("X: %s\t", osmo_hexdump_nospc(x, len)); + printf ("Y: %s\n", osmo_hexdump_nospc(y, len)); + return 0; + } + return 1; +} + +inline static void test_expansion(uint8_t * test_key, uint16_t * _KLi1, uint16_t * _KLi2, uint16_t * _KOi1, uint16_t * _KOi2, uint16_t * _KOi3, uint16_t * _KIi1, uint16_t * _KIi2, uint16_t * _KIi3, uint16_t * _KLi1_r, uint16_t * _KLi2_r, uint16_t * _KOi1_r, uint16_t * _KOi2_r, uint16_t * _KOi3_r, uint16_t * _KIi1_r, uint16_t * _KIi2_r, uint16_t * _KIi3_r) +{ + _kasumi_key_expand(test_key, _KLi1, _KLi2, _KOi1, _KOi2, _KOi3, _KIi1, _KIi2, _KIi3); + int passed = 1; + passed = _compare_mem((uint8_t *)_KLi1, (uint8_t *)_KLi1_r, 16); + passed = _compare_mem((uint8_t *)_KLi2, (uint8_t *)_KLi2_r, 16); + passed = _compare_mem((uint8_t *)_KOi1, (uint8_t *)_KOi1_r, 16); + passed = _compare_mem((uint8_t *)_KOi2, (uint8_t *)_KOi2_r, 16); + passed = _compare_mem((uint8_t *)_KOi3, (uint8_t *)_KOi3_r, 16); + passed = _compare_mem((uint8_t *)_KIi1, (uint8_t *)_KIi1_r, 16); + passed = _compare_mem((uint8_t *)_KIi2, (uint8_t *)_KIi2_r, 16); + passed = _compare_mem((uint8_t *)_KIi3, (uint8_t *)_KIi3_r, 16); + printf(passed ? " OK. " : "FAILED!"); +} + +int main(int argc, char **argv) +{ + uint16_t _KLi1[8], _KLi2[8], _KOi1[8], _KOi2[8], _KOi3[8], _KIi1[8], _KIi2[8], _KIi3[8], _KLi1_r[8], _KLi2_r[8], _KOi1_r[8], _KOi2_r[8], _KOi3_r[8], _KIi1_r[8], _KIi2_r[8], _KIi3_r[8]; + + printf("testing KASUMI key expansion and encryption (ETSI TS 135 203):\n"); + printf("KASUMI Test Set 1..."); + + uint8_t _test_key1[] = {0x2B, 0xD6, 0x45, 0x9F, 0x82, 0xC5, 0xB3, 0x00, 0x95, 0x2C, 0x49, 0x10, 0x48, 0x81, 0xFF, 0x48}; + _KLi1_r[0] = 0x57AC; _KLi1_r[1] = 0x8B3E; _KLi1_r[2] = 0x058B; _KLi1_r[3] = 0x6601; _KLi1_r[4] = 0x2A59; _KLi1_r[5] = 0x9220; _KLi1_r[6] = 0x9102; _KLi1_r[7] = 0xFE91; + _KLi2_r[0] = 0x0B6E; _KLi2_r[1] = 0x7EEF; _KLi2_r[2] = 0x6BF0; _KLi2_r[3] = 0xF388; _KLi2_r[4] = 0x3ED5; _KLi2_r[5] = 0xCD58; _KLi2_r[6] = 0x2AF5; _KLi2_r[7] = 0x00F8; + _KOi1_r[0] = 0xB3E8; _KOi1_r[1] = 0x58B0; _KOi1_r[2] = 0x6016; _KOi1_r[3] = 0xA592; _KOi1_r[4] = 0x2209; _KOi1_r[5] = 0x1029; _KOi1_r[6] = 0xE91F; _KOi1_r[7] = 0x7AC5; + _KOi2_r[0] = 0x1049; _KOi2_r[1] = 0x8148; _KOi2_r[2] = 0x48FF; _KOi2_r[3] = 0xD62B; _KOi2_r[4] = 0x9F45; _KOi2_r[5] = 0xC582; _KOi2_r[6] = 0x00B3; _KOi2_r[7] = 0x2C95; + _KOi3_r[0] = 0x2910; _KOi3_r[1] = 0x1FE9; _KOi3_r[2] = 0xC57A; _KOi3_r[3] = 0xE8B3; _KOi3_r[4] = 0xB058; _KOi3_r[5] = 0x1660; _KOi3_r[6] = 0x92A5; _KOi3_r[7] = 0x0922; + _KIi1_r[0] = 0x6BF0; _KIi1_r[1] = 0xF388; _KIi1_r[2] = 0x3ED5; _KIi1_r[3] = 0xCD58; _KIi1_r[4] = 0x2AF5; _KIi1_r[5] = 0x00F8; _KIi1_r[6] = 0x0B6E; _KIi1_r[7] = 0x7EEF; + _KIi2_r[0] = 0x7EEF; _KIi2_r[1] = 0x6BF0; _KIi2_r[2] = 0xF388; _KIi2_r[3] = 0x3ED5; _KIi2_r[4] = 0xCD58; _KIi2_r[5] = 0x2AF5; _KIi2_r[6] = 0x00F8; _KIi2_r[7] = 0x0B6E; + _KIi3_r[0] = 0xCD58; _KIi3_r[1] = 0x2AF5; _KIi3_r[2] = 0x00F8; _KIi3_r[3] = 0x0B6E; _KIi3_r[4] = 0x7EEF; _KIi3_r[5] = 0x6BF0; _KIi3_r[6] = 0xF388; _KIi3_r[7] = 0x3ED5; + test_expansion(_test_key1, _KLi1, _KLi2, _KOi1, _KOi2, _KOi3, _KIi1, _KIi2, _KIi3, _KLi1_r, _KLi2_r, _KOi1_r, _KOi2_r, _KOi3_r, _KIi1_r, _KIi2_r, _KIi3_r); + + if (0xDF1F9B251C0BF45F == _kasumi(0xEA024714AD5C4D84, _KLi1, _KLi2, _KOi1, _KOi2, _KOi3, _KIi1, _KIi2, _KIi3)) + printf("OK."); + else + printf("FAILED!"); + + printf("\nKASUMI Test Set 2..."); + + uint8_t _test_key2[] = {0x8C, 0xE3, 0x3E, 0x2C, 0xC3, 0xC0, 0xB5, 0xFC, 0x1F, 0x3D, 0xE8, 0xA6, 0xDC, 0x66, 0xB1, 0xF3}; + _KLi1_r[0] = 0x19C7; _KLi1_r[1] = 0x7C58; _KLi1_r[2] = 0x8781; _KLi1_r[3] = 0x6BF9; _KLi1_r[4] = 0x3E7A; _KLi1_r[5] = 0xD14D; _KLi1_r[6] = 0xB8CD; _KLi1_r[7] = 0x63E7; + _KLi2_r[0] = 0x4A6B; _KLi2_r[1] = 0x7813; _KLi2_r[2] = 0xE1E1; _KLi2_r[3] = 0x523E; _KLi2_r[4] = 0xAA32; _KLi2_r[5] = 0x83E3; _KLi2_r[6] = 0x8DC0; _KLi2_r[7] = 0x7B4B; + _KOi1_r[0] = 0xC587; _KOi1_r[1] = 0x7818; _KOi1_r[2] = 0xBF96; _KOi1_r[3] = 0xE7A3; _KOi1_r[4] = 0x14DD; _KOi1_r[5] = 0x8CDB; _KOi1_r[6] = 0x3E76; _KOi1_r[7] = 0x9C71; + _KOi2_r[0] = 0xA6E8; _KOi2_r[1] = 0x66DC; _KOi2_r[2] = 0xF3B1; _KOi2_r[3] = 0xE38C; _KOi2_r[4] = 0x2C3E; _KOi2_r[5] = 0xC0C3; _KOi2_r[6] = 0xFCB5; _KOi2_r[7] = 0x3D1F; + _KOi3_r[0] = 0xDB8C; _KOi3_r[1] = 0x763E; _KOi3_r[2] = 0x719C; _KOi3_r[3] = 0x87C5; _KOi3_r[4] = 0x1878; _KOi3_r[5] = 0x96BF; _KOi3_r[6] = 0xA3E7; _KOi3_r[7] = 0xDD14; + _KIi1_r[0] = 0xE1E1; _KIi1_r[1] = 0x523E; _KIi1_r[2] = 0xAA32; _KIi1_r[3] = 0x83E3; _KIi1_r[4] = 0x8DC0; _KIi1_r[5] = 0x7B4B; _KIi1_r[6] = 0x4A6B; _KIi1_r[7] = 0x7813; + _KIi2_r[0] = 0x7813; _KIi2_r[1] = 0xE1E1; _KIi2_r[2] = 0x523E; _KIi2_r[3] = 0xAA32; _KIi2_r[4] = 0x83E3; _KIi2_r[5] = 0x8DC0; _KIi2_r[6] = 0x7B4B; _KIi2_r[7] = 0x4A6B; + _KIi3_r[0] = 0x83E3; _KIi3_r[1] = 0x8DC0; _KIi3_r[2] = 0x7B4B; _KIi3_r[3] = 0x4A6B; _KIi3_r[4] = 0x7813; _KIi3_r[5] = 0xE1E1; _KIi3_r[6] = 0x523E; _KIi3_r[7] = 0xAA32; + test_expansion(_test_key2, _KLi1, _KLi2, _KOi1, _KOi2, _KOi3, _KIi1, _KIi2, _KIi3, _KLi1_r, _KLi2_r, _KOi1_r, _KOi2_r, _KOi3_r, _KIi1_r, _KIi2_r, _KIi3_r); + + if (0xDE551988CEB2F9B7 == _kasumi(0xD3C5D592327FB11C, _KLi1, _KLi2, _KOi1, _KOi2, _KOi3, _KIi1, _KIi2, _KIi3)) + printf("OK."); + else + printf("FAILED!"); + + printf("\nKASUMI Test Set 3..."); + + uint8_t _test_key3[] = {0x40, 0x35, 0xC6, 0x68, 0x0A, 0xF8, 0xC6, 0xD1, 0xA8, 0xFF, 0x86, 0x67, 0xB1, 0x71, 0x40, 0x13}; + _KLi1_r[0] = 0x806A; _KLi1_r[1] = 0x8CD1; _KLi1_r[2] = 0x15F0; _KLi1_r[3] = 0x8DA3; _KLi1_r[4] = 0x51FF; _KLi1_r[5] = 0x0CCF; _KLi1_r[6] = 0x62E3; _KLi1_r[7] = 0x8026; + _KLi2_r[0] = 0x8353; _KLi2_r[1] = 0x0B3E; _KLi2_r[2] = 0x5623; _KLi2_r[3] = 0x3CFF; _KLi2_r[4] = 0xC725; _KLi2_r[5] = 0x7203; _KLi2_r[6] = 0x4116; _KLi2_r[7] = 0x830F; + _KOi1_r[0] = 0xCD18; _KOi1_r[1] = 0x5F01; _KOi1_r[2] = 0xDA38; _KOi1_r[3] = 0x1FF5; _KOi1_r[4] = 0xCCF0; _KOi1_r[5] = 0x2E36; _KOi1_r[6] = 0x0268; _KOi1_r[7] = 0x06A8; + _KOi2_r[0] = 0x6786; _KOi2_r[1] = 0x71B1; _KOi2_r[2] = 0x1340; _KOi2_r[3] = 0x3540; _KOi2_r[4] = 0x68C6; _KOi2_r[5] = 0xF80A; _KOi2_r[6] = 0xD1C6; _KOi2_r[7] = 0xFFA8; + _KOi3_r[0] = 0x362E; _KOi3_r[1] = 0x6802; _KOi3_r[2] = 0xA806; _KOi3_r[3] = 0x18CD; _KOi3_r[4] = 0x015F; _KOi3_r[5] = 0x38DA; _KOi3_r[6] = 0xF51F; _KOi3_r[7] = 0xF0CC; + _KIi1_r[0] = 0x5623; _KIi1_r[1] = 0x3CFF; _KIi1_r[2] = 0xC725; _KIi1_r[3] = 0x7203; _KIi1_r[4] = 0x4116; _KIi1_r[5] = 0x830F; _KIi1_r[6] = 0x8353; _KIi1_r[7] = 0x0B3E; + _KIi2_r[0] = 0x0B3E; _KIi2_r[1] = 0x5623; _KIi2_r[2] = 0x3CFF; _KIi2_r[3] = 0xC725; _KIi2_r[4] = 0x7203; _KIi2_r[5] = 0x4116; _KIi2_r[6] = 0x830F; _KIi2_r[7] = 0x8353; + _KIi3_r[0] = 0x7203; _KIi3_r[1] = 0x4116; _KIi3_r[2] = 0x830F; _KIi3_r[3] = 0x8353; _KIi3_r[4] = 0x0B3E; _KIi3_r[5] = 0x5623; _KIi3_r[6] = 0x3CFF; _KIi3_r[7] = 0xC725; + test_expansion(_test_key3, _KLi1, _KLi2, _KOi1, _KOi2, _KOi3, _KIi1, _KIi2, _KIi3, _KLi1_r, _KLi2_r, _KOi1_r, _KOi2_r, _KOi3_r, _KIi1_r, _KIi2_r, _KIi3_r); + + if (0x4592B0E78690F71B == _kasumi(0x62A540981BA6F9B7, _KLi1, _KLi2, _KOi1, _KOi2, _KOi3, _KIi1, _KIi2, _KIi3)) + printf("OK."); + else + printf("FAILED!"); + + printf("\nKASUMI Test Set 4..."); + uint8_t _test_key4[] = {0x3A, 0x3B, 0x39, 0xB5, 0xC3, 0xF2, 0x37, 0x6D, 0x69, 0xF7, 0xD5, 0x46, 0xE5, 0xF8, 0x5D, 0x43}; + uint64_t I4 = 0xCA49C1C75771AB0B, i; + _kasumi_key_expand(_test_key4, _KLi1, _KLi2, _KOi1, _KOi2, _KOi3, _KIi1, _KIi2, _KIi3); + + for (i = 0; i < 50; i++) + I4 = _kasumi(I4, _KLi1, _KLi2, _KOi1, _KOi2, _KOi3, _KIi1, _KIi2, _KIi3); + + if (0x738BAD4C4A690802 == I4) printf(" OK.\n"); else printf("FAILED!"); + + + uint8_t gamma[32]; + + uint8_t _Key1[] = {0x2B, 0xD6, 0x45, 0x9F, 0x82, 0xC5, 0xBC, 0x00, 0x2B, 0xD6, 0x45, 0x9F, 0x82, 0xC5, 0xBC, 0x00}, + _gamma1[] = {0x88, 0x9E, 0xEA, 0xAF, 0x9E, 0xD1, 0xBA, 0x1A, 0xBB, 0xD8, 0x43, 0x62, 0x32, 0xE4, 0x57, 0x28, 0xD0, 0x1A, 0xA8, 0x91, 0x33, 0xDA, 0x73, 0xC1, 0x1E, 0xAB, 0x68, 0xB7, 0xD8, 0x9B, 0xC8, 0x41}; + _kasumi_kgcore(0xF, 0, 0x0024F20F, 0, _Key1, gamma, 228); + printf ("KGCORE Test Set 1: %d\n", _compare_mem(gamma, _gamma1, 32)); + + uint8_t _Key2[] = {0x95, 0x2C, 0x49, 0x10, 0x48, 0x81, 0xFF, 0x48, 0x95, 0x2C, 0x49, 0x10, 0x48, 0x81, 0xFF, 0x48}, + _gamma2[] = {0xFB, 0x4D, 0x5F, 0xBC, 0xEE, 0x13, 0xA3, 0x33, 0x89, 0x28, 0x56, 0x86, 0xE9, 0xA5, 0xC9, 0x42, 0x40, 0xDE, 0x38, 0x15, 0x01, 0x15, 0xF1, 0x5F, 0x8D, 0x9D, 0x98, 0xB9, 0x1A, 0x94, 0xB2, 0x96}; + _kasumi_kgcore(0xF, 0, 0x00061272, 0, _Key2, gamma, 228); + printf ("KGCORE Test Set 2: %d\n", _compare_mem(gamma, _gamma2, 32)); + + uint8_t _Key3[] = {0xEF, 0xA8, 0xB2, 0x22, 0x9E, 0x72, 0x0C, 0x2A, 0xEF, 0xA8, 0xB2, 0x22, 0x9E, 0x72, 0x0C, 0x2A}, + _gamma3[] = {0x0E, 0x40, 0x15, 0x75, 0x5A, 0x33, 0x64, 0x69, 0xC3, 0xDD, 0x86, 0x80, 0xE3, 0x03, 0x5B, 0xC4, 0x19, 0xA7, 0x8A, 0xD3, 0x86, 0x2C, 0x10, 0x90, 0xC6, 0x8A, 0x39, 0x1F, 0xE8, 0xA6, 0xAD, 0xEB}; + _kasumi_kgcore(0xF, 0, 0x0033FD3F, 0, _Key3, gamma, 228); + printf ("KGCORE Test Set 3: %d\n", _compare_mem(gamma, _gamma3, 32)); + + uint8_t _Key4[] = {0x5A, 0xCB, 0x1D, 0x64, 0x4C, 0x0D, 0x51, 0x20, 0x4E, 0xA5, 0x5A, 0xCB, 0x1D, 0x64, 0x4C, 0x0D}, + _gamma4[] = {0xE0, 0x95, 0x30, 0x6A, 0xD5, 0x08, 0x6E, 0x2E, 0xAC, 0x7F, 0x31, 0x07, 0xDE, 0x4F, 0xA2, 0x2D, 0xC1, 0xDF, 0xC9, 0x7D, 0x5B, 0xC5, 0x66, 0x1D, 0xD6, 0x09, 0x6F, 0x47, 0x6A, 0xED, 0xC6, 0x4B}; + _kasumi_kgcore(0xF, 0, 0x00156B26, 0, _Key4, gamma, 228); + printf ("KGCORE Test Set 4: %d\n", _compare_mem(gamma, _gamma4, 32)); + + uint8_t _Key5[] = {0xD3, 0xC5, 0xD5, 0x92, 0x32, 0x7F, 0xB1, 0x1C, 0x40, 0x35, 0xC6, 0x68, 0x0A, 0xF8, 0xC6, 0xD1}, + _gamma5[] = {0xDC, 0xE6, 0x43, 0x62, 0xAB, 0x5F, 0x89, 0xC1, 0x1E, 0xF0, 0xB3, 0x05, 0x16, 0x65, 0x70, 0xF4, 0x88, 0x9D, 0x55, 0x11, 0xE9, 0xE3, 0x57, 0x5D, 0x06, 0x2B, 0x5C, 0xED, 0x60, 0x39, 0x50, 0x6A}; + _kasumi_kgcore(0xF, 0, 0x000A59B4, 0, _Key5, gamma, 228); + printf ("KGCORE Test Set 5: %d\n", _compare_mem(gamma, _gamma5, 32)); + + return 0; +} diff --git a/tests/kasumi/kasumi_test.ok b/tests/kasumi/kasumi_test.ok new file mode 100644 index 0000000..2c2af4c --- /dev/null +++ b/tests/kasumi/kasumi_test.ok @@ -0,0 +1,10 @@ +testing KASUMI key expansion and encryption (ETSI TS 135 203): +KASUMI Test Set 1... OK. OK. +KASUMI Test Set 2... OK. OK. +KASUMI Test Set 3... OK. OK. +KASUMI Test Set 4... OK. +KGCORE Test Set 1: 1 +KGCORE Test Set 2: 1 +KGCORE Test Set 3: 1 +KGCORE Test Set 4: 1 +KGCORE Test Set 5: 1 diff --git a/tests/testsuite.at b/tests/testsuite.at index 9124f25..7ce2ee8 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -9,6 +9,12 @@ cat $abs_srcdir/a5/a5_test.ok > expout AT_CHECK([$abs_top_builddir/tests/a5/a5_test], [0], [expout]) AT_CLEANUP +AT_SETUP([kasumi]) +AT_KEYWORDS([kasumi]) +cat $abs_srcdir/kasumi/kasumi_test.ok > expout +AT_CHECK([$abs_top_builddir/tests/kasumi/kasumi_test], [0], [expout]) +AT_CLEANUP + AT_SETUP([bits]) AT_KEYWORDS([bits]) cat $abs_srcdir/bits/bitrev_test.ok > expout -- 1.9.1 From 246tnt at gmail.com Sun Jun 15 20:49:45 2014 From: 246tnt at gmail.com (Sylvain Munaut) Date: Sun, 15 Jun 2014 22:49:45 +0200 Subject: [PATCH 3/3] Add Kasumi cipher implementation In-Reply-To: <1401901663-16418-3-git-send-email-Max.Suraev@fairwaves.co> References: <1401901663-16418-1-git-send-email-Max.Suraev@fairwaves.co> <1401901663-16418-3-git-send-email-Max.Suraev@fairwaves.co> Message-ID: Hi Max, > + > +#pragma once All the other files use the classic #ifdef #define, so either replace all before that, or stick to the current way of doing it. > + > +#include > + > +/*! \brief Single iteration of KASUMI cipher > + * \param[in] P Block, 64 bits to be processed in this round > + * \param[in] KLi1 Expanded subkeys > + * \param[in] KLi2 Expanded subkeys > + * \param[in] KOi1 Expanded subkeys > + * \param[in] KOi2 Expanded subkeys > + * \param[in] KOi3 Expanded subkeys > + * \param[in] KIi1 Expanded subkeys > + * \param[in] KIi2 Expanded subkeys > + * \param[in] KIi3 Expanded subkeys > + * \returns processed block of 64 bits > + */ We usually put the documentation only in the .c file and not the header. (except for stuff that's only in the header obviously). If it's picked up by doxygen all the same then I don't have big objections against putting it in the header (to be checked though) if you insist, but then be consistent ... you have some of the doc duplicated for some of the methods > +uint64_t _kasumi(uint64_t P, const uint16_t *KLi1, const uint16_t *KLi2, const uint16_t *KOi1, const uint16_t *KOi2, const uint16_t *KOi3, const uint16_t *KIi1, const uint16_t *KIi2, const uint16_t *KIi3); Either the methods are meant to be part of the public API and then they should carry the osmo prefix. Or they're meant to be internal, then the symbol should not be exported in the map file and the header should not be installed. > +inline int _compare_mem(uint8_t * x, uint8_t * y, size_t len) > +{ > + if (0 != memcmp(x, y, len)) { > + printf ("X: %s\t", osmo_hexdump_nospc(x, len)); > + printf ("Y: %s\n", osmo_hexdump_nospc(y, len)); > + return 0; > + } > + return 1; > +} Not of much importance here I admit (and not a blocker), but for future reference, make sure all that can be static is marked static. 'inline' doesn't make it static so you'll end up with both the function being inlined at every use in the file and a symbol _compare_mem that can be called from other .o (and obviously won't be and so the linker will strip it but still it's a good habit to take). Cheers, Sylvain From Max.Suraev at fairwaves.co Sun Jun 15 21:43:00 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Sun, 15 Jun 2014 23:43:00 +0200 Subject: [PATCH 3/3] Add Kasumi cipher implementation In-Reply-To: References: <1401901663-16418-1-git-send-email-Max.Suraev@fairwaves.co> <1401901663-16418-3-git-send-email-Max.Suraev@fairwaves.co> Message-ID: <539E1364.1060408@fairwaves.co> 15.06.2014 22:49, Sylvain Munaut ?????: > Hi Max, > >> + >> +#pragma once > > All the other files use the classic #ifdef #define, so either replace > all before that, or stick to the current way of doing it. What do you mean by "all before that"? > Either the methods are meant to be part of the public API and then > they should carry the osmo prefix. > Or they're meant to be internal, then the symbol should not be > exported in the map file and the header should not be installed. I think I've asked it already but I don't recall an answer: I do not want to make it a part of public API (hence - no osmo_ prefix) but I still need to call it explicitly in test/ - how can I do that without adding it to map file? -- best regards, Max, http://fairwaves.co From 246tnt at gmail.com Sun Jun 15 22:33:41 2014 From: 246tnt at gmail.com (Sylvain Munaut) Date: Mon, 16 Jun 2014 00:33:41 +0200 Subject: [PATCH 3/3] Add Kasumi cipher implementation In-Reply-To: <539E1364.1060408@fairwaves.co> References: <1401901663-16418-1-git-send-email-Max.Suraev@fairwaves.co> <1401901663-16418-3-git-send-email-Max.Suraev@fairwaves.co> <539E1364.1060408@fairwaves.co> Message-ID: Hi, > What do you mean by "all before that"? Like change all libosmocore headers to use #pragma once. We pretty much only target gcc/llvm AFAIK so that shouldn't be a problem. Any one see an objection to that ? > I think I've asked it already but I don't recall an answer: I do not want to make it > a part of public API (hence - no osmo_ prefix) but I still need to call it explicitly > in test/ - how can I do that without adding it to map file? I think the header should be in noinst_HEADER then (don't remember the exact name). As for the testing, linking the test statically should do right ? I didn't test but since this only changes the presence of the symbol in the dynamic symbol table, linking to the static lib should work. Cheers, Sylvain From Max.Suraev at fairwaves.co Mon Jun 16 12:54:42 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Mon, 16 Jun 2014 14:54:42 +0200 Subject: [PATCH 3/3] Add Kasumi cipher implementation In-Reply-To: References: <1401901663-16418-1-git-send-email-Max.Suraev@fairwaves.co> <1401901663-16418-3-git-send-email-Max.Suraev@fairwaves.co> <539E1364.1060408@fairwaves.co> Message-ID: <539EE912.8030904@fairwaves.co> 16.06.2014 00:33, Sylvain Munaut ?????: > I think the header should be in noinst_HEADER then (don't remember the > exact name). noinst_HEADERS it is, thanks. > As for the testing, linking the test statically should do right ? I > didn't test but since this only changes the presence of the symbol in > the dynamic symbol table, linking to the static lib should work. Where should I pass -static to gcc linker? Is there some statically-linked test available as an example? -- best regards, Max, http://fairwaves.co From 246tnt at gmail.com Mon Jun 16 13:37:31 2014 From: 246tnt at gmail.com (Sylvain Munaut) Date: Mon, 16 Jun 2014 15:37:31 +0200 Subject: [PATCH 3/3] Add Kasumi cipher implementation In-Reply-To: <539EE912.8030904@fairwaves.co> References: <1401901663-16418-1-git-send-email-Max.Suraev@fairwaves.co> <1401901663-16418-3-git-send-email-Max.Suraev@fairwaves.co> <539E1364.1060408@fairwaves.co> <539EE912.8030904@fairwaves.co> Message-ID: Hi, >> As for the testing, linking the test statically should do right ? I >> didn't test but since this only changes the presence of the symbol in >> the dynamic symbol table, linking to the static lib should work. > > Where should I pass -static to gcc linker? Is there some statically-linked test > available as an example? testname_LDFLAGS = -static I fixed it up myself and pushed the 3 patches. Cheers, Sylvain From holger at freyther.de Mon Jun 16 05:41:11 2014 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Mon, 16 Jun 2014 07:41:11 +0200 Subject: [PATCH 3/3] Add Kasumi cipher implementation In-Reply-To: References: <1401901663-16418-1-git-send-email-Max.Suraev@fairwaves.co> <1401901663-16418-3-git-send-email-Max.Suraev@fairwaves.co> Message-ID: <20140616054111.GL5748@xiaoyu.lan> On Sun, Jun 15, 2014 at 10:49:45PM +0200, Sylvain Munaut wrote: Hi, > > +#pragma once > > All the other files use the classic #ifdef #define, so either replace > all before that, or stick to the current way of doing it. do we really want to be that strong? I think all future header files should use "#pragma once". From 246tnt at gmail.com Mon Jun 16 08:19:20 2014 From: 246tnt at gmail.com (Sylvain Munaut) Date: Mon, 16 Jun 2014 10:19:20 +0200 Subject: [PATCH 3/3] Add Kasumi cipher implementation In-Reply-To: <20140616054111.GL5748@xiaoyu.lan> References: <1401901663-16418-1-git-send-email-Max.Suraev@fairwaves.co> <1401901663-16418-3-git-send-email-Max.Suraev@fairwaves.co> <20140616054111.GL5748@xiaoyu.lan> Message-ID: >> > +#pragma once >> >> All the other files use the classic #ifdef #define, so either replace >> all before that, or stick to the current way of doing it. > > do we really want to be that strong? I think all future header files > should use "#pragma once". I like consistency :p Especially since such a change won't really lead to conflict since it only change a couple lines at the beginning/end of each file and it's also pretty easy to do with a script. (I did it in like 10 min). Cheers, Sylvain From Max.Suraev at fairwaves.co Mon Jun 16 08:23:16 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Mon, 16 Jun 2014 10:23:16 +0200 Subject: [PATCH 3/3] Add Kasumi cipher implementation In-Reply-To: References: <1401901663-16418-1-git-send-email-Max.Suraev@fairwaves.co> <1401901663-16418-3-git-send-email-Max.Suraev@fairwaves.co> <20140616054111.GL5748@xiaoyu.lan> Message-ID: <539EA974.7050107@fairwaves.co> 16.06.2014 10:19, Sylvain Munaut ?????: > Especially since such a change won't really lead to conflict since it > only change a couple lines at the beginning/end of each file and it's > also pretty easy to do with a script. (I did it in like 10 min). > Good. Can you commit this? -- best regards, Max, http://fairwaves.co From 246tnt at gmail.com Mon Jun 16 11:55:03 2014 From: 246tnt at gmail.com (Sylvain Munaut) Date: Mon, 16 Jun 2014 13:55:03 +0200 Subject: [PATCH 3/3] Add Kasumi cipher implementation In-Reply-To: <539EA974.7050107@fairwaves.co> References: <1401901663-16418-1-git-send-email-Max.Suraev@fairwaves.co> <1401901663-16418-3-git-send-email-Max.Suraev@fairwaves.co> <20140616054111.GL5748@xiaoyu.lan> <539EA974.7050107@fairwaves.co> Message-ID: >> Especially since such a change won't really lead to conflict since it >> only change a couple lines at the beginning/end of each file and it's >> also pretty easy to do with a script. (I did it in like 10 min). >> > > Good. Can you commit this? Holger, can I get a ack on this ? Cheers, Sylvain From holger at freyther.de Mon Jun 16 12:08:53 2014 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Mon, 16 Jun 2014 14:08:53 +0200 Subject: [PATCH 3/3] Add Kasumi cipher implementation In-Reply-To: References: <1401901663-16418-1-git-send-email-Max.Suraev@fairwaves.co> <1401901663-16418-3-git-send-email-Max.Suraev@fairwaves.co> <20140616054111.GL5748@xiaoyu.lan> <539EA974.7050107@fairwaves.co> Message-ID: <20140616120853.GX5748@xiaoyu.lan> On Mon, Jun 16, 2014 at 01:55:03PM +0200, Sylvain Munaut wrote: > >> Especially since such a change won't really lead to conflict since it > >> only change a couple lines at the beginning/end of each file and it's > >> also pretty easy to do with a script. (I did it in like 10 min). > >> > > > > Good. Can you commit this? > > > Holger, can I get a ack on this ? sure. it looked fine. From Max.Suraev at fairwaves.co Fri Jun 6 13:33:29 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Fri, 06 Jun 2014 15:33:29 +0200 Subject: [PATCH 1/3] Add generic LE/BE load/store uint type convertors and use them in msgb In-Reply-To: <1401901663-16418-1-git-send-email-Max.Suraev@fairwaves.co> References: <1401901663-16418-1-git-send-email-Max.Suraev@fairwaves.co> Message-ID: <5391C329.2000000@fairwaves.co> This series of patches adds Kasumi encryption algorithm and necessary groundwork for it. It differs from previous version only in improved documentation (based on previous comments). All the tests are included and pass just fine. Once this is merged I plan to send patches implementing A5/4, GEA4 etc which relies on Kasumi. Please review and comment. Max. From rm.engineer84 at gmail.com Thu Jun 5 17:47:11 2014 From: rm.engineer84 at gmail.com (R M) Date: Thu, 5 Jun 2014 13:47:11 -0400 Subject: si3_rest decoding Message-ID: Hi, I am having trouble understanding the decoding of SI3_REST. I have highlighted the code below if (bitvec_get_bit_high(&bv) == H) s->si2ter_ind = 1; else s->si2ter_ind = 0; Here it says that si2ter_ind is set to 1 if its high. From this can I conclude that System Information Type 2ter is available ? I am asking this because the following code says that System Information Type 2ter is present /* all relevant system informations received */ if (s->si1 && s->si2 && s->si3 && (!s->nb_ext_ind_si2 || s->si2bis) && (!s->si2ter_ind || s->si2ter)) { LOGP(DCS, LOGL_DEBUG, "Received relevant sysinfo.\n"); /* stop timer */ stop_cs_timer(cs); But gsmdecode output says that its not present as per the below snippet SI 3 Restoktett 0 Selection Parameters not present 0 Power Offset not present 1 System Information 2ter Indicator not present 1 Early Classmark Sending Control present 1 Scheduling if and where not present 1 High: GPRS indicator = present I have referred GSM 04.08. But there also I am not able to understand it. Regards, RM From mailman at lists.osmocom.org Thu Jun 5 18:18:14 2014 From: mailman at lists.osmocom.org (mailman at lists.osmocom.org) Date: Thu, 05 Jun 2014 20:18:14 +0200 Subject: Bounce action notification Message-ID: This is a Mailman mailing list bounce action notice: List: baseband-devel Member: osmocom at ninoc.nl Action: Subscription disabled. Reason: Excessive or fatal bounces. The triggering bounce notice is attached below. Questions? Contact the Mailman site administrator at mailman at lists.osmocom.org. -------------- next part -------------- An embedded message was scrubbed... From: Mail Delivery System Subject: Mail delivery failed: returning message to sender Date: Thu, 05 Jun 2014 20:04:00 +0200 Size: 5230 URL: From mailman at lists.osmocom.org Fri Jun 6 13:37:04 2014 From: mailman at lists.osmocom.org (mailman at lists.osmocom.org) Date: Fri, 06 Jun 2014 15:37:04 +0200 Subject: Bounce action notification Message-ID: This is a Mailman mailing list bounce action notice: List: baseband-devel Member: luca.bongiorni1 at studenti.unimi.it Action: Subscription disabled. Reason: Excessive or fatal bounces. The triggering bounce notice is attached below. Questions? Contact the Mailman site administrator at mailman at lists.osmocom.org. -------------- next part -------------- An embedded message was scrubbed... From: Internet Mail Delivery Subject: Delivery Notification: Delivery has failed Date: Fri, 06 Jun 2014 15:36:55 +0200 (CEST) Size: 7244 URL: From Max.Suraev at fairwaves.co Fri Jun 6 14:36:40 2014 From: Max.Suraev at fairwaves.co (Max Suraev) Date: Fri, 6 Jun 2014 16:36:40 +0200 Subject: [PATCH] use osmocom auth API instead of direct calls Message-ID: <1402065400-7969-1-git-send-email-Max.Suraev@fairwaves.co> --- .../layer23/include/osmocom/bb/mobile/settings.h | 6 ---- src/host/layer23/src/mobile/subscriber.c | 33 ++++++++++------------ src/host/layer23/src/mobile/vty_interface.c | 9 +++--- 3 files changed, 20 insertions(+), 28 deletions(-) diff --git a/src/host/layer23/include/osmocom/bb/mobile/settings.h b/src/host/layer23/include/osmocom/bb/mobile/settings.h index f3ac796..cdf6323 100644 --- a/src/host/layer23/include/osmocom/bb/mobile/settings.h +++ b/src/host/layer23/include/osmocom/bb/mobile/settings.h @@ -1,12 +1,6 @@ #ifndef _settings_h #define _settings_h -/* type of test SIM key */ -enum { - GSM_SIM_KEY_XOR = 0, - GSM_SIM_KEY_COMP128 -}; - struct gsm_settings { char layer2_socket_path[128]; char sap_socket_path[128]; diff --git a/src/host/layer23/src/mobile/subscriber.c b/src/host/layer23/src/mobile/subscriber.c index fa59d9f..ba3c328 100644 --- a/src/host/layer23/src/mobile/subscriber.c +++ b/src/host/layer23/src/mobile/subscriber.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include @@ -81,16 +81,6 @@ static char *sim_decode_bcd(uint8_t *data, uint8_t length) return result; } -static void xor96(uint8_t *ki, uint8_t *rand, uint8_t *sres, uint8_t *kc) -{ - int i; - - for (i=0; i < 4; i++) - sres[i] = rand[i] ^ ki[i]; - for (i=0; i < 8; i++) - kc[i] = rand[i] ^ ki[i+4]; -} - /* * init/exit */ @@ -262,7 +252,7 @@ static int subscr_sim_imsi(struct osmocom_ms *ms, uint8_t *data, /* decode IMSI, skip first digit (parity) */ imsi = sim_decode_bcd(data + 1, length); if (strlen(imsi) - 1 > GSM_IMSI_LENGTH - 1 || strlen(imsi) - 1 < 6) { - LOGP(DMM, LOGL_NOTICE, "IMSI invalid length = %d\n", + LOGP(DMM, LOGL_NOTICE, "IMSI invalid length = %zu\n", strlen(imsi) - 1); return -EINVAL; } @@ -940,22 +930,29 @@ int gsm_subscr_generate_kc(struct osmocom_ms *ms, uint8_t key_seq, /* test SIM */ if (subscr->sim_type == GSM_SIM_TYPE_TEST) { struct gsm48_mm_event *nmme; - uint8_t sres[4]; struct gsm_settings *set = &ms->settings; + static struct osmo_sub_auth_data auth = { + .type = OSMO_AUTH_TYPE_GSM + }; + struct osmo_auth_vector _vec; + struct osmo_auth_vector *vec = &_vec; + + auth.algo = set->test_ki_type; + memcpy(auth.u.gsm.ki, set->test_ki, sizeof(auth.u.gsm.ki)); + int ret = osmo_auth_gen_vec(vec, &auth, rand); + if (ret < 0) + return ret; - if (set->test_ki_type == GSM_SIM_KEY_COMP128) - comp128(set->test_ki, rand, sres, subscr->key); - else - xor96(set->test_ki, rand, sres, subscr->key); /* store sequence */ subscr->key_seq = key_seq; + memcpy(subscr->key, vec->kc, 8); LOGP(DMM, LOGL_INFO, "Sending authentication response\n"); nmsg = gsm48_mmevent_msgb_alloc(GSM48_MM_EVENT_AUTH_RESPONSE); if (!nmsg) return -ENOMEM; nmme = (struct gsm48_mm_event *) nmsg->data; - memcpy(nmme->sres, sres, 4); + memcpy(nmme->sres, vec->sres, 4); gsm48_mmevent_msg(ms, nmsg); return 0; diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c index 22ef7ae..5782a17 100644 --- a/src/host/layer23/src/mobile/vty_interface.c +++ b/src/host/layer23/src/mobile/vty_interface.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -1453,11 +1454,11 @@ static void config_write_ms(struct vty *vty, struct osmocom_ms *ms) vty_out(vty, " test-sim%s", VTY_NEWLINE); vty_out(vty, " imsi %s%s", set->test_imsi, VTY_NEWLINE); switch (set->test_ki_type) { - case GSM_SIM_KEY_XOR: + case OSMO_AUTH_ALG_XOR: vty_out(vty, " ki xor %s%s", osmo_hexdump(set->test_ki, 12), VTY_NEWLINE); break; - case GSM_SIM_KEY_COMP128: + case OSMO_AUTH_ALG_COMP128v1: vty_out(vty, " ki comp128 %s%s", osmo_hexdump(set->test_ki, 16), VTY_NEWLINE); break; @@ -2500,7 +2501,7 @@ DEFUN(cfg_test_ki_xor, cfg_test_ki_xor_cmd, "ki xor HEX HEX HEX HEX HEX HEX " ki[i] = strtoul(p, NULL, 16); } - set->test_ki_type = GSM_SIM_KEY_XOR; + set->test_ki_type = OSMO_AUTH_ALG_XOR; memcpy(set->test_ki, ki, 12); return CMD_SUCCESS; } @@ -2529,7 +2530,7 @@ DEFUN(cfg_test_ki_comp128, cfg_test_ki_comp128_cmd, "ki comp128 HEX HEX HEX " ki[i] = strtoul(p, NULL, 16); } - set->test_ki_type = GSM_SIM_KEY_COMP128; + set->test_ki_type = OSMO_AUTH_ALG_COMP128v1; memcpy(set->test_ki, ki, 16); return CMD_SUCCESS; } -- 1.9.1 From Max.Suraev at fairwaves.co Fri Jun 6 14:52:23 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Fri, 06 Jun 2014 16:52:23 +0200 Subject: [PATCH] use osmocom auth API instead of direct calls In-Reply-To: <1402065400-7969-1-git-send-email-Max.Suraev@fairwaves.co> References: <1402065400-7969-1-git-send-email-Max.Suraev@fairwaves.co> Message-ID: <5391D5A7.8070901@fairwaves.co> This patch switches away from directly calling COMP128 to using generic osmocom authentication API. The idea is that bypassing auth API will be deprecated in future versions of libosmocore. Using generic API will allow us to trivially introduce support for other algorithms like COMP128v23 for example. Note: I'd appreciate help with testing to make sure there are no regressions. -- best regards, Max, http://fairwaves.co From choukoumoun at gmail.com Fri Jun 6 19:37:21 2014 From: choukoumoun at gmail.com (Choukou Moun) Date: Fri, 6 Jun 2014 21:37:21 +0200 Subject: [PATCH] use osmocom auth API instead of direct calls In-Reply-To: <5391D5A7.8070901@fairwaves.co> References: <1402065400-7969-1-git-send-email-Max.Suraev@fairwaves.co> <5391D5A7.8070901@fairwaves.co> Message-ID: Hello, Im sorry for this newbies question but how to appling this patch to my osmocom-bb install ? Thanks for the plsong time to respond to me Best. Le 6 juin 2014 15:53, "?" a ?crit : > This patch switches away from directly calling COMP128 to using generic > osmocom > authentication API. The idea is that bypassing auth API will be deprecated > in future > versions of libosmocore. Using generic API will allow us to trivially > introduce > support for other algorithms like COMP128v23 for example. > > Note: I'd appreciate help with testing to make sure there are no > regressions. > > -- best regards, > Max, > http://fairwaves.co > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Max.Suraev at fairwaves.co Fri Jun 6 23:52:29 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Sat, 07 Jun 2014 01:52:29 +0200 Subject: [PATCH] use osmocom auth API instead of direct calls In-Reply-To: References: <1402065400-7969-1-git-send-email-Max.Suraev@fairwaves.co> <5391D5A7.8070901@fairwaves.co> Message-ID: <5392543D.50309@fairwaves.co> Something like this: cd osmocom-bb patch -p1 < "use osmocom auth API instead of direct calls.patch" 06.06.2014 21:37, Choukou Moun ?????: > Hello, > > Im sorry for this newbies question but how to appling this patch to my osmocom-bb > install ? > > Thanks for the plsong time to respond to me > > Best. > > Le 6 juin 2014 15:53, "?" > > a ?crit : > > This patch switches away from directly calling COMP128 to using generic osmocom > authentication API. The idea is that bypassing auth API will be deprecated in future > versions of libosmocore. Using generic API will allow us to trivially introduce > support for other algorithms like COMP128v23 for example. > > Note: I'd appreciate help with testing to make sure there are no regressions. > > -- best regards, > Max, > http://fairwaves.co > > -- best regards, Max, http://fairwaves.co From pabs at debian.org Sat Jun 7 01:04:13 2014 From: pabs at debian.org (Paul Wise) Date: Sat, 7 Jun 2014 09:04:13 +0800 Subject: [PATCH] use osmocom auth API instead of direct calls In-Reply-To: <5392543D.50309@fairwaves.co> References: <1402065400-7969-1-git-send-email-Max.Suraev@fairwaves.co> <5391D5A7.8070901@fairwaves.co> <5392543D.50309@fairwaves.co> Message-ID: On Sat, Jun 7, 2014 at 7:52 AM, ? wrote: > Something like this: > > cd osmocom-bb > patch -p1 < "use osmocom auth API instead of direct calls.patch" A better way to do it would be to save the mail as an mbox and then run this. That way you get a proper commit in the git repository. cd osmocom-bb git am "use osmocom auth API instead of direct calls.patch" -- bye, pabs http://wiki.debian.org/PaulWise From Max.Suraev at fairwaves.co Sat Jun 7 10:08:54 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Sat, 07 Jun 2014 12:08:54 +0200 Subject: [PATCH] use osmocom auth API instead of direct calls In-Reply-To: References: <1402065400-7969-1-git-send-email-Max.Suraev@fairwaves.co> <5391D5A7.8070901@fairwaves.co> <5392543D.50309@fairwaves.co> Message-ID: <5392E4B6.1040800@fairwaves.co> Instead of saving email you could get patch from http://patchwork.ozlabs.org/project/osmocom-bb/list/ That's a convenient way to track other patches pending review as well. 07.06.2014 03:04, Paul Wise ?????: > On Sat, Jun 7, 2014 at 7:52 AM, ? wrote: > >> Something like this: >> >> cd osmocom-bb >> patch -p1 < "use osmocom auth API instead of direct calls.patch" > > A better way to do it would be to save the mail as an mbox and then > run this. That way you get a proper commit in the git repository. > > cd osmocom-bb > git am "use osmocom auth API instead of direct calls.patch" > -- best regards, Max, http://fairwaves.co From Max.Suraev at fairwaves.co Fri Jun 6 15:11:18 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Fri, 06 Jun 2014 17:11:18 +0200 Subject: osmohackathon? Message-ID: <5391DA16.70709@fairwaves.co> Hi fellows. There's been awhile since I've attended osmocom meetings in Berlin - seems like the idea went extinct cause people are not interested in meetings for the sake of meetings (at least without beer :) So how about revitalizing that? Personally I'd love to attend hackathon in Berlin to work on some osmocom-related stuff: - there are tons of patches pending review for months - some branches awaits to be merged/tested/rebased - documentation always needs more love - that cool thing you've wanted to work on since forever What do you think? I mean, yepp, it's summer but come on - we're all geeks with no social life anyway ;-) And yepp, there are those customers waiting for that code to be delivered yesterday... but it might be fun to work together on something for the sake of it :) OsmoDevConf is cool but it's only once a year. I think we got enough density of devs in here to make smaller-scale local event - if the devs are interested of course. -- best regards, Max, http://fairwaves.co From mailman at lists.osmocom.org Sat Jun 7 16:28:02 2014 From: mailman at lists.osmocom.org (mailman at lists.osmocom.org) Date: Sat, 07 Jun 2014 18:28:02 +0200 Subject: Bounce action notification Message-ID: This is a Mailman mailing list bounce action notice: List: baseband-devel Member: vmj at linuxbox.fi Action: Subscription disabled. Reason: Excessive or fatal bounces. The triggering bounce notice is attached below. Questions? Contact the Mailman site administrator at mailman at lists.osmocom.org. -------------- next part -------------- An embedded message was scrubbed... From: Mail Delivery System Subject: Mail delivery failed: returning message to sender Date: Sat, 07 Jun 2014 18:28:00 +0200 Size: 4952 URL: From Max.Suraev at fairwaves.co Tue Jun 10 13:10:12 2014 From: Max.Suraev at fairwaves.co (Max Suraev) Date: Tue, 10 Jun 2014 15:10:12 +0200 Subject: [PATCH] add LTE defines to GSMTAP Message-ID: <1402405812-2281-1-git-send-email-Max.Suraev@fairwaves.co> --- include/osmocom/core/gsmtap.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/osmocom/core/gsmtap.h b/include/osmocom/core/gsmtap.h index c1c53d0..5d4755b 100644 --- a/include/osmocom/core/gsmtap.h +++ b/include/osmocom/core/gsmtap.h @@ -43,7 +43,7 @@ #define GSMTAP_TYPE_GMR1_UM 0x0a /* GMR-1 L2 packets */ #define GSMTAP_TYPE_UMTS_RLC_MAC 0x0b #define GSMTAP_TYPE_UMTS_RRC 0x0c - +#define GSMTAP_TYPE_LTE_RRC 0x0d /* ====== DO NOT MAKE UNAPPROVED MODIFICATIONS HERE ===== */ @@ -131,6 +131,13 @@ /* ====== DO NOT MAKE UNAPPROVED MODIFICATIONS HERE ===== */ +#define GSMTAP_LTE_CH_BCCH 0x01 +#define GSMTAP_LTE_CH_CCCH 0x02 +#define GSMTAP_LTE_CH_DCCH 0x03 +#define GSMTAP_LTE_CH_MCCH 0x04 +#define GSMTAP_LTE_CH_PCCH 0x05 +#define GSMTAP_LTE_CH_SCH 0x06 + #define GSMTAP_UMTS_CH_PCCH 0x01 #define GSMTAP_UMTS_CH_CCCH 0x02 #define GSMTAP_UMTS_CH_DCCH 0x03 -- 1.9.1 From Max.Suraev at fairwaves.co Tue Jun 10 13:26:51 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Tue, 10 Jun 2014 15:26:51 +0200 Subject: [PATCH] add LTE defines to GSMTAP In-Reply-To: <1402405812-2281-1-git-send-email-Max.Suraev@fairwaves.co> References: <1402405812-2281-1-git-send-email-Max.Suraev@fairwaves.co> Message-ID: <5397079B.3070906@fairwaves.co> This patch proposes extension to GSMTAP to support LTE frames - the same way it supports UMTS. I've tried to pick defines to be compatible with wireshark. Suggestions and extensions are highly appreciated. -- best regards, Max, http://fairwaves.co From 246tnt at gmail.com Tue Jun 10 15:08:00 2014 From: 246tnt at gmail.com (Sylvain Munaut) Date: Tue, 10 Jun 2014 17:08:00 +0200 Subject: [PATCH] add LTE defines to GSMTAP In-Reply-To: <1402405812-2281-1-git-send-email-Max.Suraev@fairwaves.co> References: <1402405812-2281-1-git-send-email-Max.Suraev@fairwaves.co> Message-ID: Hi Max, @ttsou, you're pretty familiar with LTE right ? Can you give it a quick look just to get a second opinion. (mine is pretty useless as my lte knowledge is near zero). > diff --git a/include/osmocom/core/gsmtap.h b/include/osmocom/core/gsmtap.h > index c1c53d0..5d4755b 100644 > --- a/include/osmocom/core/gsmtap.h > +++ b/include/osmocom/core/gsmtap.h > @@ -43,7 +43,7 @@ > #define GSMTAP_TYPE_GMR1_UM 0x0a /* GMR-1 L2 packets */ > #define GSMTAP_TYPE_UMTS_RLC_MAC 0x0b > #define GSMTAP_TYPE_UMTS_RRC 0x0c > - > +#define GSMTAP_TYPE_LTE_RRC 0x0d The '-' is an unecessary whitespace change. > /* ====== DO NOT MAKE UNAPPROVED MODIFICATIONS HERE ===== */ > > +#define GSMTAP_LTE_CH_BCCH 0x01 > +#define GSMTAP_LTE_CH_CCCH 0x02 > +#define GSMTAP_LTE_CH_DCCH 0x03 > +#define GSMTAP_LTE_CH_MCCH 0x04 > +#define GSMTAP_LTE_CH_PCCH 0x05 > +#define GSMTAP_LTE_CH_SCH 0x06 > + > #define GSMTAP_UMTS_CH_PCCH 0x01 > #define GSMTAP_UMTS_CH_CCCH 0x02 > #define GSMTAP_UMTS_CH_DCCH 0x03 1) I'd add a new separate section witht ehe " ==== ..." marker before / after and put it after the UMTS section to keep the order. Also add the same comment that those are for the GSMTAP_TYPE_LTE_RRC (look at the UM / TETRA / GMR section). 2) tab vs space for alignement of the values Cheers, Sylvain From tom at tsou.cc Tue Jun 10 15:59:40 2014 From: tom at tsou.cc (Tom Tsou) Date: Tue, 10 Jun 2014 11:59:40 -0400 Subject: [PATCH] add LTE defines to GSMTAP In-Reply-To: <1402405812-2281-1-git-send-email-Max.Suraev@fairwaves.co> References: <1402405812-2281-1-git-send-email-Max.Suraev@fairwaves.co> Message-ID: On Tue, Jun 10, 2014 at 9:10 AM, Max Suraev wrote: > +#define GSMTAP_LTE_CH_BCCH 0x01 > +#define GSMTAP_LTE_CH_CCCH 0x02 > +#define GSMTAP_LTE_CH_DCCH 0x03 > +#define GSMTAP_LTE_CH_MCCH 0x04 > +#define GSMTAP_LTE_CH_PCCH 0x05 > +#define GSMTAP_LTE_CH_SCH 0x06 The SCH is a transport channel upon which the other control channels are mapped. Downlink or uplink SCH won't interact with RRC directly, so it seems the logical traffic channels DTCH (Dedicated Traffic Channel) and MTCH (Multicast Traffic Channel) are more appropriate here. -TT From Max.Suraev at fairwaves.co Tue Jun 10 17:04:59 2014 From: Max.Suraev at fairwaves.co (Max Suraev) Date: Tue, 10 Jun 2014 19:04:59 +0200 Subject: [PATCH] add LTE defines to GSMTAP v2 In-Reply-To: <1402405812-2281-1-git-send-email-Max.Suraev@fairwaves.co> References: <1402405812-2281-1-git-send-email-Max.Suraev@fairwaves.co> Message-ID: <1402419899-24862-1-git-send-email-Max.Suraev@fairwaves.co> --- include/osmocom/core/gsmtap.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/osmocom/core/gsmtap.h b/include/osmocom/core/gsmtap.h index c1c53d0..5fac711 100644 --- a/include/osmocom/core/gsmtap.h +++ b/include/osmocom/core/gsmtap.h @@ -43,7 +43,7 @@ #define GSMTAP_TYPE_GMR1_UM 0x0a /* GMR-1 L2 packets */ #define GSMTAP_TYPE_UMTS_RLC_MAC 0x0b #define GSMTAP_TYPE_UMTS_RRC 0x0c - +#define GSMTAP_TYPE_LTE_RRC 0x0d /* LTE interface */ /* ====== DO NOT MAKE UNAPPROVED MODIFICATIONS HERE ===== */ @@ -135,6 +135,15 @@ #define GSMTAP_UMTS_CH_CCCH 0x02 #define GSMTAP_UMTS_CH_DCCH 0x03 +/* sub-types for TYPE_LTE_RRC */ +#define GSMTAP_LTE_CH_BCCH 0x01 +#define GSMTAP_LTE_CH_CCCH 0x02 +#define GSMTAP_LTE_CH_DCCH 0x03 +#define GSMTAP_LTE_CH_MCCH 0x04 +#define GSMTAP_LTE_CH_PCCH 0x05 +#define GSMTAP_LTE_CH_DTCH 0x06 +#define GSMTAP_LTE_CH_MTCH 0x07 + /* flags for the ARFCN */ #define GSMTAP_ARFCN_F_PCS 0x8000 #define GSMTAP_ARFCN_F_UPLINK 0x4000 -- 1.9.1 From Max.Suraev at fairwaves.co Tue Jun 10 17:11:08 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Tue, 10 Jun 2014 19:11:08 +0200 Subject: [PATCH] add LTE defines to GSMTAP v2 In-Reply-To: <1402419899-24862-1-git-send-email-Max.Suraev@fairwaves.co> References: <1402405812-2281-1-git-send-email-Max.Suraev@fairwaves.co> <1402419899-24862-1-git-send-email-Max.Suraev@fairwaves.co> Message-ID: <53973C2C.9050108@fairwaves.co> Thanks for your comments: incorporated @ttsou suggestion on SCH, fixed tab-vs-space. As for whitespace change in the beginning - I think it's necessary to match usage of ====== header throughout the rest of the file. -- best regards, Max, http://fairwaves.co From 246tnt at gmail.com Tue Jun 10 17:56:16 2014 From: 246tnt at gmail.com (Sylvain Munaut) Date: Tue, 10 Jun 2014 19:56:16 +0200 Subject: [PATCH] add LTE defines to GSMTAP v2 In-Reply-To: <53973C2C.9050108@fairwaves.co> References: <1402405812-2281-1-git-send-email-Max.Suraev@fairwaves.co> <1402419899-24862-1-git-send-email-Max.Suraev@fairwaves.co> <53973C2C.9050108@fairwaves.co> Message-ID: Signed-off-by: Sylvain Munaut I'll give it a couple of days to make sure everybody interested has a chance to view it, but if there are no other comments / suggestions in the mean time, I'll push that to master. From 246tnt at gmail.com Sun Jun 15 16:58:20 2014 From: 246tnt at gmail.com (Sylvain Munaut) Date: Sun, 15 Jun 2014 18:58:20 +0200 Subject: [PATCH] add LTE defines to GSMTAP v2 In-Reply-To: References: <1402405812-2281-1-git-send-email-Max.Suraev@fairwaves.co> <1402419899-24862-1-git-send-email-Max.Suraev@fairwaves.co> <53973C2C.9050108@fairwaves.co> Message-ID: Applied. BTW, you might want to include a signed-off-by line next time. Cheers, Sylvain From Max.Suraev at fairwaves.co Sun Jun 15 21:35:16 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Sun, 15 Jun 2014 23:35:16 +0200 Subject: [PATCH] add LTE defines to GSMTAP v2 In-Reply-To: References: <1402405812-2281-1-git-send-email-Max.Suraev@fairwaves.co> <1402419899-24862-1-git-send-email-Max.Suraev@fairwaves.co> <53973C2C.9050108@fairwaves.co> Message-ID: <539E1194.4000908@fairwaves.co> Thanks. Is there some git option for that or it's just plain text in a long comment? 15.06.2014 18:58, Sylvain Munaut ?????: > Applied. > > BTW, you might want to include a signed-off-by line next time. > > Cheers, > > Sylvain > -- best regards, Max, http://fairwaves.co From tom at tsou.cc Sun Jun 15 22:04:47 2014 From: tom at tsou.cc (Tom Tsou) Date: Sun, 15 Jun 2014 18:04:47 -0400 Subject: [PATCH] add LTE defines to GSMTAP v2 In-Reply-To: <539E1194.4000908@fairwaves.co> References: <1402405812-2281-1-git-send-email-Max.Suraev@fairwaves.co> <1402419899-24862-1-git-send-email-Max.Suraev@fairwaves.co> <53973C2C.9050108@fairwaves.co> <539E1194.4000908@fairwaves.co> Message-ID: On Sun, Jun 15, 2014 at 5:35 PM, ? wrote: > Is there some git option for that or it's just plain text in a long comment? git commit --signoff -TT From alexander.huemer at xx.vu Sun Jun 15 22:08:48 2014 From: alexander.huemer at xx.vu (Alexander Huemer) Date: Mon, 16 Jun 2014 00:08:48 +0200 Subject: [PATCH] add LTE defines to GSMTAP v2 In-Reply-To: <539E1194.4000908@fairwaves.co> References: <1402405812-2281-1-git-send-email-Max.Suraev@fairwaves.co> <1402419899-24862-1-git-send-email-Max.Suraev@fairwaves.co> <53973C2C.9050108@fairwaves.co> <539E1194.4000908@fairwaves.co> Message-ID: <20140615220848.GA18040@yade.xx.vu> On Sun, Jun 15, 2014 at 11:35:16PM +0200, ? wrote: > 15.06.2014 18:58, Sylvain Munaut ?????: > > BTW, you might want to include a signed-off-by line next time. > > Is there some git option for that or it's just plain text in a long > comment? That's an option to 'git commit', it's '-s, --signoff', documented in the man page. Kind regards, -Alex From Max.Suraev at fairwaves.co Mon Jun 16 09:19:02 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Mon, 16 Jun 2014 11:19:02 +0200 Subject: [PATCH] add LTE defines to GSMTAP v2 In-Reply-To: <20140615220848.GA18040@yade.xx.vu> References: <1402405812-2281-1-git-send-email-Max.Suraev@fairwaves.co> <1402419899-24862-1-git-send-email-Max.Suraev@fairwaves.co> <53973C2C.9050108@fairwaves.co> <539E1194.4000908@fairwaves.co> <20140615220848.GA18040@yade.xx.vu> Message-ID: <539EB686.1070101@fairwaves.co> Thanks for clarification guys. One more thing - was I supposed to put me or Sylvain in there? -- best regards, Max, http://fairwaves.co From 246tnt at gmail.com Mon Jun 16 10:02:35 2014 From: 246tnt at gmail.com (Sylvain Munaut) Date: Mon, 16 Jun 2014 12:02:35 +0200 Subject: [PATCH] add LTE defines to GSMTAP v2 In-Reply-To: <539EB686.1070101@fairwaves.co> References: <1402405812-2281-1-git-send-email-Max.Suraev@fairwaves.co> <1402419899-24862-1-git-send-email-Max.Suraev@fairwaves.co> <53973C2C.9050108@fairwaves.co> <539E1194.4000908@fairwaves.co> <20140615220848.GA18040@yade.xx.vu> <539EB686.1070101@fairwaves.co> Message-ID: > Thanks for clarification guys. One more thing - was I supposed to put me or Sylvain > in there? Yourself. The Signed-off-by chain is essentially taking responsibility for the patch. When taking a patch off the list, I'll add my own line to it to basically say I looked over the patch, tested it and that to the best of my knowledge the patch complies with the license. Cheers, Sylvain From Max.Suraev at fairwaves.co Wed Jun 11 15:06:41 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Wed, 11 Jun 2014 17:06:41 +0200 Subject: LTE auth in libosmocore Message-ID: <53987081.5060604@fairwaves.co> Hi. On the one hand it would be handy to have all authentication and encryption algorithms consolidated in one library behind common API, on the other hand it takes lots of time and efforts to push patches to libosmocore (kasumi patches are pending review for months). Is there any interest of having LTE encryption and authentication implementation for libosmocore or it's not worth trying? -- best regards, Max, http://fairwaves.co From mailman at lists.osmocom.org Fri Jun 13 10:56:47 2014 From: mailman at lists.osmocom.org (mailman at lists.osmocom.org) Date: Fri, 13 Jun 2014 12:56:47 +0200 Subject: Bounce action notification Message-ID: This is a Mailman mailing list bounce action notice: List: baseband-devel Member: luca.bongiorni1 at studenti.unimi.it Action: Subscription disabled. Reason: Excessive or fatal bounces. The triggering bounce notice is attached below. Questions? Contact the Mailman site administrator at mailman at lists.osmocom.org. -------------- next part -------------- An embedded message was scrubbed... From: Internet Mail Delivery Subject: Delivery Notification: Delivery has failed Date: Fri, 13 Jun 2014 12:56:41 +0200 (CEST) Size: 7166 URL: From 246tnt at gmail.com Mon Jun 16 08:23:04 2014 From: 246tnt at gmail.com (246tnt at gmail.com) Date: Mon, 16 Jun 2014 10:23:04 +0200 Subject: [PATCH] include: Switch to #pragma once pattern Message-ID: <1402906984-6454-1-git-send-email-246tnt@gmail.com> From: Sylvain Munaut Signed-off-by: Sylvain Munaut --- include/osmocom/codec/codec.h | 5 +---- include/osmocom/core/application.h | 5 +---- include/osmocom/core/backtrace.h | 5 +---- include/osmocom/core/bits.h | 5 +---- include/osmocom/core/bitvec.h | 5 +---- include/osmocom/core/conv.h | 5 +---- include/osmocom/core/crc16.h | 5 +---- include/osmocom/core/crcXXgen.h.tpl | 5 +---- include/osmocom/core/crcgen.h | 5 +---- include/osmocom/core/defs.h | 5 +---- include/osmocom/core/gsmtap.h | 5 +---- include/osmocom/core/gsmtap_util.h | 5 +---- include/osmocom/core/linuxlist.h | 6 +----- include/osmocom/core/linuxrbtree.h | 5 +---- include/osmocom/core/logging.h | 5 +---- include/osmocom/core/loggingrb.h | 5 +---- include/osmocom/core/msgb.h | 5 +---- include/osmocom/core/msgfile.h | 5 +---- include/osmocom/core/panic.h | 5 +---- include/osmocom/core/plugin.h | 5 +---- include/osmocom/core/prim.h | 5 +---- include/osmocom/core/rate_ctr.h | 4 +--- include/osmocom/core/select.h | 5 +---- include/osmocom/core/serial.h | 5 +---- include/osmocom/core/signal.h | 5 +---- include/osmocom/core/socket.h | 5 +---- include/osmocom/core/statistics.h | 5 +---- include/osmocom/core/strrb.h | 5 +---- include/osmocom/core/talloc.h | 5 +---- include/osmocom/core/timer.h | 5 +---- include/osmocom/core/timer_compat.h | 5 +---- include/osmocom/core/utils.h | 5 +---- include/osmocom/core/write_queue.h | 5 +---- include/osmocom/crypt/auth.h | 5 +---- include/osmocom/crypt/gprs_cipher.h | 5 +---- include/osmocom/gprs/gprs_bssgp.h | 5 +---- include/osmocom/gprs/gprs_bssgp_bss.h | 4 +--- include/osmocom/gprs/gprs_msgb.h | 4 +--- include/osmocom/gprs/gprs_ns.h | 5 +---- include/osmocom/gprs/gprs_ns_frgre.h | 5 +---- include/osmocom/gprs/protocol/gsm_08_16.h | 5 +---- include/osmocom/gprs/protocol/gsm_08_18.h | 5 +---- include/osmocom/gsm/a5.h | 5 +---- include/osmocom/gsm/abis_nm.h | 5 +---- include/osmocom/gsm/comp128.h | 6 +----- include/osmocom/gsm/comp128v23.h | 5 +---- include/osmocom/gsm/gan.h | 5 +---- include/osmocom/gsm/gsm0411_smc.h | 5 +---- include/osmocom/gsm/gsm0411_smr.h | 6 +----- include/osmocom/gsm/gsm0411_utils.h | 5 +---- include/osmocom/gsm/gsm0480.h | 5 +---- include/osmocom/gsm/gsm0502.h | 5 +---- include/osmocom/gsm/gsm0808.h | 5 +---- include/osmocom/gsm/gsm48.h | 5 +---- include/osmocom/gsm/gsm48_ie.h | 5 +---- include/osmocom/gsm/gsm_utils.h | 6 +----- include/osmocom/gsm/l1sap.h | 5 +---- include/osmocom/gsm/lapd_core.h | 5 +---- include/osmocom/gsm/lapdm.h | 5 +---- include/osmocom/gsm/meas_rep.h | 5 +---- include/osmocom/gsm/mncc.h | 5 +---- include/osmocom/gsm/prim.h | 5 +---- include/osmocom/gsm/protocol/gsm_03_41.h | 5 +---- include/osmocom/gsm/protocol/gsm_04_08.h | 5 +---- include/osmocom/gsm/protocol/gsm_04_11.h | 5 +---- include/osmocom/gsm/protocol/gsm_04_12.h | 5 +---- include/osmocom/gsm/protocol/gsm_04_80.h | 5 +---- include/osmocom/gsm/protocol/gsm_08_08.h | 5 +---- include/osmocom/gsm/protocol/gsm_08_58.h | 5 +---- include/osmocom/gsm/protocol/gsm_12_21.h | 5 +---- include/osmocom/gsm/protocol/gsm_44_318.h | 4 +--- include/osmocom/gsm/protocol/ipaccess.h | 5 +---- include/osmocom/gsm/protocol/smpp34_osmocom.h | 5 +---- include/osmocom/gsm/rsl.h | 5 +---- include/osmocom/gsm/rxlev_stat.h | 5 +---- include/osmocom/gsm/sysinfo.h | 5 +---- include/osmocom/gsm/tlv.h | 5 +---- include/osmocom/vty/buffer.h | 5 +---- include/osmocom/vty/command.h | 4 +--- include/osmocom/vty/logging.h | 5 +---- include/osmocom/vty/misc.h | 5 +---- include/osmocom/vty/telnet_interface.h | 5 +---- include/osmocom/vty/vector.h | 5 +---- include/osmocom/vty/vty.h | 5 +---- src/gsm/milenage/aes.h | 5 +---- src/gsm/milenage/aes_i.h | 5 +---- src/gsm/milenage/aes_wrap.h | 5 +---- src/gsm/milenage/milenage.h | 5 +---- 88 files changed, 88 insertions(+), 351 deletions(-) diff --git a/include/osmocom/codec/codec.h b/include/osmocom/codec/codec.h index 81f5d4b..d126e0f 100644 --- a/include/osmocom/codec/codec.h +++ b/include/osmocom/codec/codec.h @@ -1,5 +1,4 @@ -#ifndef _OSMOCOM_CODEC_H -#define _OSMOCOM_CODEC_H +#pragma once #include @@ -16,5 +15,3 @@ extern const uint16_t gsm690_6_7_bitorder[]; /* AMR 6.7 kbits */ extern const uint16_t gsm690_5_9_bitorder[]; /* AMR 5.9 kbits */ extern const uint16_t gsm690_5_15_bitorder[]; /* AMR 5.15 kbits */ extern const uint16_t gsm690_4_75_bitorder[]; /* AMR 4.75 kbits */ - -#endif /* _OSMOCOM_CODEC_H */ diff --git a/include/osmocom/core/application.h b/include/osmocom/core/application.h index 3457169..ecaeaa8 100644 --- a/include/osmocom/core/application.h +++ b/include/osmocom/core/application.h @@ -1,5 +1,4 @@ -#ifndef OSMO_APPLICATION_H -#define OSMO_APPLICATION_H +#pragma once /*! * \file application.h @@ -19,5 +18,3 @@ void osmo_init_ignore_signals(void); int osmo_init_logging(const struct log_info *); int osmo_daemonize(void); - -#endif diff --git a/include/osmocom/core/backtrace.h b/include/osmocom/core/backtrace.h index a24290c..0c9b6ef 100644 --- a/include/osmocom/core/backtrace.h +++ b/include/osmocom/core/backtrace.h @@ -1,7 +1,4 @@ -#ifndef _OSMO_BACKTRACE_H_ -#define _OSMO_BACKTRACE_H_ +#pragma once void osmo_generate_backtrace(void); void osmo_log_backtrace(int subsys, int level); - -#endif diff --git a/include/osmocom/core/bits.h b/include/osmocom/core/bits.h index 4c68532..d4ab505 100644 --- a/include/osmocom/core/bits.h +++ b/include/osmocom/core/bits.h @@ -1,5 +1,4 @@ -#ifndef _OSMO_BITS_H -#define _OSMO_BITS_H +#pragma once #include @@ -74,5 +73,3 @@ uint32_t osmo_revbytebits_8(uint8_t x); void osmo_revbytebits_buf(uint8_t *buf, int len); /*! @} */ - -#endif /* _OSMO_BITS_H */ diff --git a/include/osmocom/core/bitvec.h b/include/osmocom/core/bitvec.h index 9c000d0..3138226 100644 --- a/include/osmocom/core/bitvec.h +++ b/include/osmocom/core/bitvec.h @@ -1,5 +1,4 @@ -#ifndef _BITVEC_H -#define _BITVEC_H +#pragma once /* bit vector utility routines */ @@ -66,5 +65,3 @@ int bitvec_find_bit_pos(const struct bitvec *bv, unsigned int n, enum bit_value int bitvec_spare_padding(struct bitvec *bv, unsigned int up_to_bit); /*! @} */ - -#endif /* _BITVEC_H */ diff --git a/include/osmocom/core/conv.h b/include/osmocom/core/conv.h index 4cc791f..e7f6bd6 100644 --- a/include/osmocom/core/conv.h +++ b/include/osmocom/core/conv.h @@ -28,8 +28,7 @@ * Osmocom convolutional encoder and decoder */ -#ifndef __OSMO_CONV_H__ -#define __OSMO_CONV_H__ +#pragma once #include @@ -142,5 +141,3 @@ int osmo_conv_decode(const struct osmo_conv_code *code, /*! @} */ - -#endif /* __OSMO_CONV_H__ */ diff --git a/include/osmocom/core/crc16.h b/include/osmocom/core/crc16.h index 0e52417..83b2e5f 100644 --- a/include/osmocom/core/crc16.h +++ b/include/osmocom/core/crc16.h @@ -15,8 +15,7 @@ * Version 2. See the file COPYING for more details. */ -#ifndef __CRC16_H -#define __CRC16_H +#pragma once #include @@ -30,5 +29,3 @@ static inline uint16_t osmo_crc16_byte(uint16_t crc, const uint8_t data) { return (crc >> 8) ^ osmo_crc16_table[(crc ^ data) & 0xff]; } - -#endif /* __CRC16_H */ diff --git a/include/osmocom/core/crcXXgen.h.tpl b/include/osmocom/core/crcXXgen.h.tpl index a931bc3..164f720 100644 --- a/include/osmocom/core/crcXXgen.h.tpl +++ b/include/osmocom/core/crcXXgen.h.tpl @@ -20,8 +20,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef __OSMO_CRCXXGEN_H__ -#define __OSMO_CRCXXGEN_H__ +#pragma once /*! \addtogroup crcgen * @{ @@ -54,6 +53,4 @@ void osmo_crcXXgen_set_bits(const struct osmo_crcXXgen_code *code, /*! @} */ -#endif /* __OSMO_CRCXXGEN_H__ */ - /* vim: set syntax=c: */ diff --git a/include/osmocom/core/crcgen.h b/include/osmocom/core/crcgen.h index 69cef04..b39b55d 100644 --- a/include/osmocom/core/crcgen.h +++ b/include/osmocom/core/crcgen.h @@ -20,8 +20,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef __OSMO_CRCGEN_H__ -#define __OSMO_CRCGEN_H__ +#pragma once /*! \defgroup crcgen Osmocom generic CRC routines * @{ @@ -37,5 +36,3 @@ #include /*! @} */ - -#endif /* __OSMO_CRCGEN_H__ */ diff --git a/include/osmocom/core/defs.h b/include/osmocom/core/defs.h index 5ffee04..aebe925 100644 --- a/include/osmocom/core/defs.h +++ b/include/osmocom/core/defs.h @@ -1,5 +1,4 @@ -#ifndef OSMOCORE_DEFS_H -#define OSMOCORE_DEFS_H +#pragma once /*! \defgroup utils General-purpose utility functions * @{ @@ -46,5 +45,3 @@ #undef _OSMO_HAS_ATTRIBUTE_DEPRECATED /*! @} */ - -#endif diff --git a/include/osmocom/core/gsmtap.h b/include/osmocom/core/gsmtap.h index 4694219..69bd108 100644 --- a/include/osmocom/core/gsmtap.h +++ b/include/osmocom/core/gsmtap.h @@ -1,5 +1,4 @@ -#ifndef _GSMTAP_H -#define _GSMTAP_H +#pragma once /* gsmtap header, pseudo-header in front of the actua GSM payload */ @@ -239,5 +238,3 @@ struct gsmtap_hdr { uint8_t res; /* reserved for future use (RFU) */ } __attribute__((packed)); - -#endif /* _GSMTAP_H */ diff --git a/include/osmocom/core/gsmtap_util.h b/include/osmocom/core/gsmtap_util.h index eaa32a0..a5c03e7 100644 --- a/include/osmocom/core/gsmtap_util.h +++ b/include/osmocom/core/gsmtap_util.h @@ -1,5 +1,4 @@ -#ifndef _GSMTAP_UTIL_H -#define _GSMTAP_UTIL_H +#pragma once #include #include @@ -55,5 +54,3 @@ int gsmtap_send(struct gsmtap_inst *gti, uint16_t arfcn, uint8_t ts, unsigned int len); /*! @} */ - -#endif /* _GSMTAP_UTIL_H */ diff --git a/include/osmocom/core/linuxlist.h b/include/osmocom/core/linuxlist.h index fb99c5e..b684152 100644 --- a/include/osmocom/core/linuxlist.h +++ b/include/osmocom/core/linuxlist.h @@ -1,5 +1,4 @@ -#ifndef _LINUX_LLIST_H -#define _LINUX_LLIST_H +#pragma once #include @@ -355,6 +354,3 @@ static inline void llist_splice_init(struct llist_head *llist, #define llist_for_each_continue_rcu(pos, head) \ for ((pos) = (pos)->next, prefetch((pos)->next); (pos) != (head); \ (pos) = (pos)->next, ({ smp_read_barrier_depends(); 0;}), prefetch((pos)->next)) - - -#endif diff --git a/include/osmocom/core/linuxrbtree.h b/include/osmocom/core/linuxrbtree.h index 079f440..ef8bc15 100644 --- a/include/osmocom/core/linuxrbtree.h +++ b/include/osmocom/core/linuxrbtree.h @@ -91,8 +91,7 @@ static inline struct page * rb_insert_page_cache(struct inode * inode, ----------------------------------------------------------------------- */ -#ifndef _LINUX_RBTREE_H -#define _LINUX_RBTREE_H +#pragma once #include @@ -156,5 +155,3 @@ static inline void rb_link_node(struct rb_node * node, struct rb_node * parent, *rb_link = node; } - -#endif /* _LINUX_RBTREE_H */ diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index 1d57e22..caeea06 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -1,5 +1,4 @@ -#ifndef _OSMOCORE_LOGGING_H -#define _OSMOCORE_LOGGING_H +#pragma once /*! \defgroup logging Osmocom logging framework * @{ @@ -216,5 +215,3 @@ struct log_target *log_target_find(int type, const char *fname); extern struct llist_head osmo_log_target_list; /*! @} */ - -#endif /* _OSMOCORE_LOGGING_H */ diff --git a/include/osmocom/core/loggingrb.h b/include/osmocom/core/loggingrb.h index a6f377b..acdccfb 100644 --- a/include/osmocom/core/loggingrb.h +++ b/include/osmocom/core/loggingrb.h @@ -1,5 +1,4 @@ -#ifndef _LOGGINGRB_H -#define _LOGGINGRB_H +#pragma once /* (C) 2012-2013 by Katerina Barone-Adesi * All Rights Reserved @@ -36,5 +35,3 @@ const char *log_target_rb_get(struct log_target const *target, size_t logindex); struct log_target *log_target_create_rb(size_t size); /*! @} */ - -#endif /* _LOGGINGRB_H */ diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h index 33e8081..bf83d67 100644 --- a/include/osmocom/core/msgb.h +++ b/include/osmocom/core/msgb.h @@ -1,5 +1,4 @@ -#ifndef _MSGB_H -#define _MSGB_H +#pragma once /* (C) 2008 by Harald Welte * All Rights Reserved @@ -413,5 +412,3 @@ uint8_t *msgb_data(const struct msgb *msg); void msgb_set_talloc_ctx(void *ctx); /*! @} */ - -#endif /* _MSGB_H */ diff --git a/include/osmocom/core/msgfile.h b/include/osmocom/core/msgfile.h index c5e67a4..cab97b2 100644 --- a/include/osmocom/core/msgfile.h +++ b/include/osmocom/core/msgfile.h @@ -19,8 +19,7 @@ * */ -#ifndef MSG_FILE_H -#define MSG_FILE_H +#pragma once #include @@ -45,5 +44,3 @@ struct osmo_config_list { }; struct osmo_config_list* osmo_config_list_parse(void *ctx, const char *filename); - -#endif diff --git a/include/osmocom/core/panic.h b/include/osmocom/core/panic.h index fd5cf20..5d575c4 100644 --- a/include/osmocom/core/panic.h +++ b/include/osmocom/core/panic.h @@ -1,5 +1,4 @@ -#ifndef OSMOCORE_PANIC_H -#define OSMOCORE_PANIC_H +#pragma once /*! \addtogroup utils * @{ @@ -16,5 +15,3 @@ extern void osmo_panic(const char *fmt, ...); extern void osmo_set_panic_handler(osmo_panic_handler_t h); /*! @} */ - -#endif /* OSMOCORE_PANIC_H */ diff --git a/include/osmocom/core/plugin.h b/include/osmocom/core/plugin.h index 6c0eccc..aef1dfc 100644 --- a/include/osmocom/core/plugin.h +++ b/include/osmocom/core/plugin.h @@ -1,6 +1,3 @@ -#ifndef _OSMO_PLUGIN_H -#define _OSMO_PLUGIN_H +#pragma once int osmo_plugin_load_all(const char *directory); - -#endif diff --git a/include/osmocom/core/prim.h b/include/osmocom/core/prim.h index f61d808..935ce51 100644 --- a/include/osmocom/core/prim.h +++ b/include/osmocom/core/prim.h @@ -1,5 +1,4 @@ -#ifndef OSMO_PRIMITIVE_H -#define OSMO_PRIMITIVE_H +#pragma once /*! \defgroup prim Osmocom primitives * @{ @@ -56,5 +55,3 @@ osmo_prim_init(struct osmo_prim_hdr *oph, unsigned int sap, typedef int (*osmo_prim_cb)(struct osmo_prim_hdr *oph, void *ctx); /*! @} */ - -#endif /* OSMO_PRIMITIVE_H */ diff --git a/include/osmocom/core/rate_ctr.h b/include/osmocom/core/rate_ctr.h index 24577fd..821c7cf 100644 --- a/include/osmocom/core/rate_ctr.h +++ b/include/osmocom/core/rate_ctr.h @@ -1,5 +1,4 @@ -#ifndef _RATE_CTR_H -#define _RATE_CTR_H +#pragma once /*! \defgroup rate_ctr Rate counters * @{ @@ -85,4 +84,3 @@ struct rate_ctr_group *rate_ctr_get_group_by_name_idx(const char *name, const un const struct rate_ctr *rate_ctr_get_by_name(const struct rate_ctr_group *ctrg, const char *name); /*! @} */ -#endif /* RATE_CTR_H */ diff --git a/include/osmocom/core/select.h b/include/osmocom/core/select.h index efdd716..b6b9e82 100644 --- a/include/osmocom/core/select.h +++ b/include/osmocom/core/select.h @@ -1,5 +1,4 @@ -#ifndef _BSC_SELECT_H -#define _BSC_SELECT_H +#pragma once #include @@ -41,5 +40,3 @@ void osmo_fd_unregister(struct osmo_fd *fd); int osmo_select_main(int polling); /*! @} */ - -#endif /* _BSC_SELECT_H */ diff --git a/include/osmocom/core/serial.h b/include/osmocom/core/serial.h index 1640a6d..e3f7a9f 100644 --- a/include/osmocom/core/serial.h +++ b/include/osmocom/core/serial.h @@ -28,8 +28,7 @@ * Osmocom serial port helpers */ -#ifndef __OSMO_SERIAL_H__ -#define __OSMO_SERIAL_H__ +#pragma once #include @@ -39,5 +38,3 @@ int osmo_serial_set_custom_baudrate(int fd, int baudrate); int osmo_serial_clear_custom_baudrate(int fd); /*! @} */ - -#endif /* __OSMO_SERIAL_H__ */ diff --git a/include/osmocom/core/signal.h b/include/osmocom/core/signal.h index 19a2688..6f56496 100644 --- a/include/osmocom/core/signal.h +++ b/include/osmocom/core/signal.h @@ -1,5 +1,4 @@ -#ifndef OSMO_SIGNAL_H -#define OSMO_SIGNAL_H +#pragma once #include @@ -43,5 +42,3 @@ void osmo_signal_unregister_handler(unsigned int subsys, osmo_signal_cbfn *cbfn, void osmo_signal_dispatch(unsigned int subsys, unsigned int signal, void *signal_data); /*! @} */ - -#endif /* OSMO_SIGNAL_H */ diff --git a/include/osmocom/core/socket.h b/include/osmocom/core/socket.h index cb1b7a8..1df28c9 100644 --- a/include/osmocom/core/socket.h +++ b/include/osmocom/core/socket.h @@ -1,5 +1,4 @@ -#ifndef _OSMOCORE_SOCKET_H -#define _OSMOCORE_SOCKET_H +#pragma once /*! \defgroup socket Socket convenience functions * @{ @@ -37,5 +36,3 @@ int osmo_sock_unix_init_ofd(struct osmo_fd *ofd, uint16_t type, uint8_t proto, const char *socket_path, unsigned int flags); /*! @} */ - -#endif /* _OSMOCORE_SOCKET_H */ diff --git a/include/osmocom/core/statistics.h b/include/osmocom/core/statistics.h index ade0074..de250be 100644 --- a/include/osmocom/core/statistics.h +++ b/include/osmocom/core/statistics.h @@ -1,5 +1,4 @@ -#ifndef _STATISTICS_H -#define _STATISTICS_H +#pragma once /*! \file statistics.h * \brief Common routines regarding statistics */ @@ -49,5 +48,3 @@ int osmo_counters_for_each(int (*handle_counter)(struct osmo_counter *, void *), * \returns pointer to counter (\ref osmo_counter) or NULL otherwise */ struct osmo_counter *osmo_counter_get_by_name(const char *name); - -#endif /* _STATISTICS_H */ diff --git a/include/osmocom/core/strrb.h b/include/osmocom/core/strrb.h index cfc56dc..c563d1b 100644 --- a/include/osmocom/core/strrb.h +++ b/include/osmocom/core/strrb.h @@ -1,5 +1,4 @@ -#ifndef _STRRB_H -#define _STRRB_H +#pragma once /* (C) 2012-2013 by Katerina Barone-Adesi * All Rights Reserved @@ -54,5 +53,3 @@ size_t osmo_strrb_elements(const struct osmo_strrb *rb); int osmo_strrb_add(struct osmo_strrb *rb, const char *data); /*! @} */ - -#endif /* _STRRB_H */ diff --git a/include/osmocom/core/talloc.h b/include/osmocom/core/talloc.h index f7f7643..dde102b 100644 --- a/include/osmocom/core/talloc.h +++ b/include/osmocom/core/talloc.h @@ -1,5 +1,4 @@ -#ifndef _TALLOC_H_ -#define _TALLOC_H_ +#pragma once /* Unix SMB/CIFS implementation. Samba temporary memory allocation functions @@ -188,5 +187,3 @@ char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3 char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); void talloc_set_abort_fn(void (*abort_fn)(const char *reason)); - -#endif diff --git a/include/osmocom/core/timer.h b/include/osmocom/core/timer.h index d37af80..d734357 100644 --- a/include/osmocom/core/timer.h +++ b/include/osmocom/core/timer.h @@ -26,8 +26,7 @@ * \brief Osmocom timer handling routines */ -#ifndef TIMER_H -#define TIMER_H +#pragma once #include @@ -85,5 +84,3 @@ int osmo_timers_update(void); int osmo_timers_check(void); /*! @} */ - -#endif diff --git a/include/osmocom/core/timer_compat.h b/include/osmocom/core/timer_compat.h index d86c109..fb2967b 100644 --- a/include/osmocom/core/timer_compat.h +++ b/include/osmocom/core/timer_compat.h @@ -26,8 +26,7 @@ * \brief Compatibility header with some helpers */ -#ifndef TIMER_COMPAT_H -#define TIMER_COMPAT_H +#pragma once /* Convenience macros for operations on timevals. @@ -75,5 +74,3 @@ /*! @} */ - -#endif /* TIMER_COMPAT_H */ diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h index 2333de6..c08e775 100644 --- a/include/osmocom/core/utils.h +++ b/include/osmocom/core/utils.h @@ -1,5 +1,4 @@ -#ifndef OSMOCORE_UTIL_H -#define OSMOCORE_UTIL_H +#pragma once #include @@ -62,5 +61,3 @@ do { \ /*! @} */ - -#endif diff --git a/include/osmocom/core/write_queue.h b/include/osmocom/core/write_queue.h index 816c036..4e0fdf3 100644 --- a/include/osmocom/core/write_queue.h +++ b/include/osmocom/core/write_queue.h @@ -20,8 +20,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ -#ifndef OSMO_WQUEUE_H -#define OSMO_WQUEUE_H +#pragma once /*! \defgroup write_queue Osmocom msgb write queues * @{ @@ -59,5 +58,3 @@ int osmo_wqueue_enqueue(struct osmo_wqueue *queue, struct msgb *data); int osmo_wqueue_bfd_cb(struct osmo_fd *fd, unsigned int what); /*! @} */ - -#endif diff --git a/include/osmocom/crypt/auth.h b/include/osmocom/crypt/auth.h index 871e7c8..bed48e7 100644 --- a/include/osmocom/crypt/auth.h +++ b/include/osmocom/crypt/auth.h @@ -1,5 +1,4 @@ -#ifndef _OSMOCRYPTO_AUTH_H -#define _OSMOCRYPTO_AUTH_H +#pragma once /*! \addtogroup auth * @{ @@ -96,6 +95,4 @@ int osmo_auth_supported(enum osmo_auth_algo algo); const char *osmo_auth_alg_name(enum osmo_auth_algo alg); enum osmo_auth_algo osmo_auth_alg_parse(const char *name); -#endif /* _OSMOCRYPTO_AUTH_H */ - /* @} */ diff --git a/include/osmocom/crypt/gprs_cipher.h b/include/osmocom/crypt/gprs_cipher.h index 3051071..940b07b 100644 --- a/include/osmocom/crypt/gprs_cipher.h +++ b/include/osmocom/crypt/gprs_cipher.h @@ -1,5 +1,4 @@ -#ifndef _GPRS_CIPHER_H -#define _GPRS_CIPHER_H +#pragma once #include @@ -50,5 +49,3 @@ uint32_t gprs_cipher_gen_input_ui(uint32_t iov_ui, uint8_t sapi, uint32_t lfn, u /* GSM TS 04.64 / Section A.2.1 : Generation of 'input' */ uint32_t gprs_cipher_gen_input_i(uint32_t iov_i, uint32_t lfn, uint32_t oc); - -#endif /* _GPRS_CIPHER_H */ diff --git a/include/osmocom/gprs/gprs_bssgp.h b/include/osmocom/gprs/gprs_bssgp.h index eb4e721..f229253 100644 --- a/include/osmocom/gprs/gprs_bssgp.h +++ b/include/osmocom/gprs/gprs_bssgp.h @@ -1,5 +1,4 @@ -#ifndef _GPRS_BSSGP_H -#define _GPRS_BSSGP_H +#pragma once #include #include @@ -207,5 +206,3 @@ int bssgp_vty_init(void); void bssgp_set_log_ss(int ss); int bssgp_prim_cb(struct osmo_prim_hdr *oph, void *ctx); - -#endif /* _GPRS_BSSGP_H */ diff --git a/include/osmocom/gprs/gprs_bssgp_bss.h b/include/osmocom/gprs/gprs_bssgp_bss.h index f34281e..9e0cb66 100644 --- a/include/osmocom/gprs/gprs_bssgp_bss.h +++ b/include/osmocom/gprs/gprs_bssgp_bss.h @@ -1,5 +1,4 @@ -#ifndef _BSSGP_BSS_H -#define _BSSGP_BSS_H +#pragma once #include #include @@ -72,4 +71,3 @@ int bssgp_tx_fc_bvc(struct bssgp_bvc_ctx *bctx, uint8_t tag, int bssgp_tx_fc_ms(struct bssgp_bvc_ctx *bctx, uint32_t tlli, uint8_t tag, uint32_t ms_bucket_size, uint32_t bucket_leak_rate, uint8_t *bucket_full_ratio); -#endif diff --git a/include/osmocom/gprs/gprs_msgb.h b/include/osmocom/gprs/gprs_msgb.h index e277696..06f5cca 100644 --- a/include/osmocom/gprs/gprs_msgb.h +++ b/include/osmocom/gprs/gprs_msgb.h @@ -1,5 +1,4 @@ -#ifndef _LIBGB_MSGB_H -#define _LIBGB_MSGB_H +#pragma once #include /* the data structure stored in msgb->cb for libgb apps */ @@ -34,4 +33,3 @@ struct libgb_msgb_cb { #include int gprs_log_filter_fn(const struct log_context *ctx, struct log_target *tar); -#endif diff --git a/include/osmocom/gprs/gprs_ns.h b/include/osmocom/gprs/gprs_ns.h index 296800e..b4af61b 100644 --- a/include/osmocom/gprs/gprs_ns.h +++ b/include/osmocom/gprs/gprs_ns.h @@ -1,5 +1,4 @@ -#ifndef _GPRS_NS_H -#define _GPRS_NS_H +#pragma once #include @@ -215,5 +214,3 @@ struct ns_signal_data { void gprs_ns_set_log_ss(int ss); /*! }@ */ - -#endif diff --git a/include/osmocom/gprs/gprs_ns_frgre.h b/include/osmocom/gprs/gprs_ns_frgre.h index abcd43f..72ef7d1 100644 --- a/include/osmocom/gprs/gprs_ns_frgre.h +++ b/include/osmocom/gprs/gprs_ns_frgre.h @@ -1,6 +1,3 @@ -#ifndef _GPRS_NS_FRGRE_H -#define _GPRS_NS_FRGRE_H +#pragma once int gprs_ns_frgre_sendmsg(struct gprs_nsvc *nsvc, struct msgb *msg); - -#endif diff --git a/include/osmocom/gprs/protocol/gsm_08_16.h b/include/osmocom/gprs/protocol/gsm_08_16.h index 4c3eda3..8b2ac56 100644 --- a/include/osmocom/gprs/protocol/gsm_08_16.h +++ b/include/osmocom/gprs/protocol/gsm_08_16.h @@ -1,5 +1,4 @@ -#ifndef _OSMO_08_16_H -#define _OSMO_08_16_H +#pragma once /* GPRS Networks Service (NS) messages on the Gb interface * 3GPP TS 08.16 version 8.0.1 Release 1999 / ETSI TS 101 299 V8.0.1 (2002-05) @@ -81,5 +80,3 @@ enum ns_cause { NS_CAUSE_UNKN_IP_ADDR = 0x13, NS_CAUSE_UNKN_IP_TEST_FAILED = 0x14, }; - -#endif diff --git a/include/osmocom/gprs/protocol/gsm_08_18.h b/include/osmocom/gprs/protocol/gsm_08_18.h index 3a351ea..529e988 100644 --- a/include/osmocom/gprs/protocol/gsm_08_18.h +++ b/include/osmocom/gprs/protocol/gsm_08_18.h @@ -1,5 +1,4 @@ -#ifndef _OSMO_08_18_H -#define _OSMO_08_18_H +#pragma once #include @@ -140,5 +139,3 @@ enum gprs_bssgp_cause { BSSGP_CAUSE_PROTO_ERR_UNSPEC = 0x27, BSSGP_CAUSE_PDU_INCOMP_FEAT = 0x28, }; - -#endif diff --git a/include/osmocom/gsm/a5.h b/include/osmocom/gsm/a5.h index 2f78a92..c076734 100644 --- a/include/osmocom/gsm/a5.h +++ b/include/osmocom/gsm/a5.h @@ -20,8 +20,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef __OSMO_A5_H__ -#define __OSMO_A5_H__ +#pragma once #include @@ -59,5 +58,3 @@ 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); /*! @} */ - -#endif /* __OSMO_A5_H__ */ diff --git a/include/osmocom/gsm/abis_nm.h b/include/osmocom/gsm/abis_nm.h index 86b97eb..bc13ffe 100644 --- a/include/osmocom/gsm/abis_nm.h +++ b/include/osmocom/gsm/abis_nm.h @@ -1,5 +1,4 @@ -#ifndef _OSMO_GSM_ABIS_NM_H -#define _OSMO_GSM_ABIS_NM_H +#pragma once /*! \defgroup oml A-bis OML * @{ @@ -47,5 +46,3 @@ int abis_nm_chcomb4pchan(enum gsm_phys_chan_config pchan); enum gsm_phys_chan_config abis_nm_pchan4chcomb(uint8_t chcomb); /*! @} */ - -#endif /* _OSMO_GSM_ABIS_NM_H */ diff --git a/include/osmocom/gsm/comp128.h b/include/osmocom/gsm/comp128.h index e4587d4..33b997a 100644 --- a/include/osmocom/gsm/comp128.h +++ b/include/osmocom/gsm/comp128.h @@ -4,8 +4,7 @@ * See comp128.c for details */ -#ifndef __COMP128_H__ -#define __COMP128_H__ +#pragma once #include @@ -17,6 +16,3 @@ * kc : uint8_t [8] */ void comp128(const uint8_t *ki, const uint8_t *srand, uint8_t *sres, uint8_t *kc); - -#endif /* __COMP128_H__ */ - diff --git a/include/osmocom/gsm/comp128v23.h b/include/osmocom/gsm/comp128v23.h index bebeb59..31d3933 100644 --- a/include/osmocom/gsm/comp128v23.h +++ b/include/osmocom/gsm/comp128v23.h @@ -4,8 +4,7 @@ * See comp128v23.c for details */ -#ifndef __COMP128V23_H__ -#define __COMP128V23_H__ +#pragma once #include @@ -19,5 +18,3 @@ */ int comp128v2(const uint8_t *ki, const uint8_t *rand, uint8_t *sres, uint8_t *kc); int comp128v3(const uint8_t *ki, const uint8_t *rand, uint8_t *sres, uint8_t *kc); - -#endif /* __COMP128V23_H__ */ diff --git a/include/osmocom/gsm/gan.h b/include/osmocom/gsm/gan.h index ab4c1e4..6f2b535 100644 --- a/include/osmocom/gsm/gan.h +++ b/include/osmocom/gsm/gan.h @@ -1,9 +1,6 @@ -#ifndef _OSMO_GSM_GAN_H -#define _OSMO_GSM_GAN_H +#pragma once #include extern const struct value_string gan_msgt_vals[]; static const struct value_string gan_pdisc_vals[]; - -#endif diff --git a/include/osmocom/gsm/gsm0411_smc.h b/include/osmocom/gsm/gsm0411_smc.h index 239ee13..89964fa 100644 --- a/include/osmocom/gsm/gsm0411_smc.h +++ b/include/osmocom/gsm/gsm0411_smc.h @@ -1,5 +1,4 @@ -#ifndef _GSM0411_SMC_H -#define _GSM0411_SMC_H +#pragma once #include #include @@ -60,5 +59,3 @@ int gsm411_smc_send(struct gsm411_smc_inst *inst, int msg_type, /* message from lower layer */ int gsm411_smc_recv(struct gsm411_smc_inst *inst, int msg_type, struct msgb *msg, int cp_msg_type); - -#endif /* _GSM0411_SMC_H */ diff --git a/include/osmocom/gsm/gsm0411_smr.h b/include/osmocom/gsm/gsm0411_smr.h index b061492..bc908a7 100644 --- a/include/osmocom/gsm/gsm0411_smr.h +++ b/include/osmocom/gsm/gsm0411_smr.h @@ -1,5 +1,4 @@ -#ifndef _GSM0411_SMR_H -#define _GSM0411_SMR_H +#pragma once #include @@ -41,6 +40,3 @@ int gsm411_smr_send(struct gsm411_smr_inst *inst, int msg_type, /* message from lower layer */ int gsm411_smr_recv(struct gsm411_smr_inst *inst, int msg_type, struct msgb *msg); - -#endif /* _GSM0411_SMR_H */ - diff --git a/include/osmocom/gsm/gsm0411_utils.h b/include/osmocom/gsm/gsm0411_utils.h index ad368e6..7005010 100644 --- a/include/osmocom/gsm/gsm0411_utils.h +++ b/include/osmocom/gsm/gsm0411_utils.h @@ -1,5 +1,4 @@ -#ifndef _GSM0411_UTILS_H -#define _GSM0411_UTILS_H +#pragma once #include @@ -34,5 +33,3 @@ int gsm411_push_rp_header(struct msgb *msg, uint8_t rp_msg_type, /* Prefix msg with a 04.08/04.11 CP header */ int gsm411_push_cp_header(struct msgb *msg, uint8_t proto, uint8_t trans, uint8_t msg_type); - -#endif /* _GSM0411_UTILS_H */ diff --git a/include/osmocom/gsm/gsm0480.h b/include/osmocom/gsm/gsm0480.h index d6626d6..b128162 100644 --- a/include/osmocom/gsm/gsm0480.h +++ b/include/osmocom/gsm/gsm0480.h @@ -1,5 +1,4 @@ -#ifndef gsm0480_h -#define gsm0480_h +#pragma once #include #include @@ -22,5 +21,3 @@ struct msgb *gsm0480_create_notifySS(const char *text); int gsm0480_wrap_invoke(struct msgb *msg, int op, int link_id); int gsm0480_wrap_facility(struct msgb *msg); - -#endif diff --git a/include/osmocom/gsm/gsm0502.h b/include/osmocom/gsm/gsm0502.h index 46b629e..6ee5a60 100644 --- a/include/osmocom/gsm/gsm0502.h +++ b/include/osmocom/gsm/gsm0502.h @@ -1,5 +1,4 @@ -#ifndef OSMOCOM_GSM_0502_H -#define OSMOCOM_GSM_0502_H +#pragma once #include @@ -34,5 +33,3 @@ gsm0502_get_paging_group(uint64_t imsi, unsigned int bs_cc_chans, unsigned int gsm0502_calc_paging_group(struct gsm48_control_channel_descr *chan_desc, uint64_t imsi); - -#endif diff --git a/include/osmocom/gsm/gsm0808.h b/include/osmocom/gsm/gsm0808.h index 5127c00..a7e102c 100644 --- a/include/osmocom/gsm/gsm0808.h +++ b/include/osmocom/gsm/gsm0808.h @@ -17,8 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * */ -#ifndef OSMOCORE_GSM0808_H -#define OSMOCORE_GSM0808_H +#pragma once #include "tlv.h" @@ -47,5 +46,3 @@ const struct tlv_definition *gsm0808_att_tlvdef(void); const char *gsm0808_bssmap_name(uint8_t msg_type); const char *gsm0808_bssap_name(uint8_t msg_type); - -#endif diff --git a/include/osmocom/gsm/gsm48.h b/include/osmocom/gsm/gsm48.h index 1e7498a..151b14e 100644 --- a/include/osmocom/gsm/gsm48.h +++ b/include/osmocom/gsm/gsm48.h @@ -1,5 +1,4 @@ -#ifndef _OSMOCORE_GSM48_H -#define _OSMOCORE_GSM48_H +#pragma once #include #include @@ -36,5 +35,3 @@ void gsm48_parse_ra(struct gprs_ra_id *raid, const uint8_t *buf); int gsm48_construct_ra(uint8_t *buf, const struct gprs_ra_id *raid); int gsm48_number_of_paging_subchannels(struct gsm48_control_channel_descr *chan_desc); - -#endif diff --git a/include/osmocom/gsm/gsm48_ie.h b/include/osmocom/gsm/gsm48_ie.h index f4fce25..8445486 100644 --- a/include/osmocom/gsm/gsm48_ie.h +++ b/include/osmocom/gsm/gsm48_ie.h @@ -1,5 +1,4 @@ -#ifndef _OSMOCORE_GSM48_IE_H -#define _OSMOCORE_GSM48_IE_H +#pragma once #include #include @@ -113,5 +112,3 @@ struct gsm_sysinfo_freq { /* decode "Cell Channel Description" (10.5.2.1b) and other frequency lists */ int gsm48_decode_freq_list(struct gsm_sysinfo_freq *f, uint8_t *cd, uint8_t len, uint8_t mask, uint8_t frqt); - -#endif diff --git a/include/osmocom/gsm/gsm_utils.h b/include/osmocom/gsm/gsm_utils.h index 02bfe4c..6eab7ac 100644 --- a/include/osmocom/gsm/gsm_utils.h +++ b/include/osmocom/gsm/gsm_utils.h @@ -22,8 +22,7 @@ * */ -#ifndef GSM_UTILS_H -#define GSM_UTILS_H +#pragma once #include #include @@ -203,6 +202,3 @@ int gsm_7bit_decode_ussd(char *decoded, const uint8_t *user_data, uint8_t length int gsm_7bit_encode(uint8_t *result, const char *data) OSMO_DEPRECATED("Use gsm_7bit_encode_n() instead"); int gsm_7bit_encode_ussd(uint8_t *result, const char *data, int *octets_written) OSMO_DEPRECATED("Use gsm_7bit_encode_n_ussd() instead"); int gsm_7bit_encode_oct(uint8_t *result, const char *data, int *octets_written) OSMO_DEPRECATED("Use gsm_7bit_encode_n() instead"); - - -#endif diff --git a/include/osmocom/gsm/l1sap.h b/include/osmocom/gsm/l1sap.h index c21abe5..9f3fe98 100644 --- a/include/osmocom/gsm/l1sap.h +++ b/include/osmocom/gsm/l1sap.h @@ -1,5 +1,4 @@ -#ifndef _OSMOCOM_L1SAP_H -#define _OSMOCOM_L1SAP_H +#pragma once #include @@ -121,5 +120,3 @@ struct osmo_phsap_prim { struct mph_info_param info; } u; /*!< \brief request-specific data */ }; - -#endif /* _OSMOCOM_L1SAP_H */ diff --git a/include/osmocom/gsm/lapd_core.h b/include/osmocom/gsm/lapd_core.h index f88fb11..42ef417 100644 --- a/include/osmocom/gsm/lapd_core.h +++ b/include/osmocom/gsm/lapd_core.h @@ -1,5 +1,4 @@ -#ifndef _OSMOCOM_LAPD_H -#define _OSMOCOM_LAPD_H +#pragma once #include @@ -170,5 +169,3 @@ int lapd_ph_data_ind(struct msgb *msg, struct lapd_msg_ctx *lctx); int lapd_recv_dlsap(struct osmo_dlsap_prim *dp, struct lapd_msg_ctx *lctx); /*! @} */ - -#endif /* _OSMOCOM_LAPD_H */ diff --git a/include/osmocom/gsm/lapdm.h b/include/osmocom/gsm/lapdm.h index 9393406..84d109d 100644 --- a/include/osmocom/gsm/lapdm.h +++ b/include/osmocom/gsm/lapdm.h @@ -1,5 +1,4 @@ -#ifndef _OSMOCOM_LAPDM_H -#define _OSMOCOM_LAPDM_H +#pragma once #include #include @@ -112,5 +111,3 @@ void lapdm_channel_set_flags(struct lapdm_channel *lc, unsigned int flags); int lapdm_phsap_dequeue_prim(struct lapdm_entity *le, struct osmo_phsap_prim *pp); /*! @} */ - -#endif /* _OSMOCOM_LAPDM_H */ diff --git a/include/osmocom/gsm/meas_rep.h b/include/osmocom/gsm/meas_rep.h index bd24bbe..09c2c4f 100644 --- a/include/osmocom/gsm/meas_rep.h +++ b/include/osmocom/gsm/meas_rep.h @@ -1,5 +1,4 @@ -#ifndef _OSMO_MEAS_REP_H -#define _OSMO_MEAS_REP_H +#pragma once #include @@ -25,5 +24,3 @@ enum meas_rep_field { MEAS_REP_UL_RXQUAL_FULL, MEAS_REP_UL_RXQUAL_SUB, }; - -#endif diff --git a/include/osmocom/gsm/mncc.h b/include/osmocom/gsm/mncc.h index a51267e..171db7a 100644 --- a/include/osmocom/gsm/mncc.h +++ b/include/osmocom/gsm/mncc.h @@ -1,5 +1,4 @@ -#ifndef _OSMOCORE_MNCC_H -#define _OSMOCORE_MNCC_H +#pragma once #include @@ -81,5 +80,3 @@ enum { GSM_MNCC_BCAP_OTHER_ITC = 5, GSM_MNCC_BCAP_RESERVED = 7, }; - -#endif diff --git a/include/osmocom/gsm/prim.h b/include/osmocom/gsm/prim.h index 5beb200..5f61dc7 100644 --- a/include/osmocom/gsm/prim.h +++ b/include/osmocom/gsm/prim.h @@ -1,5 +1,4 @@ -#ifndef OSMO_GSM_PRIM_H -#define OSMO_GSM_PRIM_H +#pragma once #include @@ -14,5 +13,3 @@ enum osmo_gsm_sap { SAP_BSSGP_NM, SAP_BSSGP_PFM, }; - -#endif diff --git a/include/osmocom/gsm/protocol/gsm_03_41.h b/include/osmocom/gsm/protocol/gsm_03_41.h index 54365cb..b6efb5e 100644 --- a/include/osmocom/gsm/protocol/gsm_03_41.h +++ b/include/osmocom/gsm/protocol/gsm_03_41.h @@ -1,5 +1,4 @@ -#ifndef PROTO_GSM_03_41_H -#define PROTO_GSM_03_41_H +#pragma once #include @@ -47,5 +46,3 @@ struct gsm341_etws_message { #define GSM341_GS_PLMN_WIDE 1 #define GSM341_GS_LA_WIDE 2 #define GSM341_GS_CELL_WIDE 3 - -#endif /* PROTO_GSM_03_41_H */ diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h index 8fa5d9a..9fcdddc 100644 --- a/include/osmocom/gsm/protocol/gsm_04_08.h +++ b/include/osmocom/gsm/protocol/gsm_04_08.h @@ -1,5 +1,4 @@ -#ifndef PROTO_GSM_04_08_H -#define PROTO_GSM_04_08_H +#pragma once #include @@ -1336,5 +1335,3 @@ struct gsm48_ra_id { #define GSM_MACBLOCK_LEN 23 #define GSM_MACBLOCK_PADDING 0x2b - -#endif /* PROTO_GSM_04_08_H */ diff --git a/include/osmocom/gsm/protocol/gsm_04_11.h b/include/osmocom/gsm/protocol/gsm_04_11.h index 38dd553..651adca 100644 --- a/include/osmocom/gsm/protocol/gsm_04_11.h +++ b/include/osmocom/gsm/protocol/gsm_04_11.h @@ -1,5 +1,4 @@ -#ifndef PROTO_GSM_04_11_H -#define PROTO_GSM_04_11_H +#pragma once #include @@ -186,5 +185,3 @@ enum sms_alphabet { #define GSM338_DCS_1111_CLASS1_ME 1 #define GSM338_DCS_1111_CLASS2_SIM 2 #define GSM338_DCS_1111_CLASS3_TE 3 /* See TS 07.05 */ - -#endif /* PROTO_GSM_04_11_H */ diff --git a/include/osmocom/gsm/protocol/gsm_04_12.h b/include/osmocom/gsm/protocol/gsm_04_12.h index 9b1538a..aa40648 100644 --- a/include/osmocom/gsm/protocol/gsm_04_12.h +++ b/include/osmocom/gsm/protocol/gsm_04_12.h @@ -1,5 +1,4 @@ -#ifndef PROTO_GSM_04_12_H -#define PROTO_GSM_04_12_H +#pragma once #include @@ -27,5 +26,3 @@ struct gsm412_sched_msg { uint8_t cbsms_msg_map[6]; uint8_t data[0]; } __attribute__((packed)); - -#endif diff --git a/include/osmocom/gsm/protocol/gsm_04_80.h b/include/osmocom/gsm/protocol/gsm_04_80.h index fa5c945..2aebb46 100644 --- a/include/osmocom/gsm/protocol/gsm_04_80.h +++ b/include/osmocom/gsm/protocol/gsm_04_80.h @@ -1,5 +1,4 @@ -#ifndef PROTO_GSM_04_80_H -#define PROTO_GSM_04_80_H +#pragma once /* GSM TS 04.80 definitions (Supplementary Services Specification, Formats and Coding) */ @@ -122,5 +121,3 @@ #define ASN1_PRINTABLE_STRING_TAG 0x13 #define ASN1_IA5_STRING_TAG 0x16 #define ASN1_UNICODE_STRING_TAG 0x1E - -#endif /* PROTO_GSM_04_80_H */ diff --git a/include/osmocom/gsm/protocol/gsm_08_08.h b/include/osmocom/gsm/protocol/gsm_08_08.h index 6b8f935..bf408eb 100644 --- a/include/osmocom/gsm/protocol/gsm_08_08.h +++ b/include/osmocom/gsm/protocol/gsm_08_08.h @@ -1,7 +1,6 @@ /* From GSM08.08 */ -#ifndef GSM_0808_H -#define GSM_0808_H +#pragma once #include @@ -299,5 +298,3 @@ enum gsm0808_permitted_speech { GSM0808_PERM_HR2 = GSM0808_PERM_FR2 | 0x4, GSM0808_PERM_HR3 = GSM0808_PERM_FR3 | 0x4, }; - -#endif diff --git a/include/osmocom/gsm/protocol/gsm_08_58.h b/include/osmocom/gsm/protocol/gsm_08_58.h index 89aafb8..3f01a92 100644 --- a/include/osmocom/gsm/protocol/gsm_08_58.h +++ b/include/osmocom/gsm/protocol/gsm_08_58.h @@ -1,5 +1,4 @@ -#ifndef PROTO_GSM_08_58_H -#define PROTO_GSM_08_58_H +#pragma once /* GSM Radio Signalling Link messages on the A-bis interface * 3GPP TS 08.58 version 8.6.0 Release 1999 / ETSI TS 100 596 V8.6.0 */ @@ -579,5 +578,3 @@ enum rsl_rel_mode { }; /*! @} */ - -#endif /* PROTO_GSM_08_58_H */ diff --git a/include/osmocom/gsm/protocol/gsm_12_21.h b/include/osmocom/gsm/protocol/gsm_12_21.h index ad0890c..4e8e72b 100644 --- a/include/osmocom/gsm/protocol/gsm_12_21.h +++ b/include/osmocom/gsm/protocol/gsm_12_21.h @@ -1,5 +1,4 @@ -#ifndef PROTO_GSM_12_21_H -#define PROTO_GSM_12_21_H +#pragma once /* GSM Network Management messages on the A-bis interface * 3GPP TS 12.21 version 8.0.0 Release 1999 / ETSI TS 100 623 V8.0.0 */ @@ -748,5 +747,3 @@ enum ipac_bcch_info_type { }; /*! @} */ - -#endif /* PROTO_GSM_12_21_H */ diff --git a/include/osmocom/gsm/protocol/gsm_44_318.h b/include/osmocom/gsm/protocol/gsm_44_318.h index cd5ec05..5d7f878 100644 --- a/include/osmocom/gsm/protocol/gsm_44_318.h +++ b/include/osmocom/gsm/protocol/gsm_44_318.h @@ -1,5 +1,4 @@ -#ifndef PROTO_GSM_44_318_H -#define PROTO_GSM_44_318_H +#pragma once #include @@ -197,4 +196,3 @@ struct gan_cch_desc_ie { #endif uint8_t access_class[2]; } __attribute__((packed)); -#endif /* PROTO_GSM_44_318_H */ diff --git a/include/osmocom/gsm/protocol/ipaccess.h b/include/osmocom/gsm/protocol/ipaccess.h index 5d98a21..254c2bc 100644 --- a/include/osmocom/gsm/protocol/ipaccess.h +++ b/include/osmocom/gsm/protocol/ipaccess.h @@ -1,5 +1,4 @@ -#ifndef _OSMO_PROTO_IPACCESS_H -#define _OSMO_PROTO_IPACCESS_H +#pragma once #include @@ -90,5 +89,3 @@ struct sdp_header_entry { uint32_t addr2; uint32_t start; } __attribute__((packed)); - -#endif /* _OSMO_PROTO_IPACCESS_H */ diff --git a/include/osmocom/gsm/protocol/smpp34_osmocom.h b/include/osmocom/gsm/protocol/smpp34_osmocom.h index 20e9206..cff6adb 100644 --- a/include/osmocom/gsm/protocol/smpp34_osmocom.h +++ b/include/osmocom/gsm/protocol/smpp34_osmocom.h @@ -1,5 +1,4 @@ -#ifndef _SMPP34_OSMOCOM_H -#define _SMPP34_OSMOCOM_H +#pragma once /* Osmocom SMPP extensions */ /* Osmocom specific new TLV definitions */ @@ -44,5 +43,3 @@ * TLVID_osmo_rxqual_dl * TLVID_osmo_imei */ - -#endif diff --git a/include/osmocom/gsm/rsl.h b/include/osmocom/gsm/rsl.h index b8e4157..753dd19 100644 --- a/include/osmocom/gsm/rsl.h +++ b/include/osmocom/gsm/rsl.h @@ -1,5 +1,4 @@ -#ifndef _OSMOCORE_RSL_H -#define _OSMOCORE_RSL_H +#pragma once #include #include @@ -51,5 +50,3 @@ struct msgb *rsl_rll_simple(uint8_t msg_type, uint8_t chan_nr, uint8_t link_id, int transparent); /*! @} */ - -#endif /* _OSMOCORE_RSL_H */ diff --git a/include/osmocom/gsm/rxlev_stat.h b/include/osmocom/gsm/rxlev_stat.h index 415509d..7183b17 100644 --- a/include/osmocom/gsm/rxlev_stat.h +++ b/include/osmocom/gsm/rxlev_stat.h @@ -1,5 +1,4 @@ -#ifndef _OSMOCORE_RXLEV_STATS_H -#define _OSMOCORE_RXLEV_STATS_H +#pragma once #define NUM_RXLEVS 32 #define NUM_ARFCNS 1024 @@ -18,5 +17,3 @@ int16_t rxlev_stat_get_next(const struct rxlev_stats *st, uint8_t rxlev, int16_t void rxlev_stat_reset(struct rxlev_stats *st); void rxlev_stat_dump(const struct rxlev_stats *st); - -#endif /* _OSMOCORE_RXLEV_STATS_H */ diff --git a/include/osmocom/gsm/sysinfo.h b/include/osmocom/gsm/sysinfo.h index 06feb1d..7d1fe2b 100644 --- a/include/osmocom/gsm/sysinfo.h +++ b/include/osmocom/gsm/sysinfo.h @@ -1,5 +1,4 @@ -#ifndef _OSMO_GSM_SYSINFO_H -#define _OSMO_GSM_SYSINFO_H +#pragma once #include #include @@ -39,5 +38,3 @@ extern const struct value_string osmo_sitype_strs[_MAX_SYSINFO_TYPE]; uint8_t osmo_sitype2rsl(enum osmo_sysinfo_type si_type); enum osmo_sysinfo_type osmo_rsl2sitype(uint8_t rsl_si); - -#endif /* _OSMO_GSM_SYSINFO_H */ diff --git a/include/osmocom/gsm/tlv.h b/include/osmocom/gsm/tlv.h index a70b0f9..fda1810 100644 --- a/include/osmocom/gsm/tlv.h +++ b/include/osmocom/gsm/tlv.h @@ -1,5 +1,4 @@ -#ifndef _TLV_H -#define _TLV_H +#pragma once #include #include @@ -435,5 +434,3 @@ static inline uint32_t tlvp_val32_unal(const struct tlv_parsed *tp, int pos) } /*! @} */ - -#endif /* _TLV_H */ diff --git a/include/osmocom/vty/buffer.h b/include/osmocom/vty/buffer.h index c9467a9..482a919 100644 --- a/include/osmocom/vty/buffer.h +++ b/include/osmocom/vty/buffer.h @@ -20,8 +20,7 @@ * Boston, MA 02111-1307, USA. */ -#ifndef _ZEBRA_BUFFER_H -#define _ZEBRA_BUFFER_H +#pragma once #include @@ -98,5 +97,3 @@ extern buffer_status_t buffer_flush_all(struct buffer *, int fd); */ extern buffer_status_t buffer_flush_window(struct buffer *, int fd, int width, int height, int erase, int no_more); - -#endif /* _ZEBRA_BUFFER_H */ diff --git a/include/osmocom/vty/command.h b/include/osmocom/vty/command.h index b3b3029..3acbe78 100644 --- a/include/osmocom/vty/command.h +++ b/include/osmocom/vty/command.h @@ -20,8 +20,7 @@ * Boston, MA 02111-1307, USA. */ -#ifndef _ZEBRA_COMMAND_H -#define _ZEBRA_COMMAND_H +#pragma once #include #include @@ -376,4 +375,3 @@ void print_version(int print_copyright); extern void *tall_vty_cmd_ctx; /*! @} */ -#endif /* _ZEBRA_COMMAND_H */ diff --git a/include/osmocom/vty/logging.h b/include/osmocom/vty/logging.h index e0011bf..9e4b98f 100644 --- a/include/osmocom/vty/logging.h +++ b/include/osmocom/vty/logging.h @@ -1,5 +1,4 @@ -#ifndef _VTY_LOGGING_H -#define _VTY_LOGGING_H +#pragma once #define LOGGING_STR "Configure log message to this terminal\n" #define FILTER_STR "Filter log messages\n" @@ -8,5 +7,3 @@ struct log_info; void logging_vty_add_cmds(const struct log_info *cat); struct vty; struct log_target *osmo_log_vty2tgt(struct vty *vty); - -#endif /* _VTY_LOGGING_H */ diff --git a/include/osmocom/vty/misc.h b/include/osmocom/vty/misc.h index db4f4a7..db552e7 100644 --- a/include/osmocom/vty/misc.h +++ b/include/osmocom/vty/misc.h @@ -1,5 +1,4 @@ -#ifndef OSMO_VTY_MISC_H -#define OSMO_VTY_MISC_H +#pragma once #include #include @@ -15,5 +14,3 @@ void vty_out_rate_ctr_group(struct vty *vty, const char *prefix, int osmo_vty_write_config_file(const char *filename); int osmo_vty_save_config_file(void); - -#endif diff --git a/include/osmocom/vty/telnet_interface.h b/include/osmocom/vty/telnet_interface.h index 3c22201..e939ec7 100644 --- a/include/osmocom/vty/telnet_interface.h +++ b/include/osmocom/vty/telnet_interface.h @@ -18,8 +18,7 @@ * */ -#ifndef TELNET_INTERFACE_H -#define TELNET_INTERFACE_H +#pragma once #include #include @@ -52,5 +51,3 @@ int telnet_init_dynif(void *tall_ctx, void *priv, const char *ip, int port); void telnet_exit(void); /*! @} */ - -#endif /* TELNET_INTERFACE_H */ diff --git a/include/osmocom/vty/vector.h b/include/osmocom/vty/vector.h index 22a184d..7caa5ff 100644 --- a/include/osmocom/vty/vector.h +++ b/include/osmocom/vty/vector.h @@ -20,8 +20,7 @@ * 02111-1307, USA. */ -#ifndef _ZEBRA_VECTOR_H -#define _ZEBRA_VECTOR_H +#pragma once /* struct for vector */ struct _vector { @@ -60,5 +59,3 @@ void *vector_lookup(vector, unsigned int); void *vector_lookup_ensure(vector, unsigned int); extern void *tall_vty_vec_ctx; - -#endif /* _ZEBRA_VECTOR_H */ diff --git a/include/osmocom/vty/vty.h b/include/osmocom/vty/vty.h index ea987bf..ea02e4a 100644 --- a/include/osmocom/vty/vty.h +++ b/include/osmocom/vty/vty.h @@ -1,5 +1,4 @@ -#ifndef _VTY_H -#define _VTY_H +#pragma once #include #include @@ -205,5 +204,3 @@ struct vty_signal_data { }; /*! @} */ - -#endif diff --git a/src/gsm/milenage/aes.h b/src/gsm/milenage/aes.h index ba384a9..7e97f61 100644 --- a/src/gsm/milenage/aes.h +++ b/src/gsm/milenage/aes.h @@ -12,8 +12,7 @@ * See README and COPYING for more details. */ -#ifndef AES_H -#define AES_H +#pragma once #define AES_BLOCK_SIZE 16 @@ -23,5 +22,3 @@ void aes_encrypt_deinit(void *ctx); void * aes_decrypt_init(const u8 *key, size_t len); void aes_decrypt(void *ctx, const u8 *crypt, u8 *plain); void aes_decrypt_deinit(void *ctx); - -#endif /* AES_H */ diff --git a/src/gsm/milenage/aes_i.h b/src/gsm/milenage/aes_i.h index 6b40bc7..c831757 100644 --- a/src/gsm/milenage/aes_i.h +++ b/src/gsm/milenage/aes_i.h @@ -12,8 +12,7 @@ * See README and COPYING for more details. */ -#ifndef AES_I_H -#define AES_I_H +#pragma once #include "aes.h" @@ -118,5 +117,3 @@ static inline u32 rotr(u32 val, int bits) #define AES_PRIV_SIZE (4 * 44) void rijndaelKeySetupEnc(u32 rk[/*44*/], const u8 cipherKey[]); - -#endif /* AES_I_H */ diff --git a/src/gsm/milenage/aes_wrap.h b/src/gsm/milenage/aes_wrap.h index 4b1c7b0..afa1451 100644 --- a/src/gsm/milenage/aes_wrap.h +++ b/src/gsm/milenage/aes_wrap.h @@ -19,8 +19,7 @@ * See README and COPYING for more details. */ -#ifndef AES_WRAP_H -#define AES_WRAP_H +#pragma once int __must_check aes_wrap(const u8 *kek, int n, const u8 *plain, u8 *cipher); int __must_check aes_unwrap(const u8 *kek, int n, const u8 *cipher, u8 *plain); @@ -44,5 +43,3 @@ int __must_check aes_128_cbc_encrypt(const u8 *key, const u8 *iv, u8 *data, size_t data_len); int __must_check aes_128_cbc_decrypt(const u8 *key, const u8 *iv, u8 *data, size_t data_len); - -#endif /* AES_WRAP_H */ diff --git a/src/gsm/milenage/milenage.h b/src/gsm/milenage/milenage.h index a91e946..6fb779c 100644 --- a/src/gsm/milenage/milenage.h +++ b/src/gsm/milenage/milenage.h @@ -12,8 +12,7 @@ * See README and COPYING for more details. */ -#ifndef MILENAGE_H -#define MILENAGE_H +#pragma once void milenage_generate(const u8 *opc, const u8 *amf, const u8 *k, const u8 *sqn, const u8 *_rand, u8 *autn, u8 *ik, @@ -31,5 +30,3 @@ int milenage_f2345(const u8 *opc, const u8 *k, const u8 *_rand, u8 *res, u8 *ck, u8 *ik, u8 *ak, u8 *akstar); int milenage_opc_gen(u8 *opc, const u8 *k, const u8 *op); - -#endif /* MILENAGE_H */ -- 1.8.3.2 From Max.Suraev at fairwaves.co Mon Jun 16 16:35:23 2014 From: Max.Suraev at fairwaves.co (Max Suraev) Date: Mon, 16 Jun 2014 18:35:23 +0200 Subject: [PATCH] remove comp128 from public API - use osmocom/crypt/auth.h instead Message-ID: <1402936523-9857-1-git-send-email-Max.Suraev@fairwaves.co> Signed-off-by: Max Suraev --- include/Makefile.am | 6 +++--- include/osmocom/gsm/comp128.h | 4 ++-- src/gsm/auth_comp128v1.c | 2 +- src/gsm/comp128.c | 2 +- src/gsm/libosmogsm.map | 1 - tests/comp128/comp128_test.c | 1 - 6 files changed, 7 insertions(+), 9 deletions(-) diff --git a/include/Makefile.am b/include/Makefile.am index 74396de..47f5e4f 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -45,8 +45,6 @@ nobase_include_HEADERS = \ osmocom/gprs/protocol/gsm_08_18.h \ osmocom/gsm/a5.h \ osmocom/gsm/abis_nm.h \ - osmocom/gsm/comp128.h \ - osmocom/gsm/comp128v23.h \ osmocom/gsm/gan.h \ osmocom/gsm/gsm0411_smc.h \ osmocom/gsm/gsm0411_smr.h \ @@ -110,7 +108,9 @@ endif noinst_HEADERS = \ osmocom/core/timer_compat.h \ - osmocom/gsm/kasumi.h + osmocom/gsm/kasumi.h \ + osmocom/gsm/comp128.h \ + osmocom/gsm/comp128v23.h \ osmocom/core/bit%gen.h: osmocom/core/bitXXgen.h.tpl $(AM_V_GEN)$(MKDIR_P) $(dir $@) diff --git a/include/osmocom/gsm/comp128.h b/include/osmocom/gsm/comp128.h index 33b997a..c45da37 100644 --- a/include/osmocom/gsm/comp128.h +++ b/include/osmocom/gsm/comp128.h @@ -9,10 +9,10 @@ #include /* - * Performs the COMP128 algorithm (used as A3/A8) + * Performs the COMP128v1 algorithm (used as A3/A8) * ki : uint8_t [16] * srand : uint8_t [16] * sres : uint8_t [4] * kc : uint8_t [8] */ -void comp128(const uint8_t *ki, const uint8_t *srand, uint8_t *sres, uint8_t *kc); +void comp128v1(const uint8_t *ki, const uint8_t *srand, uint8_t *sres, uint8_t *kc); diff --git a/src/gsm/auth_comp128v1.c b/src/gsm/auth_comp128v1.c index 41aef71..c40027e 100644 --- a/src/gsm/auth_comp128v1.c +++ b/src/gsm/auth_comp128v1.c @@ -28,7 +28,7 @@ static int c128v1_gen_vec(struct osmo_auth_vector *vec, struct osmo_sub_auth_data *aud, const uint8_t *_rand) { - comp128(aud->u.gsm.ki, _rand, vec->sres, vec->kc); + comp128v1(aud->u.gsm.ki, _rand, vec->sres, vec->kc); vec->auth_types = OSMO_AUTH_TYPE_GSM; return 0; diff --git a/src/gsm/comp128.c b/src/gsm/comp128.c index b7a2382..e36c20d 100644 --- a/src/gsm/comp128.c +++ b/src/gsm/comp128.c @@ -185,7 +185,7 @@ _comp128_permutation(uint8_t *x, uint8_t *bits) } void -comp128(const uint8_t *ki, const uint8_t *rand, uint8_t *sres, uint8_t *kc) +comp128v1(const uint8_t *ki, const uint8_t *rand, uint8_t *sres, uint8_t *kc) { int i; uint8_t x[32], bits[128]; diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index cab4fc4..daad5bb 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -23,7 +23,6 @@ abis_nm_test_name; osmo_sitype_strs; -comp128; dbm2rxlev; gprs_cipher_gen_input_i; diff --git a/tests/comp128/comp128_test.c b/tests/comp128/comp128_test.c index eb6fb12..d6a6401 100644 --- a/tests/comp128/comp128_test.c +++ b/tests/comp128/comp128_test.c @@ -6,7 +6,6 @@ #include #include -#include #include static struct osmo_sub_auth_data test_aux2 = { -- 1.9.1 From Max.Suraev at fairwaves.co Mon Jun 16 16:43:26 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Mon, 16 Jun 2014 18:43:26 +0200 Subject: [PATCH] remove comp128 from public API - use osmocom/crypt/auth.h instead In-Reply-To: <1402936523-9857-1-git-send-email-Max.Suraev@fairwaves.co> References: <1402936523-9857-1-git-send-email-Max.Suraev@fairwaves.co> Message-ID: <539F1EAE.8040606@fairwaves.co> This will obviously require API version bump but it should not break any applications which use auth.h API. Patch for osmocom-bb to use auth.h is applied in git. Patch for OpenBSC pending review in the ML. If there are other open source projects using comp128 directly I'd be to assist with transition, although it's rather trivial - see http://patchwork.ozlabs.org/patch/356029/ for example. cheers, Max. From holger at freyther.de Mon Jun 16 17:08:51 2014 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Mon, 16 Jun 2014 19:08:51 +0200 Subject: [PATCH] remove comp128 from public API - use osmocom/crypt/auth.h instead In-Reply-To: <539F1EAE.8040606@fairwaves.co> References: <1402936523-9857-1-git-send-email-Max.Suraev@fairwaves.co> <539F1EAE.8040606@fairwaves.co> Message-ID: <20140616170851.GF5748@xiaoyu.lan> On Mon, Jun 16, 2014 at 06:43:26PM +0200, ? wrote: > This will obviously require API version bump but it should not break any applications then please patch 'TODO-RELEASE' as well. thanks holger From Max.Suraev at fairwaves.co Tue Jun 17 09:56:17 2014 From: Max.Suraev at fairwaves.co (Max Suraev) Date: Tue, 17 Jun 2014 11:56:17 +0200 Subject: [PATCH] remove comp128 from public API - use osmocom/crypt/auth.h instead In-Reply-To: <1402936523-9857-1-git-send-email-Max.Suraev@fairwaves.co> References: <1402936523-9857-1-git-send-email-Max.Suraev@fairwaves.co> Message-ID: <1402998977-22295-1-git-send-email-Max.Suraev@fairwaves.co> Signed-off-by: Max Suraev --- TODO-RELEASE | 1 + include/Makefile.am | 6 +++--- include/osmocom/gsm/comp128.h | 4 ++-- src/gsm/auth_comp128v1.c | 2 +- src/gsm/comp128.c | 2 +- src/gsm/libosmogsm.map | 1 - tests/comp128/comp128_test.c | 1 - 7 files changed, 8 insertions(+), 9 deletions(-) diff --git a/TODO-RELEASE b/TODO-RELEASE index 43b1e8e..d6f8194 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -1 +1,2 @@ #library what description / commit summary line +libosmogsm api-change remove comp128 from public API \ No newline at end of file diff --git a/include/Makefile.am b/include/Makefile.am index 74396de..47f5e4f 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -45,8 +45,6 @@ nobase_include_HEADERS = \ osmocom/gprs/protocol/gsm_08_18.h \ osmocom/gsm/a5.h \ osmocom/gsm/abis_nm.h \ - osmocom/gsm/comp128.h \ - osmocom/gsm/comp128v23.h \ osmocom/gsm/gan.h \ osmocom/gsm/gsm0411_smc.h \ osmocom/gsm/gsm0411_smr.h \ @@ -110,7 +108,9 @@ endif noinst_HEADERS = \ osmocom/core/timer_compat.h \ - osmocom/gsm/kasumi.h + osmocom/gsm/kasumi.h \ + osmocom/gsm/comp128.h \ + osmocom/gsm/comp128v23.h \ osmocom/core/bit%gen.h: osmocom/core/bitXXgen.h.tpl $(AM_V_GEN)$(MKDIR_P) $(dir $@) diff --git a/include/osmocom/gsm/comp128.h b/include/osmocom/gsm/comp128.h index 33b997a..c45da37 100644 --- a/include/osmocom/gsm/comp128.h +++ b/include/osmocom/gsm/comp128.h @@ -9,10 +9,10 @@ #include /* - * Performs the COMP128 algorithm (used as A3/A8) + * Performs the COMP128v1 algorithm (used as A3/A8) * ki : uint8_t [16] * srand : uint8_t [16] * sres : uint8_t [4] * kc : uint8_t [8] */ -void comp128(const uint8_t *ki, const uint8_t *srand, uint8_t *sres, uint8_t *kc); +void comp128v1(const uint8_t *ki, const uint8_t *srand, uint8_t *sres, uint8_t *kc); diff --git a/src/gsm/auth_comp128v1.c b/src/gsm/auth_comp128v1.c index 41aef71..c40027e 100644 --- a/src/gsm/auth_comp128v1.c +++ b/src/gsm/auth_comp128v1.c @@ -28,7 +28,7 @@ static int c128v1_gen_vec(struct osmo_auth_vector *vec, struct osmo_sub_auth_data *aud, const uint8_t *_rand) { - comp128(aud->u.gsm.ki, _rand, vec->sres, vec->kc); + comp128v1(aud->u.gsm.ki, _rand, vec->sres, vec->kc); vec->auth_types = OSMO_AUTH_TYPE_GSM; return 0; diff --git a/src/gsm/comp128.c b/src/gsm/comp128.c index b7a2382..e36c20d 100644 --- a/src/gsm/comp128.c +++ b/src/gsm/comp128.c @@ -185,7 +185,7 @@ _comp128_permutation(uint8_t *x, uint8_t *bits) } void -comp128(const uint8_t *ki, const uint8_t *rand, uint8_t *sres, uint8_t *kc) +comp128v1(const uint8_t *ki, const uint8_t *rand, uint8_t *sres, uint8_t *kc) { int i; uint8_t x[32], bits[128]; diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index cab4fc4..daad5bb 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -23,7 +23,6 @@ abis_nm_test_name; osmo_sitype_strs; -comp128; dbm2rxlev; gprs_cipher_gen_input_i; diff --git a/tests/comp128/comp128_test.c b/tests/comp128/comp128_test.c index eb6fb12..d6a6401 100644 --- a/tests/comp128/comp128_test.c +++ b/tests/comp128/comp128_test.c @@ -6,7 +6,6 @@ #include #include -#include #include static struct osmo_sub_auth_data test_aux2 = { -- 1.9.1 From Max.Suraev at fairwaves.co Mon Jun 16 20:48:37 2014 From: Max.Suraev at fairwaves.co (Max Suraev) Date: Mon, 16 Jun 2014 22:48:37 +0200 Subject: [PATCH] Addditional classmark check against A5/X support Message-ID: <1402951717-31336-1-git-send-email-Max.Suraev@fairwaves.co> Signed-off-by: Max Suraev --- include/osmocom/gsm/gsm_utils.h | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/include/osmocom/gsm/gsm_utils.h b/include/osmocom/gsm/gsm_utils.h index 6eab7ac..cf174e2 100644 --- a/include/osmocom/gsm/gsm_utils.h +++ b/include/osmocom/gsm/gsm_utils.h @@ -117,17 +117,41 @@ int rxlev2dbm(uint8_t rxlev); uint8_t dbm2rxlev(int dbm); /* According to GSM 04.08 Chapter 10.5.1.6 */ -static inline int ms_cm2_a5n_support(uint8_t *cm2, int n) { +static inline int ms_cm2_a5n_support(uint8_t *cm2, unsigned n) { switch (n) { case 0: return 1; case 1: return (cm2[0] & (1<<3)) ? 0 : 1; case 2: return (cm2[2] & (1<<0)) ? 1 : 0; case 3: return (cm2[2] & (1<<1)) ? 1 : 0; default: - return 0; + return (n > 7) ? 0 : -1; } } +/* According to GSM 04.08 Chapter 10.5.1.7 */ +static inline int ms_cm3_a5n_support(uint8_t *cm3, unsigned n) { + switch (n) { + case 4: return (cm3[0] & (1<<0)) ? 1 : 0; + case 5: return (cm3[0] & (1<<1)) ? 1 : 0; + case 6: return (cm3[0] & (1<<2)) ? 1 : 0; + case 7: return (cm3[0] & (1<<3)) ? 1 : 0; + default: + return (n > 7) ? 0 : -1; + } +} + +/*! \brief Check whether MS supports given cipher + * \param[in] cm Classmark data transmitted by MS, cannot be NULL + * \param[in] n Cipher number - A5/n + * \returns 1 if supported, 0 if unsupported, -1 on failures + * + * Implementation based on specifications from GSM 04.08 + * parts 10.5.1.6 and 10.5.1.7. + */ +static inline int ms_a5n_support(uint8_t *cm, unsigned n) { + return ((n < 4) ? ms_cm2_a5n_support(cm, n) : ms_cm3_a5n_support(cm, n)); +} + /* According to GSM 04.08 Chapter 10.5.2.29 */ static inline int rach_max_trans_val2raw(int val) { return (val >> 1) & 3; } static inline int rach_max_trans_raw2val(int raw) { -- 1.9.1 From 246tnt at gmail.com Mon Jun 16 21:04:30 2014 From: 246tnt at gmail.com (Sylvain Munaut) Date: Mon, 16 Jun 2014 23:04:30 +0200 Subject: [PATCH] Addditional classmark check against A5/X support In-Reply-To: <1402951717-31336-1-git-send-email-Max.Suraev@fairwaves.co> References: <1402951717-31336-1-git-send-email-Max.Suraev@fairwaves.co> Message-ID: Hi, > /* According to GSM 04.08 Chapter 10.5.1.6 */ > -static inline int ms_cm2_a5n_support(uint8_t *cm2, int n) { > +static inline int ms_cm2_a5n_support(uint8_t *cm2, unsigned n) { > switch (n) { > case 0: return 1; > case 1: return (cm2[0] & (1<<3)) ? 0 : 1; > case 2: return (cm2[2] & (1<<0)) ? 1 : 0; > case 3: return (cm2[2] & (1<<1)) ? 1 : 0; > default: > - return 0; > + return (n > 7) ? 0 : -1; > } > } Why this change ? I mean, you'd now have to go over __every_ use of that function in all projects and make sure it's not used in something like : if (!ms_cm2_a5n_support(cm2, n)) { error } Because an invalid n is now going to return something != 0 ... > +/*! \brief Check whether MS supports given cipher > + * \param[in] cm Classmark data transmitted by MS, cannot be NULL > + * \param[in] n Cipher number - A5/n > + * \returns 1 if supported, 0 if unsupported, -1 on failures > + * > + * Implementation based on specifications from GSM 04.08 > + * parts 10.5.1.6 and 10.5.1.7. > + */ > +static inline int ms_a5n_support(uint8_t *cm, unsigned n) { > + return ((n < 4) ? ms_cm2_a5n_support(cm, n) : ms_cm3_a5n_support(cm, n)); > +} > + Huh ... so the called has to know whether to give CM2 or CM3 ... you might as well not have this method at all then and just require it to call the right method. Cheers, Sylvain From Max.Suraev at fairwaves.co Tue Jun 17 08:56:35 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Tue, 17 Jun 2014 10:56:35 +0200 Subject: [PATCH] Addditional classmark check against A5/X support In-Reply-To: References: <1402951717-31336-1-git-send-email-Max.Suraev@fairwaves.co> Message-ID: <53A002C3.2070206@fairwaves.co> 16.06.2014 23:04, Sylvain Munaut ?????: > >> - return 0; >> + return (n > 7) ? 0 : -1; >> } >> } > > Why this change ? I mean, you'd now have to go over __every_ use of > that function in all projects and make sure it's not used in something > like : > > if (!ms_cm2_a5n_support(cm2, n)) { > error > } > > Because an invalid n is now going to return something != 0 ... > I thought it's better to expose error case explicitly. >> +static inline int ms_a5n_support(uint8_t *cm, unsigned n) { >> + return ((n < 4) ? ms_cm2_a5n_support(cm, n) : ms_cm3_a5n_support(cm, n)); >> +} >> + > > Huh ... so the called has to know whether to give CM2 or CM3 ... you > might as well not have this method at all then and just require it to > call the right method. > I'm not sure what you mean in here - we call this function with some classmark (either 2 or 3) and number from a5/n to check if this cipher support is indicated in the classmark. Anyway - just a little convenience wrapper. -- best regards, Max, http://fairwaves.co From 246tnt at gmail.com Tue Jun 17 09:15:31 2014 From: 246tnt at gmail.com (Sylvain Munaut) Date: Tue, 17 Jun 2014 11:15:31 +0200 Subject: [PATCH] Addditional classmark check against A5/X support In-Reply-To: <53A002C3.2070206@fairwaves.co> References: <1402951717-31336-1-git-send-email-Max.Suraev@fairwaves.co> <53A002C3.2070206@fairwaves.co> Message-ID: On Tue, Jun 17, 2014 at 10:56 AM, ? wrote: > 16.06.2014 23:04, Sylvain Munaut ?????: >> >>> - return 0; >>> + return (n > 7) ? 0 : -1; >>> } >>> } >> >> Why this change ? I mean, you'd now have to go over __every_ use of >> that function in all projects and make sure it's not used in something >> like : >> >> if (!ms_cm2_a5n_support(cm2, n)) { >> error >> } >> >> Because an invalid n is now going to return something != 0 ... >> > > I thought it's better to expose error case explicitly. In this case you can't change the API. Because the case I showed above is _exactly_ how it's used currently so if someone has a new libosmocore and an old openbsc, it will build fine but not do the right thing. And in either case a return value of 0 for n>7 is certainly not wrong since you can't possibly support an non-existent cipher. >>> +static inline int ms_a5n_support(uint8_t *cm, unsigned n) { >>> + return ((n < 4) ? ms_cm2_a5n_support(cm, n) : ms_cm3_a5n_support(cm, n)); >>> +} >>> + >> >> Huh ... so the called has to know whether to give CM2 or CM3 ... you >> might as well not have this method at all then and just require it to >> call the right method. >> > > I'm not sure what you mean in here - we call this function with some classmark > (either 2 or 3) and number from a5/n to check if this cipher support is indicated in > the classmark. Anyway - just a little convenience wrapper. What I mean is that it's not "either 2 or 3" it _needs_ to be CM2 for a5/[1-3] and CM3 for a5/[4-7] ... so that means that the caller _HAS_ to have the knowledge of which CM to check. If you want it to make convenient, then I'd take _both_ CM2 and CM3 in argument and choose the right one. Possibly make it accept NULL for CM2/CM3 and if you need a missing info to make the decision, return -EAGAIN. And make proper doc for this behavior. Since this is a new function, and this actually provides a useful info you can use error code for this. Cheers, Sylvain From Max.Suraev at fairwaves.co Tue Jun 17 10:07:26 2014 From: Max.Suraev at fairwaves.co (Max Suraev) Date: Tue, 17 Jun 2014 12:07:26 +0200 Subject: [PATCH] Addditional classmark check against A5/4 support In-Reply-To: <1402951717-31336-1-git-send-email-Max.Suraev@fairwaves.co> References: <1402951717-31336-1-git-send-email-Max.Suraev@fairwaves.co> Message-ID: <1402999646-23848-1-git-send-email-Max.Suraev@fairwaves.co> Signed-off-by: Max Suraev --- include/osmocom/gsm/gsm_utils.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/include/osmocom/gsm/gsm_utils.h b/include/osmocom/gsm/gsm_utils.h index 6eab7ac..5f9164b 100644 --- a/include/osmocom/gsm/gsm_utils.h +++ b/include/osmocom/gsm/gsm_utils.h @@ -117,7 +117,7 @@ int rxlev2dbm(uint8_t rxlev); uint8_t dbm2rxlev(int dbm); /* According to GSM 04.08 Chapter 10.5.1.6 */ -static inline int ms_cm2_a5n_support(uint8_t *cm2, int n) { +static inline int ms_cm2_a5n_support(uint8_t *cm2, unsigned n) { switch (n) { case 0: return 1; case 1: return (cm2[0] & (1<<3)) ? 0 : 1; @@ -128,6 +128,18 @@ static inline int ms_cm2_a5n_support(uint8_t *cm2, int n) { } } +/* According to GSM 04.08 Chapter 10.5.1.7 */ +static inline int ms_cm3_a5n_support(uint8_t *cm3, unsigned n) { + switch (n) { + case 4: return (cm3[0] & (1<<0)) ? 1 : 0; + case 5: return (cm3[0] & (1<<1)) ? 1 : 0; + case 6: return (cm3[0] & (1<<2)) ? 1 : 0; + case 7: return (cm3[0] & (1<<3)) ? 1 : 0; + default: + return 0; + } +} + /* According to GSM 04.08 Chapter 10.5.2.29 */ static inline int rach_max_trans_val2raw(int val) { return (val >> 1) & 3; } static inline int rach_max_trans_raw2val(int raw) { -- 1.9.1 From Max.Suraev at fairwaves.co Tue Jun 17 10:14:51 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Tue, 17 Jun 2014 12:14:51 +0200 Subject: [PATCH] Addditional classmark check against A5/4 support In-Reply-To: <1402999646-23848-1-git-send-email-Max.Suraev@fairwaves.co> References: <1402951717-31336-1-git-send-email-Max.Suraev@fairwaves.co> <1402999646-23848-1-git-send-email-Max.Suraev@fairwaves.co> Message-ID: <53A0151B.6040008@fairwaves.co> You've convinced me - there's no point in generalizing in here :) -- best regards, Max, http://fairwaves.co From Max.Suraev at fairwaves.co Mon Jun 16 21:06:18 2014 From: Max.Suraev at fairwaves.co (Max Suraev) Date: Mon, 16 Jun 2014 23:06:18 +0200 Subject: [PATCH] Add A5/3 and 4 support Message-ID: <1402952778-9538-1-git-send-email-Max.Suraev@fairwaves.co> Signed-off-by: Max Suraev --- include/osmocom/gsm/a5.h | 10 ++++--- src/gsm/a5.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++-- tests/Makefile.am | 1 + tests/a5/a5_test.c | 67 ++++++++++++++++++++++++++++++++++++---------- tests/a5/a5_test.ok | 24 +++++++++++++++++ 5 files changed, 152 insertions(+), 19 deletions(-) diff --git a/include/osmocom/gsm/a5.h b/include/osmocom/gsm/a5.h index c076734..e3e73f9 100644 --- a/include/osmocom/gsm/a5.h +++ b/include/osmocom/gsm/a5.h @@ -23,6 +23,7 @@ #pragma once #include +#include #include @@ -48,13 +49,16 @@ osmo_a5_fn_count(uint32_t fn) } /* Notes: - * - key must be 8 bytes long (or NULL for A5/0) + * - key must be 8/16 bytes long (or NULL for A5/0) depending on algorithm variant * - the dl and ul pointer must be either NULL or 114 bits long - * - fn is the _real_ GSM frame number. - * (converted internally to fn_count) + * - fn is the _real_ GSM frame number (unless fn_correct is false), + * converted internally to fn_count + * - only top-level osmo_a5 should be considered as part of public API */ 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); +void _osmo_a5_3(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul, bool fn_correct); +void _osmo_a5_4(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul, bool fn_correct); /*! @} */ diff --git a/src/gsm/a5.c b/src/gsm/a5.c index de821e8..c24ef2d 100644 --- a/src/gsm/a5.c +++ b/src/gsm/a5.c @@ -36,8 +36,10 @@ #include #include +#include #include +#include /*! \brief Main method to generate a A5/x cipher stream * \param[in] n Which A5/x method to use @@ -47,7 +49,7 @@ * \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. + * Currently A5/[0-4] are supported. * Either (or both) of dl/ul can be NULL if not needed. */ int @@ -70,8 +72,16 @@ osmo_a5(int n, const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul) osmo_a5_2(key, fn, dl, ul); break; + case 3: + _osmo_a5_3(key, fn, dl, ul, true); + break; + + case 4: + _osmo_a5_4(key, fn, dl, ul, true); + break; + default: - /* a5/[3..7] not supported here/yet */ + /* a5/[5..7] not supported here/yet */ return -ENOTSUP; } @@ -368,4 +378,59 @@ osmo_a5_2(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul) } } +/* ------------------------------------------------------------------------ */ +/* A5/3&4 */ +/* ------------------------------------------------------------------------ */ + +/*! \brief Generate a GSM A5/3 cipher stream + * \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 + * \param[in] fn_correct true if fn is a real GSM frame number and thus requires internal conversion + * + * Either (or both) of dl/ul should be NULL if not needed. + * + * Implementation based on specifications from 3GPP TS 55.216, 3GPP TR 55.919 and ETSI TS 135 202 + * with slight simplifications (CE hardcoded to 0). + */ +void +_osmo_a5_3(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul, bool fn_correct) +{ + uint8_t ck[16]; + memcpy(ck, key, 8); + memcpy(ck + 8, key, 8); + /* internal function require 128 bit key so we expand by concatenating supplied 64 bit key */ + _osmo_a5_4(ck, fn, dl, ul, fn_correct); +} + +/*! \brief Generate a GSM A5/4 cipher stream + * \param[in] key 16 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 + * \param[in] fn_correct true if fn is a real GSM frame number and thus requires internal conversion + * + * Either (or both) of dl/ul should be NULL if not needed. + * + * Implementation based on specifications from 3GPP TS 55.216, 3GPP TR 55.919 and ETSI TS 135 202 + * with slight simplifications (CE hardcoded to 0). + */ +void +_osmo_a5_4(const uint8_t *ck, uint32_t fn, ubit_t *dl, ubit_t *ul, bool fn_correct) +{ + uint8_t i, gamma[32], uplink[15]; + uint32_t fn_count = (fn_correct) ? osmo_a5_fn_count(fn) : fn; + + if (ul) { + _kasumi_kgcore(0xF, 0, fn_count, 0, ck, gamma, 228); + for(i = 0; i < 15; i++) uplink[i] = (gamma[i + 14] << 2) + (gamma[i + 15] >> 6); + osmo_pbit2ubit(ul, uplink, 114); + } + if (dl) { + _kasumi_kgcore(0xF, 0, fn_count, 0, ck, gamma, 114); + osmo_pbit2ubit(dl, gamma, 114); + } +} + /*! @} */ diff --git a/tests/Makefile.am b/tests/Makefile.am index ea4bf9c..baf11a2 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -18,6 +18,7 @@ utils_utils_test_LDADD = $(top_builddir)/src/libosmocore.la a5_a5_test_SOURCES = a5/a5_test.c a5_a5_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la +a5_a5_test_LDFLAGS = -static kasumi_kasumi_test_SOURCES = kasumi/kasumi_test.c kasumi_kasumi_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la diff --git a/tests/a5/a5_test.c b/tests/a5/a5_test.c index 14436f1..9425fe4 100644 --- a/tests/a5/a5_test.c +++ b/tests/a5/a5_test.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -36,24 +37,48 @@ static const uint8_t ul[] = { 0x80, 0xba, 0xab, 0xc0, 0x59, 0x26, 0x40, }; -static const char * -binstr(ubit_t *d, int n) +static inline bool print_a5(int n, int k, const char * dir, const ubit_t * out, const char * block) { - static char str[256]; - int i; + uint8_t len = 114 / 8 + 1, buf[len], res[len]; + printf("A5/%d - %s: %s => ", n, dir, osmo_ubit_dump(out, 114)); + osmo_hexparse(block, res, len); + osmo_ubit2pbit(buf, out, 114); + if (0 != memcmp(buf, res, len)) { + printf("FAIL\nGOT: [%d] %s\nEXP: [%d] %s\n", k, osmo_hexdump_nospc(buf, len), k, osmo_hexdump_nospc(res, len)); + return false; + } + printf("OK\n"); + return true; +} + +static inline bool test_a53(const char * kc, uint32_t count, const char * block1, const char * block2) +{ + ubit_t dlout[114], ulout[114]; + uint8_t key[8]; + + osmo_hexparse(kc, key, 8); + _osmo_a5_3(key, count, dlout, NULL, false); + _osmo_a5_3(key, count, NULL, ulout, false); - for (i=0; i OK\n"); else { printf(" => BAD\n"); - printf(" Expected: %s", binstr(out, 114)); + printf(" Expected: %s", osmo_ubit_dump(out, 114)); fprintf(stderr, "[!] A5/%d DL failed", n); exit(1); } @@ -82,17 +107,31 @@ int main(int argc, char **argv) osmo_a5(n, key, fn, NULL, out); - printf("A5/%d - UL: %s", n, binstr(out, 114)); + printf("A5/%d - UL: %s", n, osmo_ubit_dump(out, 114)); if (!memcmp(exp, out, 114)) printf(" => OK\n"); else { printf(" => BAD\n"); - printf(" Expected: %s", binstr(out, 114)); + printf(" Expected: %s", osmo_ubit_dump(out, 114)); fprintf(stderr, "[!] A5/%d UL failed", n); exit(1); } } +// test vectors from 3GPP TS 55.217 and TS 55.218 + test_a53("2BD6459F82C5BC00", 0x24F20F, "889EEAAF9ED1BA1ABBD8436232E440", "5CA3406AA244CF69CF047AADA2DF40"); + test_a53("952C49104881FF48", 0x061272, "FB4D5FBCEE13A33389285686E9A5C0", "25090378E0540457C57E367662E440"); + test_a53("EFA8B2229E720C2A", 0x33FD3F, "0E4015755A336469C3DD8680E30340", "6F10669E2B4E18B042431A28E47F80"); + test_a53("952C49104881FF48", 0x061527, "AB7DB38A573A325DAA76E4CB800A40", "4C4B594FEA9D00FE8978B7B7BC1080"); + test_a53("3451F23A43BD2C87", 0x0E418C, "75F7C4C51560905DFBA05E46FB54C0", "192C95353CDF979E054186DF15BF00"); + test_a53("CAA2639BE82435CF", 0x2FF229, "301437E4D4D6565D4904C631606EC0", "F0A3B8795E264D3E1A82F684353DC0"); + test_a53("7AE67E87400B9FA6", 0x2F24E5, "F794290FEF643D2EA348A7796A2100", "CB6FA6C6B8A705AF9FEFE975818500"); + test_a53("58AF69935540698B", 0x05446B, "749CA4E6B691E5A598C461D5FE4740", "31C9E444CD04677ADAA8A082ADBC40"); + test_a53("017F81E5F236FE62", 0x156B26, "2A6976761E60CC4E8F9F52160276C0", "A544D8475F2C78C35614128F1179C0"); + test_a53("1ACA8B448B767B39", 0x0BC3B5, "A4F70DC5A2C9707F5FA1C60EB10640", "7780B597B328C1400B5C74823E8500"); + test_a54("3D43C388C9581E337FF1F97EB5C1F85E", 0x35D2CF, "A2FE3034B6B22CC4E33C7090BEC340", "170D7497432FF897B91BE8AECBA880"); + test_a54("A4496A64DF4F399F3B4506814A3E07A1", 0x212777, "89CDEE360DF9110281BCF57755A040", "33822C0C779598C9CBFC49183AF7C0"); + return 0; } diff --git a/tests/a5/a5_test.ok b/tests/a5/a5_test.ok index 4497e14..cefcdb6 100644 --- a/tests/a5/a5_test.ok +++ b/tests/a5/a5_test.ok @@ -4,3 +4,27 @@ A5/1 - DL: 110010111010001001010101011101100001011101011101001110110001110001111 A5/1 - UL: 110110010000001101011110000011110010101011101100000100111001101000000101110101001010100001111011101100010110010010 => OK A5/2 - DL: 010001011001110010001000110000111000001010110111111111111011001110011000110100101111100101101110000011110001010010 => OK A5/2 - UL: 111100000011101010101100110111101110001101011011010111100110010110000000101110101010101111000000010110010010011001 => OK +A5/3 - DL: 100010001001111011101010101011111001111011010001101110100001101010111011110110000100001101100010001100101110010001 => OK +A5/3 - UL: 010111001010001101000000011010101010001001000100110011110110100111001111000001000111101010101101101000101101111101 => OK +A5/3 - DL: 111110110100110101011111101111001110111000010011101000110011001110001001001010000101011010000110111010011010010111 => OK +A5/3 - UL: 001001010000100100000011011110001110000001010100000001000101011111000101011111100011011001110110011000101110010001 => OK +A5/3 - DL: 000011100100000000010101011101010101101000110011011001000110100111000011110111011000011010000000111000110000001101 => OK +A5/3 - UL: 011011110001000001100110100111100010101101001110000110001011000001000010010000110001101000101000111001000111111110 => OK +A5/3 - DL: 101010110111110110110011100010100101011100111010001100100101110110101010011101101110010011001011100000000000101001 => OK +A5/3 - UL: 010011000100101101011001010011111110101010011101000000001111111010001001011110001011011110110111101111000001000010 => OK +A5/3 - DL: 011101011111011111000100110001010001010101100000100100000101110111111011101000000101111001000110111110110101010011 => OK +A5/3 - UL: 000110010010110010010101001101010011110011011111100101111001111000000101010000011000011011011111000101011011111100 => OK +A5/3 - DL: 001100000001010000110111111001001101010011010110010101100101110101001001000001001100011000110001011000000110111011 => OK +A5/3 - UL: 111100001010001110111000011110010101111000100110010011010011111000011010100000101111011010000100001101010011110111 => OK +A5/3 - DL: 111101111001010000101001000011111110111101100100001111010010111010100011010010001010011101111001011010100010000100 => OK +A5/3 - UL: 110010110110111110100110110001101011100010100111000001011010111110011111111011111110100101110101100000011000010100 => OK +A5/3 - DL: 011101001001110010100100111001101011011010010001111001011010010110011000110001000110000111010101111111100100011101 => OK +A5/3 - UL: 001100011100100111100100010001001100110100000100011001110111101011011010101010001010000010000010101011011011110001 => OK +A5/3 - DL: 001010100110100101110110011101100001111001100000110011000100111010001111100111110101001000010110000000100111011011 => OK +A5/3 - UL: 101001010100010011011000010001110101111100101100011110001100001101010110000101000001001010001111000100010111100111 => OK +A5/3 - DL: 101001001111011100001101110001011010001011001001011100000111111101011111101000011100011000001110101100010000011001 => OK +A5/3 - UL: 011101111000000010110101100101111011001100101000110000010100000000001011010111000111010010000010001111101000010100 => OK +A5/4 - DL: 101000101111111000110000001101001011011010110010001011001100010011100011001111000111000010010000101111101100001101 => OK +A5/4 - UL: 000101110000110101110100100101110100001100101111111110001001011110111001000110111110100010101110110010111010100010 => OK +A5/4 - DL: 100010011100110111101110001101100000110111111001000100010000001010000001101111001111010101110111010101011010000001 => OK +A5/4 - UL: 001100111000001000101100000011000111011110010101100110001100100111001011111111000100100100011000001110101111011111 => OK -- 1.9.1 From 246tnt at gmail.com Mon Jun 16 21:24:00 2014 From: 246tnt at gmail.com (Sylvain Munaut) Date: Mon, 16 Jun 2014 23:24:00 +0200 Subject: [PATCH] Add A5/3 and 4 support In-Reply-To: <1402952778-9538-1-git-send-email-Max.Suraev@fairwaves.co> References: <1402952778-9538-1-git-send-email-Max.Suraev@fairwaves.co> Message-ID: Hi, > /* Notes: > - * - key must be 8 bytes long (or NULL for A5/0) > + * - key must be 8/16 bytes long (or NULL for A5/0) depending on algorithm variant > * - the dl and ul pointer must be either NULL or 114 bits long > - * - fn is the _real_ GSM frame number. > - * (converted internally to fn_count) > + * - fn is the _real_ GSM frame number (unless fn_correct is false), > + * converted internally to fn_count > + * - only top-level osmo_a5 should be considered as part of public API > */ > 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); > +void _osmo_a5_3(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul, bool fn_correct); > +void _osmo_a5_4(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul, bool fn_correct); Why the _ prefix ? It's exported and in the header and none of the other have it. Unnecessary inconsistency. Same for fn_correct, none of the other have it. The only use for it seem to be for the test ... but then the correct way is to make the test compute the real fn from the fn_count before the call, not pollute the API with a useless parameter. > a5_a5_test_SOURCES = a5/a5_test.c > a5_a5_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la > +a5_a5_test_LDFLAGS = -static Why is that needed at all ? If the functions are in the installed header they should be in the .map. If you don't want the other osmo_a5_x function as part of the API then first remove them from the header (they shouldn't be used anywhere anyway) and from the map and make them static. And then don't add the 3/4 to the .h file either and make the test go through the osmo_a5 function. Cheers, Sylvain From Max.Suraev at fairwaves.co Tue Jun 17 08:43:56 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Tue, 17 Jun 2014 10:43:56 +0200 Subject: [PATCH] Add A5/3 and 4 support In-Reply-To: References: <1402952778-9538-1-git-send-email-Max.Suraev@fairwaves.co> Message-ID: <539FFFCC.80503@fairwaves.co> 16.06.2014 23:24, Sylvain Munaut ?????: > Why the _ prefix ? It's exported and in the header and none of the > other have it. Unnecessary inconsistency. > Agree but I would rather hide implementation details of all osmo_a5_* from public API completely into separate non-installable header. Generic osmo_a5 should be fine for all use cases. Are there any reasons we expose those? -- best regards, Max, http://fairwaves.co From Max.Suraev at fairwaves.co Tue Jun 17 14:59:21 2014 From: Max.Suraev at fairwaves.co (Max Suraev) Date: Tue, 17 Jun 2014 16:59:21 +0200 Subject: [PATCH] Add A5/3-4 cipher support In-Reply-To: <1402952778-9538-1-git-send-email-Max.Suraev@fairwaves.co> References: <1402952778-9538-1-git-send-email-Max.Suraev@fairwaves.co> Message-ID: <1403017161-19040-1-git-send-email-Max.Suraev@fairwaves.co> Signed-off-by: Max Suraev --- include/Makefile.am | 3 +- include/osmocom/gsm/a34.h | 45 ++++++++++++++++++++++++++++++ src/gsm/a5.c | 70 +++++++++++++++++++++++++++++++++++++++++++++-- tests/Makefile.am | 1 + tests/a5/a5_test.c | 68 +++++++++++++++++++++++++++++++++++---------- tests/a5/a5_test.ok | 24 ++++++++++++++++ 6 files changed, 194 insertions(+), 17 deletions(-) create mode 100644 include/osmocom/gsm/a34.h diff --git a/include/Makefile.am b/include/Makefile.am index 74396de..f7d77c0 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -110,7 +110,8 @@ endif noinst_HEADERS = \ osmocom/core/timer_compat.h \ - osmocom/gsm/kasumi.h + osmocom/gsm/kasumi.h \ + osmocom/gsm/a34.h osmocom/core/bit%gen.h: osmocom/core/bitXXgen.h.tpl $(AM_V_GEN)$(MKDIR_P) $(dir $@) diff --git a/include/osmocom/gsm/a34.h b/include/osmocom/gsm/a34.h new file mode 100644 index 0000000..39e32db --- /dev/null +++ b/include/osmocom/gsm/a34.h @@ -0,0 +1,45 @@ +/* + * a34.h + * + * Copyright (C) 2014 Max Suraev + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#pragma once + +#include +#include + +/*! \defgroup a5 GSM A5/3-4 ciphering algorithms + * @{ + */ + +/*! \file gsm/a34.h + * \brief Osmocom implementation of GSM A5/3 and A5/4 ciphering algorithms + */ + + /* Notes: + * - key must be 8/16 bytes long depending on algorithm variant + * - the dl and ul pointer must be either NULL or 114 bits long + * - fn is the _real_ GSM frame number (unless fn_correct is false), + * converted internally to fn_count + */ +void _a5_3(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul, bool fn_correct); +void _a5_4(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul, bool fn_correct); + +/*! @} */ diff --git a/src/gsm/a5.c b/src/gsm/a5.c index de821e8..fc5e64f 100644 --- a/src/gsm/a5.c +++ b/src/gsm/a5.c @@ -36,8 +36,11 @@ #include #include +#include #include +#include +#include /*! \brief Main method to generate a A5/x cipher stream * \param[in] n Which A5/x method to use @@ -47,7 +50,7 @@ * \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. + * Currently A5/[0-4] are supported. * Either (or both) of dl/ul can be NULL if not needed. */ int @@ -70,8 +73,16 @@ osmo_a5(int n, const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul) 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/[3..7] not supported here/yet */ + /* a5/[5..7] not supported here/yet */ return -ENOTSUP; } @@ -368,4 +379,59 @@ osmo_a5_2(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul) } } +/* ------------------------------------------------------------------------ */ +/* A5/3&4 */ +/* ------------------------------------------------------------------------ */ + +/*! \brief Generate a GSM A5/4 cipher stream + * \param[in] key 16 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 + * \param[in] fn_correct true if fn is a real GSM frame number and thus requires internal conversion + * + * Either (or both) of dl/ul should be NULL if not needed. + * + * Implementation based on specifications from 3GPP TS 55.216, 3GPP TR 55.919 and ETSI TS 135 202 + * with slight simplifications (CE hardcoded to 0). + */ +void +_a5_4(const uint8_t *ck, uint32_t fn, ubit_t *dl, ubit_t *ul, bool fn_correct) +{ + uint8_t i, gamma[32], uplink[15]; + uint32_t fn_count = (fn_correct) ? osmo_a5_fn_count(fn) : fn; + + if (ul) { + _kasumi_kgcore(0xF, 0, fn_count, 0, ck, gamma, 228); + for(i = 0; i < 15; i++) uplink[i] = (gamma[i + 14] << 2) + (gamma[i + 15] >> 6); + osmo_pbit2ubit(ul, uplink, 114); + } + if (dl) { + _kasumi_kgcore(0xF, 0, fn_count, 0, ck, gamma, 114); + osmo_pbit2ubit(dl, gamma, 114); + } +} + +/*! \brief Generate a GSM A5/3 cipher stream + * \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 + * \param[in] fn_correct true if fn is a real GSM frame number and thus requires internal conversion + * + * Either (or both) of dl/ul should be NULL if not needed. + * + * Implementation based on specifications from 3GPP TS 55.216, 3GPP TR 55.919 and ETSI TS 135 202 + * with slight simplifications (CE hardcoded to 0). + */ +void +_a5_3(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul, bool fn_correct) +{ + uint8_t ck[16]; + memcpy(ck, key, 8); + memcpy(ck + 8, key, 8); + /* internal function require 128 bit key so we expand by concatenating supplied 64 bit key */ + _a5_4(ck, fn, dl, ul, fn_correct); +} + /*! @} */ diff --git a/tests/Makefile.am b/tests/Makefile.am index ea4bf9c..baf11a2 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -18,6 +18,7 @@ utils_utils_test_LDADD = $(top_builddir)/src/libosmocore.la a5_a5_test_SOURCES = a5/a5_test.c a5_a5_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la +a5_a5_test_LDFLAGS = -static kasumi_kasumi_test_SOURCES = kasumi/kasumi_test.c kasumi_kasumi_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la diff --git a/tests/a5/a5_test.c b/tests/a5/a5_test.c index 14436f1..a40489e 100644 --- a/tests/a5/a5_test.c +++ b/tests/a5/a5_test.c @@ -2,10 +2,12 @@ #include #include #include +#include #include #include #include +#include static const uint8_t key[] = { 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }; static const uint32_t fn = 123456; @@ -36,24 +38,48 @@ static const uint8_t ul[] = { 0x80, 0xba, 0xab, 0xc0, 0x59, 0x26, 0x40, }; -static const char * -binstr(ubit_t *d, int n) +static inline bool print_a5(int n, int k, const char * dir, const ubit_t * out, const char * block) { - static char str[256]; - int i; + uint8_t len = 114 / 8 + 1, buf[len], res[len]; + printf("A5/%d - %s: %s => ", n, dir, osmo_ubit_dump(out, 114)); + osmo_hexparse(block, res, len); + osmo_ubit2pbit(buf, out, 114); + if (0 != memcmp(buf, res, len)) { + printf("FAIL\nGOT: [%d] %s\nEXP: [%d] %s\n", k, osmo_hexdump_nospc(buf, len), k, osmo_hexdump_nospc(res, len)); + return false; + } + printf("OK\n"); + return true; +} + +static inline bool test_a53(const char * kc, uint32_t count, const char * block1, const char * block2) +{ + ubit_t dlout[114], ulout[114]; + uint8_t key[8]; + + osmo_hexparse(kc, key, 8); + _a5_3(key, count, dlout, NULL, false); + _a5_3(key, count, NULL, ulout, false); - for (i=0; i OK\n"); else { printf(" => BAD\n"); - printf(" Expected: %s", binstr(out, 114)); + printf(" Expected: %s", osmo_ubit_dump(out, 114)); fprintf(stderr, "[!] A5/%d DL failed", n); exit(1); } @@ -82,17 +108,31 @@ int main(int argc, char **argv) osmo_a5(n, key, fn, NULL, out); - printf("A5/%d - UL: %s", n, binstr(out, 114)); + printf("A5/%d - UL: %s", n, osmo_ubit_dump(out, 114)); if (!memcmp(exp, out, 114)) printf(" => OK\n"); else { printf(" => BAD\n"); - printf(" Expected: %s", binstr(out, 114)); + printf(" Expected: %s", osmo_ubit_dump(out, 114)); fprintf(stderr, "[!] A5/%d UL failed", n); exit(1); } } +// test vectors from 3GPP TS 55.217 and TS 55.218 + test_a53("2BD6459F82C5BC00", 0x24F20F, "889EEAAF9ED1BA1ABBD8436232E440", "5CA3406AA244CF69CF047AADA2DF40"); + test_a53("952C49104881FF48", 0x061272, "FB4D5FBCEE13A33389285686E9A5C0", "25090378E0540457C57E367662E440"); + test_a53("EFA8B2229E720C2A", 0x33FD3F, "0E4015755A336469C3DD8680E30340", "6F10669E2B4E18B042431A28E47F80"); + test_a53("952C49104881FF48", 0x061527, "AB7DB38A573A325DAA76E4CB800A40", "4C4B594FEA9D00FE8978B7B7BC1080"); + test_a53("3451F23A43BD2C87", 0x0E418C, "75F7C4C51560905DFBA05E46FB54C0", "192C95353CDF979E054186DF15BF00"); + test_a53("CAA2639BE82435CF", 0x2FF229, "301437E4D4D6565D4904C631606EC0", "F0A3B8795E264D3E1A82F684353DC0"); + test_a53("7AE67E87400B9FA6", 0x2F24E5, "F794290FEF643D2EA348A7796A2100", "CB6FA6C6B8A705AF9FEFE975818500"); + test_a53("58AF69935540698B", 0x05446B, "749CA4E6B691E5A598C461D5FE4740", "31C9E444CD04677ADAA8A082ADBC40"); + test_a53("017F81E5F236FE62", 0x156B26, "2A6976761E60CC4E8F9F52160276C0", "A544D8475F2C78C35614128F1179C0"); + test_a53("1ACA8B448B767B39", 0x0BC3B5, "A4F70DC5A2C9707F5FA1C60EB10640", "7780B597B328C1400B5C74823E8500"); + test_a54("3D43C388C9581E337FF1F97EB5C1F85E", 0x35D2CF, "A2FE3034B6B22CC4E33C7090BEC340", "170D7497432FF897B91BE8AECBA880"); + test_a54("A4496A64DF4F399F3B4506814A3E07A1", 0x212777, "89CDEE360DF9110281BCF57755A040", "33822C0C779598C9CBFC49183AF7C0"); + return 0; } diff --git a/tests/a5/a5_test.ok b/tests/a5/a5_test.ok index 4497e14..cefcdb6 100644 --- a/tests/a5/a5_test.ok +++ b/tests/a5/a5_test.ok @@ -4,3 +4,27 @@ A5/1 - DL: 110010111010001001010101011101100001011101011101001110110001110001111 A5/1 - UL: 110110010000001101011110000011110010101011101100000100111001101000000101110101001010100001111011101100010110010010 => OK A5/2 - DL: 010001011001110010001000110000111000001010110111111111111011001110011000110100101111100101101110000011110001010010 => OK A5/2 - UL: 111100000011101010101100110111101110001101011011010111100110010110000000101110101010101111000000010110010010011001 => OK +A5/3 - DL: 100010001001111011101010101011111001111011010001101110100001101010111011110110000100001101100010001100101110010001 => OK +A5/3 - UL: 010111001010001101000000011010101010001001000100110011110110100111001111000001000111101010101101101000101101111101 => OK +A5/3 - DL: 111110110100110101011111101111001110111000010011101000110011001110001001001010000101011010000110111010011010010111 => OK +A5/3 - UL: 001001010000100100000011011110001110000001010100000001000101011111000101011111100011011001110110011000101110010001 => OK +A5/3 - DL: 000011100100000000010101011101010101101000110011011001000110100111000011110111011000011010000000111000110000001101 => OK +A5/3 - UL: 011011110001000001100110100111100010101101001110000110001011000001000010010000110001101000101000111001000111111110 => OK +A5/3 - DL: 101010110111110110110011100010100101011100111010001100100101110110101010011101101110010011001011100000000000101001 => OK +A5/3 - UL: 010011000100101101011001010011111110101010011101000000001111111010001001011110001011011110110111101111000001000010 => OK +A5/3 - DL: 011101011111011111000100110001010001010101100000100100000101110111111011101000000101111001000110111110110101010011 => OK +A5/3 - UL: 000110010010110010010101001101010011110011011111100101111001111000000101010000011000011011011111000101011011111100 => OK +A5/3 - DL: 001100000001010000110111111001001101010011010110010101100101110101001001000001001100011000110001011000000110111011 => OK +A5/3 - UL: 111100001010001110111000011110010101111000100110010011010011111000011010100000101111011010000100001101010011110111 => OK +A5/3 - DL: 111101111001010000101001000011111110111101100100001111010010111010100011010010001010011101111001011010100010000100 => OK +A5/3 - UL: 110010110110111110100110110001101011100010100111000001011010111110011111111011111110100101110101100000011000010100 => OK +A5/3 - DL: 011101001001110010100100111001101011011010010001111001011010010110011000110001000110000111010101111111100100011101 => OK +A5/3 - UL: 001100011100100111100100010001001100110100000100011001110111101011011010101010001010000010000010101011011011110001 => OK +A5/3 - DL: 001010100110100101110110011101100001111001100000110011000100111010001111100111110101001000010110000000100111011011 => OK +A5/3 - UL: 101001010100010011011000010001110101111100101100011110001100001101010110000101000001001010001111000100010111100111 => OK +A5/3 - DL: 101001001111011100001101110001011010001011001001011100000111111101011111101000011100011000001110101100010000011001 => OK +A5/3 - UL: 011101111000000010110101100101111011001100101000110000010100000000001011010111000111010010000010001111101000010100 => OK +A5/4 - DL: 101000101111111000110000001101001011011010110010001011001100010011100011001111000111000010010000101111101100001101 => OK +A5/4 - UL: 000101110000110101110100100101110100001100101111111110001001011110111001000110111110100010101110110010111010100010 => OK +A5/4 - DL: 100010011100110111101110001101100000110111111001000100010000001010000001101111001111010101110111010101011010000001 => OK +A5/4 - UL: 001100111000001000101100000011000111011110010101100110001100100111001011111111000100100100011000001110101111011111 => OK -- 1.9.1 From Max.Suraev at fairwaves.co Tue Jun 17 15:04:59 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Tue, 17 Jun 2014 17:04:59 +0200 Subject: [PATCH] Add A5/3-4 cipher support In-Reply-To: <1403017161-19040-1-git-send-email-Max.Suraev@fairwaves.co> References: <1402952778-9538-1-git-send-email-Max.Suraev@fairwaves.co> <1403017161-19040-1-git-send-email-Max.Suraev@fairwaves.co> Message-ID: <53A0591B.4010304@fairwaves.co> This version avoids polluting external API with implementation details by introducing separate noinst header. -- best regards, Max, http://fairwaves.co From 246tnt at gmail.com Tue Jun 17 15:21:17 2014 From: 246tnt at gmail.com (Sylvain Munaut) Date: Tue, 17 Jun 2014 17:21:17 +0200 Subject: [PATCH] Add A5/3-4 cipher support In-Reply-To: <53A0591B.4010304@fairwaves.co> References: <1402952778-9538-1-git-send-email-Max.Suraev@fairwaves.co> <1403017161-19040-1-git-send-email-Max.Suraev@fairwaves.co> <53A0591B.4010304@fairwaves.co> Message-ID: As I stated in the previous comment, I don't even see why you need that header. Just make your test go through the public API and test the whole chain. It gets rid of the header, the need to static link, that extraneous param and only add one new inline function in the test ... On Tue, Jun 17, 2014 at 5:04 PM, ? wrote: > This version avoids polluting external API with implementation details by introducing > separate noinst header. > > -- > best regards, > Max, http://fairwaves.co > From Max.Suraev at fairwaves.co Tue Jun 17 15:30:09 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Tue, 17 Jun 2014 17:30:09 +0200 Subject: [PATCH] Add A5/3-4 cipher support In-Reply-To: References: <1402952778-9538-1-git-send-email-Max.Suraev@fairwaves.co> <1403017161-19040-1-git-send-email-Max.Suraev@fairwaves.co> <53A0591B.4010304@fairwaves.co> Message-ID: <53A05F01.5010203@fairwaves.co> 17.06.2014 17:21, Sylvain Munaut ?????: > As I stated in the previous comment, I don't even see why you need > that header. Just make your test go through the public API and test > the whole chain. It gets rid of the header, the need to static link, > that extraneous param and only add one new inline function in the test Well, that's a function which will only be used once - and it got to be written, debugged and tested. And all that for the sake of? I do not consider extra non-public header to be of such great burden that it justifies extra work necessary to get rid of it. -- best regards, Max, http://fairwaves.co From 246tnt at gmail.com Tue Jun 17 18:05:22 2014 From: 246tnt at gmail.com (Sylvain Munaut) Date: Tue, 17 Jun 2014 20:05:22 +0200 Subject: [PATCH] Add A5/3-4 cipher support In-Reply-To: <53A05F01.5010203@fairwaves.co> References: <1402952778-9538-1-git-send-email-Max.Suraev@fairwaves.co> <1403017161-19040-1-git-send-email-Max.Suraev@fairwaves.co> <53A0591B.4010304@fairwaves.co> <53A05F01.5010203@fairwaves.co> Message-ID: On Tue, Jun 17, 2014 at 5:30 PM, ? wrote: > 17.06.2014 17:21, Sylvain Munaut ?????: >> As I stated in the previous comment, I don't even see why you need >> that header. Just make your test go through the public API and test >> the whole chain. It gets rid of the header, the need to static link, >> that extraneous param and only add one new inline function in the test > > Well, that's a function which will only be used once - and it got to be written, > debugged and tested. static inline uint32_t osmo_a5_fn(uint32_t fn_count) { int t1 = fn_count >> 11; int t2 = fn_count & 0x1f; int t3 = (fn_count >> 5) & 0x3f; return (t1 * 26 * 51) + ((t3 - t2 + 26) % 26) * 51 + t3; } There, it's written. No need to debug it, it's correct. No need to test it, it's going to be in the test path of the A5/[3,4] test and tested automatically as part of them. > And all that for the sake of? I do not consider extra non-public > header to be of such great burden that it justifies extra work necessary to get rid > of it. Writing it in the first place was more typing that this function. Also there is an issue in it anyway, you used the Doxygen defgroup which is to define new groups while what you want is include it in an existing group. Cheers, Sylvain From 246tnt at gmail.com Tue Jun 17 18:11:18 2014 From: 246tnt at gmail.com (Sylvain Munaut) Date: Tue, 17 Jun 2014 20:11:18 +0200 Subject: [PATCH] Add A5/3-4 cipher support In-Reply-To: References: <1402952778-9538-1-git-send-email-Max.Suraev@fairwaves.co> <1403017161-19040-1-git-send-email-Max.Suraev@fairwaves.co> <53A0591B.4010304@fairwaves.co> <53A05F01.5010203@fairwaves.co> Message-ID: Also forgot to say that the 'Notes:' in the public header should be updated to reflect the key length. So should be the osmo_a5 doxygen doc for the 'key' parameter. Cheers, Sylvain From Max.Suraev at fairwaves.co Tue Jun 17 18:28:24 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Tue, 17 Jun 2014 20:28:24 +0200 Subject: [PATCH] Add A5/3-4 cipher support In-Reply-To: References: <1402952778-9538-1-git-send-email-Max.Suraev@fairwaves.co> <1403017161-19040-1-git-send-email-Max.Suraev@fairwaves.co> <53A0591B.4010304@fairwaves.co> <53A05F01.5010203@fairwaves.co> Message-ID: <53A088C8.3040300@fairwaves.co> 17.06.2014 20:05, Sylvain Munaut ?????: > static inline uint32_t > osmo_a5_fn(uint32_t fn_count) > { > int t1 = fn_count >> 11; > int t2 = fn_count & 0x1f; > int t3 = (fn_count >> 5) & 0x3f; > return (t1 * 26 * 51) + ((t3 - t2 + 26) % 26) * 51 + t3; > } > > There, it's written. No need to debug it, it's correct. No need to > test it, it's going to be in the test path of the A5/[3,4] test and > tested automatically as part of them. > Surprisingly those tests fail for some of the test vectors for me. How exactly you've applied and tested this function? Could you share entire a5_test.c? -- best regards, Max, http://fairwaves.co From 246tnt at gmail.com Tue Jun 17 19:35:59 2014 From: 246tnt at gmail.com (Sylvain Munaut) Date: Tue, 17 Jun 2014 21:35:59 +0200 Subject: [PATCH] Add A5/3-4 cipher support In-Reply-To: <53A088C8.3040300@fairwaves.co> References: <1402952778-9538-1-git-send-email-Max.Suraev@fairwaves.co> <1403017161-19040-1-git-send-email-Max.Suraev@fairwaves.co> <53A0591B.4010304@fairwaves.co> <53A05F01.5010203@fairwaves.co> <53A088C8.3040300@fairwaves.co> Message-ID: #include #include static inline uint32_t osmo_a5_fn_count(uint32_t fn) { int t1 = fn / (26 * 51); int t2 = fn % 26; int t3 = fn % 51; return (t1 << 11) | (t3 << 5) | t2; } static inline uint32_t osmo_a5_fn(uint32_t fn_count) { int t1 = fn_count >> 11; int t2 = fn_count & 0x1f; int t3 = (fn_count >> 5) & 0x3f; return (t1 * 26 * 51) + ((t3 - t2 + 26) % 26) * 51 + t3; } #define FN_MAX 26*51*2048 int main(int argc, char *argv[]) { int i; for (i=0; i References: <1402952778-9538-1-git-send-email-Max.Suraev@fairwaves.co> <1403017161-19040-1-git-send-email-Max.Suraev@fairwaves.co> <53A0591B.4010304@fairwaves.co> <53A05F01.5010203@fairwaves.co> <53A088C8.3040300@fairwaves.co> Message-ID: Bunch of fucking idiots who chose as test data completely invalid FN count values that can't possibly happen in a GSM system ... - Either just use different test vector you generate - Or use a marker bit like (1<<31) to indicate to _a5_{3,4} not to convert the values for testing On Tue, Jun 17, 2014 at 9:35 PM, Sylvain Munaut <246tnt at gmail.com> wrote: > #include > #include > > > static inline uint32_t > osmo_a5_fn_count(uint32_t fn) > { > int t1 = fn / (26 * 51); > int t2 = fn % 26; > int t3 = fn % 51; > return (t1 << 11) | (t3 << 5) | t2; > } > > static inline uint32_t > osmo_a5_fn(uint32_t fn_count) > { > int t1 = fn_count >> 11; > int t2 = fn_count & 0x1f; > int t3 = (fn_count >> 5) & 0x3f; > return (t1 * 26 * 51) + ((t3 - t2 + 26) % 26) * 51 + t3; > } > > #define FN_MAX 26*51*2048 > > int main(int argc, char *argv[]) > { > int i; > for (i=0; i if (i != osmo_a5_fn(osmo_a5_fn_count(i))) > printf("%d\n", i); > > } From Max.Suraev at fairwaves.co Tue Jun 17 21:05:15 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Tue, 17 Jun 2014 23:05:15 +0200 Subject: [PATCH] Add A5/3-4 cipher support In-Reply-To: References: <1402952778-9538-1-git-send-email-Max.Suraev@fairwaves.co> <1403017161-19040-1-git-send-email-Max.Suraev@fairwaves.co> <53A0591B.4010304@fairwaves.co> <53A05F01.5010203@fairwaves.co> <53A088C8.3040300@fairwaves.co> Message-ID: <53A0AD8B.1080308@fairwaves.co> 17.06.2014 21:46, Sylvain Munaut ?????: > Bunch of fucking idiots who chose as test data completely invalid FN > count values that can't possibly happen in a GSM system ... I presume the idea was not to test gsm use cases but to cover all the internal states of the cipher. > > - Either just use different test vector you generate I would rather stick to official test vectors published in standard. > - Or use a marker bit like (1<<31) to indicate to _a5_{3,4} not to > convert the values for testing > I really like my initial proposal: - it works already - it's simpler Could you emphasize - why exactly introducing private header is such a disaster that we have to waste time and efforts trying to not let it happen? -- best regards, Max, http://fairwaves.co From 246tnt at gmail.com Tue Jun 17 22:15:09 2014 From: 246tnt at gmail.com (Sylvain Munaut) Date: Wed, 18 Jun 2014 00:15:09 +0200 Subject: [PATCH] Add A5/3-4 cipher support In-Reply-To: <53A0AD8B.1080308@fairwaves.co> References: <1402952778-9538-1-git-send-email-Max.Suraev@fairwaves.co> <1403017161-19040-1-git-send-email-Max.Suraev@fairwaves.co> <53A0591B.4010304@fairwaves.co> <53A05F01.5010203@fairwaves.co> <53A088C8.3040300@fairwaves.co> <53A0AD8B.1080308@fairwaves.co> Message-ID: > Could you emphasize - why exactly introducing private header is such a disaster that > we have to waste time and efforts trying to not let it happen? - It's a useless file that's used at exactly 1 place and not even for code used in installed libs but just for the test. At that point you might just as well just pre-declare them in the test source file directly. - It prevents making those function static - It requires static linking for the test - For the A5/[3/4] you bypass the osmo_a5 wrapper and thus don't cover a breakage that would happen there. The alternative solves all of the above and requires exactly 1 lines changes in the original _a5_4 function : uint32_t fn_count = (fn_correct) ? osmo_a5_fn_count(fn) : fn; becomes uint32_t fn_count = (fn & (1<<31)) ? (fn & ~(1<<31)) : osmo_a5_fn_count(fn); btw, in your test I also see + osmo_a5(4, key, osmo_a5_fn(count), dlout, NULL); + osmo_a5(4, key, osmo_a5_fn(count), NULL, ulout); Why separate ? The case where both dlout and ulout are requested at the same time should work as well. Cheers, Sylvain From Max.Suraev at fairwaves.co Tue Jun 17 23:09:34 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Wed, 18 Jun 2014 01:09:34 +0200 Subject: [PATCH] Add A5/3-4 cipher support In-Reply-To: References: <1402952778-9538-1-git-send-email-Max.Suraev@fairwaves.co> <1403017161-19040-1-git-send-email-Max.Suraev@fairwaves.co> <53A0591B.4010304@fairwaves.co> <53A05F01.5010203@fairwaves.co> <53A088C8.3040300@fairwaves.co> <53A0AD8B.1080308@fairwaves.co> Message-ID: <53A0CAAE.8040305@fairwaves.co> 18.06.2014 00:15, Sylvain Munaut ?????: >> Could you emphasize - why exactly introducing private header is such a disaster that >> we have to waste time and efforts trying to not let it happen? > > - It's a useless file that's used at exactly 1 place and not even for > code used in installed libs but just for the test. At that point you > might just as well just pre-declare them in the test source file > directly. > - It prevents making those function static > - It requires static linking for the test > - For the A5/[3/4] you bypass the osmo_a5 wrapper and thus don't cover > a breakage that would happen there. > > > The alternative solves all of the above and requires exactly 1 lines > changes in the original _a5_4 function : > > uint32_t fn_count = (fn_correct) ? osmo_a5_fn_count(fn) : fn; > > becomes > > uint32_t fn_count = (fn & (1<<31)) ? (fn & ~(1<<31)) : osmo_a5_fn_count(fn); > > I probably apply it wrongly - test still fails for me. Feel free to commit your variant though - I think it's less readable but as long as it works and covered by test suit it's fine. -- best regards, Max, http://fairwaves.co From Max.Suraev at fairwaves.co Tue Jun 17 19:46:47 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Tue, 17 Jun 2014 21:46:47 +0200 Subject: [PATCH] Add A5/3-4 cipher support In-Reply-To: References: <1402952778-9538-1-git-send-email-Max.Suraev@fairwaves.co> <1403017161-19040-1-git-send-email-Max.Suraev@fairwaves.co> <53A0591B.4010304@fairwaves.co> <53A05F01.5010203@fairwaves.co> <53A088C8.3040300@fairwaves.co> Message-ID: <53A09B27.9090600@fairwaves.co> Seems nice but it case of a5 test vectors it still fails. Could you have a look into attached patch? -- best regards, Max, http://fairwaves.co From Max.Suraev at fairwaves.co Tue Jun 17 19:45:30 2014 From: Max.Suraev at fairwaves.co (Max Suraev) Date: Tue, 17 Jun 2014 21:45:30 +0200 Subject: [PATCH] broken A5/3-4 cipher support Message-ID: --- src/gsm/a5.c | 143 +++++++++++++++++++++++++++++++++++++--------------- tests/a5/a5_test.c | 75 ++++++++++++++++++++++----- tests/a5/a5_test.ok | 24 +++++++++ 3 files changed, 188 insertions(+), 54 deletions(-) diff --git a/src/gsm/a5.c b/src/gsm/a5.c index de821e8..e8c86a2 100644 --- a/src/gsm/a5.c +++ b/src/gsm/a5.c @@ -38,46 +38,7 @@ #include #include - -/*! \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; -} - +#include /* ------------------------------------------------------------------------ */ /* A5/1&2 common stuff */ @@ -368,4 +329,106 @@ osmo_a5_2(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul) } } +/* ------------------------------------------------------------------------ */ +/* A5/3&4 */ +/* ------------------------------------------------------------------------ */ + +/*! \brief Generate a GSM A5/4 cipher stream + * \param[in] key 16 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 + * \param[in] fn_correct true if fn is a real GSM frame number and thus requires internal conversion + * + * Either (or both) of dl/ul should be NULL if not needed. + * + * Implementation based on specifications from 3GPP TS 55.216, 3GPP TR 55.919 and ETSI TS 135 202 + * with slight simplifications (CE hardcoded to 0). + */ +void +_a5_4(const uint8_t *ck, uint32_t fn, ubit_t *dl, ubit_t *ul) +{ + uint8_t i, gamma[32], uplink[15]; + uint32_t fn_count = osmo_a5_fn_count(fn); + + if (ul) { + _kasumi_kgcore(0xF, 0, fn_count, 0, ck, gamma, 228); + for(i = 0; i < 15; i++) uplink[i] = (gamma[i + 14] << 2) + (gamma[i + 15] >> 6); + osmo_pbit2ubit(ul, uplink, 114); + } + if (dl) { + _kasumi_kgcore(0xF, 0, fn_count, 0, ck, gamma, 114); + osmo_pbit2ubit(dl, gamma, 114); + } +} + +/*! \brief Generate a GSM A5/3 cipher stream + * \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 + * \param[in] fn_correct true if fn is a real GSM frame number and thus requires internal conversion + * + * Either (or both) of dl/ul should be NULL if not needed. + * + * Implementation based on specifications from 3GPP TS 55.216, 3GPP TR 55.919 and ETSI TS 135 202 + * with slight simplifications (CE hardcoded to 0). + */ +void +_a5_3(const uint8_t *key, uint32_t fn, ubit_t *dl, ubit_t *ul) +{ + uint8_t ck[16]; + memcpy(ck, key, 8); + memcpy(ck + 8, key, 8); + /* internal function require 128 bit key so we expand by concatenating supplied 64 bit key */ + _a5_4(ck, fn, dl, 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-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); + break; + + case 4: + _a5_4(key, fn, dl, ul); + break; + + default: + /* a5/[5..7] not supported here/yet */ + return -ENOTSUP; + } + + return 0; +} + /*! @} */ diff --git a/tests/a5/a5_test.c b/tests/a5/a5_test.c index 14436f1..a6b799e 100644 --- a/tests/a5/a5_test.c +++ b/tests/a5/a5_test.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -36,24 +37,56 @@ static const uint8_t ul[] = { 0x80, 0xba, 0xab, 0xc0, 0x59, 0x26, 0x40, }; -static const char * -binstr(ubit_t *d, int n) +static inline uint32_t osmo_a5_fn(uint32_t fn_count) { - static char str[256]; - int i; + int t1 = fn_count >> 11; + int t2 = fn_count & 0x1f; + int t3 = (fn_count >> 5) & 0x3f; + return (t1 * 26 * 51) + ((t3 - t2 + 26) % 26) * 51 + t3; +} - for (i=0; i ", n, dir, osmo_ubit_dump(out, 114)); + osmo_hexparse(block, res, len); + osmo_ubit2pbit(buf, out, 114); + if (0 != memcmp(buf, res, len)) { + printf("FAIL\nGOT: [%d] %s\nEXP: [%d] %s\n", k, osmo_hexdump_nospc(buf, len), k, osmo_hexdump_nospc(res, len)); + return false; + } + printf("OK\n"); + return true; +} - str[i] = '\0'; +static inline bool test_a53(const char * kc, uint32_t count, const char * block1, const char * block2) +{ + ubit_t dlout[114], ulout[114]; + uint8_t key[8]; + + osmo_hexparse(kc, key, 8); + osmo_a5(3, key, osmo_a5_fn(count), dlout, NULL); + osmo_a5(3, key, osmo_a5_fn(count), NULL, ulout); - return str; + return print_a5(3, 8, "DL", dlout, block1) & print_a5(3, 8, "UL", ulout, block2); } +static inline bool test_a54(const char * kc, uint32_t count, const char * block1, const char * block2) +{ + ubit_t dlout[114], ulout[114]; + uint8_t key[16]; + + osmo_hexparse(kc, key, 16); + osmo_a5(4, key, osmo_a5_fn(count), dlout, NULL); + osmo_a5(4, key, osmo_a5_fn(count), NULL, ulout); + + return print_a5(4, 8, "DL", dlout, block1) & print_a5(4, 8, "UL", ulout, block2); +} + + int main(int argc, char **argv) { - ubit_t exp[114]; - ubit_t out[114]; + ubit_t exp[114], out[114]; int n, i; for (n=0; n<3; n++) { @@ -66,13 +99,13 @@ int main(int argc, char **argv) osmo_a5(n, key, fn, out, NULL); - printf("A5/%d - DL: %s", n, binstr(out, 114)); + printf("A5/%d - DL: %s", n, osmo_ubit_dump(out, 114)); if (!memcmp(exp, out, 114)) printf(" => OK\n"); else { printf(" => BAD\n"); - printf(" Expected: %s", binstr(out, 114)); + printf(" Expected: %s", osmo_ubit_dump(out, 114)); fprintf(stderr, "[!] A5/%d DL failed", n); exit(1); } @@ -82,17 +115,31 @@ int main(int argc, char **argv) osmo_a5(n, key, fn, NULL, out); - printf("A5/%d - UL: %s", n, binstr(out, 114)); + printf("A5/%d - UL: %s", n, osmo_ubit_dump(out, 114)); if (!memcmp(exp, out, 114)) printf(" => OK\n"); else { printf(" => BAD\n"); - printf(" Expected: %s", binstr(out, 114)); + printf(" Expected: %s", osmo_ubit_dump(out, 114)); fprintf(stderr, "[!] A5/%d UL failed", n); exit(1); } } +// test vectors from 3GPP TS 55.217 and TS 55.218 + test_a53("2BD6459F82C5BC00", 0x24F20F, "889EEAAF9ED1BA1ABBD8436232E440", "5CA3406AA244CF69CF047AADA2DF40"); + test_a53("952C49104881FF48", 0x061272, "FB4D5FBCEE13A33389285686E9A5C0", "25090378E0540457C57E367662E440"); + test_a53("EFA8B2229E720C2A", 0x33FD3F, "0E4015755A336469C3DD8680E30340", "6F10669E2B4E18B042431A28E47F80"); + test_a53("952C49104881FF48", 0x061527, "AB7DB38A573A325DAA76E4CB800A40", "4C4B594FEA9D00FE8978B7B7BC1080"); + test_a53("3451F23A43BD2C87", 0x0E418C, "75F7C4C51560905DFBA05E46FB54C0", "192C95353CDF979E054186DF15BF00"); + test_a53("CAA2639BE82435CF", 0x2FF229, "301437E4D4D6565D4904C631606EC0", "F0A3B8795E264D3E1A82F684353DC0"); + test_a53("7AE67E87400B9FA6", 0x2F24E5, "F794290FEF643D2EA348A7796A2100", "CB6FA6C6B8A705AF9FEFE975818500"); + test_a53("58AF69935540698B", 0x05446B, "749CA4E6B691E5A598C461D5FE4740", "31C9E444CD04677ADAA8A082ADBC40"); + test_a53("017F81E5F236FE62", 0x156B26, "2A6976761E60CC4E8F9F52160276C0", "A544D8475F2C78C35614128F1179C0"); + test_a53("1ACA8B448B767B39", 0x0BC3B5, "A4F70DC5A2C9707F5FA1C60EB10640", "7780B597B328C1400B5C74823E8500"); + test_a54("3D43C388C9581E337FF1F97EB5C1F85E", 0x35D2CF, "A2FE3034B6B22CC4E33C7090BEC340", "170D7497432FF897B91BE8AECBA880"); + test_a54("A4496A64DF4F399F3B4506814A3E07A1", 0x212777, "89CDEE360DF9110281BCF57755A040", "33822C0C779598C9CBFC49183AF7C0"); + return 0; } diff --git a/tests/a5/a5_test.ok b/tests/a5/a5_test.ok index 4497e14..cefcdb6 100644 --- a/tests/a5/a5_test.ok +++ b/tests/a5/a5_test.ok @@ -4,3 +4,27 @@ A5/1 - DL: 110010111010001001010101011101100001011101011101001110110001110001111 A5/1 - UL: 110110010000001101011110000011110010101011101100000100111001101000000101110101001010100001111011101100010110010010 => OK A5/2 - DL: 010001011001110010001000110000111000001010110111111111111011001110011000110100101111100101101110000011110001010010 => OK A5/2 - UL: 111100000011101010101100110111101110001101011011010111100110010110000000101110101010101111000000010110010010011001 => OK +A5/3 - DL: 100010001001111011101010101011111001111011010001101110100001101010111011110110000100001101100010001100101110010001 => OK +A5/3 - UL: 010111001010001101000000011010101010001001000100110011110110100111001111000001000111101010101101101000101101111101 => OK +A5/3 - DL: 111110110100110101011111101111001110111000010011101000110011001110001001001010000101011010000110111010011010010111 => OK +A5/3 - UL: 001001010000100100000011011110001110000001010100000001000101011111000101011111100011011001110110011000101110010001 => OK +A5/3 - DL: 000011100100000000010101011101010101101000110011011001000110100111000011110111011000011010000000111000110000001101 => OK +A5/3 - UL: 011011110001000001100110100111100010101101001110000110001011000001000010010000110001101000101000111001000111111110 => OK +A5/3 - DL: 101010110111110110110011100010100101011100111010001100100101110110101010011101101110010011001011100000000000101001 => OK +A5/3 - UL: 010011000100101101011001010011111110101010011101000000001111111010001001011110001011011110110111101111000001000010 => OK +A5/3 - DL: 011101011111011111000100110001010001010101100000100100000101110111111011101000000101111001000110111110110101010011 => OK +A5/3 - UL: 000110010010110010010101001101010011110011011111100101111001111000000101010000011000011011011111000101011011111100 => OK +A5/3 - DL: 001100000001010000110111111001001101010011010110010101100101110101001001000001001100011000110001011000000110111011 => OK +A5/3 - UL: 111100001010001110111000011110010101111000100110010011010011111000011010100000101111011010000100001101010011110111 => OK +A5/3 - DL: 111101111001010000101001000011111110111101100100001111010010111010100011010010001010011101111001011010100010000100 => OK +A5/3 - UL: 110010110110111110100110110001101011100010100111000001011010111110011111111011111110100101110101100000011000010100 => OK +A5/3 - DL: 011101001001110010100100111001101011011010010001111001011010010110011000110001000110000111010101111111100100011101 => OK +A5/3 - UL: 001100011100100111100100010001001100110100000100011001110111101011011010101010001010000010000010101011011011110001 => OK +A5/3 - DL: 001010100110100101110110011101100001111001100000110011000100111010001111100111110101001000010110000000100111011011 => OK +A5/3 - UL: 101001010100010011011000010001110101111100101100011110001100001101010110000101000001001010001111000100010111100111 => OK +A5/3 - DL: 101001001111011100001101110001011010001011001001011100000111111101011111101000011100011000001110101100010000011001 => OK +A5/3 - UL: 011101111000000010110101100101111011001100101000110000010100000000001011010111000111010010000010001111101000010100 => OK +A5/4 - DL: 101000101111111000110000001101001011011010110010001011001100010011100011001111000111000010010000101111101100001101 => OK +A5/4 - UL: 000101110000110101110100100101110100001100101111111110001001011110111001000110111110100010101110110010111010100010 => OK +A5/4 - DL: 100010011100110111101110001101100000110111111001000100010000001010000001101111001111010101110111010101011010000001 => OK +A5/4 - UL: 001100111000001000101100000011000111011110010101100110001100100111001011111111000100100100011000001110101111011111 => OK -- 1.9.1 --------------070906000208070902060208-- From mailman-bounces at lists.osmocom.org Tue Jun 17 07:00:08 2014 From: mailman-bounces at lists.osmocom.org (mailman-bounces at lists.osmocom.org) Date: Tue, 17 Jun 2014 09:00:08 +0200 Subject: baseband-devel unsubscribe notification Message-ID: bjoern.riemer at fokus.fraunhofer.de has been removed from baseband-devel. From Max.Suraev at fairwaves.co Tue Jun 17 09:51:54 2014 From: Max.Suraev at fairwaves.co (Max Suraev) Date: Tue, 17 Jun 2014 11:51:54 +0200 Subject: [PATCH] Remove osmo_a5_1 and osmo_a5_2 from public API - use generic osmo_a5() instead Message-ID: <1402998714-21349-1-git-send-email-Max.Suraev@fairwaves.co> Signed-off-by: Max Suraev --- 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 -/*! \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 From mailman at lists.osmocom.org Tue Jun 17 22:32:30 2014 From: mailman at lists.osmocom.org (mailman at lists.osmocom.org) Date: Wed, 18 Jun 2014 00:32:30 +0200 Subject: Bounce action notification Message-ID: This is a Mailman mailing list bounce action notice: List: baseband-devel Member: luca.bongiorni1 at studenti.unimi.it Action: Subscription disabled. Reason: Excessive or fatal bounces. The triggering bounce notice is attached below. Questions? Contact the Mailman site administrator at mailman at lists.osmocom.org. -------------- next part -------------- An embedded message was scrubbed... From: Internet Mail Delivery Subject: Delivery Notification: Delivery has failed Date: Wed, 18 Jun 2014 00:17:52 +0200 (CEST) Size: 9328 URL: From msokolov at ivan.Harhan.ORG Sat Jun 21 00:27:52 2014 From: msokolov at ivan.Harhan.ORG (Michael Spacefalcon) Date: Sat, 21 Jun 2014 00:27:52 GMT Subject: Calypso differences between C139 and C156? Message-ID: <1406210027.AA12628@ivan.Harhan.ORG> Hello fellow hackers, In process of getting FreeCalypso loadtools (primarily the flash manipulation utility fc-loadtool) working on the C1xx family in addition to the previously supported Openmoko and Pirelli targets, I discovered one bit of strangeness for which I have no explanation, and I wonder if anyone else has seen it or might have an explanation for it. According to Calypso chip documentation (gathered on the GSM mini- Wikileaks site ftp.ifctf.org:/pub/GSM), the complete nCS0 flash bank should always be accessible at address 0x03000000, regardless of whether the physical nIBOOT input is low or high, and regardless of what may have been written into the FFFF:FB10 register to enable or disable the mapping of the boot ROM at address 0. And indeed I have always used this nCS0 mapping at 0x03000000 on Openmoko and Pirelli targets, and have got used to it always working. But when I started playing with Compal phones a few months ago, I discovered that at least on the North American (1900+850 MHz) C139s reading from 0x03000000 returns all 0xFF's instead of the flash content, no matter what the FFFF:FB10 register is set to. So I figured it must be some difference between the full Calypso in the Openmoko & Pirelli phones and the Calypso Lite in C1xx, or perhaps that mapping at 0x03000000 only works when the physical nIBOOT input is low. Then last night I dusted off my North American C156 (this C156 and a bunch of NA C139s are the only Compal phones I have, as the more "mainstream" 900+1800 MHz models aren't of much use to me, given my geographic location) and tried my tools on it, as I'm polishing them up for a stable release. And guess what: reading from 0x03000000 yields the flash content on this phone, not the 0xFF's I get on all of the C139s I've tested! But don't all C1xx phones use the same Calypso Lite chip? And this C156 surely has nIBOOT tied high just like the other C1xx: the small sector at 0x2000 is all 0xFF's (blank), so if the boot ROM were enabled, the phone would never boot. (The boot ROM requires the 32-bit word at 0x2000 to be either 0 or 1, selecting different modes of booting the main fw.) Just wondering if anyone else has seen this strangeness, and what the behaviour might be on other C1xx phones besides those I have... Oh, and all of the work I've done for Compal target support in FreeCalypso loadtools is in the public Hg repository: https://bitbucket.org/falconian/freecalypso-sw VLR, SF P.S. Is Christophe Devine still on this list? Christophe, if you are reading this: I sent unicast email to your gmail address last night, but it bounced. Are you still around? From mailman at lists.osmocom.org Sat Jun 21 00:51:54 2014 From: mailman at lists.osmocom.org (mailman at lists.osmocom.org) Date: Sat, 21 Jun 2014 02:51:54 +0200 Subject: Bounce action notification Message-ID: This is a Mailman mailing list bounce action notice: List: baseband-devel Member: cbalke at charter.net Action: Subscription disabled. Reason: Excessive or fatal bounces. The triggering bounce notice is attached below. Questions? Contact the Mailman site administrator at mailman at lists.osmocom.org. -------------- next part -------------- An embedded message was scrubbed... From: Mail Delivery System Subject: Mail delivery failed: returning message to sender Date: Sat, 21 Jun 2014 02:37:54 +0200 Size: 5314 URL: From mailman at lists.osmocom.org Sat Jun 21 01:38:08 2014 From: mailman at lists.osmocom.org (mailman at lists.osmocom.org) Date: Sat, 21 Jun 2014 03:38:08 +0200 Subject: Bounce action notification Message-ID: This is a Mailman mailing list bounce action notice: List: baseband-devel Member: mki at mki-consult.de Action: Subscription disabled. Reason: Excessive or fatal bounces. The triggering bounce notice is attached below. Questions? Contact the Mailman site administrator at mailman at lists.osmocom.org. -------------- next part -------------- An embedded message was scrubbed... From: Mail Delivery System Subject: Mail delivery failed: returning message to sender Date: Sat, 21 Jun 2014 03:38:06 +0200 Size: 5414 URL: From mailman-bounces at lists.osmocom.org Mon Jun 23 07:00:13 2014 From: mailman-bounces at lists.osmocom.org (mailman-bounces at lists.osmocom.org) Date: Mon, 23 Jun 2014 09:00:13 +0200 Subject: baseband-devel unsubscribe notification Message-ID: 3304xfq at 163.com has been removed from baseband-devel. From mailman-bounces at lists.osmocom.org Thu Jun 26 07:00:03 2014 From: mailman-bounces at lists.osmocom.org (mailman-bounces at lists.osmocom.org) Date: Thu, 26 Jun 2014 09:00:03 +0200 Subject: baseband-devel unsubscribe notification Message-ID: osmocom at ninoc.nl has been removed from baseband-devel. From sammy.zada at gmail.com Fri Jun 27 03:28:54 2014 From: sammy.zada at gmail.com (sammy zada) Date: Fri, 27 Jun 2014 10:28:54 +0700 Subject: Hardware Preparation for Osmocom Bb Project Message-ID: Hi All, I'm interesting to make a final report for my study at college about the Osmocom Bb Topics. According to information from http://bb.osmocom.org/trac/ the most important device is old handset such as motorola C123. My question is, do we have to modify the component board of the motorola C123 or we can use it directly to build Osmocom Bb system? Is there any info regarding this question? Thanks, Sammy -------------- next part -------------- An HTML attachment was scrubbed... URL: From Max.Suraev at fairwaves.co Fri Jun 27 09:06:14 2014 From: Max.Suraev at fairwaves.co (=?UTF-8?B?4piO?=) Date: Fri, 27 Jun 2014 11:06:14 +0200 Subject: Hardware Preparation for Osmocom Bb Project In-Reply-To: References: Message-ID: <53AD3406.6030209@fairwaves.co> You build osmocom-bb on your laptop and only run it on c123 using appropriate loader. There are no modifications needed unless you plan to use it as a BTS. 27.06.2014 05:28, sammy zada ?????: > Hi All, > > I'm interesting to make a final report for my study at college about the Osmocom Bb > Topics. According to information from http://bb.osmocom.org/trac/ the most important > device is old handset such as motorola C123. > > My question is, do we have to modify the component board of the motorola C123 or we > can use it directly to build Osmocom Bb system? Is there any info regarding this > question? > > Thanks, > > Sammy -- best regards, Max, http://fairwaves.co