[PATCH 3/3] Add Kasumi cipher implementation

---
 .gitignore                   |   1 +
 include/osmocom/gsm/kasumi.h |  41 ++++++++++
 src/gsm/Makefile.am          |   2 +-
 src/gsm/kasumi.c             | 190 +++++++++++++++++++++++++++++++++++++++++++
 src/gsm/libosmogsm.map       |   4 +
 tests/Makefile.am            |   7 +-
 tests/kasumi/kasumi_test.c   | 136 +++++++++++++++++++++++++++++++
 tests/kasumi/kasumi_test.ok  |  10 +++
 tests/testsuite.at           |   6 ++
 9 files changed, 394 insertions(+), 3 deletions(-)
 create mode 100644 include/osmocom/gsm/kasumi.h
 create mode 100644 src/gsm/kasumi.c
 create mode 100644 tests/kasumi/kasumi_test.c
 create mode 100644 tests/kasumi/kasumi_test.ok

diff --git a/.gitignore b/.gitignore
index 3fa1bbc..1299028 100644
--- a/.gitignore
+++ b/.gitignore
@@ -56,6 +56,7 @@ tests/testsuite.dir/
 tests/testsuite.log

 tests/utils/utils_test
+tests/kasumi/kasumi_test
 tests/sms/sms_test
 tests/timer/timer_test
 tests/msgfile/msgfile_test
diff --git a/include/osmocom/gsm/kasumi.h b/include/osmocom/gsm/kasumi.h
new file mode 100644
(Continue reading)

Re: [PATCH 3/3] Add Kasumi cipher implementation

Hi Max,

> +
> +#pragma once

All the other files use the classic #ifdef #define, so either replace
all before that, or stick to the current way of doing it.

> +
> +#include <stdint.h>
> +
> +/*! \brief Single iteration of KASUMI cipher
> + * \param[in] P Block, 64 bits to be processed in this round
> + * \param[in] KLi1 Expanded subkeys
> + * \param[in] KLi2 Expanded subkeys
> + * \param[in] KOi1 Expanded subkeys
> + * \param[in] KOi2 Expanded subkeys
> + * \param[in] KOi3 Expanded subkeys
> + * \param[in] KIi1 Expanded subkeys
> + * \param[in] KIi2 Expanded subkeys
> + * \param[in] KIi3 Expanded subkeys
> + * \returns processed block of 64 bits
> + */

We usually put the documentation only in the .c file and not the
header. (except for stuff that's only in the header obviously).

If it's picked up by doxygen all the same then I don't have big
objections against putting it in the header (to be checked though) if
you insist, but then be consistent ... you have some of the doc
(Continue reading)

Re: [PATCH 3/3] Add Kasumi cipher implementation

15.06.2014 22:49, Sylvain Munaut пишет:
> Hi Max,
> 
>> +
>> +#pragma once
> 
> All the other files use the classic #ifdef #define, so either replace
> all before that, or stick to the current way of doing it.

What do you mean by "all before that"?

> Either the methods are meant to be part of the public API and then
> they should carry the osmo prefix.
> Or they're meant to be internal, then the symbol should not be
> exported in the map file and the header should not be installed.

I think I've asked it already but I don't recall an answer: I do not want to make it
a part of public API (hence - no osmo_ prefix) but I still need to call it explicitly
in test/ - how can I do that without adding it to map file?

--

-- 
best regards,
Max, http://fairwaves.co

Re: [PATCH 3/3] Add Kasumi cipher implementation

Hi,

> What do you mean by "all before that"?

Like change all libosmocore headers to use #pragma once.

We pretty much only target gcc/llvm AFAIK so that shouldn't be a problem.

Any one see an objection to that ?

> I think I've asked it already but I don't recall an answer: I do not want to make it
> a part of public API (hence - no osmo_ prefix) but I still need to call it explicitly
> in test/ - how can I do that without adding it to map file?

I think the header should be in noinst_HEADER then (don't remember the
exact name).

As for the testing, linking the test statically should do right ? I
didn't test but since this only changes the presence of the symbol in
the dynamic symbol table, linking to the static lib should work.

Cheers,

   Sylvain

Re: [PATCH 3/3] Add Kasumi cipher implementation

16.06.2014 00:33, Sylvain Munaut пишет:

> I think the header should be in noinst_HEADER then (don't remember the
> exact name).

noinst_HEADERS it is, thanks.

> As for the testing, linking the test statically should do right ? I
> didn't test but since this only changes the presence of the symbol in
> the dynamic symbol table, linking to the static lib should work.

Where should I pass -static to gcc linker? Is there some statically-linked test
available as an example?

--

-- 
best regards,
Max, http://fairwaves.co

Re: [PATCH 3/3] Add Kasumi cipher implementation

Hi,

>> As for the testing, linking the test statically should do right ? I
>> didn't test but since this only changes the presence of the symbol in
>> the dynamic symbol table, linking to the static lib should work.
>
> Where should I pass -static to gcc linker? Is there some statically-linked test
> available as an example?

testname_LDFLAGS = -static

I fixed it up myself and pushed the 3 patches.

Cheers,

    Sylvain

Re: [PATCH 3/3] Add Kasumi cipher implementation

On Sun, Jun 15, 2014 at 10:49:45PM +0200, Sylvain Munaut wrote:

Hi,

> > +#pragma once
> 
> All the other files use the classic #ifdef #define, so either replace
> all before that, or stick to the current way of doing it.

do we really want to be that strong? I think all future header files
should use "#pragma once".

Re: [PATCH 3/3] Add Kasumi cipher implementation

>> > +#pragma once
>>
>> All the other files use the classic #ifdef #define, so either replace
>> all before that, or stick to the current way of doing it.
>
> do we really want to be that strong? I think all future header files
> should use "#pragma once".

I like consistency :p

Especially since such a change won't really lead to conflict since it
only change a couple lines at the beginning/end of each file and it's
also pretty easy to do with a script. (I did it in like 10 min).

Cheers,

   Sylvain

Re: [PATCH 3/3] Add Kasumi cipher implementation

16.06.2014 10:19, Sylvain Munaut пишет:

> Especially since such a change won't really lead to conflict since it
> only change a couple lines at the beginning/end of each file and it's
> also pretty easy to do with a script. (I did it in like 10 min).
> 

Good. Can you commit this?

--

-- 
best regards,
Max, http://fairwaves.co

Re: [PATCH 3/3] Add Kasumi cipher implementation

>> Especially since such a change won't really lead to conflict since it
>> only change a couple lines at the beginning/end of each file and it's
>> also pretty easy to do with a script. (I did it in like 10 min).
>>
>
> Good. Can you commit this?

Holger, can I get a ack on this ?

Cheers,

   Sylvain

Re: [PATCH 3/3] Add Kasumi cipher implementation

On Mon, Jun 16, 2014 at 01:55:03PM +0200, Sylvain Munaut wrote:
> >> Especially since such a change won't really lead to conflict since it
> >> only change a couple lines at the beginning/end of each file and it's
> >> also pretty easy to do with a script. (I did it in like 10 min).
> >>
> >
> > Good. Can you commit this?
> 
> 
> Holger, can I get a ack on this ?

sure. it looked fine.