[PATCH] Add generic LE/BE load/store uint type convertors and use them in msgb

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/baseband-devel@lists.osmocom.org/.

Holger Hans Peter Freyther holger at freyther.de
Thu Mar 6 11:28:25 UTC 2014


On Thu, Mar 06, 2014 at 11:52:10AM +0100, ☎ wrote:
> Thanks for comments - all either fixed or comments added to clarify.

let me have another look. On general comment. The amount of parameters
you pass to the method are a lot. Would you be able to be woken up in
the middle of the day/night (whatever is less comfortable) and would
you know the parameters? Did you consider passing them as a struct?

> +static void check_ls_64(uint8_t bytes)
> +{
> +	/* calculate various adjustment constants (number of bits, bytes, octets etc.)
> +		based on number of bytes in type we actually test */


I was more thinking about what exactly do you want to test? Encode/Decode
being compatible with each other? Corner cases? This is very difficult to
understand code and I don't see your intend. I wonder/guess that there is
a more simple approach to it.

>  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++) {
> +	srand(time(NULL));
> +
> +	for (offs = 0; offs < sizeof(out); offs++)
> +	{

coding style. :)

> -		if (memcmp(start, exp_out + offs, len)) {
> +		if (memcmp(start, exp_out + offs, len))
> +		{

coding style. :)

> +	if (0 != memcmp(s, p, 2))
> +	{

coding style. :)

> +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);

sorry. I didn't see that the first time. _NAME is reversed by the system.

> +inline static uint16_t _kasumi_FI(uint16_t I, uint16_t skey)

_kasumi is reserved for gcc/glibc. :)

> +	static const uint16_t S7[] = {
> +	};
> +	static const uint16_t S9[] = {
> +	};

these tables were copied from the spec?

> +inline static uint32_t _kasumi_FO(uint32_t I, const uint16_t *KOi1, const uint16_t *KOi2, const uint16_t *KOi3, const uint16_t *KIi1, const uint16_t *KIi2, const uint16_t *KIi3, unsigned i)
> +inline static uint32_t _kasumi_FL(uint32_t I, const uint16_t *KLi1, const uint16_t *KLi2, unsigned i)

again reserved symbol. :)

> +uint64_t _kasumi(uint64_t P, const uint16_t *KLi1, const uint16_t *KLi2, const uint16_t *KOi1, const uint16_t *KOi2, const uint16_t *KOi3, const uint16_t *KIi1, const uint16_t *KIi2, const uint16_t *KIi3)
> +{
> +	uint32_t i, L = P >> 32, R = P; /* Split 64 bit input into Left and Right parts */
> +
> +	for (i = 0; i < 8; i++)
> +	{

coding style. :)

> +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)
> +{
> +	for (i = 0; i < 8; i++)
> +	{

coding style. :) (and reserved symbol)


> +	_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 */
> +	{

coding style. :)


time is up. probably more coding style and symbol issues. :)




More information about the baseband-devel mailing list