From zero-kelvin at gmx.de Mon Jan 27 22:43:03 2014 From: zero-kelvin at gmx.de (dexter) Date: Mon, 27 Jan 2014 23:43:03 +0100 Subject: UPDATE -- Osmocom Berlin User Group meeting -- NEXT MEETING In-Reply-To: <20130605121428.GA10030@nataraja.gnumonks.org> References: <502d01a9.mirider@mirider.augusta.de> <20120818115942.GV29525@prithivi.gnumonks.org> <51AF0097.10402@gmx.de> <20130605121428.GA10030@nataraja.gnumonks.org> Message-ID: <52E6E0F7.4040205@gmx.de> Hi All. It's time Again! This is the announcement for the next Osmocom Berlin meeting. Jan 29, 8pm @ CCC Berlin, Marienstr. 11, 10117 Berlin There is no formal presentation scheduled for this meeting. If you are interested to show up, feel free to do so. There is no registration required. The meeting is free as in "free beer", despite no actual free beer being around. I am looking forward to see you there! regards. Philipp From laforge at gnumonks.org Wed Jan 1 18:49:42 2014 From: laforge at gnumonks.org (Harald Welte) Date: Wed, 1 Jan 2014 19:49:42 +0100 Subject: OsmoDevCon 2014 / Date / Venue In-Reply-To: <20131105155825.GK12353@nataraja.gnumonks.org> References: <20131105155825.GK12353@nataraja.gnumonks.org> Message-ID: <20140101184942.GM7022@nataraja.gnumonks.org> Dear all, as the December 31st registration deadline has just passed, I'm happy to announce that all 17 requests for participation have been approved. We are still below the ~20 people limit of the venue. What we now need to do is to fill the schedule with talks / discussions. Please add your suggestions to https://openbsc.osmocom.org/trac/wiki/OsmoDevCon2014 even if it is just a topic you would like to discuss about, and not something that anyone feels compelled to hold a formal presentation about. Looking forward to seeing you in ~ 2 months in Berlin, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Sun Jan 12 18:36:00 2014 From: laforge at gnumonks.org (Harald Welte) Date: Sun, 12 Jan 2014 19:36:00 +0100 Subject: [PATCH] warnings cleanup In-Reply-To: <52AF19D2.9060603@fairwaves.ru> References: <52AF19D2.9060603@fairwaves.ru> Message-ID: <20140112183600.GR23594@nataraja> Hi Max, On Mon, Dec 16, 2013 at 04:18:42PM +0100, ? wrote: > I'd like to see osmocom-bb builds less cluttered by compiler warnings > - attached is (far from complete) attempt to do so. It's tested which > means it builds on my machine and resulting mobile app seems to run > fine - no in-depth testing were made. Thanks a lot for your work on this, it is much appreciated if somebody looks at this. > However I'd like to get some feedback before going further: there > seems to be some evil hackery happening around > src/target/firmware/apps/loader/main.c: The loader was written by Andreas, so I'll leave it to him to comment on this. > Why do we have external "unsigned char _start" which later used as > msgb_put_u32(msg, &_start); the _start and other related symbols are typically generated by the linker scripts. the msgb_put_u32() appears to be used in this case to send that address (for diagnostics?) via the L1CTL interface to the host application. > Do we make some assumptions on the size of unsigned char? Is this > documented somewhere by any chance? I implicitly assume unsigned char is an uint8_t. I doubt it is documented explicitly anywhere. > Also there are plenty of warnings regarding alignment: some things are > marked as "__attribute__ ((packed))" and some are not which seems to > make compiler unhappy. Is there rule of thumb to decide when we should > care about alignment? My suspicion is that those warnings started to appear at some point when compiler flags or compiler versions changed? __attribute__((packed)) is used in two cases: 1) when it is a network protocol either GSM/ETSI/3GPP specified or a custom ad-hoc like L1CTL. Basically whenever two parts of software running on different systems interact and we do not want compilers to add any padding int between whcih would cause incompatibility 2) for some data structures where size is more relevant than the access latency caused by a differently-aligned load + bit-shifting. I think this was the case for some of the TDMA / scheduling structures in layer1. As nobody else has picked up your patch so far, I'd rather apply it (and let people compalain in case of fall-out) rather than to have it lost in the list archives. Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From laforge at gnumonks.org Sun Jan 12 18:40:19 2014 From: laforge at gnumonks.org (Harald Welte) Date: Sun, 12 Jan 2014 19:40:19 +0100 Subject: [PATCH] adjust msgb api In-Reply-To: <52AF264E.1020903@fairwaves.ru> References: <52AF264E.1020903@fairwaves.ru> Message-ID: <20140112184019.GS23594@nataraja> Hi Max, On Mon, Dec 16, 2013 at 05:11:58PM +0100, ? wrote: > While looking at osmocom-bb compilation warnings I've noticed that > there are plenty of those cause by signed-unsigned comparison with > msgb-related functions. Attached is a trivial patch which fixes that > by changing int -> uint16_t. For the sake of completeness I've also > changed other functions to explicitly use uint16_t - this is used for > length fields in "struct msgb" anyway. I'm not squite sure how you will fix the problem if the return values are changed to unit16_t. All you get is that the result is truncated ? Keeping the implementation with unsigend int / int and the implementation having uint16_t means that we can still later change the implementation [if we ever need msgb's larger than that] with only an ABI breakage but no ABI breakage, so I liked that somehow. > Although technically it's API change I do not expect any sane code to > break. If you still think it's potentially insecure, this could be > applied during next api version bump alongside with gprs api change. The GPRS API change can be applied at any time, I'm not worried about that, really. But msgb API changes are affecting literally every program/project in the Osmocom sphere... Summary: Yes, I appreciate this being fixed - but I'd appreciate it even more if we didn't have to break the ABI :) -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From Max.Suraev at fairwaves.ru Tue Jan 14 16:36:15 2014 From: Max.Suraev at fairwaves.ru (=?UTF-8?B?4piO?=) Date: Tue, 14 Jan 2014 17:36:15 +0100 Subject: [PATCH] adjust msgb api In-Reply-To: <20140112184019.GS23594@nataraja> References: <52AF264E.1020903@fairwaves.ru> <20140112184019.GS23594@nataraja> Message-ID: <52D5677F.20400@fairwaves.ru> I see your point. You're right it's better to just switch msgb*room to unsigned - those values should never be negative anyway. 12.01.2014 19:40, Harald Welte ?????: > Hi Max, > > On Mon, Dec 16, 2013 at 05:11:58PM +0100, ? wrote: >> While looking at osmocom-bb compilation warnings I've noticed that >> there are plenty of those cause by signed-unsigned comparison with >> msgb-related functions. Attached is a trivial patch which fixes that >> by changing int -> uint16_t. For the sake of completeness I've also >> changed other functions to explicitly use uint16_t - this is used for >> length fields in "struct msgb" anyway. > > I'm not squite sure how you will fix the problem if the return values > are changed to unit16_t. All you get is that the result is truncated ? > > Keeping the implementation with unsigend int / int and the > implementation having uint16_t means that we can still later change the > implementation [if we ever need msgb's larger than that] with only an > ABI breakage but no ABI breakage, so I liked that somehow. > >> Although technically it's API change I do not expect any sane code to >> break. If you still think it's potentially insecure, this could be >> applied during next api version bump alongside with gprs api change. > > The GPRS API change can be applied at any time, I'm not worried about > that, really. But msgb API changes are affecting literally every > program/project in the Osmocom sphere... > > Summary: Yes, I appreciate this being fixed - but I'd appreciate it even > more if we didn't have to break the ABI :) > -- best regards, Max, http://fairwaves.ru From max.suraev at fairwaves.ru Tue Jan 14 16:32:09 2014 From: max.suraev at fairwaves.ru (Max) Date: Tue, 14 Jan 2014 17:32:09 +0100 Subject: [PATCH] Adjust msgb API Message-ID: --- include/osmocom/core/msgb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h index fe2733b..5610a22 100644 --- a/include/osmocom/core/msgb.h +++ b/include/osmocom/core/msgb.h @@ -147,7 +147,7 @@ static inline unsigned int msgb_headlen(const struct msgb *msgb) * This function computes the amount of octets left in the underlying * data buffer after the end of the message. */ -static inline int msgb_tailroom(const struct msgb *msgb) +static inline unsigned int msgb_tailroom(const struct msgb *msgb) { return (msgb->head + msgb->data_len) - msgb->tail; } @@ -159,7 +159,7 @@ static inline int msgb_tailroom(const struct msgb *msgb) * This function computes the amount of bytes left in the underlying * data buffer before the start of the actual message. */ -static inline int msgb_headroom(const struct msgb *msgb) +static inline unsigned int msgb_headroom(const struct msgb *msgb) { return (msgb->data - msgb->head); } -- 1.8.3.2 --------------070704060003090203050700-- From laforge at gnumonks.org Sun Jan 12 18:46:54 2014 From: laforge at gnumonks.org (Harald Welte) Date: Sun, 12 Jan 2014 19:46:54 +0100 Subject: [PATCH] Add generic LE/BE load/store uint type convertors and use them in msgb In-Reply-To: <52BF3C52.40207@fairwaves.ru> References: <52BF344B.1020001@fairwaves.ru> <52BF3C52.40207@fairwaves.ru> Message-ID: <20140112184654.GT23594@nataraja> Hi Max, On Sat, Dec 28, 2013 at 10:02:10PM +0100, ? wrote: > Improved version of 1st patch (rol16 implementation were missing) and > actual kasumi implementation which uses macro from 1st patch. thanks for your patch. I think it would be better if the load/store macros would at least have an OSMO_ name prefix in order to avoid namespace clashes with other code. I'd consider that mandatory for a merge. As a matter of style, I would prefer to have proper inline functions rather than hard to read multi-line macros. I'd consider that optional, as we could still increase readibility later on by either breaking the macros into multi-line macros or inline functions at a later point without breaking the API / uesers. What you get from inline functions is better compiler warnings in case of type mismatches on the input side. Trying to understand compiler warnings in complex macros is much harder. Regards, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) From Max.Suraev at fairwaves.ru Tue Jan 14 12:19:03 2014 From: Max.Suraev at fairwaves.ru (=?UTF-8?B?4piO?=) Date: Tue, 14 Jan 2014 13:19:03 +0100 Subject: [PATCH] Add generic LE/BE load/store uint type convertors and use them in msgb In-Reply-To: <20140112184654.GT23594@nataraja> References: <52BF344B.1020001@fairwaves.ru> <52BF3C52.40207@fairwaves.ru> <20140112184654.GT23594@nataraja> Message-ID: <52D52B37.5040300@fairwaves.ru> Hi. Attached is v2: converted to inline functions, fixed all compiler warnings and changed names to osmo_* Note: there are not much tests but kasumi and msgb code uses store/load routines so it could be considered as an indirect test case. -- best regards, Max, http://fairwaves.ru From max.suraev at fairwaves.ru Tue Jan 14 12:13:03 2014 From: max.suraev at fairwaves.ru (Max) Date: Tue, 14 Jan 2014 13:13:03 +0100 Subject: [PATCH 1/2] Add generic LE/BE load/store uint type convertors Message-ID: --- include/osmocom/core/bits.h | 142 +++++++++++++++++++++++++++++++++++++++++++- include/osmocom/core/msgb.h | 23 +++---- src/gsm/libosmogsm.map | 21 +++++++ tests/bits/bitrev_test.c | 19 +++++- tests/bits/bitrev_test.ok | 1 + 5 files changed, 193 insertions(+), 13 deletions(-) diff --git a/include/osmocom/core/bits.h b/include/osmocom/core/bits.h index 4c68532..fac87b8 100644 --- a/include/osmocom/core/bits.h +++ b/include/osmocom/core/bits.h @@ -2,7 +2,7 @@ #define _OSMO_BITS_H #include - +#include /*! \defgroup bits soft, unpacked and packed bits * @{ */ @@ -15,6 +15,136 @@ typedef int8_t sbit_t; /*!< \brief soft bit (-127...127) */ typedef uint8_t ubit_t; /*!< \brief unpacked bit (0 or 1) */ typedef uint8_t pbit_t; /*!< \brief packed bis (8 bits in a byte) */ +static inline uint16_t osmo_load16le(const uint8_t *p) +{//Load unaligned 16-bit integer (little-endian encoding) + return (((uint16_t *)(p))[0] | (((uint16_t *)(p))[1] << 8)); +} + +static inline uint16_t osmo_load16be(const uint8_t *p) +{//Load unaligned 16-bit integer (big-endian encoding) + return ((((uint16_t *)(p))[0] << 8) | ((uint16_t *)(p))[1]); +} + +static inline uint32_t osmo_load24le(const uint8_t *p) +{//Load unaligned 24-bit integer (little-endian encoding) + return (((uint32_t *)(p))[0] | + (((uint32_t *)(p))[1] << 8) | + (((uint32_t *)(p))[2] << 16)); +} + +static inline uint32_t osmo_load24be(const uint8_t *p) +{//Load unaligned 24-bit integer (big-endian encoding) + return ((((uint32_t *)(p))[0] << 16) | + (((uint32_t *)(p))[1] << 8) | + ((uint32_t *)(p))[2]); +} + +static inline uint32_t osmo_load32le(const uint8_t *p) +{//Load unaligned 32-bit integer (little-endian encoding) + return (((uint32_t *)(p))[0] | + (((uint32_t *)(p))[1] << 8) | + (((uint32_t *)(p))[2] << 16) | + (((uint32_t *)(p))[3] << 24)); +} + +static inline uint32_t osmo_load32be(const uint8_t *p) +{//Load unaligned 32-bit integer (big-endian encoding) + return ((((uint32_t *)(p))[0] << 24) | + (((uint32_t *)(p))[1] << 16) | + (((uint32_t *)(p))[2] << 8) | + ((uint32_t *)(p))[3]); +} + +static inline uint64_t osmo_load64le(const uint8_t *p) +{//Load unaligned 64-bit integer (little-endian encoding) + return (((uint64_t *)(p))[0] | + (((uint64_t *)(p))[1] << 8) | + (((uint64_t *)(p))[2] << 16) | + (((uint64_t *)(p))[3] << 24) | + (((uint64_t *)(p))[4] << 32) | + (((uint64_t *)(p))[5] << 40) | + (((uint64_t *)(p))[6] << 48) | + (((uint64_t *)(p))[7] << 56)); +} + +static inline uint64_t osmo_load64be(const uint8_t *p) +{//Load unaligned 64-bit integer (big-endian encoding) + return ((((uint64_t *)(p))[0] << 56) | + (((uint64_t *)(p))[1] << 48) | + (((uint64_t *)(p))[2] << 40) | + (((uint64_t *)(p))[3] << 32) | + (((uint64_t *)(p))[4] << 24) | + (((uint64_t *)(p))[5] << 16) | + (((uint64_t *)(p))[6] << 8) | + ((uint64_t *)(p))[7]); +} + +static inline void osmo_store16le(uint16_t a, uint8_t *p) +{//Store unaligned 16-bit integer (little-endian encoding) + ((uint8_t *)(p))[0] = (a) & 0xFF; + ((uint8_t *)(p))[1] = ((a) >> 8) & 0xFF; +} + +static inline void osmo_store16be(uint16_t a, uint8_t *p) +{//Store unaligned 32-bit integer (big-endian encoding) + ((uint8_t *)(p))[0] = ((a) >> 8) & 0xFF; + ((uint8_t *)(p))[1] = (a) & 0xFF; +} + +static inline void osmo_store24le(uint32_t a, uint8_t *p) +{//Store unaligned 24-bit integer (little-endian encoding) + ((uint8_t *)(p))[0] = (a) & 0xFF; + ((uint8_t *)(p))[1] = ((a) >> 8) & 0xFF; + ((uint8_t *)(p))[2] = ((a) >> 16) & 0xFF; +} + +static inline void osmo_store24be(uint32_t a, uint8_t *p) +{//Store unaligned 24-bit integer (big-endian encoding) + ((uint8_t *)(p))[0] = ((a) >> 16) & 0xFF; + ((uint8_t *)(p))[1] = ((a) >> 8) & 0xFF; + ((uint8_t *)(p))[2] = (a) & 0xFF; +} + +static inline void osmo_store32le(uint32_t a, uint8_t *p) +{//Store unaligned 32-bit integer (little-endian encoding) + ((uint8_t *)(p))[0] = (a) & 0xFF; + ((uint8_t *)(p))[1] = ((a) >> 8) & 0xFF; + ((uint8_t *)(p))[2] = ((a) >> 16) & 0xFF; + ((uint8_t *)(p))[3] = ((a) >> 24) & 0xFF; +} + +static inline void osmo_store32be(uint32_t a, uint8_t *p) +{//Store unaligned 32-bit integer (big-endian encoding) + ((uint8_t *)(p))[0] = ((a) >> 24) & 0xFF; + ((uint8_t *)(p))[1] = ((a) >> 16) & 0xFF; + ((uint8_t *)(p))[2] = ((a) >> 8) & 0xFF; + ((uint8_t *)(p))[3] = (a) & 0xFF; +} + +static inline void osmo_store64le(uint64_t a, uint8_t *p) +{//Store unaligned 64-bit integer (little-endian encoding) + ((uint8_t *)(p))[0] = (a) & 0xFF; + ((uint8_t *)(p))[1] = ((a) >> 8) & 0xFF; + ((uint8_t *)(p))[2] = ((a) >> 16) & 0xFF; + ((uint8_t *)(p))[3] = ((a) >> 24) & 0xFF; + ((uint8_t *)(p))[4] = ((a) >> 32) & 0xFF; + ((uint8_t *)(p))[5] = ((a) >> 40) & 0xFF; + ((uint8_t *)(p))[6] = ((a) >> 48) & 0xFF; + ((uint8_t *)(p))[7] = ((a) >> 56) & 0xFF; +} + +static inline void osmo_store64be(uint64_t a, uint8_t *p) +{//Store unaligned 64-bit integer (big-endian encoding) + ((uint8_t *)(p))[0] = ((a) >> 56) & 0xFF; + ((uint8_t *)(p))[1] = ((a) >> 48) & 0xFF; + ((uint8_t *)(p))[2] = ((a) >> 40) & 0xFF; + ((uint8_t *)(p))[3] = ((a) >> 32) & 0xFF; + ((uint8_t *)(p))[4] = ((a) >> 24) & 0xFF; + ((uint8_t *)(p))[5] = ((a) >> 16) & 0xFF; + ((uint8_t *)(p))[6] = ((a) >> 8) & 0xFF; + ((uint8_t *)(p))[7] = (a) & 0xFF; +} + /* NOTE on the endianess of pbit_t: Bits in a pbit_t are ordered MSB first, i.e. 0x80 is the first bit. @@ -73,6 +203,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 reverse the order of the bytes in a given buffer */ +void osmo_revbytes_buf(uint8_t *buf, size_t len); + +/* \brief left circular shift */ +static inline uint16_t rol16(uint16_t in, unsigned shift) +{ + return (in << shift) | (in >> (16 - shift)); +} + + /*! @} */ #endif /* _OSMO_BITS_H */ diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h index fe2733b..72fdc24 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 * @{ @@ -204,8 +205,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 @@ -215,10 +215,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 @@ -235,6 +232,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 @@ -244,6 +242,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 @@ -251,8 +250,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 @@ -260,7 +260,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 @@ -284,6 +284,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 @@ -308,6 +309,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 @@ -315,8 +317,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 @@ -324,7 +327,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/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index 9d15d66..41fff21 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -22,6 +22,23 @@ abis_nm_test_name; osmo_sitype_strs; +osmo_load16le; +osmo_load16be; +osmo_load24le; +osmo_load24be; +osmo_load32le; +osmo_load32be; +osmo_load64le; +osmo_load64be; +osmo_store16le; +osmo_store16be; +osmo_store24le; +osmo_store24be; +osmo_store32le; +osmo_store32be; +osmo_store64le; +osmo_store64be; + comp128; dbm2rxlev; @@ -196,6 +213,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/bits/bitrev_test.c b/tests/bits/bitrev_test.c index 5eca990..2e3b44f 100644 --- a/tests/bits/bitrev_test.c +++ b/tests/bits/bitrev_test.c @@ -1,4 +1,4 @@ - +#include #include #include #include @@ -12,7 +12,7 @@ static const uint8_t exp_out[] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x0 int main(int argc, char **argv) { - uint8_t out[ARRAY_SIZE(input)]; + uint8_t out[ARRAY_SIZE(input)], test[8]; unsigned int offs; for (offs = 0; offs < sizeof(out); offs++) { @@ -32,5 +32,20 @@ int main(int argc, char **argv) printf("\n"); } + printf("checking bit packer... "); + uint64_t _test = ((uint64_t)rand() << 32) + rand(); + osmo_store64be(_test, test); + + char s[18], *p; + snprintf(s, 17, "%.16" PRIx64, _test); + p = osmo_hexdump_nospc(test, 8); + if (0 != memcmp(s, p, 8)) { + printf ("%s\t", s); + printf ("%s\t", p); + printf("FAILED!\n"); + return 2; + } + printf("OK\n"); + return 0; } diff --git a/tests/bits/bitrev_test.ok b/tests/bits/bitrev_test.ok index 47f402f..8a5fc6e 100644 --- a/tests/bits/bitrev_test.ok +++ b/tests/bits/bitrev_test.ok @@ -22,3 +22,4 @@ REVERSED: 02 01 INORDER: 80 REVERSED: 01 +checking bit packer... OK -- 1.8.3.2 --------------040302010900050708060301 Content-Type: text/x-patch; name="0002-Add-Kasumi-cipher-implementation.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0002-Add-Kasumi-cipher-implementation.patch" From max.suraev at fairwaves.ru Tue Jan 14 12:14:00 2014 From: max.suraev at fairwaves.ru (Max) Date: Tue, 14 Jan 2014 13:14:00 +0100 Subject: [PATCH 2/2] Add Kasumi cipher implementation Message-ID: --- .gitignore | 1 + include/osmocom/gsm/kasumi.h | 36 ++++++++ src/gsm/Makefile.am | 2 +- src/gsm/kasumi.c | 193 +++++++++++++++++++++++++++++++++++++++++++ tests/Makefile.am | 7 +- tests/kasumi/kasumi_test.c | 128 ++++++++++++++++++++++++++++ tests/kasumi/kasumi_test.ok | 10 +++ 7 files changed, 374 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 71b27f2..e735dd0 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,7 @@ tests/testsuite tests/testsuite.dir/ tests/testsuite.log +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..8479968 --- /dev/null +++ b/include/osmocom/gsm/kasumi.h @@ -0,0 +1,36 @@ +/* + * KASUMI header + * + * See kasumi.c for details + */ + +#ifndef __KASUMI_H__ +#define __KASUMI_H__ + +#include + +/* + * Single iteration of KASUMI cipher +*/ +uint64_t _kasumi(uint64_t P, uint16_t *KLi1, uint16_t *KLi2, uint16_t *KOi1, uint16_t *KOi2, uint16_t *KOi3, uint16_t *KIi1, uint16_t *KIi2, uint16_t *KIi3); + +/* + * Implementation of the KGCORE algorithm (used by A5/3, A5/4, GEA3, GEA4 and ECSD) + * + * CA : uint8_t + * cb : uint8_t + * cc : uint32_t + * cd : uint8_t + * ck : uint8_t [8] + * co : uint8_t [output, cl-dependent] + * cl : uint16_t + */ +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); + +#endif /* __KASUMI_H__ */ diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am index 3162a7f..8ccbaec 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..9900e05 --- /dev/null +++ b/src/gsm/kasumi.c @@ -0,0 +1,193 @@ +/* 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 + +static uint16_t +_kasumi_FI(uint16_t I, uint16_t skey) +{ + static 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 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; +} + +static uint32_t +_kasumi_FO(uint32_t I, uint16_t *KOi1, uint16_t *KOi2, uint16_t *KOi3, uint16_t *KIi1, uint16_t *KIi2, 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; +} + +static uint32_t +_kasumi_FL(uint32_t I, uint16_t *KLi1, 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 ^= rol16(tmp, 1); + + tmp = R | KLi2[i]; + L ^= rol16(tmp, 1); + + return (((uint32_t)L) << 16) + R; +} + +uint64_t +_kasumi(uint64_t P, uint16_t *KLi1, uint16_t *KLi2, uint16_t *KOi1, uint16_t *KOi2, uint16_t *KOi3, uint16_t *KIi1, uint16_t *KIi2, 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 }; + + for (i = 0; i < 8; i++) /* Work with 16 bit subkeys and create prime subkeys */ + { + C[i] ^= osmo_load16be(key + i * 2); + } + /* C[] now stores K-prime[] */ + for (i = 0; i < 8; i++) /* Create round-specific subkeys */ + { + KLi1[i] = rol16(osmo_load16be(key + i * 2), 1); + KLi2[i] = C[(i + 2) & 0x7]; + + KOi1[i] = rol16(osmo_load16be(key + ((2 * (i + 1)) & 0xE)), 5); + KOi2[i] = rol16(osmo_load16be(key + ((2 * (i + 5)) & 0xE)), 8); + KOi3[i] = 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); + for (i = 0; i < cl / 64 + 1; i++) /* i is a block counter */ + { + BLK = _kasumi(A ^ i ^ BLK, KLi1, KLi2, KOi1, KOi2, KOi3, KIi1, KIi2, KIi3); + osmo_store64be(BLK, co + (i * 8)); + } +} 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..5504905 --- /dev/null +++ b/tests/kasumi/kasumi_test.c @@ -0,0 +1,128 @@ +#include +#include +#include +#include +#include + +#include +#include +#include // for testing internal A5/3 functions + + +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); + if (passed) printf(" OK. "); else printf("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 -- 1.8.3.2 --------------040302010900050708060301-- From holger at freyther.de Fri Jan 31 11:26:09 2014 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Fri, 31 Jan 2014 12:26:09 +0100 Subject: [PATCH] Add generic LE/BE load/store uint type convertors and use them in msgb In-Reply-To: <52D52B37.5040300@fairwaves.ru> References: <52BF344B.1020001@fairwaves.ru> <52BF3C52.40207@fairwaves.ru> <20140112184654.GT23594@nataraja> <52D52B37.5040300@fairwaves.ru> Message-ID: <20140131112609.GA18567@xiaoyu.lan> On Tue, Jan 14, 2014 at 01:19:03PM +0100, ? wrote: > Hi. > > Attached is v2: converted to inline functions, fixed all compiler warnings and > changed names to osmo_* > > Note: there are not much tests but kasumi and msgb code uses store/load routines so > it could be considered as an indirect test case. tests is some how important. At least knowing that all routines got executed at least once. > +static inline uint16_t osmo_load16le(const uint8_t *p) > +{//Load unaligned 16-bit integer (little-endian encoding) C89 didn't have this style of comments. Use /* */ but maybe consider using api comments above the function instead of directly after {? > +static inline uint16_t osmo_load16be(const uint8_t *p) > +{//Load unaligned 16-bit integer (big-endian encoding) > + return ((((uint16_t *)(p))[0] << 8) | ((uint16_t *)(p))[1]); this is not lisp. Can you remove the number of braces? Now that this is a method you can omit the () around p. In terms of readability. > +_kasumi; > +_kasumi_key_expand; > +_kasumi_kgcore; too early. please move that to the later patch. cheers holger From Max.Suraev at fairwaves.ru Fri Jan 31 14:10:48 2014 From: Max.Suraev at fairwaves.ru (=?UTF-8?B?4piO?=) Date: Fri, 31 Jan 2014 15:10:48 +0100 Subject: [PATCH] Add generic LE/BE load/store uint type convertors and use them in msgb In-Reply-To: <20140131112609.GA18567@xiaoyu.lan> References: <52BF344B.1020001@fairwaves.ru> <52BF3C52.40207@fairwaves.ru> <20140112184654.GT23594@nataraja> <52D52B37.5040300@fairwaves.ru> <20140131112609.GA18567@xiaoyu.lan> Message-ID: <52EBAEE8.2020104@fairwaves.ru> v3 attached, comments are inline. 31.01.2014 12:26, Holger Hans Peter Freyther ?????: > tests is some how important. At least knowing that all routines got > executed at least once. Added. > C89 didn't have this style of comments. Use /* */ but maybe > consider using api comments above the function instead of > directly after {? I've converted my comments but I'd like to point out that libosmocore does not actually follow this style - just do git grep -n "//"|grep -v http to verify. > this is not lisp. Yepp, that makes me sad too :) Anyway, fixed. -- best regards, Max, http://fairwaves.ru From max.suraev at fairwaves.ru Fri Jan 31 14:01:38 2014 From: max.suraev at fairwaves.ru (Max) Date: Fri, 31 Jan 2014 15:01:38 +0100 Subject: [PATCH 1/2] Add generic LE/BE load store uint type convertors Message-ID: --- include/osmocom/core/bits.h | 291 +++++++++++++++++++++++++++++++++++++++++++- include/osmocom/core/msgb.h | 23 ++-- src/gsm/libosmogsm.map | 23 ++++ tests/bits/bitrev_test.c | 134 +++++++++++++++++++- tests/bits/bitrev_test.ok | 15 +++ 5 files changed, 472 insertions(+), 14 deletions(-) diff --git a/include/osmocom/core/bits.h b/include/osmocom/core/bits.h index 4c68532..fa4d900 100644 --- a/include/osmocom/core/bits.h +++ b/include/osmocom/core/bits.h @@ -2,7 +2,7 @@ #define _OSMO_BITS_H #include - +#include /*! \defgroup bits soft, unpacked and packed bits * @{ */ @@ -15,6 +15,285 @@ typedef int8_t sbit_t; /*!< \brief soft bit (-127...127) */ typedef uint8_t ubit_t; /*!< \brief unpacked bit (0 or 1) */ typedef uint8_t pbit_t; /*!< \brief packed bis (8 bits in a byte) */ +/* Load unaligned 16-bit integer (little-endian encoding) */ +static inline uint16_t osmo_load16le(const uint8_t *p) +{ + return ((uint16_t)p[0]) | ((uint16_t)p[1] << 8); +} + +/* Load unaligned 16-bit integer (big-endian encoding) */ +static inline uint16_t osmo_load16be(const uint8_t *p) +{ + return ((uint16_t)p[0] << 8) | ((uint16_t)p[1]); +} + +/* Load unaligned 24-bit integer (little-endian encoding) */ +static inline uint32_t osmo_load24le(const uint8_t *p) +{ + return ((uint32_t)p[0]) | + ((uint32_t)p[1] << 8) | + ((uint32_t)p[2] << 16); +} + +/* Load unaligned 24-bit integer (big-endian encoding) */ +static inline uint32_t osmo_load24be(const uint8_t *p) +{ + return ((uint32_t)p[0] << 16) | + ((uint32_t)p[1] << 8) | + ((uint32_t)p[2]); +} + +/* Load unaligned 32-bit integer (little-endian encoding) */ +static inline uint32_t osmo_load32le(const uint8_t *p) +{ + return ((uint32_t)p[0]) | + ((uint32_t)p[1] << 8) | + ((uint32_t)p[2] << 16) | + ((uint32_t)p[3] << 24); +} + +/* Load unaligned 32-bit integer (big-endian encoding) */ +static inline uint32_t osmo_load32be(const uint8_t *p) +{ + return ((uint32_t)p[0] << 24) | + ((uint32_t)p[1] << 16) | + ((uint32_t)p[2] << 8) | + ((uint32_t)p[3]); +} + +/* Load unaligned 40-bit integer (little-endian encoding) */ +static inline uint64_t osmo_load40le(const uint8_t *p) +{ + return ((uint64_t)p[0]) | + ((uint64_t)p[1] << 8) | + ((uint64_t)p[2] << 16) | + ((uint64_t)p[3] << 24) | + ((uint64_t)p[4] << 32); +} + +/* Load unaligned 40-bit integer (big-endian encoding) */ +static inline uint64_t osmo_load40be(const uint8_t *p) +{ + return (((uint64_t)p[0]) << 32) | + ((uint64_t)p[1] << 24) | + ((uint64_t)p[2] << 16) | + ((uint64_t)p[3] << 8) | + ((uint64_t)p[4]); +} + +/* Load unaligned 48-bit integer (little-endian encoding) */ +static inline uint64_t osmo_load48le(const uint8_t *p) +{ + return ((uint64_t)p[0]) | + ((uint64_t)p[1] << 8) | + ((uint64_t)p[2] << 16) | + ((uint64_t)p[3] << 24) | + ((uint64_t)p[4] << 32) | + ((uint64_t)p[5] << 40); +} + +/* Load unaligned 48-bit integer (big-endian encoding) */ +static inline uint64_t osmo_load48be(const uint8_t *p) +{ + return (((uint64_t)p[0]) << 40) | + ((uint64_t)p[1] << 32) | + ((uint64_t)p[2] << 24) | + ((uint64_t)p[3] << 16) | + ((uint64_t)p[4] << 8) | + ((uint64_t)p[5]); +} + +/* Load unaligned 56-bit integer (little-endian encoding) */ +static inline uint64_t osmo_load56le(const uint8_t *p) +{ + return ((uint64_t)p[0]) | + ((uint64_t)p[1] << 8) | + ((uint64_t)p[2] << 16) | + ((uint64_t)p[3] << 24) | + ((uint64_t)p[4] << 32) | + ((uint64_t)p[5] << 40) | + ((uint64_t)p[6] << 48); +} + +/* Load unaligned 56-bit integer (big-endian encoding) */ +static inline uint64_t osmo_load56be(const uint8_t *p) +{ + return (((uint64_t)p[0]) << 48) | + ((uint64_t)p[1] << 40) | + ((uint64_t)p[2] << 32) | + ((uint64_t)p[3] << 24) | + ((uint64_t)p[4] << 16) | + ((uint64_t)p[5] << 8) | + ((uint64_t)p[6]); +} + +/* Load unaligned 64-bit integer (little-endian encoding) */ +static inline uint64_t osmo_load64le(const uint8_t *p) +{ + return ((uint64_t)p[0]) | + ((uint64_t)p[1] << 8) | + ((uint64_t)p[2] << 16) | + ((uint64_t)p[3] << 24) | + ((uint64_t)p[4] << 32) | + ((uint64_t)p[5] << 40) | + ((uint64_t)p[6] << 48) | + ((uint64_t)p[7] << 56); +} + +/* Load unaligned 64-bit integer (big-endian encoding) */ +static inline uint64_t osmo_load64be(const uint8_t *p) +{ + return (((uint64_t)p[0]) << 56) | + ((uint64_t)p[1] << 48) | + ((uint64_t)p[2] << 40) | + ((uint64_t)p[3] << 32) | + ((uint64_t)p[4] << 24) | + ((uint64_t)p[5] << 16) | + ((uint64_t)p[6] << 8) | + ((uint64_t)p[7]); +} + +/* Store unaligned 16-bit integer (little-endian encoding) */ +static inline void osmo_store16le(uint16_t a, uint8_t *p) +{ + ((uint8_t *)p)[0] = (a) & 0xFF; + ((uint8_t *)p)[1] = (a >> 8) & 0xFF; +} + +/* Store unaligned 16-bit integer (big-endian encoding) */ +static inline void osmo_store16be(uint16_t a, uint8_t *p) +{ + ((uint8_t *)p)[0] = (a >> 8) & 0xFF; + ((uint8_t *)p)[1] = (a) & 0xFF; +} + +/* Store unaligned 24-bit integer (little-endian encoding) */ +static inline void osmo_store24le(uint32_t a, uint8_t *p) +{ + ((uint8_t *)p)[0] = a & 0xFF; + ((uint8_t *)p)[1] = (a >> 8) & 0xFF; + ((uint8_t *)p)[2] = (a >> 16) & 0xFF; +} + +/* Store unaligned 24-bit integer (big-endian encoding) */ +static inline void osmo_store24be(uint32_t a, uint8_t *p) +{ + ((uint8_t *)p)[0] = (a >> 16) & 0xFF; + ((uint8_t *)p)[1] = (a >> 8) & 0xFF; + ((uint8_t *)p)[2] = a & 0xFF; +} + +/* Store unaligned 32-bit integer (little-endian encoding) */ +static inline void osmo_store32le(uint32_t a, uint8_t *p) +{ + ((uint8_t *)p)[0] = a & 0xFF; + ((uint8_t *)p)[1] = (a >> 8) & 0xFF; + ((uint8_t *)p)[2] = (a >> 16) & 0xFF; + ((uint8_t *)p)[3] = (a >> 24) & 0xFF; +} + +/* Store unaligned 32-bit integer (big-endian encoding) */ +static inline void osmo_store32be(uint32_t a, uint8_t *p) +{ + ((uint8_t *)p)[0] = (a >> 24) & 0xFF; + ((uint8_t *)p)[1] = (a >> 16) & 0xFF; + ((uint8_t *)p)[2] = (a >> 8) & 0xFF; + ((uint8_t *)p)[3] = a & 0xFF; +} + +/* Store unaligned 40-bit integer (little-endian encoding) */ +static inline void osmo_store40le(uint64_t a, uint8_t *p) +{ + ((uint8_t *)p)[0] = a & 0xFF; + ((uint8_t *)p)[1] = (a >> 8) & 0xFF; + ((uint8_t *)p)[2] = (a >> 16) & 0xFF; + ((uint8_t *)p)[3] = (a >> 24) & 0xFF; + ((uint8_t *)p)[4] = (a >> 32) & 0xFF; +} + +/* Store unaligned 40-bit integer (big-endian encoding) */ +static inline void osmo_store40be(uint64_t a, uint8_t *p) +{ + ((uint8_t *)p)[0] = (a >> 32) & 0xFF; + ((uint8_t *)p)[1] = (a >> 24) & 0xFF; + ((uint8_t *)p)[2] = (a >> 16) & 0xFF; + ((uint8_t *)p)[3] = (a >> 8) & 0xFF; + ((uint8_t *)p)[4] = a & 0xFF; +} + +/* Store unaligned 48-bit integer (little-endian encoding) */ +static inline void osmo_store48le(uint64_t a, uint8_t *p) +{ + ((uint8_t *)p)[0] = a & 0xFF; + ((uint8_t *)p)[1] = (a >> 8) & 0xFF; + ((uint8_t *)p)[2] = (a >> 16) & 0xFF; + ((uint8_t *)p)[3] = (a >> 24) & 0xFF; + ((uint8_t *)p)[4] = (a >> 32) & 0xFF; + ((uint8_t *)p)[5] = (a >> 40) & 0xFF; +} + +/* Store unaligned 48-bit integer (big-endian encoding) */ +static inline void osmo_store48be(uint64_t a, uint8_t *p) +{ + ((uint8_t *)p)[0] = (a >> 40) & 0xFF; + ((uint8_t *)p)[1] = (a >> 32) & 0xFF; + ((uint8_t *)p)[2] = (a >> 24) & 0xFF; + ((uint8_t *)p)[3] = (a >> 16) & 0xFF; + ((uint8_t *)p)[4] = (a >> 8) & 0xFF; + ((uint8_t *)p)[5] = a & 0xFF; +} + +/* Store unaligned 56-bit integer (little-endian encoding) */ +static inline void osmo_store56le(uint64_t a, uint8_t *p) +{ + ((uint8_t *)p)[0] = a & 0xFF; + ((uint8_t *)p)[1] = (a >> 8) & 0xFF; + ((uint8_t *)p)[2] = (a >> 16) & 0xFF; + ((uint8_t *)p)[3] = (a >> 24) & 0xFF; + ((uint8_t *)p)[4] = (a >> 32) & 0xFF; + ((uint8_t *)p)[5] = (a >> 40) & 0xFF; + ((uint8_t *)p)[6] = (a >> 48) & 0xFF; +} + +/* Store unaligned 56-bit integer (big-endian encoding) */ +static inline void osmo_store56be(uint64_t a, uint8_t *p) +{ + ((uint8_t *)p)[0] = (a >> 48) & 0xFF; + ((uint8_t *)p)[1] = (a >> 40) & 0xFF; + ((uint8_t *)p)[2] = (a >> 32) & 0xFF; + ((uint8_t *)p)[3] = (a >> 24) & 0xFF; + ((uint8_t *)p)[4] = (a >> 16) & 0xFF; + ((uint8_t *)p)[5] = (a >> 8) & 0xFF; + ((uint8_t *)p)[6] = a & 0xFF; +} + +/* Store unaligned 64-bit integer (little-endian encoding) */ +static inline void osmo_store64le(uint64_t a, uint8_t *p) +{ + ((uint8_t *)p)[0] = a & 0xFF; + ((uint8_t *)p)[1] = (a >> 8) & 0xFF; + ((uint8_t *)p)[2] = (a >> 16) & 0xFF; + ((uint8_t *)p)[3] = (a >> 24) & 0xFF; + ((uint8_t *)p)[4] = (a >> 32) & 0xFF; + ((uint8_t *)p)[5] = (a >> 40) & 0xFF; + ((uint8_t *)p)[6] = (a >> 48) & 0xFF; + ((uint8_t *)p)[7] = (a >> 56) & 0xFF; +} + +/* Store unaligned 64-bit integer (big-endian encoding) */ +static inline void osmo_store64be(uint64_t a, uint8_t *p) +{ + + ((uint8_t *)p)[0] = (a >> 56) & 0xFF; + ((uint8_t *)p)[1] = (a >> 48) & 0xFF; + ((uint8_t *)p)[2] = (a >> 40) & 0xFF; + ((uint8_t *)p)[3] = (a >> 32) & 0xFF; + ((uint8_t *)p)[4] = (a >> 24) & 0xFF; + ((uint8_t *)p)[5] = (a >> 16) & 0xFF; + ((uint8_t *)p)[6] = (a >> 8) & 0xFF; + ((uint8_t *)p)[7] = a & 0xFF; +} + /* NOTE on the endianess of pbit_t: Bits in a pbit_t are ordered MSB first, i.e. 0x80 is the first bit. @@ -73,6 +352,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 reverse the order of the bytes in a given buffer */ +void osmo_revbytes_buf(uint8_t *buf, size_t len); + +/* \brief left circular shift */ +static inline uint16_t rol16(uint16_t in, unsigned shift) +{ + return (in << shift) | (in >> (16 - shift)); +} + + /*! @} */ #endif /* _OSMO_BITS_H */ diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h index fe2733b..72fdc24 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 * @{ @@ -204,8 +205,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 @@ -215,10 +215,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 @@ -235,6 +232,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 @@ -244,6 +242,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 @@ -251,8 +250,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 @@ -260,7 +260,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 @@ -284,6 +284,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 @@ -308,6 +309,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 @@ -315,8 +317,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 @@ -324,7 +327,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/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index 9d15d66..d54f940 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -22,6 +22,29 @@ abis_nm_test_name; osmo_sitype_strs; +osmo_load16le; +osmo_load16be; +osmo_load24le; +osmo_load24be; +osmo_load32le; +osmo_load32be; +osmo_load64le; +osmo_load64be; +osmo_store16le; +osmo_store16be; +osmo_store24le; +osmo_store24be; +osmo_store32le; +osmo_store32be; +osmo_store40le; +osmo_store40be; +osmo_store48le; +osmo_store48be; +osmo_store56le; +osmo_store56be; +osmo_store64le; +osmo_store64be; + comp128; dbm2rxlev; diff --git a/tests/bits/bitrev_test.c b/tests/bits/bitrev_test.c index 5eca990..f82dbf3 100644 --- a/tests/bits/bitrev_test.c +++ b/tests/bits/bitrev_test.c @@ -1,4 +1,4 @@ - +#include #include #include #include @@ -12,9 +12,10 @@ static const uint8_t exp_out[] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x0 int main(int argc, char **argv) { - uint8_t out[ARRAY_SIZE(input)]; + uint8_t out[ARRAY_SIZE(input)], test[8]; unsigned int offs; - + char s[18], *p; + for (offs = 0; offs < sizeof(out); offs++) { uint8_t *start = out + offs; uint8_t len = sizeof(out) - offs; @@ -32,5 +33,132 @@ int main(int argc, char **argv) printf("\n"); } + printf("checking byte packing...\n"); + + uint64_t _test64 = ((uint64_t)rand() << 32) + rand(); + osmo_store64be(_test64, test); + + snprintf(s, 17, "%.16" PRIx64, _test64); + p = osmo_hexdump_nospc(test, 8); + if (0 != memcmp(s, p, 8)) { + printf ("%s\t", s); + printf ("%s\t", p); + printf("64 BE FAILED!\n"); + } else printf("64 BE OK\n"); + + osmo_store64le(_test64, test); + if (osmo_load64le(test) == _test64) + printf("64 LE OK\n"); + else + printf("64 LE FAILED: %s, %.16" PRIx64 ", %.16" PRIx64 "\n", osmo_hexdump(test, 8), osmo_load64le(test), _test64); + + + uint64_t _test56 = ((((uint64_t)rand() << 32) + rand()) << 8) >> 8; + osmo_store56be(_test56, test); + + snprintf(s, 17, "%.14" PRIx64, _test56); + p = osmo_hexdump_nospc(test, 7); + if (0 != memcmp(s, p, 7)) { + printf ("%s\t", s); + printf ("%s\t", p); + printf("56 BE FAILED!\n"); + } else printf("56 BE OK\n"); + + osmo_store56le(_test56, test); + if (osmo_load56le(test) == _test56) + printf("56 LE OK\n"); + else + printf("56 LE FAILED: %s, %.14" PRIx64 ", %.14" PRIx64 "\n", osmo_hexdump(test, 7), osmo_load56le(test), _test56); + + + uint64_t _test48 = ((((uint64_t)rand() << 32) + rand()) << 16) >> 16; + osmo_store48be(_test48, test); + + snprintf(s, 17, "%.12" PRIx64, _test48); + p = osmo_hexdump_nospc(test, 6); + if (0 != memcmp(s, p, 6)) { + printf ("%s\t", s); + printf ("%s\t", p); + printf("48 BE FAILED!\n"); + } else printf("48 BE OK\n"); + + osmo_store48le(_test48, test); + if (osmo_load48le(test) == _test48) + printf("48 LE OK\n"); + else + printf("48 LE FAILED: %s, %.12" PRIx64 ", %.12" PRIx64 "\n", osmo_hexdump(test, 6), osmo_load48le(test), _test48); + + + uint64_t _test40 = ((((uint64_t)rand() << 32) + rand()) << 24) >> 24; + osmo_store40be(_test40, test); + + snprintf(s, 17, "%.10" PRIx64, _test40); + p = osmo_hexdump_nospc(test, 5); + if (0 != memcmp(s, p, 5)) { + printf ("%s\t", s); + printf ("%s\t", p); + printf("40 BE FAILED!\n"); + } else printf("40 BE OK\n"); + + osmo_store40le(_test40, test); + if (osmo_load40le(test) == _test40) + printf("40 LE OK\n"); + else + printf("40 LE FAILED: %s, %.10" PRIx64 ", %.10" PRIx64 "\n", osmo_hexdump(test, 5), osmo_load40le(test), _test40); + + + uint32_t _test32 = (uint32_t)rand(); + osmo_store32be(_test32, test); + + snprintf(s, 17, "%.8" PRIx32, _test32); + p = osmo_hexdump_nospc(test, 4); + if (0 != memcmp(s, p, 4)) { + printf ("%s\t", s); + printf ("%s\t", p); + printf("32 BE FAILED!\n"); + } else printf("32 BE OK\n"); + + osmo_store32le(_test32, test); + if (osmo_load32le(test) == _test32) + printf("32 LE OK\n"); + else + printf("32 LE FAILED: %s, %.8" PRIx32 ", %.8" PRIx32 "\n", osmo_hexdump(test, 4), osmo_load32le(test), _test32); + + + uint32_t _test24 = ((uint32_t)rand() << 8) >> 8; + osmo_store24be(_test24, test); + + snprintf(s, 17, "%.6" PRIx32, _test24); + p = osmo_hexdump_nospc(test, 3); + if (0 != memcmp(s, p, 3)) { + printf ("%s\t", s); + printf ("%s\t", p); + printf("24 BE FAILED!\n"); + } else printf("24 BE OK\n"); + + osmo_store24le(_test24, test); + if (osmo_load24le(test) == _test24) + printf("24 LE OK\n"); + else + printf("24 LE FAILED: %s, %.6" PRIx32 ", %.6" PRIx32 "\n", osmo_hexdump(test, 3), osmo_load24le(test), _test24); + + + uint16_t _test16 = (uint16_t)rand(); + osmo_store16be(_test16, test); + + snprintf(s, 17, "%.4" PRIx16, _test16); + p = osmo_hexdump_nospc(test, 2); + if (0 != memcmp(s, p, 2)) { + printf ("%s\t", s); + printf ("%s\t", p); + printf("16 BE FAILED!\n"); + } else printf("16 BE OK\n"); + + osmo_store16le(_test16, test); + if (osmo_load16le(test) == _test16) + printf("16 LE OK\n"); + else + printf("16 LE FAILED: %s, %.4" PRIx16 ", %.4" PRIx16 "\n", osmo_hexdump(test, 2), osmo_load16le(test), _test16); + return 0; } diff --git a/tests/bits/bitrev_test.ok b/tests/bits/bitrev_test.ok index 47f402f..e319af2 100644 --- a/tests/bits/bitrev_test.ok +++ b/tests/bits/bitrev_test.ok @@ -22,3 +22,18 @@ REVERSED: 02 01 INORDER: 80 REVERSED: 01 +checking byte packing... +64 BE OK +64 LE OK +56 BE OK +56 LE OK +48 BE OK +48 LE OK +40 BE OK +40 LE OK +32 BE OK +32 LE OK +24 BE OK +24 LE OK +16 BE OK +16 LE OK -- 1.8.3.2 --------------060209070104080702030101 Content-Type: text/x-patch; name="0002-Add-Kasumi-cipher-implementation.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0002-Add-Kasumi-cipher-implementation.patch" From max.suraev at fairwaves.ru Fri Jan 31 14:03:35 2014 From: max.suraev at fairwaves.ru (Max) Date: Fri, 31 Jan 2014 15:03:35 +0100 Subject: [PATCH 2/2] Add Kasumi cipher implementation Message-ID: --- .gitignore | 2 + include/osmocom/gsm/kasumi.h | 36 ++++++++ src/gsm/Makefile.am | 2 +- src/gsm/kasumi.c | 193 +++++++++++++++++++++++++++++++++++++++++++ src/gsm/libosmogsm.map | 4 + tests/Makefile.am | 7 +- tests/kasumi/kasumi_test.c | 128 ++++++++++++++++++++++++++++ tests/kasumi/kasumi_test.ok | 10 +++ 8 files changed, 379 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 71b27f2..6436310 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,8 @@ tests/testsuite 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..8479968 --- /dev/null +++ b/include/osmocom/gsm/kasumi.h @@ -0,0 +1,36 @@ +/* + * KASUMI header + * + * See kasumi.c for details + */ + +#ifndef __KASUMI_H__ +#define __KASUMI_H__ + +#include + +/* + * Single iteration of KASUMI cipher +*/ +uint64_t _kasumi(uint64_t P, uint16_t *KLi1, uint16_t *KLi2, uint16_t *KOi1, uint16_t *KOi2, uint16_t *KOi3, uint16_t *KIi1, uint16_t *KIi2, uint16_t *KIi3); + +/* + * Implementation of the KGCORE algorithm (used by A5/3, A5/4, GEA3, GEA4 and ECSD) + * + * CA : uint8_t + * cb : uint8_t + * cc : uint32_t + * cd : uint8_t + * ck : uint8_t [8] + * co : uint8_t [output, cl-dependent] + * cl : uint16_t + */ +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); + +#endif /* __KASUMI_H__ */ diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am index 3162a7f..8ccbaec 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..9900e05 --- /dev/null +++ b/src/gsm/kasumi.c @@ -0,0 +1,193 @@ +/* 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 + +static uint16_t +_kasumi_FI(uint16_t I, uint16_t skey) +{ + static 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 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; +} + +static uint32_t +_kasumi_FO(uint32_t I, uint16_t *KOi1, uint16_t *KOi2, uint16_t *KOi3, uint16_t *KIi1, uint16_t *KIi2, 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; +} + +static uint32_t +_kasumi_FL(uint32_t I, uint16_t *KLi1, 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 ^= rol16(tmp, 1); + + tmp = R | KLi2[i]; + L ^= rol16(tmp, 1); + + return (((uint32_t)L) << 16) + R; +} + +uint64_t +_kasumi(uint64_t P, uint16_t *KLi1, uint16_t *KLi2, uint16_t *KOi1, uint16_t *KOi2, uint16_t *KOi3, uint16_t *KIi1, uint16_t *KIi2, 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 }; + + for (i = 0; i < 8; i++) /* Work with 16 bit subkeys and create prime subkeys */ + { + C[i] ^= osmo_load16be(key + i * 2); + } + /* C[] now stores K-prime[] */ + for (i = 0; i < 8; i++) /* Create round-specific subkeys */ + { + KLi1[i] = rol16(osmo_load16be(key + i * 2), 1); + KLi2[i] = C[(i + 2) & 0x7]; + + KOi1[i] = rol16(osmo_load16be(key + ((2 * (i + 1)) & 0xE)), 5); + KOi2[i] = rol16(osmo_load16be(key + ((2 * (i + 5)) & 0xE)), 8); + KOi3[i] = 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); + for (i = 0; i < cl / 64 + 1; i++) /* i is a block counter */ + { + 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 d54f940..7551c4a 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -219,6 +219,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..5504905 --- /dev/null +++ b/tests/kasumi/kasumi_test.c @@ -0,0 +1,128 @@ +#include +#include +#include +#include +#include + +#include +#include +#include // for testing internal A5/3 functions + + +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); + if (passed) printf(" OK. "); else printf("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 -- 1.8.3.2 --------------060209070104080702030101-- From max.suraev at fairwaves.ru Fri Jan 31 14:03:35 2014 From: max.suraev at fairwaves.ru (Max) Date: Fri, 31 Jan 2014 15:03:35 +0100 Subject: [PATCH 2/2] Add Kasumi cipher implementation Message-ID: --- .gitignore | 2 + include/osmocom/gsm/kasumi.h | 36 ++++++++ src/gsm/Makefile.am | 2 +- src/gsm/kasumi.c | 193 +++++++++++++++++++++++++++++++++++++++++++ src/gsm/libosmogsm.map | 4 + tests/Makefile.am | 7 +- tests/kasumi/kasumi_test.c | 128 ++++++++++++++++++++++++++++ tests/kasumi/kasumi_test.ok | 10 +++ 8 files changed, 379 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 71b27f2..6436310 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,8 @@ tests/testsuite 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..8479968 --- /dev/null +++ b/include/osmocom/gsm/kasumi.h @@ -0,0 +1,36 @@ +/* + * KASUMI header + * + * See kasumi.c for details + */ + +#ifndef __KASUMI_H__ +#define __KASUMI_H__ + +#include + +/* + * Single iteration of KASUMI cipher +*/ +uint64_t _kasumi(uint64_t P, uint16_t *KLi1, uint16_t *KLi2, uint16_t *KOi1, uint16_t *KOi2, uint16_t *KOi3, uint16_t *KIi1, uint16_t *KIi2, uint16_t *KIi3); + +/* + * Implementation of the KGCORE algorithm (used by A5/3, A5/4, GEA3, GEA4 and ECSD) + * + * CA : uint8_t + * cb : uint8_t + * cc : uint32_t + * cd : uint8_t + * ck : uint8_t [8] + * co : uint8_t [output, cl-dependent] + * cl : uint16_t + */ +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); + +#endif /* __KASUMI_H__ */ diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am index 3162a7f..8ccbaec 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..9900e05 --- /dev/null +++ b/src/gsm/kasumi.c @@ -0,0 +1,193 @@ +/* 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 + +static uint16_t +_kasumi_FI(uint16_t I, uint16_t skey) +{ + static 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 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; +} + +static uint32_t +_kasumi_FO(uint32_t I, uint16_t *KOi1, uint16_t *KOi2, uint16_t *KOi3, uint16_t *KIi1, uint16_t *KIi2, 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; +} + +static uint32_t +_kasumi_FL(uint32_t I, uint16_t *KLi1, 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 ^= rol16(tmp, 1); + + tmp = R | KLi2[i]; + L ^= rol16(tmp, 1); + + return (((uint32_t)L) << 16) + R; +} + +uint64_t +_kasumi(uint64_t P, uint16_t *KLi1, uint16_t *KLi2, uint16_t *KOi1, uint16_t *KOi2, uint16_t *KOi3, uint16_t *KIi1, uint16_t *KIi2, 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 }; + + for (i = 0; i < 8; i++) /* Work with 16 bit subkeys and create prime subkeys */ + { + C[i] ^= osmo_load16be(key + i * 2); + } + /* C[] now stores K-prime[] */ + for (i = 0; i < 8; i++) /* Create round-specific subkeys */ + { + KLi1[i] = rol16(osmo_load16be(key + i * 2), 1); + KLi2[i] = C[(i + 2) & 0x7]; + + KOi1[i] = rol16(osmo_load16be(key + ((2 * (i + 1)) & 0xE)), 5); + KOi2[i] = rol16(osmo_load16be(key + ((2 * (i + 5)) & 0xE)), 8); + KOi3[i] = 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); + for (i = 0; i < cl / 64 + 1; i++) /* i is a block counter */ + { + 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 d54f940..7551c4a 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -219,6 +219,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..5504905 --- /dev/null +++ b/tests/kasumi/kasumi_test.c @@ -0,0 +1,128 @@ +#include +#include +#include +#include +#include + +#include +#include +#include // for testing internal A5/3 functions + + +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); + if (passed) printf(" OK. "); else printf("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 -- 1.8.3.2 --------------040706090709050002010705-- From andreas at eversberg.eu Sat Jan 4 08:18:24 2014 From: andreas at eversberg.eu (Andreas Eversberg) Date: Sat, 04 Jan 2014 09:18:24 +0100 Subject: what menu.e88loader.bin: No such file or directory In-Reply-To: <1388332973973-4026277.post@n3.nabble.com> References: <1388332973973-4026277.post@n3.nabble.com> Message-ID: <52C7C3D0.8060201@eversberg.eu> warriornew wrote: > what menu.e88loader.bin: No such file or directory I refer to this > article : http://bb.osmocom.org/trac/wiki/flashing_new But why can't > find menu.e88loader.bin?? Does anyone know? hi, it is not merged to master yet. please change to the jolly/menu branch. regards, andreas From saxenaneetesh061 at rediffmail.com Thu Jan 2 13:20:44 2014 From: saxenaneetesh061 at rediffmail.com (neetesh saxena) Date: 2 Jan 2014 13:20:44 -0000 Subject: =?utf-8?B?T3Ntb2NvbTogYXNzZW1ibGVyIGVycm9ycyAoc3dhYi5oKQ==?= Message-ID: <1388145549.S.3898.RU.sfs11, sfs11, 629, 327.23727.f4mail-235-237.rediffmail.com.old.1388668844.11653@webmail.rediffmail.com> Hi everyone, Next time when I am trying to compile osmocom-bb source using "make" command it is showing two errors. Even I have removed the complete directory where I had put osmocom-bb, toolchain, libosmocore. I tried two times as a fresh installation but still I am getting the errors. Can anyone help me what to do? The details of the commands and the generated errors are as: neetesh at neetesh-VirtualBox:~/GSMP$ git clone git://git.osmocom.org/osmocom-bb.git Cloning into 'osmocom-bb'... remote: Counting objects: 19471, done. remote: Compressing objects: 100% (6037/6037), done. remote: Total 19471 (delta 13610), reused 18108 (delta 12508) Receiving objects: 100% (19471/19471), 3.37 MiB | 1.07 MiB/s, done. Resolving deltas: 100% (13610/13610), done. neetesh at neetesh-VirtualBox:~/GSMP$ cd osmocom-bb/ neetesh at neetesh-VirtualBox:~/GSMP/osmocom-bb$ git pull --rebase Current branch master is up to date. neetesh at neetesh-VirtualBox:~/GSMP/osmocom-bb$ cd src/ neetesh at neetesh-VirtualBox:~/GSMP/osmocom-bb/src$ sudo make cd shared/libosmocore && autoreconf -fi libtoolize: putting auxiliary files in `.'. libtoolize: copying file `./config.guess' libtoolize: copying file `./config.sub' libtoolize: copying file `./install-sh' libtoolize: copying file `./ltmain.sh' libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'. libtoolize: copying file `m4/libtool.m4' libtoolize: copying file `m4/ltoptions.m4' libtoolize: copying file `m4/ltsugar.m4' libtoolize: copying file `m4/ltversion.m4' libtoolize: copying file `m4/lt~obsolete.m4' configure.ac:5: installing `./missing' src/Makefile.am: installing `./depcomp' mkdir shared/libosmocore/build-target cd shared/libosmocore/build-target && ../configure \             --host=arm-none-eabi --enable-embedded --disable-shared \             --disable-tests ac_cv_header_sys_select_h=no \             --disable-tests ac_cv_header_sys_socket_h=no \         CFLAGS="-Os -ffunction-sections -I/home/neetesh/GSMP/osmocom-bb/src/target/firmware/include -nostartfiles -nodefaultlibs" configure: WARNING: unrecognized options: --disable-tests, --disable-tests configure: WARNING: if you wanted to set the --build type, don't use --host.     If a cross compiler is detected then cross compile mode will be used checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for arm-none-eabi-strip... no checking for strip... strip checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... no checking for mawk... mawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking whether make sets $(MAKE)... (cached) yes checking for arm-none-eabi-gcc... no checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... yes checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking for style of include used by make... GNU checking dependency style of gcc... gcc3 checking build system type... i686-pc-linux-gnu checking host system type... arm-none-eabi checking how to print strings... printf checking for a sed that does not truncate output... /bin/sed checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for fgrep... /bin/grep -F checking for ld used by gcc... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... yes checking for BSD- or MS-compatible name lister (nm)... no checking for arm-none-eabi-dumpbin... no checking for arm-none-eabi-link... no checking for dumpbin... no checking for link... link -dump configure: WARNING: using cross tools not prefixed with host triplet checking the name lister (nm) interface... BSD nm checking whether ln -s works... yes checking the maximum length of command line arguments... 805306365 checking whether the shell understands some XSI constructs... yes checking whether the shell understands "+="... yes checking how to convert i686-pc-linux-gnu file names to arm-none-eabi format... func_convert_file_noop checking how to convert i686-pc-linux-gnu file names to toolchain format... func_convert_file_noop checking for /usr/bin/ld option to reload object files... -r checking for arm-none-eabi-objdump... no checking for objdump... objdump checking how to recognize dependent libraries... unknown checking for arm-none-eabi-dlltool... no checking for dlltool... no checking how to associate runtime and link libraries... printf %s\n checking for arm-none-eabi-ar... no checking for ar... ar checking for archiver @FILE support... @ checking for arm-none-eabi-strip... strip checking for arm-none-eabi-ranlib... no checking for ranlib... ranlib checking command to parse nm output from gcc object... ok checking for sysroot... no checking for arm-none-eabi-mt... no checking for mt... mt checking if mt is a manifest tool... no checking how to run the C preprocessor... gcc -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for dlfcn.h... yes checking for objdir... .libs checking if gcc supports -fno-rtti -fno-exceptions... no checking for gcc option to produce PIC... -fPIC -DPIC checking if gcc PIC flag -fPIC -DPIC works... yes checking if gcc static flag -static works... no checking if gcc supports -c -o file.o... yes checking if gcc supports -c -o file.o... (cached) yes checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes checking dynamic linker characteristics... no checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... no checking whether to build shared libraries... no checking whether to build static libraries... yes checking for ANSI C header files... (cached) yes checking execinfo.h usability... yes checking execinfo.h presence... yes checking for execinfo.h... yes checking for sys/select.h... (cached) no checking for sys/socket.h... (cached) no checking syslog.h usability... yes checking syslog.h presence... yes checking for syslog.h... yes checking ctype.h usability... yes checking ctype.h presence... yes checking for ctype.h... yes checking for size_t... yes checking for working alloca.h... no checking for alloca... no checking whether `alloca.c' needs Cray hooks... no checking stack direction for C alloca... 0 checking for library containing dlopen... -ldl checking for doxygen... false checking if gcc supports -fvisibility=hidden... yes checking whether struct tm has tm_gmtoff member... no configure: creating ./config.status config.status: creating libosmocore.pc config.status: creating libosmocodec.pc config.status: creating libosmovty.pc config.status: creating libosmogsm.pc config.status: creating libosmogb.pc config.status: creating include/Makefile config.status: creating src/Makefile config.status: creating src/vty/Makefile config.status: creating src/codec/Makefile config.status: creating src/gsm/Makefile config.status: creating src/gb/Makefile config.status: creating tests/Makefile config.status: creating utils/Makefile config.status: creating Doxyfile.core config.status: creating Doxyfile.gsm config.status: creating Doxyfile.vty config.status: creating Doxyfile.codec config.status: creating Makefile config.status: creating config.h config.status: executing tests/atconfig commands config.status: executing depfiles commands config.status: executing libtool commands configure: WARNING: unrecognized options: --disable-tests, --disable-tests cd shared/libosmocore/build-target && make make[1]: Entering directory `/home/neetesh/GSMP/osmocom-bb/src/shared/libosmocore/build-target' echo UNKNOWN > ../.version-t && mv ../.version-t ../.version make  all-recursive make[2]: Entering directory `/home/neetesh/GSMP/osmocom-bb/src/shared/libosmocore/build-target' Making all in include make[3]: Entering directory `/home/neetesh/GSMP/osmocom-bb/src/shared/libosmocore/build-target/include'   GEN    osmocom/core/crc16gen.h   GEN    osmocom/core/crc16gen.h   GEN    osmocom/core/crc32gen.h   GEN    osmocom/core/crc32gen.h   GEN    osmocom/core/crc64gen.h   GEN    osmocom/core/crc64gen.h   GEN    osmocom/core/crc8gen.h   GEN    osmocom/core/crc8gen.h make[3]: Leaving directory `/home/neetesh/GSMP/osmocom-bb/src/shared/libosmocore/build-target/include' Making all in src make[3]: Entering directory `/home/neetesh/GSMP/osmocom-bb/src/shared/libosmocore/build-target/src'   GEN    crc8gen.c   GEN    crc16gen.c   GEN    crc32gen.c   GEN    crc64gen.c make  all-am make[4]: Entering directory `/home/neetesh/GSMP/osmocom-bb/src/shared/libosmocore/build-target/src'   CC     timer.lo   CC     select.lo   CC     signal.lo   CC     msgb.lo   CC     bits.lo   CC     bitvec.lo   CC     statistics.lo ../../src/statistics.c: In function 'osmo_counter_get_by_name': ../../src/statistics.c:72:3: warning: implicit declaration of function 'strcmp' [-Wimplicit-function-declaration]   CC     write_queue.lo   CC     utils.lo ../../src/utils.c: In function 'get_string_value': ../../src/utils.c:49:3: warning: implicit declaration of function 'strcasecmp' [-Wimplicit-function-declaration]   CC     socket.lo   CC     logging.lo ../../src/logging.c: In function 'log_parse_category': ../../src/logging.c:151:3: warning: implicit declaration of function 'strcasecmp' [-Wimplicit-function-declaration] ../../src/logging.c: In function 'log_parse_category_mask': ../../src/logging.c:168:2: warning: implicit declaration of function 'strdup' [-Wimplicit-function-declaration] ../../src/logging.c:168:15: warning: incompatible implicit declaration of built-in function 'strdup' [enabled by default] ../../src/logging.c:175:2: warning: implicit declaration of function 'strtok' [-Wimplicit-function-declaration] ../../src/logging.c:175:17: warning: assignment makes pointer from integer without a cast [enabled by default] ../../src/logging.c:179:4: warning: implicit declaration of function 'strstr' [-Wimplicit-function-declaration] ../../src/logging.c:179:18: warning: incompatible implicit declaration of built-in function 'strstr' [enabled by default] ../../src/logging.c:194:4: warning: implicit declaration of function 'strncasecmp' [-Wimplicit-function-declaration] ../../src/logging.c:205:27: warning: assignment makes pointer from integer without a cast [enabled by default] ../../src/logging.c: In function '_file_output': ../../src/logging.c:446:2: warning: implicit declaration of function 'fprintf' [-Wimplicit-function-declaration] ../../src/logging.c:446:2: warning: incompatible implicit declaration of built-in function 'fprintf' [enabled by default] ../../src/logging.c:447:2: warning: implicit declaration of function 'fflush' [-Wimplicit-function-declaration] ../../src/logging.c: In function 'log_target_create_file': ../../src/logging.c:520:2: warning: implicit declaration of function 'fopen' [-Wimplicit-function-declaration] ../../src/logging.c:520:23: warning: assignment makes pointer from integer without a cast [enabled by default] ../../src/logging.c: In function 'log_target_find': ../../src/logging.c:544:4: warning: implicit declaration of function 'strcmp' [-Wimplicit-function-declaration] ../../src/logging.c: In function 'log_target_destroy': ../../src/logging.c:566:4: warning: implicit declaration of function 'fclose' [-Wimplicit-function-declaration] ../../src/logging.c: In function 'log_target_file_reopen': ../../src/logging.c:579:23: warning: assignment makes pointer from integer without a cast [enabled by default]   CC     logging_syslog.lo   CC     rate_ctr.lo ../../src/rate_ctr.c: In function 'rate_ctr_get_group_by_name_idx': ../../src/rate_ctr.c:153:3: warning: implicit declaration of function 'strcmp' [-Wimplicit-function-declaration]   CC     gsmtap_util.lo In file included from /home/neetesh/GSMP/osmocom-bb/src/target/firmware/include/swab.h:5:0,                  from /home/neetesh/GSMP/osmocom-bb/src/target/firmware/include/byteorder.h:12,                  from /home/neetesh/GSMP/osmocom-bb/src/target/firmware/include/arpa/inet.h:2,                  from ../../src/gsmtap_util.c:37: /home/neetesh/GSMP/osmocom-bb/src/target/firmware/include/defines.h:5:0: warning: "__attribute_const__" redefined [enabled by default] /usr/include/i386-linux-gnu/sys/cdefs.h:241:0: note: this is the location of the previous definition /home/neetesh/GSMP/osmocom-bb/src/target/firmware/include/asm/swab.h: Assembler messages: /home/neetesh/GSMP/osmocom-bb/src/target/firmware/include/asm/swab.h:32: Error: no such instruction: `eor %edx,%ecx,%ecx,ror' make[4]: *** [gsmtap_util.lo] Error 1 make[4]: Leaving directory `/home/neetesh/GSMP/osmocom-bb/src/shared/libosmocore/build-target/src' make[3]: *** [all] Error 2 make[3]: Leaving directory `/home/neetesh/GSMP/osmocom-bb/src/shared/libosmocore/build-target/src' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/home/neetesh/GSMP/osmocom-bb/src/shared/libosmocore/build-target' make[1]: *** [all] Error 2 make[1]: Leaving directory `/home/neetesh/GSMP/osmocom-bb/src/shared/libosmocore/build-target' make: *** [shared/libosmocore/build-target/src/.libs/libosmocore.a] Error 2 With regards Neetesh Saxena... -------------- next part -------------- An HTML attachment was scrubbed... URL: From andreas at eversberg.eu Sat Jan 4 07:48:53 2014 From: andreas at eversberg.eu (Andreas Eversberg) Date: Sat, 04 Jan 2014 08:48:53 +0100 Subject: Osmocom: assembler errors (swab.h) In-Reply-To: <1388145549.S.3898.RU.sfs11, sfs11, 629, 327.23727.f4mail-235-237.rediffmail.com.old.1388668844.11653@webmail.rediffmail.com> References: <1388145549.S.3898.RU.sfs11, sfs11, 629, 327.23727.f4mail-235-237.rediffmail.com.old.1388668844.11653@webmail.rediffmail.com> Message-ID: <52C7BCE5.9010908@eversberg.eu> neetesh saxena wrote: > */home/neetesh/GSMP/osmocom-bb/src/target/firmware/include/asm/swab.h:32: > Error: no such instruction: `eor %edx,%ecx,%ecx,ror'* hi, are your arm-elf-* executables inside your path? my executables are inside /usr/bin: $ which arm-elf-gcc /usr/bin/arm-elf-gcc you can add the location of your path using: export PATH="$PATH:/your/location" regards, andreas -------------- next part -------------- An HTML attachment was scrubbed... URL: From saxenaneetesh061 at rediffmail.com Sun Jan 5 09:03:34 2014 From: saxenaneetesh061 at rediffmail.com (neetesh saxena) Date: 5 Jan 2014 09:03:34 -0000 Subject: =?utf-8?B?UmU6IE9zbW9jb206IGFzc2VtYmxlciBlcnJvcnMgKHN3YWIuaCk=?= In-Reply-To: <52C7BCE5.9010908@eversberg.eu> Message-ID: <1388821854.S.5135.32532.H.TkFuZHJlYXMgRXZlcnNiZXJnAFJlOiBPc21vY29tOiBhc3NlbWJsZXIgZXJyb3JzIChzd2FiLmgp.RU.rfs281, rfs281, 244, 977.f4-235-134.old.1388912614.16827@webmail.rediffmail.com> Hi,I have already set the path of arm-elf-gcc. But I am still getting the same error. Is there any command or procedure by which I can completely remove this installation so that I can try as a fresh one. NeeteshSent from RediffmailNG on Android From: "Andreas Eversberg"andreas at eversberg.eu Sent:Sat, 04 Jan 2014 13:20:54 +0530 To: neetesh saxena saxenaneetesh061 at rediffmail.com Cc: "baseband-devel"baseband-devel at lists.osmocom.org Subject: Re: Osmocom: assembler errors (swab.h) neetesh saxena wrote: /home/neetesh/GSMP/osmocom-bb/src/target/firmware/include/asm/swab.h:32: Error: no such instruction: `eor %edx,%ecx,%ecx,ror' hi, > > are your arm-elf-* executables inside your path? > > my executables are inside /usr/bin: > $ which arm-elf-gcc > /usr/bin/arm-elf-gcc > > you can add the location of your path using: > > export PATH="$PATH:/your/location" > > regards, > > andreas > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From saxenaneetesh061 at rediffmail.com Sun Jan 5 18:34:30 2014 From: saxenaneetesh061 at rediffmail.com (neetesh saxena) Date: 5 Jan 2014 18:34:30 -0000 Subject: =?utf-8?B?UmU6IE9zbW9jb206IGFzc2VtYmxlciBlcnJvcnMgKHN3YWIuaCk=?= In-Reply-To: <52C7BCE5.9010908@eversberg.eu> Message-ID: <1388821854.S.5135.32532.H.TkFuZHJlYXMgRXZlcnNiZXJnAFJlOiBPc21vY29tOiBhc3NlbWJsZXIgZXJyb3JzIChzd2FiLmgp.RU.rfs281, rfs281, 244, 977.f4-235-134.old.replied.1388946870.15236@webmail.rediffmail.com> Hi,It is written when building the toolchain that after build complete. Add yourpath/bin to your path to make arm-elf-gcc. It is also written that if you are using bash, you can add the following in your -/.baserc file. Export PATH equalto $ PATH:YOURPATH/install/binDoes both are required? Is it necessary to edit baserc file?Sent from RediffmailNG on Android From: "Andreas Eversberg"andreas at eversberg.eu Sent:Sat, 04 Jan 2014 13:20:54 +0530 To: neetesh saxena saxenaneetesh061 at rediffmail.com Cc: "baseband-devel"baseband-devel at lists.osmocom.org Subject: Re: Osmocom: assembler errors (swab.h) neetesh saxena wrote: /home/neetesh/GSMP/osmocom-bb/src/target/firmware/include/asm/swab.h:32: Error: no such instruction: `eor %edx,%ecx,%ecx,ror' hi, > > are your arm-elf-* executables inside your path? > > my executables are inside /usr/bin: > $ which arm-elf-gcc > /usr/bin/arm-elf-gcc > > you can add the location of your path using: > > export PATH="$PATH:/your/location" > > regards, > > andreas > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve at steve-m.de Sun Jan 5 18:51:19 2014 From: steve at steve-m.de (Steve Markgraf) Date: Sun, 05 Jan 2014 19:51:19 +0100 Subject: Osmocom: assembler errors (swab.h) In-Reply-To: <1388821854.S.5135.32532.H.TkFuZHJlYXMgRXZlcnNiZXJnAFJlOiBPc21vY29tOiBhc3NlbWJsZXIgZXJyb3JzIChzd2FiLmgp.RU.rfs281, rfs281, 244, 977.f4-235-134.old.1388912614.16827@webmail.rediffmail.com> References: <1388821854.S.5135.32532.H.TkFuZHJlYXMgRXZlcnNiZXJnAFJlOiBPc21vY29tOiBhc3NlbWJsZXIgZXJyb3JzIChzd2FiLmgp.RU.rfs281, rfs281, 244, 977.f4-235-134.old.1388912614.16827@webmail.rediffmail.com> Message-ID: <52C9A9A7.1030503@steve-m.de> Hi, On 05.01.2014 10:03, neetesh saxena wrote: > I have already set the path of arm-elf-gcc. > But I am still getting the same error. Is there any command or procedure > by which I can completely remove this installation so that I can try as > a fresh one. > _Neetesh_ If you tried building without the toolchain in place, you have to do a fresh clone of the git repo, or make sure to delete everything that automake and gcc created. Regards, Steve From saxenaneetesh061 at rediffmail.com Fri Jan 3 09:51:38 2014 From: saxenaneetesh061 at rediffmail.com (neetesh saxena) Date: 3 Jan 2014 09:51:38 -0000 Subject: =?utf-8?B?UmU6IOWbnuWkje+8mk9zbW9jb206IGFzc2VtYmxlciBlcnJvcnMgKHN3YWIuaCk=?= Message-ID: <1388720526.S.45807.24846.H.TkxTWAC72Li0o7pPc21vY29tOiBhc3NlbWJsZXIgZXJyb3JzIChzd2FiLmgp.RU.rfs288, rfs288, 779, 373.f4-234-146.old.1388742698.27129@webmail.rediffmail.com> Hi, I am using Ubuntu 32 bit OS with C118 Motorola phone. You have written "remember to use 64." in your blog, however you use Kali OS. Does it mean that osmocom doesn't support 32 bit Ubuntu? Do I need to switch on 64 bits OS? With regards Neetesh Saxena... From: "LSX" <289039690 at qq.com> Sent: Fri, 03 Jan 2014 09:12:06 To: "neetesh saxena" <saxenaneetesh061 at rediffmail.com> Subject: ???Osmocom: assembler errors (swab.h) ???????????????????????????????????????????kali 64 ????????????? ????????blog.lishixin.net ------------------ ???? ------------------???: "neetesh saxena";<saxenaneetesh061 at rediffmail.com>;????: 2014?1?2?(???) ??9:20???: "baseband-devel "<baseband-devel at lists.osmocom.org>; ??: Osmocom: assembler errors (swab.h) Hi everyone, Next time when I am trying to compile osmocom-bb source using "make" command it is showing two errors. Even I have removed the complete directory where I had put osmocom-bb, toolchain, libosmocore. I tried two times as a fresh installation but still I am getting the errors. Can anyone help me what to do? The details of the commands and the generated errors are as: neetesh at neetesh-VirtualBox:~/GSMP$ git clone git://git.osmocom.org/osmocom-bb.git Cloning into 'osmocom-bb'... remote: Counting objects: 19471, done. remote: Compressing objects: 100% (6037/6037), done. remote: Total 19471 (delta 13610), reused 18108 (delta 12508) Receiving objects: 100% (19471/19471), 3.37 MiB | 1.07 MiB/s, done. Resolving deltas: 100% (13610/13610), done. neetesh at neetesh-VirtualBox:~/GSMP$ cd osmocom-bb/ neetesh at neetesh-VirtualBox:~/GSMP/osmocom-bb$ git pull --rebase Current branch master is up to date. neetesh at neetesh-VirtualBox:~/GSMP/osmocom-bb$ cd src/ neetesh at neetesh-VirtualBox:~/GSMP/osmocom-bb/src$ sudo make cd shared/libosmocore && autoreconf -fi libtoolize: putting auxiliary files in `.'. libtoolize: copying file `./config.guess' libtoolize: copying file `./config.sub' libtoolize: copying file `./install-sh' libtoolize: copying file `./ltmain.sh' libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'. libtoolize: copying file `m4/libtool.m4' libtoolize: copying file `m4/ltoptions.m4' libtoolize: copying file `m4/ltsugar.m4' libtoolize: copying file `m4/ltversion.m4' libtoolize: copying file `m4/lt~obsolete.m4' configure.ac:5: installing `./missing' src/Makefile.am: installing `./depcomp' mkdir shared/libosmocore/build-target cd shared/libosmocore/build-target && ../configure \             --host=arm-none-eabi --enable-embedded --disable-shared \             --disable-tests ac_cv_header_sys_select_h=no \             --disable-tests ac_cv_header_sys_socket_h=no \         CFLAGS="-Os -ffunction-sections -I/home/neetesh/GSMP/osmocom-bb/src/target/firmware/include -nostartfiles -nodefaultlibs" configure: WARNING: unrecognized options: --disable-tests, --disable-tests configure: WARNING: if you wanted to set the --build type, don't use --host.     If a cross compiler is detected then cross compile mode will be used checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for arm-none-eabi-strip... no checking for strip... strip checking for a thread-safe mkdir -p... /bin/mkdir -p checking for gawk... no checking for mawk... mawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking whether make sets $(MAKE)... (cached) yes checking for arm-none-eabi-gcc... no checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... yes checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking for style of include used by make... GNU checking dependency style of gcc... gcc3 checking build system type... i686-pc-linux-gnu checking host system type... arm-none-eabi checking how to print strings... printf checking for a sed that does not truncate output... /bin/sed checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for fgrep... /bin/grep -F checking for ld used by gcc... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... yes checking for BSD- or MS-compatible name lister (nm)... no checking for arm-none-eabi-dumpbin... no checking for arm-none-eabi-link... no checking for dumpbin... no checking for link... link -dump configure: WARNING: using cross tools not prefixed with host triplet checking the name lister (nm) interface... BSD nm checking whether ln -s works... yes checking the maximum length of command line arguments... 805306365 checking whether the shell understands some XSI constructs... yes checking whether the shell understands "+="... yes checking how to convert i686-pc-linux-gnu file names to arm-none-eabi format... func_convert_file_noop checking how to convert i686-pc-linux-gnu file names to toolchain format... func_convert_file_noop checking for /usr/bin/ld option to reload object files... -r checking for arm-none-eabi-objdump... no checking for objdump... objdump checking how to recognize dependent libraries... unknown checking for arm-none-eabi-dlltool... no checking for dlltool... no checking how to associate runtime and link libraries... printf %s\n checking for arm-none-eabi-ar... no checking for ar... ar checking for archiver @FILE support... @ checking for arm-none-eabi-strip... strip checking for arm-none-eabi-ranlib... no checking for ranlib... ranlib checking command to parse nm output from gcc object... ok checking for sysroot... no checking for arm-none-eabi-mt... no checking for mt... mt checking if mt is a manifest tool... no checking how to run the C preprocessor... gcc -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for dlfcn.h... yes checking for objdir... .libs checking if gcc supports -fno-rtti -fno-exceptions... no checking for gcc option to produce PIC... -fPIC -DPIC checking if gcc PIC flag -fPIC -DPIC works... yes checking if gcc static flag -static works... no checking if gcc supports -c -o file.o... yes checking if gcc supports -c -o file.o... (cached) yes checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes checking dynamic linker characteristics... no checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... no checking whether to build shared libraries... no checking whether to build static libraries... yes checking for ANSI C header files... (cached) yes checking execinfo.h usability... yes checking execinfo.h presence... yes checking for execinfo.h... yes checking for sys/select.h... (cached) no checking for sys/socket.h... (cached) no checking syslog.h usability... yes checking syslog.h presence... yes checking for syslog.h... yes checking ctype.h usability... yes checking ctype.h presence... yes checking for ctype.h... yes checking for size_t... yes checking for working alloca.h... no checking for alloca... no checking whether `alloca.c' needs Cray hooks... no checking stack direction for C alloca... 0 checking for library containing dlopen... -ldl checking for doxygen... false checking if gcc supports -fvisibility=hidden... yes checking whether struct tm has tm_gmtoff member... no configure: creating ./config.status config.status: creating libosmocore.pc config.status: creating libosmocodec.pc config.status: creating libosmovty.pc config.status: creating libosmogsm.pc config.status: creating libosmogb.pc config.status: creating include/Makefile config.status: creating src/Makefile config.status: creating src/vty/Makefile config.status: creating src/codec/Makefile config.status: creating src/gsm/Makefile config.status: creating src/gb/Makefile config.status: creating tests/Makefile config.status: creating utils/Makefile config.status: creating Doxyfile.core config.status: creating Doxyfile.gsm config.status: creating Doxyfile.vty config.status: creating Doxyfile.codec config.status: creating Makefile config.status: creating config.h config.status: executing tests/atconfig commands config.status: executing depfiles commands config.status: executing libtool commands configure: WARNING: unrecognized options: --disable-tests, --disable-tests cd shared/libosmocore/build-target && make make[1]: Entering directory `/home/neetesh/GSMP/osmocom-bb/src/shared/libosmocore/build-target' echo UNKNOWN > ../.version-t && mv ../.version-t ../.version make  all-recursive make[2]: Entering directory `/home/neetesh/GSMP/osmocom-bb/src/shared/libosmocore/build-target' Making all in include make[3]: Entering directory `/home/neetesh/GSMP/osmocom-bb/src/shared/libosmocore/build-target/include'   GEN    osmocom/core/crc16gen.h   GEN    osmocom/core/crc16gen.h   GEN    osmocom/core/crc32gen.h   GEN    osmocom/core/crc32gen.h   GEN    osmocom/core/crc64gen.h   GEN    osmocom/core/crc64gen.h   GEN    osmocom/core/crc8gen.h   GEN    osmocom/core/crc8gen.h make[3]: Leaving directory `/home/neetesh/GSMP/osmocom-bb/src/shared/libosmocore/build-target/include' Making all in src make[3]: Entering directory `/home/neetesh/GSMP/osmocom-bb/src/shared/libosmocore/build-target/src'   GEN    crc8gen.c   GEN    crc16gen.c   GEN    crc32gen.c   GEN    crc64gen.c make  all-am make[4]: Entering directory `/home/neetesh/GSMP/osmocom-bb/src/shared/libosmocore/build-target/src'   CC     timer.lo   CC     select.lo   CC     signal.lo   CC     msgb.lo   CC     bits.lo   CC     bitvec.lo   CC     statistics.lo ../../src/statistics.c: In function 'osmo_counter_get_by_name': ../../src/statistics.c:72:3: warning: implicit declaration of function 'strcmp' [-Wimplicit-function-declaration]   CC     write_queue.lo   CC     utils.lo ../../src/utils.c: In function 'get_string_value': ../../src/utils.c:49:3: warning: implicit declaration of function 'strcasecmp' [-Wimplicit-function-declaration]   CC     socket.lo   CC     logging.lo ../../src/logging.c: In function 'log_parse_category': ../../src/logging.c:151:3: warning: implicit declaration of function 'strcasecmp' [-Wimplicit-function-declaration] ../../src/logging.c: In function 'log_parse_category_mask': ../../src/logging.c:168:2: warning: implicit declaration of function 'strdup' [-Wimplicit-function-declaration] ../../src/logging.c:168:15: warning: incompatible implicit declaration of built-in function 'strdup' [enabled by default] ../../src/logging.c:175:2: warning: implicit declaration of function 'strtok' [-Wimplicit-function-declaration] ../../src/logging.c:175:17: warning: assignment makes pointer from integer without a cast [enabled by default] ../../src/logging.c:179:4: warning: implicit declaration of function 'strstr' [-Wimplicit-function-declaration] ../../src/logging.c:179:18: warning: incompatible implicit declaration of built-in function 'strstr' [enabled by default] ../../src/logging.c:194:4: warning: implicit declaration of function 'strncasecmp' [-Wimplicit-function-declaration] ../../src/logging.c:205:27: warning: assignment makes pointer from integer without a cast [enabled by default] ../../src/logging.c: In function '_file_output': ../../src/logging.c:446:2: warning: implicit declaration of function 'fprintf' [-Wimplicit-function-declaration] ../../src/logging.c:446:2: warning: incompatible implicit declaration of built-in function 'fprintf' [enabled by default] ../../src/logging.c:447:2: warning: implicit declaration of function 'fflush' [-Wimplicit-function-declaration] ../../src/logging.c: In function 'log_target_create_file': ../../src/logging.c:520:2: warning: implicit declaration of function 'fopen' [-Wimplicit-function-declaration] ../../src/logging.c:520:23: warning: assignment makes pointer from integer without a cast [enabled by default] ../../src/logging.c: In function 'log_target_find': ../../src/logging.c:544:4: warning: implicit declaration of function 'strcmp' [-Wimplicit-function-declaration] ../../src/logging.c: In function 'log_target_destroy': ../../src/logging.c:566:4: warning: implicit declaration of function 'fclose' [-Wimplicit-function-declaration] ../../src/logging.c: In function 'log_target_file_reopen': ../../src/logging.c:579:23: warning: assignment makes pointer from integer without a cast [enabled by default]   CC     logging_syslog.lo   CC     rate_ctr.lo ../../src/rate_ctr.c: In function 'rate_ctr_get_group_by_name_idx': ../../src/rate_ctr.c:153:3: warning: implicit declaration of function 'strcmp' [-Wimplicit-function-declaration]   CC     gsmtap_util.lo In file included from /home/neetesh/GSMP/osmocom-bb/src/target/firmware/include/swab.h:5:0,                  from /home/neetesh/GSMP/osmocom-bb/src/target/firmware/include/byteorder.h:12,                  from /home/neetesh/GSMP/osmocom-bb/src/target/firmware/include/arpa/inet.h:2,                  from ../../src/gsmtap_util.c:37: /home/neetesh/GSMP/osmocom-bb/src/target/firmware/include/defines.h:5:0: warning: "__attribute_const__" redefined [enabled by default] /usr/include/i386-linux-gnu/sys/cdefs.h:241:0: note: this is the location of the previous definition /home/neetesh/GSMP/osmocom-bb/src/target/firmware/include/asm/swab.h: Assembler messages: /home/neetesh/GSMP/osmocom-bb/src/target/firmware/include/asm/swab.h:32: Error: no such instruction: `eor %edx,%ecx,%ecx,ror' make[4]: *** [gsmtap_util.lo] Error 1 make[4]: Leaving directory `/home/neetesh/GSMP/osmocom-bb/src/shared/libosmocore/build-target/src' make[3]: *** [all] Error 2 make[3]: Leaving directory `/home/neetesh/GSMP/osmocom-bb/src/shared/libosmocore/build-target/src' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/home/neetesh/GSMP/osmocom-bb/src/shared/libosmocore/build-target' make[1]: *** [all] Error 2 make[1]: Leaving directory `/home/neetesh/GSMP/osmocom-bb/src/shared/libosmocore/build-target' make: *** [shared/libosmocore/build-target/src/.libs/libosmocore.a] Error 2 With regards Neetesh Saxena... Get your own FREE website, FREE domain & FREE mobile app with Company email.  Know More > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mailman at lists.osmocom.org Fri Jan 3 10:16:20 2014 From: mailman at lists.osmocom.org (mailman at lists.osmocom.org) Date: Fri, 03 Jan 2014 11:16:20 +0100 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, 03 Jan 2014 11:01:08 +0100 (CET) Size: 46843 URL: From admin at lishixin.net Sat Jan 4 05:29:34 2014 From: admin at lishixin.net (warriornew) Date: Fri, 3 Jan 2014 21:29:34 -0800 (PST) Subject: C118 JTAG Message-ID: <1388813374818-4026286.post@n3.nabble.com> Can anyone help me what to do? the phone is bricked.C118,I want to brush through the jtag line into the bootloader,Feasible? But I can't find the instructions about C118 pin. -- View this message in context: http://baseband-devel.722152.n3.nabble.com/C118-JTAG-tp4026286.html Sent from the baseband-devel mailing list archive at Nabble.com. From saxenaneetesh061 at rediffmail.com Tue Jan 7 10:33:00 2014 From: saxenaneetesh061 at rediffmail.com (neetesh saxena) Date: 7 Jan 2014 10:33:00 -0000 Subject: =?utf-8?B?T3Ntb2NvbTogYXNzZW1ibGVyIGVycm9ycyAoc3dhYi5oKQ==?= Message-ID: <1388947883.S.2388.22659.H.TlN0ZXZlIE1hcmtncmFmAFJlOiBPc21vY29tOiBhc3NlbWJsZXIgZXJyb3JzIChzd2FiLmgp.RU.rfs288, rfs288, 408, 1023.f4-234-118.old.1389090780.7218@webmail.rediffmail.com> Hi, I have tried everything which I can. I removed the installtion (dependencies) and libosmocore, osmocom-bb, gnu-arm. Now I have installed again all. I added the PATH to bashrc (by opening it and paste the path) along with typing it on terminal (as suggested on wiki osmocom-bb). But I am still getting the error. "swab.h:32: error: no such instruction: 'eor %edx, %ecx, %ecx, ror'" and "osmocom-bb/src/shared/libosmocore/build-target/src" any suggestion on it? With regards Neetesh Saxena... From: Steve Markgraf <steve at steve-m.de> Sent: Mon, 06 Jan 2014 00:21:23 To: neetesh saxena <saxenaneetesh061 at rediffmail.com>, Andreas Eversberg <andreas at eversberg.eu> Cc: baseband-devel <baseband-devel at lists.osmocom.org> Subject: Re: Osmocom: assembler errors (swab.h) Hi, On 05.01.2014 10:03, neetesh saxena wrote: > I have already set the path of arm-elf-gcc. > But I am still getting the same error. Is there any command or procedure > by which I can completely remove this installation so that I can try as > a fresh one. > _Neetesh_ If you tried building without the toolchain in place, you have to do a fresh clone of the git repo, or make sure to delete everything that automake and gcc created. Regards, Steve -------------- next part -------------- An HTML attachment was scrubbed... URL: From holger at freyther.de Tue Jan 7 10:42:05 2014 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Tue, 7 Jan 2014 11:42:05 +0100 Subject: Osmocom: assembler errors (swab.h) Message-ID: <20140107104205.GD15182@xiaoyu.lan> On Tue, Jan 07, 2014 at 10:33:00AM -0000, neetesh saxena wrote: > Hi, Hi, > > I have tried everything which I can. > I removed the installtion (dependencies) and libosmocore, osmocom-bb, gnu-arm. > > Now I have installed again all. > I added the PATH to bashrc (by opening it and paste the path) along with typing it on terminal (as suggested on wiki osmocom-bb). But I am still getting the error. > > "swab.h:32: error: no such instruction: 'eor %edx, %ecx, %ecx, ror'" and > "osmocom-bb/src/shared/libosmocore/build-target/src" $ git clean -dxf . make sure your cross compiler is in the toolchain build again From saxenaneetesh061 at rediffmail.com Tue Jan 7 15:48:21 2014 From: saxenaneetesh061 at rediffmail.com (neetesh saxena) Date: 7 Jan 2014 15:48:21 -0000 Subject: =?utf-8?B?UmU6IE9zbW9jb206IGFzc2VtYmxlciBlcnJvcnMgKHN3YWIuaCk=?= Message-ID: <1389091614.S.3513.2378.H.TkhvbGdlciBIYW5zIFBldGVyIEZyZXl0aGVyAFJlOiBPc21vY29tOiBhc3NlbWJsZXIgZXJyb3JzIChzd2E_.RU.rfs288, rfs288, 409, 306.f4-234-182.old.1389109701.31034@webmail.rediffmail.com> Hi, Thanks for your help. But it didn't work for me. With regards Neetesh Saxena... From: Holger Hans Peter Freyther <holger at freyther.de> Sent: Tue, 07 Jan 2014 16:16:54 To: neetesh saxena <saxenaneetesh061 at rediffmail.com> Cc: baseband-devel <baseband-devel at lists.osmocom.org>, Steve Markgraf <steve at steve-m.de> Subject: Re: Osmocom: assembler errors (swab.h) On Tue, Jan 07, 2014 at 10:33:00AM -0000, neetesh  saxena wrote: > Hi, Hi, > > I have tried everything which I can. > I removed the installtion (dependencies) and libosmocore, osmocom-bb, gnu-arm. > > Now I have installed again all. > I added the PATH to bashrc (by opening it and paste the path) along with typing it on terminal (as suggested on wiki osmocom-bb). But I am still getting the error. > > "swab.h:32: error: no such instruction: 'eor %edx, %ecx, %ecx, ror'" and > "osmocom-bb/src/shared/libosmocore/build-target/src" $ git clean -dxf . make sure your cross compiler is in the toolchain build again -------------- next part -------------- An HTML attachment was scrubbed... URL: From holger at freyther.de Tue Jan 7 16:20:53 2014 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Tue, 7 Jan 2014 17:20:53 +0100 Subject: Osmocom: assembler errors (swab.h) In-Reply-To: <1389091614.S.3513.2378.H.TkhvbGdlciBIYW5zIFBldGVyIEZyZXl0aGVyAFJlOiBPc21vY29tOiBhc3NlbWJsZXIgZXJyb3JzIChzd2E_.RU.rfs288, rfs288, 409, 306.f4-234-182.old.1389109701.31034@webmail.rediffmail.com> References: <1389091614.S.3513.2378.H.TkhvbGdlciBIYW5zIFBldGVyIEZyZXl0aGVyAFJlOiBPc21vY29tOiBhc3NlbWJsZXIgZXJyb3JzIChzd2E_.RU.rfs288, rfs288, 409, 306.f4-234-182.old.1389109701.31034@webmail.rediffmail.com> Message-ID: <20140107162053.GA1759@xiaoyu.lan> On Tue, Jan 07, 2014 at 03:48:21PM -0000, neetesh saxena wrote: > Hi, > > Thanks for your help. But it didn't work for me. well, it builds on the jenkins[1]. And your error is typical for someone having compiled parts without the toolchain in the path, getting this compiler issue, then trying to set path.. but it is too late. it really is. You need to clean the tree. [1] http://jenkins.osmocom.org/jenkins/view/OsmocomBB/job/OsmocomBB/ From saxenaneetesh061 at rediffmail.com Thu Jan 9 11:31:14 2014 From: saxenaneetesh061 at rediffmail.com (neetesh saxena) Date: 9 Jan 2014 11:31:14 -0000 Subject: =?utf-8?B?QXNzZW1ibGVyIGVycm9yOiBvc21vY29tQkI=?= Message-ID: <20140109113114.23792.qmail@f4mail-235-231.rediffmail.com> Hi everyone, I installed a fresh Ubuntu and then installed everything related to osmocomBB. I have added path of arm-elf-gcc using export PATh=$PATH:<path>/install/bin and also added in bashrc file. Now when I am compiling it I am receiving the same errors: /home/saxena/osmocom-bb/src/target/firmware/include/asm/swab.h: Assembler messages: /home/saxena/osmocom-bb/src/target/firmware/include/asm/swab.h:32: Error: no such instruction: `eor %edx,%ecx,%ecx,ror' make[4]: *** [gsmtap_util.lo] Error 1 make[4]: Leaving directory `/home/saxena/osmocom-bb/src/shared/libosmocore/build-target/src' make[3]: *** [all] Error 2 make[3]: Leaving directory `/home/saxena/osmocom-bb/src/shared/libosmocore/build-target/src' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/home/saxena/osmocom-bb/src/shared/libosmocore/build-target' make[1]: *** [all] Error 2 make[1]: Leaving directory `/home/saxena/osmocom-bb/src/shared/libosmocore/build-target' make: *** [shared/libosmocore/build-target/src/.libs/libosmocore.a] Error 2 Can anybody tell me where I am wrong? With regards Neetesh Saxena... -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander.huemer at xx.vu Thu Jan 9 12:20:32 2014 From: alexander.huemer at xx.vu (Alexander Huemer) Date: Thu, 9 Jan 2014 13:20:32 +0100 Subject: Assembler error: osmocomBB In-Reply-To: <20140109113114.23792.qmail@f4mail-235-231.rediffmail.com> References: <20140109113114.23792.qmail@f4mail-235-231.rediffmail.com> Message-ID: <20140109122032.GA8501@yade.xx.vu> Hi, On Thu, Jan 09, 2014 at 11:31:14AM -0000, neetesh saxena wrote: > I installed a fresh Ubuntu and then installed everything related to > osmocomBB. > > I have added path of arm-elf-gcc using export > PATh=$PATH:<path>/install/bin > and also added in bashrc file. > > Now when I am compiling it I am receiving the same errors: As before, the cross compiler is not found. Since you put the path to the binaries of the toolchain in your .bashrc, the following should work: $ arm-elf-gcc Is that the case? Kind regards, -Alex From craig_comstock at yahoo.com Thu Jan 9 15:50:35 2014 From: craig_comstock at yahoo.com (Craig Comstock) Date: Thu, 9 Jan 2014 07:50:35 -0800 (PST) Subject: Assembler error: osmocomBB In-Reply-To: <20140109122032.GA8501@yade.xx.vu> References: <20140109113114.23792.qmail@f4mail-235-231.rediffmail.com> <20140109122032.GA8501@yade.xx.vu> Message-ID: <1389282635.99901.YahooMailNeo@web120703.mail.ne1.yahoo.com> Make sure you aren't running "sudo make" as you mentioned before.. your root environment is probably not picking up your PATH to arm-elf-* You can also just check in your shell to see if arm-elf-* is there by starting to type arm-elf and then hit tab... if nothing shows up you probably didn't setup PATH correctly. I reproduced your error using "sudo make" with a fresh checkout/install on Debian /home/comstock/Personal/osmocom-bb/src/target/firmware/include/asm/swab.h: Assembler messages: /home/comstock/Personal/osmocom-bb/src/target/firmware/include/asm/swab.h:32: Error: no such instruction: `eor %edx,%ebp,%ebp,ror' Linux cwd364 3.2.35 #1 SMP Wed Mar 13 22:50:31 CDT 2013 x86_64 GNU/Linux -Craig On Thursday, January 9, 2014 6:22 AM, Alexander Huemer wrote: Hi, On Thu, Jan 09, 2014 at 11:31:14AM -0000, neetesh? saxena wrote: > I installed a fresh Ubuntu and then installed everything related to > osmocomBB. > > I have added path of arm-elf-gcc using export > PATh=$PATH:<path>/install/bin > and also added in bashrc file. > > Now when I am compiling it I am receiving the same errors: As before, the cross compiler is not found. Since you put the path to the binaries of the toolchain in your .bashrc, the following should work: ? ? ? ? $ arm-elf-gcc Is that the case? Kind regards, -Alex -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander.huemer at xx.vu Thu Jan 9 15:56:04 2014 From: alexander.huemer at xx.vu (Alexander Huemer) Date: Thu, 9 Jan 2014 16:56:04 +0100 Subject: Assembler error: osmocomBB In-Reply-To: <1389282635.99901.YahooMailNeo@web120703.mail.ne1.yahoo.com> References: <20140109113114.23792.qmail@f4mail-235-231.rediffmail.com> <20140109122032.GA8501@yade.xx.vu> <1389282635.99901.YahooMailNeo@web120703.mail.ne1.yahoo.com> Message-ID: <20140109155604.GD8501@yade.xx.vu> On Thu, Jan 09, 2014 at 07:50:35AM -0800, Craig Comstock wrote: > Make sure you aren't running "sudo make" as you mentioned before.. > your root environment is probably not picking up your PATH to > arm-elf-* > > You can also just check in your shell to see if arm-elf-* is there by > starting to type arm-elf and then hit tab... if nothing shows up you > probably didn't setup PATH correctly. > > I reproduced your error using "sudo make" with a fresh > checkout/install on Debian Why would one run 'sudo make'? I don't see a good reason to do so. Anyway, if you want to preserve your environment when running sudo, use 'sudo -E'. Kind regards, -Alex From steve at steve-m.de Thu Jan 9 15:53:11 2014 From: steve at steve-m.de (Steve Markgraf) Date: Thu, 09 Jan 2014 16:53:11 +0100 Subject: Assembler error: osmocomBB In-Reply-To: <20140109113114.23792.qmail@f4mail-235-231.rediffmail.com> References: <20140109113114.23792.qmail@f4mail-235-231.rediffmail.com> Message-ID: <52CEC5E7.5070901@steve-m.de> Hi, On 09.01.2014 12:31, neetesh saxena wrote: > I have added path of arm-elf-gcc using export PATh=$PATH:<path>/install/bin > and also added in bashrc file. That doesn't look right and you seem to have at least one typo (PATh). Add the following to your /home/saxena/.bashrc (mind the .): export PATH=$PATH:/home/saxena/gnu-arm-toolchain/install/bin ...for the case that the toolchain was built inside the folder gnu-arm- toolchain of your home folder, if that is not the case please adjust the path. Regards, Steve From saxenaneetesh061 at rediffmail.com Thu Jan 9 16:00:27 2014 From: saxenaneetesh061 at rediffmail.com (neetesh saxena) Date: 9 Jan 2014 16:00:27 -0000 Subject: =?utf-8?B?TVMgJzEnIGlzIGRvd24sIHJhZGlvIGlzIG5vdCBzdGFydGVk?= Message-ID: <1389267446.S.8843.14542.H.Tm5lZXRlc2ggIHNheGVuYQBBc3NlbWJsZXIgZXJyb3I6IG9zbW9jb21CQg__.RU.rfs288, rfs288, 607, 830.f4-235-162.old.1389283227.26854@webmail.rediffmail.com> Hi everyone, Thanks for your help. Now I am able to compile and run the source of osmocmBB. The problem was I had not installed toolchain as a root. But unfortunately, now I m receiving the same error as I was getting earlier which is as follows: (I am using the "Ja! Mobil" SIM card) root at neetesh-VirtualBox:/opt/osmocom-bb/src/host/osmocon# telnet localhost 4247 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Welcome to the OsmocomBB control interface OsmocomBB> en OsmocomBB# conf t OsmocomBB(config)# ms 1 OsmocomBB(ms)#no shutdown OsmocomBB(ms)#en OsmocomBB# write Configuration saved to /home/neetesh/.osmocom/bb/mobile.cfg OsmocomBB# show ms 1 MS '1' is down, radio is not started   IMEI: 000000000000000      IMEISV: 0000000000000000      IMEI generation: fixed   automatic network selection state: A0 null   cell selection state: C0 null   radio ressource layer state: idle   mobility management layer state: MM idle, PLMN search OsmocomBB# show subs 1 Mobile Subscriber of MS '1':  No SIM present. OsmocomBB# sim read 1 OsmocomBB# show subs Mobile Subscriber of MS '1':  IMSI:  Status: U2_NOT_UPDATED  IMSI detached  LAI: invalid  Access barred cells: no  Access classes: I tried the patches SIM in the firmware provided by  Lukas Kuzmiak available at : http://baseband-devel.722152.n3.nabble.com/patches-for-SIM-in-the-firmware-td4026261.html But in my first attempt I am getting some error in l23_api.c while I am compileing the osmocomBB source because I think when I am changing the code then I need to recompile and run it. Didi anyone help me on this? Has anybody used this patch earlier? Am i doing something wrong? With regards Neetesh Saxena... -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander.huemer at xx.vu Thu Jan 9 16:19:07 2014 From: alexander.huemer at xx.vu (Alexander Huemer) Date: Thu, 9 Jan 2014 17:19:07 +0100 Subject: MS '1' is down, radio is not started Message-ID: <20140109161907.GE8501@yade.xx.vu> On Thu, Jan 09, 2014 at 04:00:27PM -0000, neetesh saxena wrote: > Thanks for your help. Now I am able to compile and run the source of > osmocmBB. The problem was I had not installed toolchain as a root. Great that it works now. Just as a side note: It is not necessary to perform any operation as root. I assume you installed the toolchain in /usr/local or so which is not writable as a normal user. You can have e.g. a ~/install and then add $HOME/install/bin to your path. Kind regards, -Alex From saxenaneetesh061 at rediffmail.com Fri Jan 10 12:30:30 2014 From: saxenaneetesh061 at rediffmail.com (neetesh saxena) Date: 10 Jan 2014 12:30:30 -0000 Subject: =?utf-8?B?ZXJyb3I6IE1TICcxJyBpcyBkb3duLCByYWRpbyBpcyBub3Qgc3RhcnRlZA==?= Message-ID: <1389283351.S.10487.9704.H.Tm5lZXRlc2ggIHNheGVuYQBNUyAnMScgaXMgZG93biwgcmFkaW8gaXMgbm90IHN0YXJ0ZWQ_.RU.rfs288, rfs288, 926, 953.f4-234-243.old.1389357030.26859@webmail.rediffmail.com> Hi everyone, I m receiving the following errors: (I am using the "Ja! Mobil" SIM card with Motorola C118) root at neetesh-VirtualBox:/opt/osmocom-bb/src/host/osmocon# telnet localhost 4247 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Welcome to the OsmocomBB control interface OsmocomBB> en OsmocomBB# conf t OsmocomBB(config)# ms 1 OsmocomBB(ms)#no shutdown OsmocomBB(ms)#en OsmocomBB# write Configuration saved to /home/neetesh/.osmocom/bb/mobile.cfg OsmocomBB# show ms 1 MS '1' is down, radio is not started   IMEI: 000000000000000      IMEISV: 0000000000000000      IMEI generation: fixed   automatic network selection state: A0 null   cell selection state: C0 null   radio ressource layer state: idle   mobility management layer state: MM idle, PLMN search OsmocomBB# show subs 1 Mobile Subscriber of MS '1':  No SIM present. OsmocomBB# sim read 1 OsmocomBB# show subs Mobile Subscriber of MS '1':  IMSI:  Status: U2_NOT_UPDATED  IMSI detached  LAI: invalid  Access barred cells: no  Access classes: Can anyone tell me whether the problem is related to SIM card or it is related to phone? Do you have any clue how to fix it? I tried to fix the patch of SIM, but then I am not able to compile source (errors occurred). Please let me know your views. regards, neetesh -------------- next part -------------- An HTML attachment was scrubbed... URL: From holger at freyther.de Sat Jan 11 15:57:35 2014 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Sat, 11 Jan 2014 16:57:35 +0100 Subject: R&S CTS55 to sell/give away Message-ID: <20140111155735.GE8384@xiaoyu.lan> Hi, I am cleaning up my office and would like to get rid of a R&S CTS55. The device powers up but I have never used it for any development. It is currently located in Germany and before posting it on eBay I would be happy to give it someone involved/intersted in the OsmocomBB project. Please contact me off list in case you would like to have it. holger From laforge at gnumonks.org Sun Jan 12 18:53:26 2014 From: laforge at gnumonks.org (Harald Welte) Date: Sun, 12 Jan 2014 19:53:26 +0100 Subject: [RFC] [ADMIN] Making lists subscriber-only? Message-ID: <20140112185326.GU23594@nataraja> Dear all, so far the osmocom.org mailing lists have always been in a 'non-members are manually moderated' mode. This has created a lot of work for manual list moderation, where a lot of the messages caught are simply spam, and only the occasional valid message is being received. I'd like to thank the list moderators for taking care of this. However, in more recent discussions, we were considering to move the lists to a completely closed mode, i.e. postings would automatically be rejected from non-members. The automatic response would contain a description of how to subscribe in 'nomail' mode, i.e. to subscribe in a way to be able to post to the list, while still not receiving any incoming traffic. The latter should be fine for occasional posters who don't want the bulk e-mail that goes with a full/regular subscription. Please provide feedback in case you disagree with that change. Unless there is major opposition, we will likely transition to the 'closed' mode within one month. Thanks, Harald -- - Harald Welte http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 190 bytes Desc: Digital signature URL: From kaber at trash.net Sun Jan 12 19:38:55 2014 From: kaber at trash.net (Patrick McHardy) Date: Sun, 12 Jan 2014 19:38:55 +0000 Subject: [RFC] [ADMIN] Making lists subscriber-only? In-Reply-To: <20140112185326.GU23594@nataraja> References: <20140112185326.GU23594@nataraja> Message-ID: <20140112193855.GB13545@macbook.localnet> On Sun, Jan 12, 2014 at 07:53:26PM +0100, Harald Welte wrote: > Dear all, > > so far the osmocom.org mailing lists have always been in a 'non-members > are manually moderated' mode. This has created a lot of work for manual > list moderation, where a lot of the messages caught are simply spam, and > only the occasional valid message is being received. > > I'd like to thank the list moderators for taking care of this. > > However, in more recent discussions, we were considering to move the > lists to a completely closed mode, i.e. postings would automatically be > rejected from non-members. > > The automatic response would contain a description of how to subscribe > in 'nomail' mode, i.e. to subscribe in a way to be able to post to the > list, while still not receiving any incoming traffic. The latter should > be fine for occasional posters who don't want the bulk e-mail that goes > with a full/regular subscription. > > Please provide feedback in case you disagree with that change. Unless > there is major opposition, we will likely transition to the 'closed' > mode within one month. For the dect list I'm all in favour of this. There's very low traffic and almost only spam. Cheers, Patrick From holger at freyther.de Sun Jan 12 19:55:41 2014 From: holger at freyther.de (Holger Hans Peter Freyther) Date: Sun, 12 Jan 2014 20:55:41 +0100 Subject: [RFC] [ADMIN] Making lists subscriber-only? In-Reply-To: <20140112185326.GU23594@nataraja> References: <20140112185326.GU23594@nataraja> Message-ID: <20140112195541.GJ9767@xiaoyu.lan> On Sun, Jan 12, 2014 at 07:53:26PM +0100, Harald Welte wrote: > Dear all, Good Evening, > Please provide feedback in case you disagree with that change. Unless > there is major opposition, we will likely transition to the 'closed' > mode within one month. when I think I make a one time contribution I use the gmane.org service a lot. On some mailinglists the patch/email sent i just dropped and will never arrive at the mailinglist. If we could find a 'closed' but gmane for posting will still work kind of solution that would be super. holger From nikos.balkanas at eyeonix.com Mon Jan 13 10:12:01 2014 From: nikos.balkanas at eyeonix.com (Nikos Balkanas) Date: Mon, 13 Jan 2014 12:12:01 +0200 Subject: [RFC] [ADMIN] Making lists subscriber-only? In-Reply-To: <20140112185326.GU23594@nataraja> References: <20140112185326.GU23594@nataraja> Message-ID: I, for one, agree totally. Not that i have received *any* spam from this list, but your proposal makes sense. Not that would stop spam, though, they do fake addresses sometimes :-( But because that's how all of the lists, that I know of, work. PS You didn't specify for "personal" feedback, so I am replying to the lists, many of whom I am not a member. Hope it is not considered spam ;-) BR, Nikos On Sun, Jan 12, 2014 at 8:53 PM, Harald Welte wrote: > Dear all, > > so far the osmocom.org mailing lists have always been in a 'non-members > are manually moderated' mode. This has created a lot of work for manual > list moderation, where a lot of the messages caught are simply spam, and > only the occasional valid message is being received. > > I'd like to thank the list moderators for taking care of this. > > However, in more recent discussions, we were considering to move the > lists to a completely closed mode, i.e. postings would automatically be > rejected from non-members. > > The automatic response would contain a description of how to subscribe > in 'nomail' mode, i.e. to subscribe in a way to be able to post to the > list, while still not receiving any incoming traffic. The latter should > be fine for occasional posters who don't want the bulk e-mail that goes > with a full/regular subscription. > > Please provide feedback in case you disagree with that change. Unless > there is major opposition, we will likely transition to the 'closed' > mode within one month. > > Thanks, > Harald > > -- > - Harald Welte > http://laforge.gnumonks.org/ > > ============================================================================ > "Privacy in residential applications is a desirable marketing option." > (ETSI EN 300 175-7 Ch. > A6) > -------------- next part -------------- An HTML attachment was scrubbed... URL: From edoardo.rispoli at gmail.com Mon Jan 13 22:46:47 2014 From: edoardo.rispoli at gmail.com (Edoardo Rispoli) Date: Mon, 13 Jan 2014 23:46:47 +0100 Subject: [RFC] [ADMIN] Making lists subscriber-only? In-Reply-To: <20140112185326.GU23594@nataraja> References: <20140112185326.GU23594@nataraja> Message-ID: ok for the closed mode ! 73 IW3BTI 2014/1/12 Harald Welte > Dear all, > > so far the osmocom.org mailing lists have always been in a 'non-members > are manually moderated' mode. This has created a lot of work for manual > list moderation, where a lot of the messages caught are simply spam, and > only the occasional valid message is being received. > > I'd like to thank the list moderators for taking care of this. > > However, in more recent discussions, we were considering to move the > lists to a completely closed mode, i.e. postings would automatically be > rejected from non-members. > > The automatic response would contain a description of how to subscribe > in 'nomail' mode, i.e. to subscribe in a way to be able to post to the > list, while still not receiving any incoming traffic. The latter should > be fine for occasional posters who don't want the bulk e-mail that goes > with a full/regular subscription. > > Please provide feedback in case you disagree with that change. Unless > there is major opposition, we will likely transition to the 'closed' > mode within one month. > > Thanks, > Harald > > -- > - Harald Welte > http://laforge.gnumonks.org/ > > ============================================================================ > "Privacy in residential applications is a desirable marketing option." > (ETSI EN 300 175-7 Ch. > A6) > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stevie.glass at gmail.com Tue Jan 14 08:21:06 2014 From: stevie.glass at gmail.com (Steve Glass) Date: Tue, 14 Jan 2014 18:21:06 +1000 Subject: [RFC] [ADMIN] Making lists subscriber-only? In-Reply-To: <20140112185326.GU23594@nataraja> References: <20140112185326.GU23594@nataraja> Message-ID: <52D4F372.8010403@gmail.com> Hi Closed lists will just be more efficient. If the bounce message is clear then most genuine contributors will get that and respond appropriately. I've only dealt with one real, actual problem as a moderator and it was purely accidental that the offender wasn't a subscriber and I was able to catch it. We should expect some spammers to join but even this hurdle will eliminate the majority and we can boot any subscribed spammers quite quickly. ATB Stevie From e_tews at seceng.informatik.tu-darmstadt.de Wed Jan 15 08:28:34 2014 From: e_tews at seceng.informatik.tu-darmstadt.de (Erik Tews) Date: Wed, 15 Jan 2014 09:28:34 +0100 Subject: [RFC] [ADMIN] Making lists subscriber-only? In-Reply-To: <20140112185326.GU23594@nataraja> References: <20140112185326.GU23594@nataraja> Message-ID: <1389774514.6112.2.camel@lima> Am Sonntag, den 12.01.2014, 19:53 +0100 schrieb Harald Welte: > Dear all, > > so far the osmocom.org mailing lists have always been in a 'non-members > are manually moderated' mode. This has created a lot of work for manual > list moderation, where a lot of the messages caught are simply spam, and > only the occasional valid message is being received. > > I'd like to thank the list moderators for taking care of this. > > However, in more recent discussions, we were considering to move the > lists to a completely closed mode, i.e. postings would automatically be > rejected from non-members. > > The automatic response would contain a description of how to subscribe > in 'nomail' mode, i.e. to subscribe in a way to be able to post to the > list, while still not receiving any incoming traffic. The latter should > be fine for occasional posters who don't want the bulk e-mail that goes > with a full/regular subscription. > > Please provide feedback in case you disagree with that change. Unless > there is major opposition, we will likely transition to the 'closed' > mode within one month. Hi The only disadvantage I can see is, that you cannot simply CC the list, when you get a question to your personal address, that might be interesting for the list. Your mail will still get through, but the next reply will not make it to the list. But that is quiet acceptable, compared to a lot of spam being send to such lists. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 181 bytes Desc: This is a digitally signed message part URL: From saxenaneetesh061 at rediffmail.com Wed Jan 22 11:00:10 2014 From: saxenaneetesh061 at rediffmail.com (neetesh saxena) Date: 22 Jan 2014 11:00:10 -0000 Subject: =?utf-8?B?UXVlcnkgcmVnYXJkaW5nIHJ1bm5pbmcgb3Ntb29jb21CQg==?= Message-ID: <1389444542.S.14319.32433.H.TkFyc2xhbiBBbmp1bQBSZTogZXJyb3I6IE1TICcxJyBpcyBkb3duLCByYWRpbyBpcyBub3Qgc3RhcnRlZA__.RU.rfs288, rfs288, 157, 536.f4-234-118.old.1390388409.19639@webmail.rediffmail.com> Hi everyone, Here, i wish to know the answer of a basic question. When I uploaded the firmware onto the mobile phone (with ./osmocon command), I can start other application programs like CCCh program, mobile program in other terminals. My problem is when I am doing it I can see that the layer1 is uploaded onto the phone but I am not able to switch on my phone. When I again press the red button to start phone, it again starts getting uploaded layer1. When I terminate the command of uploading firmware and start my phone then I am not able to view of SIM details and it shows me "service is unavailable" or "administratively down". My question is we need to continue run the terminal with ./osmocon command (for uploading layer1) or i need to stop it after uploading layer1 once onto the phone. When to switched on my phone ? With regards Neetesh Saxena... -------------- next part -------------- An HTML attachment was scrubbed... URL: From peter at stuge.se Wed Jan 22 11:47:12 2014 From: peter at stuge.se (Peter Stuge) Date: Wed, 22 Jan 2014 12:47:12 +0100 Subject: Query regarding running osmoocomBB Message-ID: <20140122114712.12402.qmail@stuge.se> neetesh saxena wrote: > My question is we need to continue run the terminal with ./osmocon > command (for uploading layer1) Yes. > or i need to stop it after uploading layer1 once onto the phone. No. > When to switched on my phone ? If layer1 is successfully uploaded then the phone is already switched on. Just start the layer23 (mobile, ccch_scan, etc..) program on the host. //Peter From saxenaneetesh061 at rediffmail.com Wed Jan 22 18:19:36 2014 From: saxenaneetesh061 at rediffmail.com (neetesh saxena) Date: 22 Jan 2014 18:19:36 -0000 Subject: =?utf-8?B?UmU6IFByb2JsZW0gdG8gcnVuIGNjY2hfc2Nhbg==?= In-Reply-To: <1389444542.S.14319.32433.H.TkFyc2xhbiBBbmp1bQBSZTogZXJyb3I6IE1TICcxJyBpcyBkb3duLCByYWRpbyBpcyBub3Qgc3RhcnRlZA__.RU.rfs288, rfs288, 157, 536.f4-234-118.old.1390388409.19639@webmail.rediffmail.com> Message-ID: <1390389705.S.8010.26673.H.Tm5lZXRlc2ggIHNheGVuYQBRdWVyeSByZWdhcmRpbmcgcnVubmluZyBvc21vb2NvbUJC.RU.rfs281, rfs281, 841, 233.f4-234-90.old.1390414776.9478@webmail.rediffmail.com> Hi everyone,Now I am facing some unknown problem to me. I am getting the following error messages (1) on the terminal after uploading layer1: Failed to write msg to the socket(2) failed to connect to '/tmp/osmocom_sap' Failed during sap_open (), no SIM reader <000c> l1ctl.c:118 FBSB RESP: result=255 <000f> sim.c:858 received APDU but no job, please fixShall anyone tell me where I am doing wrong? What exactly is the problem. Because earlier when I run mobile application then it was working well.Thanks in advance.NeeteshSent from RediffmailNG on Android From: "neetesh saxena"saxenaneetesh061 at rediffmail.com Sent:Wed, 22 Jan 2014 16:51:45 +0530 To: "baseband-devel " baseband-devel at lists.osmocom.org Subject: Query regarding running osmoocomBB Hi everyone, > >Here, i wish to know the answer of a basic question. When I uploaded the firmware onto the mobile phone (with ./osmocon command), I can start other application programs like CCCh program, mobile program in other terminals. > >My problem is when I am doing it I can see that the layer1 is uploaded onto the phone but I am not able to switch on my phone. When I again press the red button to start phone, it again starts getting uploaded layer1. > >When I terminate the command of uploading firmware and start my phone then I am not able to view of SIM details and it shows me "service is unavailable" or "administratively down". > >My question is we need to continue run the terminal with ./osmocon command (for uploading layer1) or i need to stop it after uploading layer1 once onto the phone. When to switched on my phone ? > > >With regards > Neetesh Saxena... > > > >Get your own FREE website, FREE domain & FREE mobile app with Company email. Know More > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cs at saturn2.franken.de Wed Jan 29 16:36:31 2014 From: cs at saturn2.franken.de (Christian Schulte) Date: Wed, 29 Jan 2014 17:36:31 +0100 Subject: BTS using osmocombb trx Message-ID: <52E92E0F.6010100@saturn2.franken.de> Hello dear osmocom team first off, thanks for all the work you have put into this project. Its great to have a starting point for toying with this new/old technology. ;) I got myself a C155 and have used osmocom-bb on it to read some traffic with wireshark. So far everything works nicely. Now i wanted to communicate with a second phone and have tried setting up a BTS following this guide http://openbsc.osmocom.org/trac/wiki/network_from_scratch (using a single phone) My problem is that the phone doesnt transmit anything. Yes i have enabled the transmitter flag in the Makefile. ;) When i use osmocon to load the TRX into the phone and start the osmocom-transceiver i get this debug output from osmocon. ... Synchronize_TDMA =>FB @ FNR 26585 fn_offset=2002505 qbits=4924 LOST 1910! BTS MODE: 255 65535 {0,0,0,0,0,0,0,0} TX 0..7 RX 0..7 After taking a look at the code the values seem weird and they come from the transceiver function l1ctl_tx_bts_mode() like that. /host/layer23/src/transceiver/l1ctl.c:120 As a test i got the phone to transmit something by overwriting the values on the TRX side. I havent gone further yet but wanted to ask if someone could maybe point me to an obvious mistake i did before i spend more hours on this issue. A hint as to how i enable the different logging settings would be great as well. thanks, best regards, Christian From cs at saturn2.franken.de Wed Jan 29 17:20:05 2014 From: cs at saturn2.franken.de (Christian Schulte) Date: Wed, 29 Jan 2014 18:20:05 +0100 Subject: BTS using osmocombb trx In-Reply-To: <52E92E0F.6010100@saturn2.franken.de> References: <52E92E0F.6010100@saturn2.franken.de> Message-ID: <52E93845.9070704@saturn2.franken.de> Oh i am sorry. I think i got it. osmobts-trx was not running. There was simply no configuration being distributed from layer2 to layer1. (as far as i understand it) That guide is quite useful but also quite lengthy :D http://openbsc.osmocom.org/trac/wiki/network_from_scratch cheers, Christian On 01/29/2014 05:36 PM, Christian Schulte wrote: ..... > > Now i wanted to communicate with a second phone and > have tried setting up a BTS following this guide > > http://openbsc.osmocom.org/trac/wiki/network_from_scratch > (using a single phone) > > My problem is that the phone doesnt transmit anything. > Yes i have enabled the transmitter flag in the Makefile. ;) > When i use osmocon to load the TRX into the phone and start the > osmocom-transceiver i get this debug output from osmocon. > > ... > Synchronize_TDMA > =>FB @ FNR 26585 fn_offset=2002505 qbits=4924 > LOST 1910! > BTS MODE: 255 65535 {0,0,0,0,0,0,0,0} TX 0..7 RX 0..7 > > > After taking a look at the code the values seem weird > and they come from the transceiver function l1ctl_tx_bts_mode() > like that. > /host/layer23/src/transceiver/l1ctl.c:120 > > As a test i got the phone to transmit something by > overwriting the values on the TRX side. > > I havent gone further yet but wanted to ask if someone could > maybe point me to an obvious mistake i did before i > spend more hours on this issue. > A hint as to how i enable the different logging settings > would be great as well. > > > thanks, > best regards, Christian > > > >